diff --git a/CHANGELOG.md b/CHANGELOG.md index 76bcb69afd..f002a4573a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com). -## [Unreleased] +## Unreleased +... + +## [1.9.2] - 2016-06-21 +### Fixed +- Issues with ignored/CJS files in [`export`] and [`no-deprecated`] rules. ([#348], [#370]) ## [1.9.1] - 2016-06-16 ### Fixed @@ -252,6 +257,8 @@ for info on changes for earlier releases. [#314]: https://github.com/benmosher/eslint-plugin-import/pull/314 [#373]: https://github.com/benmosher/eslint-plugin-import/issues/373 +[#370]: https://github.com/benmosher/eslint-plugin-import/issues/370 +[#348]: https://github.com/benmosher/eslint-plugin-import/issues/348 [#342]: https://github.com/benmosher/eslint-plugin-import/issues/342 [#328]: https://github.com/benmosher/eslint-plugin-import/issues/328 [#317]: https://github.com/benmosher/eslint-plugin-import/issues/317 @@ -272,7 +279,8 @@ for info on changes for earlier releases. [#119]: https://github.com/benmosher/eslint-plugin-import/issues/119 [#89]: https://github.com/benmosher/eslint-plugin-import/issues/89 -[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v1.9.1...HEAD +[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v1.9.2...HEAD +[1.9.2]: https://github.com/benmosher/eslint-plugin-import/compare/v1.9.1...v1.9.2 [1.9.1]: https://github.com/benmosher/eslint-plugin-import/compare/v1.9.0...v1.9.1 [1.9.0]: https://github.com/benmosher/eslint-plugin-import/compare/v1.8.1...v1.9.0 [1.8.1]: https://github.com/benmosher/eslint-plugin-import/compare/v1.8.0...v1.8.1 diff --git a/package.json b/package.json index 8fc455739f..c964e77499 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-import", - "version": "1.9.1", + "version": "1.9.2", "description": "Import with sanity.", "main": "lib/index.js", "directories": { diff --git a/src/core/getExports.js b/src/core/getExports.js index f0cf676144..00a0a273b8 100644 --- a/src/core/getExports.js +++ b/src/core/getExports.js @@ -334,8 +334,11 @@ export default class ExportMap { this.namespace.forEach((v, n) => callback.call(thisArg, v, n, this)) - this.reexports.forEach(({ getImport, local }, name) => - callback.call(thisArg, getImport().get(local), name, this)) + this.reexports.forEach(({ getImport, local }, name) => { + const reexported = getImport() + // can't look up meta for ignored re-exports (#348) + callback.call(thisArg, reexported && reexported.get(local), name, this) + }) this.dependencies.forEach(dep => dep().forEach((v, n) => n !== 'default' && callback.call(thisArg, v, n, this))) diff --git a/src/rules/no-deprecated.js b/src/rules/no-deprecated.js index 034827034c..882f5e48c2 100644 --- a/src/rules/no-deprecated.js +++ b/src/rules/no-deprecated.js @@ -50,11 +50,11 @@ module.exports = function (context) { } // unknown thing can't be deprecated - if (!imports.has(imported)) return + const exported = imports.get(imported) + if (exported == null) return // capture import of deep namespace - const { namespace } = imports.get(imported) - if (namespace) namespaces.set(local, namespace) + if (exported.namespace) namespaces.set(local, exported.namespace) const deprecation = getDeprecation(imports.get(imported)) if (!deprecation) return diff --git a/tests/files/issue-370-commonjs-namespace/bar.js b/tests/files/issue-370-commonjs-namespace/bar.js new file mode 100644 index 0000000000..3ec93603af --- /dev/null +++ b/tests/files/issue-370-commonjs-namespace/bar.js @@ -0,0 +1,2 @@ +// bar.js +export { default as foo } from './foo' \ No newline at end of file diff --git a/tests/files/issue-370-commonjs-namespace/foo.js b/tests/files/issue-370-commonjs-namespace/foo.js new file mode 100644 index 0000000000..ba097965ed --- /dev/null +++ b/tests/files/issue-370-commonjs-namespace/foo.js @@ -0,0 +1,2 @@ +// foo.js +module.exports = { foo: 'foo' } \ No newline at end of file diff --git a/tests/src/rules/export.js b/tests/src/rules/export.js index 3f101291c9..97714dc5fa 100644 --- a/tests/src/rules/export.js +++ b/tests/src/rules/export.js @@ -1,4 +1,4 @@ -import { test } from '../utils' +import { test, SYNTAX_CASES } from '../utils' import { RuleTester } from 'eslint' @@ -24,6 +24,8 @@ ruleTester.run('export', rule, { // #328: "export * from" does not export a default test({ code: 'export default foo; export * from "./bar"' }), + + ...SYNTAX_CASES, ], invalid: [ diff --git a/tests/src/rules/no-deprecated.js b/tests/src/rules/no-deprecated.js index ef6912dd1e..1ab242b007 100644 --- a/tests/src/rules/no-deprecated.js +++ b/tests/src/rules/no-deprecated.js @@ -1,4 +1,4 @@ -import { test } from '../utils' +import { test, SYNTAX_CASES } from '../utils' import { RuleTester } from 'eslint' @@ -37,6 +37,9 @@ ruleTester.run('no-deprecated', rule, { test({ code: "import { deepDep } from './deep-deprecated'; function x(deepDep) { console.log(deepDep.MY_TERRIBLE_ACTION) }", }), + + + ...SYNTAX_CASES, ], invalid: [ diff --git a/tests/src/utils.js b/tests/src/utils.js index db5fed076e..18ec6e98a5 100644 --- a/tests/src/utils.js +++ b/tests/src/utils.js @@ -63,4 +63,15 @@ export const SYNTAX_CASES = [ settings: { 'import/extensions': ['.js'] }, // breaking: remove for v2 }), + // issue #370: deep commonjs import + test({ + code: 'import { foo } from "./issue-370-commonjs-namespace/bar"', + settings: { 'import/ignore': ['foo'] }, + }), + + // issue #348: deep commonjs re-export + test({ + code: 'export * from "./issue-370-commonjs-namespace/bar"', + settings: { 'import/ignore': ['foo'] }, + }), ]