Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hapi-capitalize-modules

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-capitalize-modules - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

5

lib/index.js
'use strict';
module.exports = function(context) {
var message = 'Imported module variable name not capitalized.';
var globalScopeOnly = context.options[0] === 'global-scope-only';

@@ -22,2 +23,6 @@

function check(node) {
if (globalScopeOnly === true && context.getScope().type !== 'global') {
return;
}
if (node.type === 'VariableDeclarator' &&

@@ -24,0 +29,0 @@ isRequire(node.init) &&

2

package.json
{
"name": "hapi-capitalize-modules",
"version": "1.0.0",
"version": "1.1.0",
"description": "ESLint rule to enforce the capitalization of imported module variables",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -9,1 +9,8 @@ # hapi-capitalize-modules

ESLint rule to enforce the capitalization of imported module variables.
## Rule options
### `global-scope-only`
If the string `'global-scope-only'` is passed as the first option to this rule,
then it will only be enforced on assignments in the module's top level scope.

@@ -21,3 +21,4 @@ 'use strict';

'var hapi = require("hapi");',
'var poop; poop = require("poop");'
'var poop; poop = require("poop");',
'var foo = {bar: function() { var hapi = require("hapi"); }};'
];

@@ -43,3 +44,4 @@

'var Hapi = require("hapi");',
'var Poop; Poop = require("poop");'
'var Poop; Poop = require("poop");',
'Code = require("code");'
];

@@ -59,2 +61,36 @@

it('only warns on globals when global-scope-only is set', function(done) {
var code = [
'function foo() { var hapi = require("hapi"); }',
'var foo = function() { var hapi = require("hapi"); }',
'var foo = {bar: function() { hapi = require("hapi"); }};'
];
linterConfig.rules[HapiCapitalizeModules.esLintRuleName] = [1, 'global-scope-only'];
for (var i = 0; i < code.length; ++i) {
var result = linter.verify(code[i], linterConfig);
expect(result).to.be.an.array();
expect(result.length).to.equal(0);
}
code = [
'hapi = require("hapi");',
'var poop; poop = require("poop");'
];
for (var i = 0; i < code.length; ++i) {
var result = linter.verify(code[i], linterConfig);
expect(result).to.be.an.array();
expect(result.length).to.equal(1);
expect(result[0].ruleId).to.equal(HapiCapitalizeModules.esLintRuleName);
expect(result[0].message).to.equal('Imported module variable name not capitalized.');
expect(result[0].nodeType).to.match(/VariableDeclarator|AssignmentExpression/);
}
done();
});
it('does not report anything for non-module variables', function(done) {

@@ -61,0 +97,0 @@ var code = [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc