Skip to content

Commit

Permalink
Fix #566: reject false positive on export default from '...'
Browse files Browse the repository at this point in the history
  • Loading branch information
benmosher committed Sep 20, 2016
1 parent c45fdc3 commit b6ac532
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]).
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/rules/no-named-as-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions tests/src/rules/no-named-as-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],

Expand Down

0 comments on commit b6ac532

Please sign in to comment.