1 | "use strict";
|
2 |
|
3 | const camelcase = {
|
4 | allow: ["^UNSAFE_"],
|
5 | ignoreDestructuring: false,
|
6 | properties: "always",
|
7 | };
|
8 |
|
9 | module.exports = {
|
10 |
|
11 | ["camelcase"]: camelcase,
|
12 | ["comma-spacing"]: {
|
13 | after: true,
|
14 | before: false
|
15 | },
|
16 | ["indent"]: {
|
17 | ArrayExpression: 1,
|
18 | CallExpression: {
|
19 | arguments: 1
|
20 | },
|
21 | FunctionDeclaration: {
|
22 | body: 1,
|
23 | parameters: 1
|
24 | },
|
25 | FunctionExpression: {
|
26 | body: 1,
|
27 | parameters: 1
|
28 | },
|
29 | MemberExpression: 1,
|
30 | ObjectExpression: 1,
|
31 | SwitchCase: 1,
|
32 | VariableDeclarator: 1,
|
33 |
|
34 |
|
35 | ignoredNodes: [
|
36 | "JSXElement",
|
37 | "JSXElement > *",
|
38 | "JSXAttribute",
|
39 | "JSXIdentifier",
|
40 | "JSXNamespacedName",
|
41 | "JSXMemberExpression",
|
42 | "JSXSpreadAttribute",
|
43 | "JSXExpressionContainer",
|
44 | "JSXOpeningElement",
|
45 | "JSXClosingElement",
|
46 | "JSXText",
|
47 | "JSXEmptyExpression",
|
48 | "JSXSpreadChild"
|
49 | ],
|
50 | outerIIFEBody: 1
|
51 | },
|
52 | ["max-lines"]: {
|
53 | max: 700,
|
54 | skipBlankLines: true,
|
55 | skipComments: true
|
56 | },
|
57 | ["no-unused-expressions"]: {
|
58 | allowShortCircuit: true,
|
59 | allowTernary: true
|
60 | },
|
61 | ["no-unused-vars"]: {
|
62 | args: "none",
|
63 | caughtErrors: "none",
|
64 | ignoreRestSiblings: true,
|
65 | vars: "all"
|
66 | },
|
67 | ["quotes"]: {
|
68 | avoidEscape: true
|
69 | },
|
70 | ["space-before-function-paren"]: {
|
71 | anonymous: "always",
|
72 | named: "never"
|
73 | },
|
74 | ["@typescript-eslint/ban-types"]: {
|
75 | types: {
|
76 |
|
77 | String: {
|
78 | message: "Use string instead",
|
79 | fixWith: "string"
|
80 | },
|
81 | Boolean: {
|
82 | message: "Use boolean instead",
|
83 | fixWith: "boolean"
|
84 | },
|
85 | Number: {
|
86 | message: "Use number instead",
|
87 | fixWith: "number"
|
88 | },
|
89 | Object: {
|
90 | message: "Use Record<string, unknown> instead",
|
91 | fixWith: "Record<string, unknown>"
|
92 | },
|
93 | Symbol: {
|
94 | message: "Use symbol instead",
|
95 | fixWith: "symbol"
|
96 | }
|
97 | }
|
98 | },
|
99 | ["@typescript-eslint/camelcase"]: {
|
100 | ...camelcase,
|
101 | genericType: "always"
|
102 | },
|
103 | ["@typescript-eslint/naming-convention"]: (() => {
|
104 | const options = {
|
105 | default: {
|
106 | format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
107 | leadingUnderscore: "allow",
|
108 | selector: "default",
|
109 | trailingUnderscore: "allow",
|
110 | },
|
111 | function: {
|
112 | format: ["camelCase"],
|
113 | leadingUnderscore: "allow",
|
114 | selector: "function",
|
115 | trailingUnderscore: "allow",
|
116 | },
|
117 | parameter: {
|
118 | format: ["camelCase", "PascalCase"],
|
119 | leadingUnderscore: "allow",
|
120 | selector: "parameter",
|
121 | trailingUnderscore: "allow",
|
122 | },
|
123 | method: {
|
124 | format: ["camelCase"],
|
125 | leadingUnderscore: "allow",
|
126 | selector: "method",
|
127 | trailingUnderscore: "allow",
|
128 | },
|
129 | typeLike: {
|
130 | format: ["PascalCase"],
|
131 | leadingUnderscore: "allow",
|
132 | selector: "typeLike",
|
133 | trailingUnderscore: "allow",
|
134 | },
|
135 | enumMember: {
|
136 | format: ["PascalCase"],
|
137 | leadingUnderscore: "allow",
|
138 | selector: "enumMember",
|
139 | trailingUnderscore: "allow",
|
140 | },
|
141 | };
|
142 |
|
143 |
|
144 |
|
145 | const escapeHatches = [
|
146 | "variable",
|
147 | "function",
|
148 | "parameter",
|
149 | "property",
|
150 | "parameterProperty",
|
151 | "method",
|
152 | "accessor",
|
153 | "enumMember",
|
154 | "class",
|
155 | "interface",
|
156 | "typeAlias",
|
157 | "enum",
|
158 | "typeParameter"
|
159 | ].map(selector => ({
|
160 | filter: {
|
161 | match: true,
|
162 |
|
163 | regex: "^(__|UNSAFE_).+$",
|
164 | },
|
165 | format: null,
|
166 | selector,
|
167 | }));
|
168 |
|
169 | options.defaultRules = [
|
170 | ...Object.values(options),
|
171 | ...escapeHatches,
|
172 | ];
|
173 |
|
174 | options.ignoreProperties = {
|
175 | selector: "property",
|
176 | format: null,
|
177 | };
|
178 |
|
179 | return options;
|
180 | })()
|
181 |
|
182 | };
|