From b6ac53216cd50ed099c658bcc7ae2feea81e7d78 Mon Sep 17 00:00:00 2001 From: Ben Mosher Date: Tue, 20 Sep 2016 06:12:14 -0400 Subject: [PATCH] Fix #566: reject false positive on `export default from '...'` --- CHANGELOG.md | 7 +++++++ src/rules/no-named-as-default.js | 3 +++ tests/src/rules/no-named-as-default.js | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a898f2641..c65f2753d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel - New rule [`no-internal-modules`]: restrict deep package imports to specific folders. ([#485], thanks [@spalger]!) - [`extensions`]: allow override of a chosen default with options object ([#555], thanks [@ljharb]!) +### Fixed +- [`no-named-as-default`] no longer false-positive's on `export default from '...'` + ([#566], thanks [@preco21]) + ## [1.15.0] - 2016-09-12 ### Added - Added an `allow` option to [`no-nodejs-modules`] to allow exceptions ([#452], [#509]). @@ -288,6 +292,7 @@ for info on changes for earlier releases. [`no-amd`]: ./docs/rules/no-amd.md [`namespace`]: ./docs/rules/namespace.md [`no-namespace`]: ./docs/rules/no-namespace.md +[`no-named-as-default`]: ./docs/rules/no-named-as-default.md [`no-named-as-default-member`]: ./docs/rules/no-named-as-default-member.md [`no-extraneous-dependencies`]: ./docs/rules/no-extraneous-dependencies.md [`extensions`]: ./docs/rules/extensions.md @@ -350,6 +355,7 @@ for info on changes for earlier releases. [#157]: https://github.com/benmosher/eslint-plugin-import/pull/157 [#314]: https://github.com/benmosher/eslint-plugin-import/pull/314 +[#566]: https://github.com/benmosher/eslint-plugin-import/issues/566 [#530]: https://github.com/benmosher/eslint-plugin-import/issues/530 [#507]: https://github.com/benmosher/eslint-plugin-import/issues/507 [#478]: https://github.com/benmosher/eslint-plugin-import/issues/478 @@ -451,3 +457,4 @@ for info on changes for earlier releases. [@tizmagik]: https://github.com/tizmagik [@knpwrs]: https://github.com/knpwrs [@spalger]: https://github.com/spalger +[@preco21]: https://github.com/preco21 diff --git a/src/rules/no-named-as-default.js b/src/rules/no-named-as-default.js index a6a3ffd52..bba744d51 100644 --- a/src/rules/no-named-as-default.js +++ b/src/rules/no-named-as-default.js @@ -3,6 +3,9 @@ import importDeclaration from '../importDeclaration' module.exports = function (context) { function checkDefault(nameKey, defaultSpecifier) { + // #566: default is a valid specifier + if (defaultSpecifier[nameKey].name === 'default') return + var declaration = importDeclaration(context) var imports = Exports.get(declaration.source.value, context) diff --git a/tests/src/rules/no-named-as-default.js b/tests/src/rules/no-named-as-default.js index e3a843378..d249545f4 100644 --- a/tests/src/rules/no-named-as-default.js +++ b/tests/src/rules/no-named-as-default.js @@ -17,6 +17,10 @@ ruleTester.run('no-named-as-default', rule, { test({ code: 'export bar from "./bar";' , parser: 'babel-eslint' }), + // #566: don't false-positive on `default` itself + test({ code: 'export default from "./bar";' + , parser: 'babel-eslint' }), + ...SYNTAX_CASES, ],