Sha256: 821c720e4e6e91ec998ff0937fe197d24643a332de57b91d4f4b11a93f794065

Contents?: true

Size: 1.35 KB

Versions: 49

Compression:

Stored size: 1.35 KB

Contents

# import/no-named-as-default

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

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

Reports use of an exported name as the locally imported name of a default export.

Rationale: using an exported name as the name of the default export is likely...

 - _misleading_: others familiar with `foo.js` probably expect the name to be `foo`
 - _a mistake_: only needed to import `bar` and forgot the brackets (the case that is prompting this)

## Rule Details

Given:

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

...this would be valid:

```js
import foo from './foo.js';
```

...and this would be reported:

```js
// message: Using exported name 'bar' as identifier for default export.
import bar from './foo.js';
```

For post-ES2015 `export` extensions, this also prevents exporting the default from a referenced module as a name within that module, for the same reasons:

```js
// valid:
export foo from './foo.js';

// message: Using exported name 'bar' as identifier for default export.
export bar from './foo.js';
```

## Further Reading

 - ECMAScript Proposal: [export ns from]
 - ECMAScript Proposal: [export default from]

[export ns from]: https://github.com/leebyron/ecmascript-export-ns-from
[export default from]: https://github.com/leebyron/ecmascript-export-default-from

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.md
immosquare-cleaner-0.1.59 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.58 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.57 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.56 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.55 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.54 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.53 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.52 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.51 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.50 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.49 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.48 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.47 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.46 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.45 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.44 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.43 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.42 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md
immosquare-cleaner-0.1.41 node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md