Skip to content

Commit 6e8f0c6

Browse files
committed
Create no-const-enum and no-enum
1 parent 5498399 commit 6e8f0c6

File tree

14 files changed

+2714
-7
lines changed

14 files changed

+2714
-7
lines changed

docs/rules/no-const-enum.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Disallow the use of TypeScript const enums (`no-const-enum`)
2+
3+
This rule disallows the use of TypeScript const enums.
4+
5+
## Rule Details
6+
7+
Examples of **incorrect** code for this rule:
8+
9+
```ts
10+
const enum Foo {
11+
Bar = "Bar",
12+
Baz = "Baz",
13+
}
14+
```
15+
16+
Examples of **correct** code for this rule:
17+
18+
```ts
19+
type Foo = "Bar" | "Baz";
20+
```

docs/rules/no-enum.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Disallow the use of TypeScript enums (`no-enum`)
2+
3+
This rule disallows the use of TypeScript enums.
4+
5+
## Rule Details
6+
7+
Examples of **incorrect** code for this rule:
8+
9+
```ts
10+
enum Foo {
11+
Bar,
12+
Baz,
13+
}
14+
15+
const enum Foo {
16+
Bar = "Bar",
17+
Baz = "Baz",
18+
}
19+
20+
enum Foo {
21+
Bar = "BAR",
22+
Baz = "BAZ",
23+
}
24+
```
25+
26+
Examples of **correct** code for this rule:
27+
28+
```ts
29+
const Foo = {
30+
Bar: 0,
31+
Baz: 1,
32+
} as const;
33+
34+
type Foo = "Bar" | "Baz";
35+
36+
const Foo = {
37+
Bar: "BAR",
38+
Baz: "BAZ",
39+
} as const;
40+
```

0 commit comments

Comments
 (0)