-
Notifications
You must be signed in to change notification settings - Fork 367
/
.eslintrc.cjs
148 lines (147 loc) · 4 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
const { overrides } = require('@netlify/eslint-config-node')
module.exports = {
extends: '@netlify/eslint-config-node',
plugins: [
'sort-destructure-keys',
// custom workspace lint rules found under `./tools/lint-rules`
'workspace',
],
parserOptions: {
ecmaVersion: '2020',
babelOptions: {
parserOpts: {
sourceType: 'unambiguous',
},
},
},
// .js files in this folder are compiled from TS
ignorePatterns: ['src/**/*.js'],
rules: {
'workspace/no-process-cwd': 'error',
// Those rules from @netlify/eslint-config-node are currently disabled
// TODO: remove, so those rules are enabled
complexity: 0,
'no-inline-comments': 'off',
'func-style': 'off',
'max-depth': 0,
'max-lines': 0,
'max-lines-per-function': 0,
'max-nested-callbacks': 0,
'max-statements': 0,
'no-param-reassign': 0,
'no-process-exit': 0,
'fp/no-loops': 'off',
'import/max-dependencies': 0,
'import/no-dynamic-require': 0,
'import/extensions': [2, 'ignorePackages'],
'n/no-process-exit': 0,
'n/no-sync': 0,
'no-magic-numbers': 'off',
'sort-destructure-keys/sort-destructure-keys': 2,
'unicorn/consistent-destructuring': 0,
// TODO: harmonize with filename snake_case in other Netlify Dev projects
'unicorn/filename-case': [2, { case: 'kebabCase' }],
'max-params': 'off',
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': 'off',
},
overrides: [
...overrides,
// Documentation site's browser JavaScript
{
files: ['site/src/**/*.js'],
parserOptions: {
sourceType: 'module',
babelOptions: {
presets: ['@babel/preset-react'],
parserOpts: {
sourceType: 'module',
},
},
},
rules: {
complexity: 0,
'fp/no-this': 0,
'import/extensions': [2, 'always'],
'unicorn/consistent-destructuring': 0,
'max-lines': 0,
},
},
// Example functions
{
files: ['functions-templates/**/*.mjs', 'functions-templates/**/*.mts'],
rules: {
'require-await': 0,
'import/no-unresolved': 0,
'n/no-missing-require': 0,
'n/no-unsupported-features/es-syntax': 0,
'import/no-anonymous-default-export': 0,
'no-undef': 0,
'no-unused-vars': 0,
'arrow-body-style': 0,
'n/no-unsupported-features/node-builtins': 0,
camelcase: 0,
},
parserOptions: {
sourceType: 'module',
babelOptions: {
parserOpts: {
sourceType: 'module',
},
},
},
},
{
files: ['bin/**/*.js'],
parserOptions: {
ecmaVersion: '2020',
sourceType: 'module',
babelOptions: {
parserOpts: {
sourceType: 'module',
},
},
},
rules: {
'import/extensions': [2, 'always'],
'no-restricted-imports': [
'error',
{
name: 'chalk',
message:
'Please use the safe chalk import that handles colors for json output. `import { chalk } from "src/utils/command-helpers.js"`',
},
],
},
},
{
files: ['tests/**/*'],
rules: {
'require-await': 'off',
'import/no-deprecated': 'off',
},
},
{
files: ['*.ts'],
rules: {
// Pure ES modules with TypeScript require using `.js` instead of `.ts`
// in imports
'import/extensions': 'off',
'import/no-namespace': 'off',
'n/no-missing-import': 'off',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': 'error',
},
},
{
files: ['tests/**/*.ts'],
rules: {
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
},
},
],
}