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

eslint-plugin-import

Package Overview
Dependencies
Maintainers
1
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-import - npm Package Compare versions

Comparing version 0.3.10 to 0.3.11

files/empty-folder/anchor.txt

6

lib/rules/exists.js

@@ -13,7 +13,7 @@ /**

"ImportDeclaration": function (node) {
if (resolve(node.source.value, context.getFilename()) == null) {
context.report(node.source, "Imported file does not exist.");
}
if (resolve(node.source.value, context.getFilename()) == null)
context.report(node.source,
"Unable to resolve path to module '" + node.source.value + "'.");
}
};
};

@@ -61,13 +61,17 @@ "use strict";

checkIdentifier(vr.id);
}
},
// todo: destructuring assignment
// "ObjectPattern": function (o) {
"ObjectPattern": function (o) {
o.properties.forEach(function (p) {
if (p.key.type === "Identifier") checkIdentifier(p.key);
});
},
// },
// "ArrayPattern": function (a) {
// }
"ArrayPattern": function (a) {
a.elements.forEach(function (p) {
if (p.type === "Identifier") checkIdentifier(p);
});
}
};
};
{
"name": "eslint-plugin-import",
"version": "0.3.10",
"version": "0.3.11",
"description": "Import with sanity.",

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

@@ -53,3 +53,3 @@ eslint-plugin-import

**Implementation note**: currently, this rule does not check for possible redefinition of the namespace in an intermediate scope. Adherence to the ESLint `no-shadow` rule for namespaces will prevent this from being a problem.
**Implementation note**: currently, this rule does not check for possible redefinition of the namespace in an intermediate scope. Adherence to either `import/no-reassign` or the ESLint `no-shadow` rule for namespaces will prevent this from being a problem.

@@ -56,0 +56,0 @@ ### `no-reassign`

"use strict";
var assign = require("object-assign");
var path = require("path");
var test = require("../../utils").test;

@@ -11,34 +10,20 @@ var linter = require("eslint").linter,

var ecmaFeatures = {ecmaFeatures: { modules: true}};
function filename(f) {
return path.join(process.cwd(), "./files", f);
}
var ERRORS = [{message: "Imported file does not exist.", type: "Literal"}];
eslintTester.addRuleTest("lib/rules/exists", {
valid: [
assign({
code: "import foo from './bar';",
filename: filename("foo.js")
}, ecmaFeatures),
assign({
code: "import bar from './bar.js';",
filename: filename("foo.js")
}, ecmaFeatures),
assign({
code: "import {someThing} from './module';",
filename: filename("foo.js")
}, ecmaFeatures)
],
test({
code: "import foo from './bar';"}),
test({
code: "import bar from './bar.js';"}),
test({
code: "import {someThing} from './module';"})
],
invalid: [
assign({
test({
code: "import bar from './baz';",
filename: filename("foo.js"),
errors: ERRORS
}, ecmaFeatures)
errors: [{message: "Unable to resolve path to module './baz'.", type: "Literal"}]}),
test({
code: "import bar from './empty-folder';",
errors: [{message: "Unable to resolve path to module './empty-folder'.", type: "Literal"}]})
]
});

@@ -16,3 +16,7 @@ "use strict";

// may assign to imported namespaces' names' members
test({code: "import * as foo from './bar'; foo.x.y = 42; "})
test({code: "import * as foo from './bar'; foo.x.y = 42; "}),
// ensure object literals are not compromised
test({code: "import * as foo from './bar'; var x = {foo: 42}; "}),
test({code: "import * as foo from './bar'; var x = {\"foo\": 42}; "})
],

@@ -60,4 +64,33 @@

code: "import * as foo from './bar'; foo.x = 'y';",
errors: [{ message: "Assignment to member of namespace 'foo'."}]})
errors: [{ message: "Assignment to member of namespace 'foo'."}]}),
///////////////////
// destructuring //
///////////////////
test({
code: "import { foo } from './bar'; var { foo } = {foo: 'y'};",
errors: [{ message: "Reassignment of local imported name 'foo'."}],
ecmaFeatures: {modules: true, destructuring: true}}),
test({
code: "import { foo } from './bar'; var [foo] = ['y'];",
errors: [{ message: "Reassignment of local imported name 'foo'."}],
ecmaFeatures: {modules: true, destructuring: true}}),
test({
code: "import { foo } from './bar'; var [[foo]] = [['y']];",
errors: [{ message: "Reassignment of local imported name 'foo'."}],
ecmaFeatures: {modules: true, destructuring: true}}),
test({
code: "import { foo } from './bar'; var [{foo}] = [{foo:'y'}];",
errors: [{ message: "Reassignment of local imported name 'foo'."}],
ecmaFeatures: {modules: true, destructuring: true}}),
test({
code: "import { foo } from './bar'; var {bar: [foo]} = {bar:['y']};",
errors: [{ message: "Reassignment of local imported name 'foo'."}],
ecmaFeatures: {modules: true, destructuring: true}})
]
});
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