eslint-plugin-import
Advanced tools
Comparing version 0.3.6 to 0.3.8
@@ -37,9 +37,12 @@ "use strict"; | ||
parse(path).body.forEach(function (n) { | ||
var ast = parse(path); | ||
ast.body.forEach(function (n) { | ||
m.captureDefault(n); | ||
m.captureAll(n, path); | ||
m.captureNamedDeclaration(n); | ||
m.commonJs(n); | ||
}); | ||
m.commonJs(ast); | ||
return m; | ||
@@ -88,21 +91,16 @@ }; | ||
// todo: capture names | ||
ExportMap.prototype.commonJs = function (node) { | ||
if (this.isCommon) return; | ||
ExportMap.prototype.commonJs = function (ast) { | ||
var map = this; | ||
traverse(node, { | ||
traverse(ast, { | ||
fallback: "iteration", | ||
enter: function (n) { | ||
if (n.type !== "ExpressionStatement") return; | ||
var expr = n.expression; | ||
if (n.type !== "AssignmentExpression") return; | ||
if (expr.type !== "AssignmentExpression") return; | ||
if (n.operator !== "=") return; | ||
if (n.left.type !== "MemberExpression") return; | ||
if (expr.operator !== "=") return; | ||
if (expr.left.type !== "MemberExpression") return; | ||
if (n.left.object.type !== "Identifier") return; | ||
if (expr.left.object.type !== "Identifier") return; | ||
if (expr.left.object.name === "module" || expr.left.object.name === "exports") { | ||
if (n.left.object.name === "module" || n.left.object.name === "exports") { | ||
map.isCommon = true; | ||
@@ -109,0 +107,0 @@ this.break(); |
{ | ||
"name": "eslint-plugin-import", | ||
"version": "0.3.6", | ||
"version": "0.3.8", | ||
"description": "Import with sanity.", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "mocha --recursive tests/" | ||
"test": "mocha --reporter dot --recursive tests/" | ||
}, | ||
@@ -13,0 +13,0 @@ "repository": { |
@@ -15,2 +15,3 @@ eslint-plugin-import | ||
* Ensure imported namespaces contain dereferenced properties as they are dereferenced. ([`namespace`](#namespace)) | ||
* Report assignments (at any scope) to imported names/namespaces. ([`no-reassign`](#no-reassign)) | ||
@@ -55,1 +56,4 @@ ## Rules | ||
### `no-reassign` | ||
Reports on assignment to an imported name (or a member of an imported namespace). Does not consider scope or shadowing, so failure to adhere to ESLint's `no-shadow` may result in spurious warnings. |
@@ -24,4 +24,7 @@ "use strict"; | ||
test({code: "import {x} from './nested-common';", | ||
errors: [{ message: "'./nested-common' is a CommonJS module."}]}) | ||
errors: [{ message: "'./nested-common' is a CommonJS module."}]}), | ||
test({code: "import {x} from './umd';", | ||
errors: [{ message: "'./umd' is a CommonJS module."}]}) | ||
] | ||
}); |
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
25374
41
583
58