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.

73 lines
2.0 KiB

  1. # import/no-anonymous-default-export
  2. Reports if a module's default export is unnamed. This includes several types of unnamed data types; literals, object expressions, arrays, anonymous functions, arrow functions, and anonymous class declarations.
  3. Ensuring that default exports are named helps improve the grepability of the codebase by encouraging the re-use of the same identifier for the module's default export at its declaration site and at its import sites.
  4. ## Options
  5. By default, all types of anonymous default exports are forbidden, but any types can be selectively allowed by toggling them on in the options.
  6. The complete default configuration looks like this.
  7. ```js
  8. "import/no-anonymous-default-export": ["error", {
  9. "allowArray": false,
  10. "allowArrowFunction": false,
  11. "allowAnonymousClass": false,
  12. "allowAnonymousFunction": false,
  13. "allowCallExpression": true, // The true value here is for backward compatibility
  14. "allowLiteral": false,
  15. "allowObject": false
  16. }]
  17. ```
  18. ## Rule Details
  19. ### Fail
  20. ```js
  21. export default []
  22. export default () => {}
  23. export default class {}
  24. export default function () {}
  25. /* eslint import/no-anonymous-default-export: [2, {"allowCallExpression": false}] */
  26. export default foo(bar)
  27. export default 123
  28. export default {}
  29. ```
  30. ### Pass
  31. ```js
  32. const foo = 123
  33. export default foo
  34. export default class MyClass() {}
  35. export default function foo() {}
  36. /* eslint import/no-anonymous-default-export: [2, {"allowArray": true}] */
  37. export default []
  38. /* eslint import/no-anonymous-default-export: [2, {"allowArrowFunction": true}] */
  39. export default () => {}
  40. /* eslint import/no-anonymous-default-export: [2, {"allowAnonymousClass": true}] */
  41. export default class {}
  42. /* eslint import/no-anonymous-default-export: [2, {"allowAnonymousFunction": true}] */
  43. export default function () {}
  44. export default foo(bar)
  45. /* eslint import/no-anonymous-default-export: [2, {"allowLiteral": true}] */
  46. export default 123
  47. /* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
  48. export default {}
  49. ```