Skip to content

Commit 8615306

Browse files
authored
build(devs-dep): simplify eslint config (#2403)
1 parent 77871b8 commit 8615306

40 files changed

+250
-328
lines changed

.eslintrc.js

Lines changed: 60 additions & 252 deletions
Original file line numberDiff line numberDiff line change
@@ -4,266 +4,74 @@ module.exports = {
44
es6: true,
55
'jest/globals': true,
66
},
7-
extends: [
8-
'eslint:recommended',
9-
'plugin:@typescript-eslint/recommended',
10-
'plugin:@typescript-eslint/recommended-requiring-type-checking',
11-
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
12-
'plugin:jest/recommended',
13-
'plugin:prettier/recommended'
14-
],
15-
parser: '@typescript-eslint/parser',
167
parserOptions: {
17-
project: 'tsconfig.json',
188
ecmaVersion: 2020,
199
sourceType: 'module',
20-
impliedStrict: true,
2110
ecmaFeatures: {
2211
jsx: true,
2312
},
2413
},
25-
plugins: ['@typescript-eslint', 'import', 'jest', 'jsdoc'],
26-
rules: {
27-
'arrow-body-style': 'warn',
28-
'arrow-parens': ['off', 'always'],
29-
'brace-style': ['off', 'off'],
30-
camelcase: 'warn',
31-
'class-methods-use-this': 'warn',
32-
'comma-dangle': 'off',
33-
complexity: 'off',
34-
'constructor-super': 'error',
35-
curly: ['warn', 'multi-line'],
36-
'default-case': 'error',
37-
'dot-notation': 'error',
38-
'eol-last': 'off',
39-
eqeqeq: ['error', 'smart'],
40-
'for-direction': ['error'],
41-
'getter-return': 'warn',
42-
'guard-for-in': 'error',
43-
'id-match': 'error',
44-
'import/order': [
45-
'error',
46-
{
47-
'alphabetize': {
48-
'order': 'asc',
49-
'caseInsensitive': true,
50-
},
51-
// this is the default order except for added `internal` in the middle
52-
'groups': [
53-
'builtin',
54-
'external',
55-
'internal',
56-
'parent',
57-
'sibling',
58-
'index',
59-
],
60-
'newlines-between': 'always',
61-
}
62-
],
63-
'jest/valid-title': 'off',
64-
'jest/no-conditional-expect': 'off',
65-
'jsdoc/check-alignment': 'error',
66-
'jsdoc/check-indentation': 'error',
67-
'jsdoc/newline-after-description': 'warn',
68-
'linebreak-style': 'off',
69-
'max-classes-per-file': 'off',
70-
'max-len': 'off',
71-
'new-parens': 'off',
72-
'newline-per-chained-call': 'off',
73-
'no-bitwise': 'off',
74-
'no-caller': 'error',
75-
'no-duplicate-imports': 'error',
76-
'no-eval': 'error',
77-
'no-console': 'error',
78-
'no-async-promise-executor': ['error'],
79-
'no-case-declarations': ['error'],
80-
'no-class-assign': ['error'],
81-
'no-compare-neg-zero': ['error'],
82-
'no-cond-assign': 'error',
83-
'no-const-assign': ['error'],
84-
'no-constant-condition': ['warn'],
85-
'no-control-regex': ['warn'],
86-
'no-debugger': 'error',
87-
'no-delete-var': ['error'],
88-
'no-dupe-args': ['error'],
89-
'no-dupe-class-members': 'warn',
90-
'no-dupe-keys': ['error'],
91-
'no-duplicate-case': ['error'],
92-
'no-empty': [
93-
'error',
94-
{
95-
allowEmptyCatch: true,
96-
},
97-
],
98-
'no-empty-character-class': ['error'],
99-
'no-empty-pattern': ['error'],
100-
'no-ex-assign': ['error'],
101-
'no-extra-boolean-cast': ['error'],
102-
'no-extra-semi': 'off',
103-
'no-fallthrough': 'off',
104-
'no-func-assign': ['error'],
105-
'no-global-assign': ['error'],
106-
'no-inner-declarations': ['error'],
107-
'no-invalid-this': 'off',
108-
'no-invalid-regexp': ['error'],
109-
'no-irregular-whitespace': 'off',
110-
'no-misleading-character-class': ['error'],
111-
'no-mixed-spaces-and-tabs': ['error'],
112-
'no-multiple-empty-lines': 'off',
113-
'no-new-symbol': ['error'],
114-
'no-new-wrappers': 'error',
115-
'no-obj-calls': ['error'],
116-
'no-octal': ['error'],
117-
'no-prototype-builtins': ['error'],
118-
'no-redeclare': 'warn',
119-
'no-regex-spaces': ['error'],
120-
'no-return-await': 'error',
121-
'no-self-assign': ['error'],
122-
'no-shadow': [
123-
'off',
124-
{
125-
hoist: 'all',
126-
},
127-
],
128-
'no-shadow-restricted-names': ['error'],
129-
'no-sparse-arrays': ['error'],
130-
'no-template-curly-in-string': 'error',
131-
'no-this-before-super': ['error'],
132-
'no-throw-literal': 'error',
133-
'no-trailing-spaces': 'off',
134-
'no-undef-init': 'error',
135-
'no-underscore-dangle': 'off',
136-
'no-unused-expressions': [
137-
'error',
138-
{ allowTernary: true },
139-
],
140-
'no-undef': ['error'],
141-
'no-unexpected-multiline': ['error'],
142-
'no-unreachable': ['error'],
143-
'no-unsafe-finally': 'error',
144-
'no-unsafe-negation': ['error'],
145-
'no-unused-labels': 'error',
146-
'no-unused-vars': 'off', // let typescript-eslint handle this
147-
'no-useless-catch': ['error'],
148-
'no-useless-escape': 'warn',
149-
'no-var': 'error',
150-
'no-with': ['error'],
151-
'object-shorthand': 'error',
152-
'one-var': ['error', 'never'],
153-
'padding-line-between-statements': [
154-
"error",
155-
{ blankLine: "always", prev: "*", next: "return" }
156-
],
157-
'prefer-const': 'error',
158-
'prefer-object-spread': 'error',
159-
'prefer-template': 'error',
160-
'prettier/prettier': 'error',
161-
'quote-props': 'off',
162-
radix: 'error',
163-
'require-yield': ['error'],
164-
'space-before-function-paren': 'off',
165-
'space-in-parens': ['off', 'never'],
166-
'spaced-comment': [
167-
'warn',
168-
'always',
169-
{
170-
markers: ['/'],
171-
},
172-
],
173-
'use-isnan': 'error',
174-
'valid-typeof': 'off',
175-
'@typescript-eslint/adjacent-overload-signatures': 'error',
176-
'@typescript-eslint/array-type': [
177-
'warn',
178-
{
179-
default: 'array',
180-
},
181-
],
182-
'@typescript-eslint/ban-types': [
183-
'error',
184-
{
185-
types: {
186-
Object: {
187-
message: 'Avoid using the `Object` type. Did you mean `object`?',
188-
},
189-
Function: {
190-
message: 'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.',
191-
},
192-
Boolean: {
193-
message: 'Avoid using the `Boolean` type. Did you mean `boolean`?',
194-
},
195-
Number: {
196-
message: 'Avoid using the `Number` type. Did you mean `number`?',
197-
},
198-
String: {
199-
message: 'Avoid using the `String` type. Did you mean `string`?',
200-
},
201-
Symbol: {
202-
message: 'Avoid using the `Symbol` type. Did you mean `symbol`?',
203-
},
204-
},
14+
overrides: [
15+
{
16+
files: ['*.ts'],
17+
parser: '@typescript-eslint/parser',
18+
parserOptions: {
19+
project: 'tsconfig.json',
20+
impliedStrict: true,
21+
createDefaultProgram: true,
20522
},
206-
],
207-
'@typescript-eslint/consistent-type-assertions': 'error',
208-
'@typescript-eslint/consistent-type-definitions': 'error',
209-
'@typescript-eslint/explicit-function-return-type': 'off',
210-
'@typescript-eslint/explicit-member-accessibility': [
211-
'error',
212-
{
213-
accessibility: 'no-public',
214-
},
215-
],
216-
'@typescript-eslint/interface-name-prefix': 'off',
217-
'@typescript-eslint/member-delimiter-style': [
218-
'error',
219-
{
220-
multiline: {
221-
delimiter: 'none',
222-
requireLast: true,
223-
},
224-
singleline: {
225-
delimiter: 'semi',
226-
requireLast: false,
227-
},
228-
},
229-
],
230-
'@typescript-eslint/no-unused-vars': ["error", { "argsIgnorePattern": "^_" }],
231-
'@typescript-eslint/no-empty-function': ['error', { 'allow': ['arrowFunctions']}],
232-
'@typescript-eslint/no-empty-interface': 'off',
233-
'@typescript-eslint/no-explicit-any': 'off',
234-
'@typescript-eslint/no-for-in-array': 'error',
235-
'@typescript-eslint/no-inferrable-types': 'error',
236-
'@typescript-eslint/no-misused-new': 'error',
237-
'@typescript-eslint/no-namespace': 'warn',
238-
'@typescript-eslint/no-parameter-properties': 'off',
239-
'@typescript-eslint/no-unsafe-assignment': 'off',
240-
'@typescript-eslint/no-unsafe-call': 'off',
241-
'@typescript-eslint/no-unsafe-member-access': 'off',
242-
'@typescript-eslint/no-unsafe-return': 'off',
243-
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
244-
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
245-
'@typescript-eslint/no-use-before-define': 'off',
246-
'@typescript-eslint/no-var-requires': 'off',
247-
'@typescript-eslint/prefer-includes': 'warn',
248-
'@typescript-eslint/prefer-regexp-exec': 'warn',
249-
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
250-
'@typescript-eslint/prefer-for-of': 'off',
251-
'@typescript-eslint/prefer-function-type': 'error',
252-
'@typescript-eslint/prefer-namespace-keyword': 'error',
253-
'@typescript-eslint/prefer-readonly': 'error',
254-
'@typescript-eslint/prefer-ts-expect-error': 'error',
255-
'@typescript-eslint/require-await': 'off',
256-
'@typescript-eslint/triple-slash-reference': [
257-
'error',
258-
{
259-
path: 'always',
260-
types: 'prefer-import',
261-
lib: 'always',
23+
plugins: ['eslint-plugin-prefer-arrow', 'import', 'jsdoc'],
24+
extends: [
25+
'plugin:@typescript-eslint/recommended',
26+
'plugin:jest/recommended',
27+
'plugin:import/typescript',
28+
'plugin:prettier/recommended',
29+
],
30+
rules: {
31+
'@typescript-eslint/array-type': [
32+
'error',
33+
{
34+
'default': 'array-simple',
35+
}
36+
],
37+
'@typescript-eslint/comma-spacing': 'error',
38+
'@typescript-eslint/no-redeclare': 'error',
39+
'@typescript-eslint/no-unused-vars': ["error", { "argsIgnorePattern": "^_" }],
40+
'@typescript-eslint/no-var-requires': 'off',
41+
'@typescript-eslint/prefer-ts-expect-error': 'error',
42+
'jest/valid-title': 'off',
43+
'import/order': [
44+
'error',
45+
{
46+
'alphabetize': {
47+
'order': 'asc',
48+
'caseInsensitive': true,
49+
},
50+
// this is the default order except for added `internal` in the middle
51+
'groups': [
52+
'builtin',
53+
'external',
54+
'internal',
55+
'parent',
56+
'sibling',
57+
'index',
58+
],
59+
'newlines-between': 'always',
60+
}
61+
],
62+
'object-shorthand': 'error',
63+
'padding-line-between-statements': [
64+
'error',
65+
{ 'blankLine': 'always', 'prev': '*', 'next': 'return' },
66+
],
67+
'prefer-object-spread': 'error',
26268
},
263-
],
264-
'@typescript-eslint/type-annotation-spacing': 'off',
265-
'@typescript-eslint/unbound-method': 'off',
266-
'@typescript-eslint/unified-signatures': 'error',
69+
}
70+
],
71+
rules: {
72+
'comma-spacing': 'off',
73+
'no-redeclare': 'off',
74+
'no-shadow': 'off',
75+
'quotes': 'off',
26776
},
268-
settings: {},
26977
}

e2e/__helpers__/test-case/run-descriptor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { RunTestOptions, RunWithTemplateIteratorContext, RunWithTemplatesIt
88

99
export default class RunDescriptor {
1010
protected _options: RunTestOptions
11+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1112
protected _sourcePackageJson: any
1213

1314
constructor(readonly name: string, options: RunTestOptions = {}) {
@@ -18,6 +19,7 @@ export default class RunDescriptor {
1819
return join(Paths.e2eSourceDir, this.name)
1920
}
2021

22+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2123
get sourcePackageJson(): any {
2224
try {
2325
return this._sourcePackageJson || (this._sourcePackageJson = require(join(this.sourceDir, 'package.json')))

e2e/__helpers__/test-case/run-result.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ export default class RunResult {
8989
if (!this.context.ioDir) {
9090
throw new Error('IO not written for test, you must configure the test with `writeIo: true`.')
9191
}
92-
let io: any = { in: ['', '', {}, {}], out: '' }
92+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
93+
let io: Record<string, any> = { in: ['', '', {}, {}], out: '' }
9394
try {
9495
io = require(`${this.context.ioDir}/${relFilePath}.json`)
9596
} catch (err) {
@@ -127,6 +128,7 @@ export default class RunResult {
127128
}
128129

129130
return map
131+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
130132
.sort((a, b) => ((b.from as any).length || Infinity) - ((a.from as any).length || Infinity))
131133
.reduce((str, { from, to }) => str.replace(typeof from === 'string' ? new RegExp(`${escapeRegex(from)}`, 'g') : from, to), str)
132134
}

0 commit comments

Comments
 (0)