ast-module-types
Advanced tools
Comparing version 2.7.0 to 2.7.1
18
index.js
@@ -141,3 +141,6 @@ // Deprecated | ||
return args && args.length > 0 && (args[0].type === 'Literal' || args[0].type === 'StringLiteral'); | ||
return args && args.length == 3 && | ||
(args[0].type === 'Literal' || args[0].type === 'StringLiteral') && | ||
(args[1].type == 'ArrayExpression') && | ||
(args[2].type == 'FunctionExpression'); | ||
}; | ||
@@ -151,3 +154,5 @@ | ||
return args && args.length > 0 && args[0].type === 'ArrayExpression'; | ||
return args && args.length == 2 && | ||
args[0].type === 'ArrayExpression' && | ||
args[1].type == 'FunctionExpression'; | ||
}; | ||
@@ -163,4 +168,6 @@ | ||
// Node should have a function whose first param is 'require' | ||
return args && args.length > 0 && args[0].type === 'FunctionExpression' && | ||
firstParamNode && firstParamNode.type === 'Identifier' && firstParamNode.name === 'require'; | ||
return args && args.length == 1 && | ||
args[0].type === 'FunctionExpression' && | ||
firstParamNode && firstParamNode.type === 'Identifier' && | ||
firstParamNode.name === 'require'; | ||
}; | ||
@@ -174,3 +181,4 @@ | ||
return args && args.length > 0 && args[0].type === 'ObjectExpression'; | ||
return args && args.length == 1 && | ||
args[0].type === 'ObjectExpression'; | ||
}; | ||
@@ -177,0 +185,0 @@ |
{ | ||
"name": "ast-module-types", | ||
"version": "2.7.0", | ||
"version": "2.7.1", | ||
"description": "Collection of useful helper functions when trying to determine module type (CommonJS or AMD) properties of an AST node.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -47,3 +47,3 @@ var types = require('../'); | ||
it('detect a named form AMD define function call', function() { | ||
it('detects a named form AMD define function call', function() { | ||
assert(!check('define();', types.isDefineAMD)); | ||
@@ -102,12 +102,56 @@ }); | ||
it('detects named form', function() { | ||
assert(check('define("foobar", ["a"], function(a){});', types.isNamedForm)); | ||
describe('named form', function() { | ||
it('detects named form', function() { | ||
assert(check('define("foobar", ["a"], function(a){});', types.isNamedForm)); | ||
}); | ||
it('needs 3 arguments', function() { | ||
assert(!check('define("foobar", ["a"]);', types.isNamedForm)); | ||
assert(!check('define("foobar", ["a"], function(a){}, "foo");', types.isNamedForm)); | ||
}); | ||
it('needs the first argument to be a literal', function() { | ||
assert(!check('define(["foobar"], ["a"], function(a){});', types.isNamedForm)); | ||
}); | ||
it('needs the second argument to be an array', function() { | ||
assert(!check('define("foobar", 123, function(a){});', types.isNamedForm)); | ||
}); | ||
it('needs the third argument to be a function', function() { | ||
assert(!check('define("foobar", ["foo"], 123);', types.isNamedForm)); | ||
assert(!check('define("reset", [0, 0], "modifier");', types.isNamedForm)); | ||
}); | ||
}); | ||
it('detects dependency form modules', function() { | ||
assert(check('define(["a"], function(a){});', types.isDependencyForm)); | ||
describe('dependency form', function() { | ||
it('detects dependency form modules', function() { | ||
assert(check('define(["a"], function(a){});', types.isDependencyForm)); | ||
}); | ||
it('needs the first argument to be an array', function() { | ||
assert(!check('define(123, function(a){});', types.isDependencyForm)); | ||
}); | ||
it('needs the second argument to be a function', function() { | ||
assert(!check('define(["a"], 123);', types.isDependencyForm)); | ||
}); | ||
it('needs 2 arguments', function() { | ||
assert(!check('define(["a"], function(a){}, 123);', types.isDependencyForm)); | ||
}); | ||
}); | ||
it('detects factory form modules', function() { | ||
assert(check('define(function(require){});', types.isFactoryForm)); | ||
describe('factory form', function() { | ||
it('detects factory form modules', function() { | ||
assert(check('define(function(require){});', types.isFactoryForm)); | ||
}); | ||
it('needs one argument', function() { | ||
assert(!check('define(function(require){}, 123);', types.isFactoryForm)); | ||
}); | ||
it('needs the first argument to be a function', function() { | ||
assert(!check('define(123);', types.isFactoryForm)); | ||
}); | ||
}); | ||
@@ -119,4 +163,14 @@ | ||
it('detects no dependency form modules', function() { | ||
assert(check('define({});', types.isNoDependencyForm)); | ||
describe('no dependency form', function() { | ||
it('detects no dependency form modules', function() { | ||
assert(check('define({});', types.isNoDependencyForm)); | ||
}); | ||
it('needs a aingle argument', function() { | ||
assert(!check('define({}, 123);', types.isNoDependencyForm)); | ||
}); | ||
it('needs the first argument to be an object', function() { | ||
assert(!check('define(function(){});', types.isNoDependencyForm)); | ||
}); | ||
}); | ||
@@ -123,0 +177,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16987
346