Skip to content

Commit

Permalink
Fix false positive with default import having a "default" property (f…
Browse files Browse the repository at this point in the history
…ixes #507, closes #508)
  • Loading branch information
jquense authored and benmosher committed Aug 23, 2016
1 parent ff0ef90 commit 0d98253
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).

## [Unreleased]
### Added
- Added an `allow` option to [`no-nodejs-modules`] to allow exceptions ([#452], [#509]).

### Fixed
- [`no-named-as-default-member`] Allow default import to have a property named "default" ([#507], thanks [@jquense])

## [1.14.0] - 2016-08-22
### Added
- [`import/parsers` setting]: parse some dependencies (i.e. TypeScript!) with a different parser than the ESLint-configured parser. ([#503])
Expand Down Expand Up @@ -329,6 +333,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

[#507]: https://github.com/benmosher/eslint-plugin-import/issues/507
[#478]: https://github.com/benmosher/eslint-plugin-import/issues/478
[#456]: https://github.com/benmosher/eslint-plugin-import/issues/456
[#453]: https://github.com/benmosher/eslint-plugin-import/issues/453
Expand Down
4 changes: 4 additions & 0 deletions src/rules/no-named-as-default-member.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ module.exports = function(context) {
if (fileImport == null) return

lookups.forEach(({propName, node}) => {
// the default import can have a "default" property
if (propName === 'default') {
return
}
if (fileImport.exportMap.namespace.has(propName)) {
context.report({
node,
Expand Down
4 changes: 4 additions & 0 deletions tests/files/default-export-default-property.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export default {
default: 'baz'
}
1 change: 1 addition & 0 deletions tests/src/rules/no-named-as-default-member.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ruleTester.run('no-named-as-default-member', rule, {
test({code: 'import bar from "./bar"; const baz = bar.baz'}),
test({code: 'import {foo} from "./bar"; const baz = foo.baz;'}),
test({code: 'import * as named from "./named-exports"; const a = named.a'}),
test({code: 'import foo from "./default-export-default-property"; const a = foo.default'}),

...SYNTAX_CASES,
],
Expand Down

0 comments on commit 0d98253

Please sign in to comment.