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.

71 lines
1.8 KiB

  1. # import/default
  2. If a default import is requested, this rule will report if there is no default
  3. export in the imported module.
  4. For [ES7], reports if a default is named and exported but is not found in the
  5. referenced module.
  6. Note: for packages, the plugin will find exported names
  7. from [`jsnext:main`], if present in `package.json`.
  8. Redux's npm module includes this key, and thereby is lintable, for example.
  9. A module path that is [ignored] or not [unambiguously an ES module] will not be reported when imported.
  10. [ignored]: ../README.md#importignore
  11. [unambiguously an ES module]: https://github.com/bmeck/UnambiguousJavaScriptGrammar
  12. ## Rule Details
  13. Given:
  14. ```js
  15. // ./foo.js
  16. export default function () { return 42 }
  17. // ./bar.js
  18. export function bar() { return null }
  19. // ./baz.js
  20. module.exports = function () { /* ... */ }
  21. // node_modules/some-module/index.js
  22. exports.sharedFunction = function shared() { /* ... */ }
  23. ```
  24. The following is considered valid:
  25. ```js
  26. import foo from './foo'
  27. // assuming 'node_modules' are ignored (true by default)
  28. import someModule from 'some-module'
  29. ```
  30. ...and the following cases are reported:
  31. ```js
  32. import bar from './bar' // no default export found in ./bar
  33. import baz from './baz' // no default export found in ./baz
  34. ```
  35. ## When Not To Use It
  36. If you are using CommonJS and/or modifying the exported namespace of any module at
  37. runtime, you will likely see false positives with this rule.
  38. This rule currently does not interpret `module.exports = ...` as a `default` export,
  39. either, so such a situation will be reported in the importing module.
  40. ## Further Reading
  41. - Lee Byron's [ES7] export proposal
  42. - [`import/ignore`] setting
  43. - [`jsnext:main`] (Rollup)
  44. [ES7]: https://github.com/leebyron/ecmascript-more-export-from
  45. [`import/ignore`]: ../../README.md#importignore
  46. [`jsnext:main`]: https://github.com/rollup/rollup/wiki/jsnext:main