-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
no-enum.ts
41 lines (38 loc) · 1.06 KB
/
no-enum.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* @license Use of this source code is governed by an MIT-style license that
* can be found in the LICENSE file at https://github.com/cartant/eslint-plugin-etc
*/
import { TSESTree as es } from "@typescript-eslint/experimental-utils";
import { getLoc, getParserServices } from "eslint-etc";
import * as ts from "typescript";
import { ruleCreator } from "../utils";
const rule = ruleCreator({
defaultOptions: [],
meta: {
docs: {
description: "Forbids the use of `enum`.",
recommended: false,
},
fixable: undefined,
hasSuggestions: false,
messages: {
forbidden: "`enum` is forbidden.",
},
schema: [],
type: "problem",
},
name: "no-enum",
create: (context) => ({
TSEnumDeclaration: (node: es.Node) => {
const { esTreeNodeToTSNodeMap } = getParserServices(context);
const enumDeclaration = esTreeNodeToTSNodeMap.get(
node
) as ts.EnumDeclaration;
context.report({
messageId: "forbidden",
loc: getLoc(enumDeclaration.name),
});
},
}),
});
export = rule;