web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB

  1. # import/no-named-as-default
  2. Reports use of an exported name as the locally imported name of a default export.
  3. Rationale: using an exported name as the name of the default export is likely...
  4. - *misleading*: others familiar with `foo.js` probably expect the name to be `foo`
  5. - *a mistake*: only needed to import `bar` and forgot the brackets (the case that is prompting this)
  6. ## Rule Details
  7. Given:
  8. ```js
  9. // foo.js
  10. export default 'foo';
  11. export const bar = 'baz';
  12. ```
  13. ...this would be valid:
  14. ```js
  15. import foo from './foo.js';
  16. ```
  17. ...and this would be reported:
  18. ```js
  19. // message: Using exported name 'bar' as identifier for default export.
  20. import bar from './foo.js';
  21. ```
  22. 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:
  23. ```js
  24. // valid:
  25. export foo from './foo.js'
  26. // message: Using exported name 'bar' as identifier for default export.
  27. export bar from './foo.js';
  28. ```
  29. ## Further Reading
  30. - ECMAScript Proposal: [export ns from]
  31. - ECMAScript Proposal: [export default from]
  32. [export ns from]: https://github.com/leebyron/ecmascript-export-ns-from
  33. [export default from]: https://github.com/leebyron/ecmascript-export-default-from