source: frontend/node_modules/eslint-plugin-import/docs/rules/no-anonymous-default-export.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.2 KB
Line 
1# import/no-anonymous-default-export
2
3<!-- end auto-generated rule header -->
4
5Reports 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.
6
7Ensuring 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.
8
9## Options
10
11By default, all types of anonymous default exports are forbidden, but any types can be selectively allowed by toggling them on in the options.
12
13The complete default configuration looks like this.
14
15```js
16"import/no-anonymous-default-export": ["error", {
17 "allowArray": false,
18 "allowArrowFunction": false,
19 "allowAnonymousClass": false,
20 "allowAnonymousFunction": false,
21 "allowCallExpression": true, // The true value here is for backward compatibility
22 "allowNew": false,
23 "allowLiteral": false,
24 "allowObject": false
25}]
26```
27
28## Rule Details
29
30### Fail
31
32```js
33export default []
34
35export default () => {}
36
37export default class {}
38
39export default function () {}
40
41/* eslint import/no-anonymous-default-export: [2, {"allowCallExpression": false}] */
42export default foo(bar)
43
44export default 123
45
46export default {}
47
48export default new Foo()
49```
50
51### Pass
52
53```js
54const foo = 123
55export default foo
56
57export default class MyClass() {}
58
59export default function foo() {}
60
61/* eslint import/no-anonymous-default-export: [2, {"allowArray": true}] */
62export default []
63
64/* eslint import/no-anonymous-default-export: [2, {"allowArrowFunction": true}] */
65export default () => {}
66
67/* eslint import/no-anonymous-default-export: [2, {"allowAnonymousClass": true}] */
68export default class {}
69
70/* eslint import/no-anonymous-default-export: [2, {"allowAnonymousFunction": true}] */
71export default function () {}
72
73export default foo(bar)
74
75/* eslint import/no-anonymous-default-export: [2, {"allowLiteral": true}] */
76export default 123
77
78/* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
79export default {}
80
81/* eslint import/no-anonymous-default-export: [2, {"allowNew": true}] */
82export default new Foo()
83```
Note: See TracBrowser for help on using the repository browser.