-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path.eslintrc.cjs
155 lines (146 loc) · 3.53 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
149
150
151
152
153
154
155
module.exports = {
root: true,
env: {
node: true,
},
extends: [
'@snapwp/eslint-config',
'plugin:@eslint-community/eslint-comments/recommended',
'plugin:@typescript-eslint/eslint-recommended',
],
parser: '@typescript-eslint/parser',
plugins: [ '@typescript-eslint', 'jest' ],
ignorePatterns: [
'**/__generated/',
'**/.eslintrc.cjs',
'**/config/*.js',
'**/dist-types/**',
'**/dist',
'**/dist/**',
'**/node_modules/**',
'assets/**/*.js',
'coverage/**',
'data/**',
'out/**',
],
globals: {
globalThis: 'readonly',
},
settings: {
'import/resolver': require.resolve( './config/import-resolver.cjs' ),
},
rules: {
// Restrict usage of "bad" libraries.
'@typescript-eslint/no-restricted-imports': [
'error',
'classnames',
'lodash',
],
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'classnames',
message:
"Please use `clsx` instead. It's a lighter and faster drop-in replacement for `classnames`.",
},
{
name: 'lodash',
message: 'Please use native functionality instead.',
},
],
},
],
// Enforce description on directive comments.
'@eslint-community/eslint-comments/require-description': 'error',
// Enforce the use of dot notation over square brackets.
'dot-notation': [ 'error', { allowKeywords: false } ],
// Restricted syntax should error, not warn.
'no-restricted-syntax': [ 'error' ],
// Import rules.
'import/default': 'error',
'import/named': 'error',
// Jest rules.
'jest/expect-expect': 'off',
// Turn of JSdoc types and use TypeScript types instead.
'jsdoc/no-types': [ 'off' ],
'jsdoc/require-returns': [ 'warn' ],
// Restrict the use of empty functions.
'no-empty-function': 'error',
// Disallow unnecessary JSX curly braces when literals alone are enough.
'react/jsx-curly-brace-presence': [
'error',
{ children: 'never', props: 'never' },
],
'react/jsx-boolean-value': 'error',
// Prevent the use of any in type annotation.
'@typescript-eslint/no-explicit-any': 'error',
},
overrides: [
{
files: '**/*.test.ts',
env: {
jest: true,
},
},
{
files: [ '**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx' ],
// Mandate doc block for arrow functions, class declarations, class expressions, function expressions, and method definition.
rules: {
'jsdoc/require-jsdoc': [
'error',
{
require: {
ArrowFunctionExpression: true,
ClassDeclaration: true,
ClassExpression: true,
FunctionExpression: true,
MethodDefinition: true,
},
},
],
},
},
// Rules for bin and cli files.
{
files: [ 'bin/**/*.js', 'bin/**/*.mjs', 'packages/cli/src/*.cjs' ],
rules: {
// Enable the use of console log.
'no-console': 'off',
// Enable the use of process-env.
'n/no-process-env': 'off',
},
},
// Disable n/no-process-env for `codegen.ts` file.
{
files: [ '**/codegen.ts', '**/*.test.*', '**/jest.setup.js' ],
rules: {
'n/no-process-env': 'off',
},
},
{
files: [ '**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts' ],
excludedFiles: [
'**/codegen.ts',
'packages/query/src/**/tests/*',
'packages/next/src/**/tests/*',
],
rules: {
'dot-notation': 'off',
'@typescript-eslint/dot-notation': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
},
parserOptions: {
project: true,
},
},
{
files: [ '**/packages/e2e-tests/src/utils/*.ts' ],
rules: {
'n/no-process-env': 'off',
'no-console': 'off',
},
},
],
};