forked from netlify/build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.cjs
120 lines (118 loc) · 3.28 KB
/
.eslintrc.cjs
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
const { overrides } = require('@netlify/eslint-config-node/.eslintrc_esm.cjs')
module.exports = {
extends: ['plugin:fp/recommended', '@netlify/eslint-config-node/.eslintrc_esm.cjs'],
rules: {
strict: 2,
'max-lines': 'off',
// eslint-plugin-ava needs to know where test files are located
'ava/no-ignored-test-files': [
2,
{ files: ['tests/**/*.{cjs,mjs,js}', '!tests/{helpers,fixtures}/**/*.{cjs,mjs,js,json}'] },
],
'ava/no-import-test-files': [
2,
{ files: ['tests/**/*.{cjs,mjs,js}', '!tests/{helpers,fixtures}/**/*.{cjs,mjs,js,json}'] },
],
// Avoid state mutation except for some known state variables
'fp/no-mutating-methods': [
2,
{
allowedObjects: [
'error',
'errorA',
'req',
'request',
'res',
'response',
'state',
'runState',
'logs',
'logsArray',
'currentEnv',
't',
],
},
],
'fp/no-mutation': [
2,
{
commonjs: true,
exceptions: [
{ object: 'error' },
{ object: 'errorA' },
{ object: 'res' },
{ object: 'state' },
{ object: 'runState' },
{ object: 'logs' },
{ object: 'logsArray' },
{ object: 'currentEnv' },
{ object: 'process', property: 'exitCode' },
],
},
],
// `eslint-plugin-node` seems to have a bug finding `chalk`
'n/no-missing-import': [2, { allowModules: ['chalk'] }],
},
overrides: [
...overrides,
{
files: ['**/fixtures/**/*.{cjs,mjs,js}'],
rules: {
'import/no-unresolved': 0,
'n/no-missing-import': 0,
},
},
// @todo As it stands, this rule is problematic with methods that get+send
// many parameters, such as `runStep` in `src/steps/run_step.js`.
// We should discuss whether we want to keep this rule or discontinue it.
{
files: ['packages/build/**/*.{cjs,mjs,js}'],
rules: {
'max-lines-per-function': 'off',
},
},
{
files: ['**/test-d/**/*.ts'],
rules: {
// We use `tsd` which sometimes require declaring variables without
// using them
'@typescript-eslint/no-unused-vars': 0,
// Allow self-imports
'n/no-extraneous-import': 0,
},
},
{
// **/*.md/*.js references code blocks inside markdown files
files: ['**/*.md/*.js'],
rules: {
// Allow self-imports
'n/no-extraneous-import': 0,
},
},
// `@netlify/config` currently imports some test helpers from
// `@netlify/build`.
// This is creating linting issues, but only on Windows for some reason.
{
files: ['packages/config/tests/helpers/main.js'],
rules: {
'import/named': 0,
},
},
// TODO: remove once we use named exports in test fixtures
{
files: ['packages/build/tests/**/fixtures/**/*.{mjs,js}'],
rules: {
'import/no-anonymous-default-export': 0,
},
},
// Disabling certain rules for test files.
{
files: ['packages/build/tests/**/*.{mjs,js}'],
rules: {
'import/no-named-as-default-member': 'off',
'max-statements': 'off',
'no-magic-numbers': 'off',
},
},
],
}