-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eslintrc.js
127 lines (111 loc) · 3.63 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
const COMPLEXITY = 15
module.exports = {
root: true,
// Make ESLint compatible with TypeScript
parser: '@typescript-eslint/parser',
parserOptions: {
// Enable linting rules with type information from our tsconfig
tsconfigRootDir: __dirname,
project: ['./tsconfig.eslint.json'],
// Allow the use of imports / ES modules
sourceType: 'module',
ecmaFeatures: {
// Enable global strict mode
impliedStrict: true,
},
},
ignorePatterns: [
// Ignoring node_modules since generated code doesn't conform to our linting standards
'node_modules',
// Ignore build since generated code doesn't conform to our linting standards
'build',
// Eslint doesn't lint typing files well so we will just ignore them
'*.d.ts',
// Database-config is a common-js file that is required by sequelize cli and doesn't conform to our more cultured ways
'database-config.js',
],
// Specify global variables that are predefined
env: {
// Enable node global variables & Node.js scoping
node: true,
// Add all ECMAScript 2020 globals and automatically set the ecmaVersion parser option to ES2020
es2020: true,
},
plugins: ['mocha', 'disable'],
processor: 'disable/disable',
extends: ['@xpring-eng/eslint-config-base/loose', 'plugin:mocha/recommended'],
rules: {
// Removes comments and blank lines from the max-line rules
'max-lines-per-function': [
'warn',
{
max: 75,
skipBlankLines: true,
skipComments: true,
},
],
'max-lines': [
'warn',
{
max: 250,
skipBlankLines: true,
skipComments: true,
},
],
// Multiple manifest formats means naming conventions vary
'@typescript-eslint/naming-convention': 'off',
// Up complexity for type guards, which check many conditions
complexity: ['error', COMPLEXITY],
},
overrides: [
{
files: ['test/**/*.ts'],
rules: {
// Removed the max for test files and test helper files, since tests usually need to import more things
'import/max-dependencies': 'off',
// describe blocks count as a function in Mocha tests, and can be insanely long
'max-lines-per-function': 'off',
// Tests can be very long turns off max-line count
'max-lines': 'off',
// We have lots of statements in tests
'max-statements': 'off',
},
},
{
files: ['test/**/*.test.ts'],
env: {
// Global variables for mocha
mocha: true,
},
rules: {
// For our test files, the pattern has been to have unnamed functions
'func-names': 'off',
// Allow magic numbers for testing
'@typescript-eslint/no-magic-numbers': 'off',
},
settings: {
'disable/plugins': ['mocha'],
},
},
{
files: ['src/migrations/*.js'],
rules: {
// Removed no-commonjs requirement as migrations must be in common js format for the sequelize cli
'import/no-commonjs': 'off',
// Removed this as the format required by the migrations prevents us from doing this differently
'import/unambiguous': 'off',
// Removed as these are not typescript files and you can't define a return type
'@typescript-eslint/explicit-function-return-type': 'off',
},
},
{
files: ['.eslintrc.js', 'mocha.config.js'],
rules: {
// Removed no-commonjs requirement as eslint must be in common js format
'import/no-commonjs': 'off',
// Removed this as eslint prevents us from doing this differently
'import/unambiguous': 'off',
},
},
],
}