-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
88 lines (86 loc) · 2.62 KB
/
.eslintrc.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const ERROR = 2;
const OFF = 0;
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: ['./tsconfig.eslint.json'],
tsconfigRootDir: __dirname,
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
node: {
moduleDirectory: ['node_modules', 'src/'],
},
},
},
plugins: ['jest'],
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'prettier',
'plugin:prettier/recommended',
],
rules: {
semi: [ERROR, 'always'],
},
overrides: [
{
files: ['**/*.ts', '**/*.tsx'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
rules: {
'@typescript-eslint/no-non-null-assertion': OFF, // sometimes we need to use ! to mark variable will never be undefined, avoid TS errors like: the Type 'number | undefined' is not assignable to type 'number', https://github.com/bobbyquennell/leetcode/blob/a7a3ac69fc686d136007b46810532b139e148300/src/twoSum/index.ts#L54
},
},
{
files: ['**/__tests__/**/*.{js,ts,tsx}', '**/*.@(spec|test).{js,ts,tsx}'],
env: {
'jest/globals': true,
},
extends: ['plugin:jest/recommended'],
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'jest/expect-expect': 'off',
'jest/prefer-strict-equal': 'off',
'no-use-before-define': 'off',
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-alias-methods': 'error',
'jest/no-identical-title': 'error',
'jest/no-jasmine-globals': 'error',
'jest/no-jest-import': 'error',
'jest/no-test-prefixes': 'error',
'jest/no-done-callback': 'error',
'jest/no-test-return-statement': 'error',
'jest/prefer-to-be-null': 'warn',
'jest/prefer-to-be-undefined': 'warn',
'jest/prefer-to-contain': 'warn',
'jest/prefer-to-have-length': 'warn',
'jest/prefer-spy-on': 'error',
'jest/valid-expect': 'error',
'jest/no-deprecated-functions': 'error',
'jest/prefer-todo': 'error',
'jest/valid-title': 'error',
},
},
],
};