Sha256: ad87a63b2ab58e85ee1817b5330152613ee0ace5721189f88d36bbd68b08c341

Contents?: true

Size: 1.38 KB

Versions: 49

Compression:

Stored size: 1.38 KB

Contents

# import/no-named-as-default-member

⚠️ This rule _warns_ in the following configs: ☑️ `recommended`, 🚸 `warnings`.

<!-- end auto-generated rule header -->

Reports use of an exported name as a property on the default export.

Rationale: Accessing a property that has a name that is shared by an exported
name from the same module is likely to be a mistake.

Named import syntax looks very similar to destructuring assignment. It's easy to
make the (incorrect) assumption that named exports are also accessible as
properties of the default export.

Furthermore, [in Babel 5 this is actually how things worked][blog]. This was
fixed in Babel 6. Before upgrading an existing codebase to Babel 6, it can be
useful to run this lint rule.

[blog]: https://kentcdodds.com/blog/misunderstanding-es6-modules-upgrading-babel-tears-and-a-solution

## Rule Details

Given:

```js
// foo.js
export default 'foo';
export const bar = 'baz';
```

...this would be valid:

```js
import foo, {bar} from './foo.js';
```

...and the following would be reported:

```js
// Caution: `foo` also has a named export `bar`.
// Check if you meant to write `import {bar} from './foo.js'` instead.
import foo from './foo.js';
const bar = foo.bar;
```

```js
// Caution: `foo` also has a named export `bar`.
// Check if you meant to write `import {bar} from './foo.js'` instead.
import foo from './foo.js';
const {bar} = foo;
```

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
immosquare-cleaner-0.1.60 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.59 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.58 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.57 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.56 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.55 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.54 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.53 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.52 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.51 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.50 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.49 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.48 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.47 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.46 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.45 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.44 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.43 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.42 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md
immosquare-cleaner-0.1.41 node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md