-
Notifications
You must be signed in to change notification settings - Fork 66.9k
Expand file tree
/
Copy patheslint.config.ts
More file actions
193 lines (173 loc) · 5.41 KB
/
eslint.config.ts
File metadata and controls
193 lines (173 loc) · 5.41 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import js from '@eslint/js'
import tseslint from '@typescript-eslint/eslint-plugin'
import tsParser from '@typescript-eslint/parser'
import github from 'eslint-plugin-github'
import importPlugin from 'eslint-plugin-import'
import jsxA11y from 'eslint-plugin-jsx-a11y'
import primerReact from 'eslint-plugin-primer-react'
import eslintComments from 'eslint-plugin-eslint-comments'
import i18nText from 'eslint-plugin-i18n-text'
import filenames from 'eslint-plugin-filenames'
import noOnlyTests from 'eslint-plugin-no-only-tests'
import prettierPlugin from 'eslint-plugin-prettier'
import prettier from 'eslint-config-prettier'
import globals from 'globals'
import customRules from 'eslint-plugin-custom-rules'
export default [
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: tsParser,
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.browser,
...globals.node,
...globals.commonjs,
...globals.es2020,
// Fetch API types for TypeScript
RequestInit: 'readonly',
RequestInfo: 'readonly',
HeadersInit: 'readonly',
JSX: 'readonly',
// Node.js types for TypeScript
BufferEncoding: 'readonly',
NodeJS: 'readonly',
// cheerio namespace for TypeScript
cheerio: 'readonly',
},
parserOptions: {
requireConfigFile: false,
},
},
settings: {
'import/resolver': {
typescript: true,
node: true,
},
},
plugins: {
github,
import: importPlugin,
'eslint-comments': eslintComments,
'i18n-text': i18nText,
filenames,
'no-only-tests': noOnlyTests,
prettier: prettierPlugin,
'@typescript-eslint': tseslint,
'primer-react': primerReact,
'jsx-a11y': jsxA11y,
'custom-rules': customRules,
},
rules: {
// ESLint recommended rules
...js.configs.recommended.rules,
// GitHub plugin recommended rules
...github.configs.recommended.rules,
// Import plugin error rules
...importPlugin.configs.errors.rules,
// TypeScript ESLint recommended rules
...tseslint.configs.recommended.rules,
// Primer React recommended rules
...primerReact.configs.recommended.rules,
// JSX A11y recommended rules
...jsxA11y.configs.recommended.rules,
// Overrides
'import/no-extraneous-dependencies': [
'error',
{
packageDir: '.',
},
],
'import/extensions': ['error', { json: 'always' }],
'no-empty': ['error', { allowEmptyCatch: true }],
'@typescript-eslint/no-unused-vars': 'error',
'prefer-const': ['error', { destructuring: 'all' }],
// Rules that must be disabled
'no-redeclare': 'off', // Allow function overloads in TypeScript
'i18n-text/no-en': 'off', // This rule causes eslint to not run at all
'filenames/match-regex': 'off', // This rule causes eslint to not run at all
camelcase: 'off', // Many gh apis use underscores, 600+ uses
// Disabled rules to review
'no-console': 'off', // 800+
'@typescript-eslint/no-explicit-any': 'off',
// Custom rules (disabled by default for now)
'custom-rules/use-custom-logger': 'off',
},
},
// Configuration for eslint-rules directory (CommonJS JavaScript files)
{
files: ['src/eslint-rules/**/*.js'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'script',
globals: {
...globals.node,
...globals.commonjs,
...globals.es2020,
},
},
plugins: {
github,
import: importPlugin,
'eslint-comments': eslintComments,
filenames,
'no-only-tests': noOnlyTests,
prettier: prettierPlugin,
},
rules: {
// ESLint recommended rules
...js.configs.recommended.rules,
// GitHub plugin recommended rules
...github.configs.recommended.rules,
// Import plugin error rules
...importPlugin.configs.errors.rules,
// Allow CommonJS in eslint rules
'import/no-commonjs': 'off',
// Overrides
'import/extensions': ['error', { json: 'always' }],
'no-empty': ['error', { allowEmptyCatch: true }],
'prefer-const': ['error', { destructuring: 'all' }],
// Disabled rules
'i18n-text/no-en': 'off',
'filenames/match-regex': 'off',
camelcase: 'off',
'no-console': 'off',
},
},
// Disable custom logger rule for logger implementation itself
{
files: ['src/observability/logger/**/*.{ts,js}'],
rules: {
'custom-rules/use-custom-logger': 'off',
},
},
// Override for scripts, tests, workflows, content-linter, and React files (disable custom logger rule)
{
files: [
'**/scripts/**/*.{ts,js}',
'**/tests/**/*.{ts,js}',
'src/workflows/**/*.{ts,js}',
'src/content-linter/**/*.{ts,js}',
'**/*.{tsx,jsx}',
],
rules: {
'custom-rules/use-custom-logger': 'off',
},
},
// Ignored patterns
// CodeQL scripts included because cocofix is install manually by the workflow
{
ignores: [
'tmp/*',
'.next/',
'rest-api-description/',
'docs-internal-data/',
'src/codeql-queries/scripts/generate-code-scanning-query-list.ts',
'src/codeql-queries/scripts/generate-code-quality-query-list.ts',
'next-env.d.ts',
],
},
// Prettier config (should be last to override formatting rules)
prettier,
]