1 | # `no-useless-empty-export`
|
2 |
|
3 | Disallow empty exports that don't change anything in a module file.
|
4 |
|
5 | ## Rule Details
|
6 |
|
7 | An empty `export {}` statement is sometimes useful in TypeScript code to turn a file that would otherwise be a script file into a module file.
|
8 | Per the TypeScript Handbook [Modules](https://www.typescriptlang.org/docs/handbook/modules.html) page:
|
9 |
|
10 | > In TypeScript, just as in ECMAScript 2015, any file containing a top-level import or export is considered a module.
|
11 | > Conversely, a file without any top-level import or export declarations is treated as a script whose contents are available in the global scope (and therefore to modules as well).
|
12 |
|
13 | However, an `export {}` statement does nothing if there are any other top-level import or export statements in a file.
|
14 |
|
15 | Examples of code for this rule:
|
16 |
|
17 |
|
18 |
|
19 | ### ❌ Incorrect
|
20 |
|
21 | ```ts
|
22 | export const value = 'Hello, world!';
|
23 | export {};
|
24 | ```
|
25 |
|
26 | ```ts
|
27 | import 'some-other-module';
|
28 | export {};
|
29 | ```
|
30 |
|
31 | ### ✅ Correct
|
32 |
|
33 | ```ts
|
34 | export const value = 'Hello, world!';
|
35 | ```
|
36 |
|
37 | ```ts
|
38 | import 'some-other-module';
|
39 | ```
|
40 |
|
41 | ## Options
|
42 |
|
43 | ```jsonc
|
44 | // .eslintrc.json
|
45 | {
|
46 | "rules": {
|
47 | "@typescript-eslint/no-useless-empty-export": "warn"
|
48 | }
|
49 | }
|
50 | ```
|
51 |
|
52 | This rule is not configurable.
|
53 |
|
54 | ## Attributes
|
55 |
|
56 | - Configs:
|
57 | - [ ] ✅ Recommended
|
58 | - [ ] 🔒 Strict
|
59 | - [x] 🔧 Fixable
|
60 | - [ ] 💭 Requires type information
|