forked from dotansimha/graphql-code-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
184 lines (171 loc) · 5.25 KB
/
eslint.config.mjs
File metadata and controls
184 lines (171 loc) · 5.25 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
// eslint-disable-next-line import/no-extraneous-dependencies
import importPlugin from 'eslint-plugin-import';
import tailwindcss from 'eslint-plugin-tailwindcss';
// eslint-disable-next-line import/no-extraneous-dependencies
import unicorn from 'eslint-plugin-unicorn';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
const compat = new FlatCompat({
baseDirectory: import.meta.dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
// Use sub-modules of @theguild/eslint-config that don't trigger @rushstack/eslint-patch
// (the main index.js requires @rushstack/eslint-patch/modern-module-resolution which doesn't support ESLint 10)
// FlatCompat uses CJS require() which can't load ESM-only plugins (unicorn v57+).
// We import them directly and patch the FlatCompat output.
const theGuildIndex = compat.config({
reportUnusedDisableDirectives: true,
overrides: [
{
files: ['*.{,c,m}{j,t}s{,x}'],
extends: ['./node_modules/@theguild/eslint-config/src/base.js'],
},
{
files: ['*.{,c,m}ts{,x}'],
excludedFiles: ['**/*.md{,x}/*'],
parserOptions: {
projectService: true,
},
rules: {
'@typescript-eslint/prefer-optional-chain': 'error',
},
},
{
files: ['*.{,c,m}ts{,x}'],
rules: {
'@typescript-eslint/consistent-type-assertions': 'error',
},
},
{
files: ['*.c{j,t}s'],
env: { node: true },
rules: { '@typescript-eslint/no-var-requires': 'off' },
},
{
files: [
'jest.config.js',
'webpack.config.js',
'bob.config.js',
'babel.config.js',
'postcss.config.{js,cjs}',
'rollup.config.js',
'next-sitemap.config.js',
],
env: { node: true },
},
{
files: ['*.{spec,test}.*'],
env: { jest: true },
rules: { 'import/extensions': ['error', 'never'] },
},
{
files: ['vite.config.ts', 'jest.config.js', '*.d.ts', 'tsup.config.ts', 'prettier.config.js'],
rules: { 'import/no-default-export': 'off' },
},
{
files: ['*.d.ts'],
rules: {
'no-var': 'off',
},
},
],
});
export default [
// Global ignores (replaces ignorePatterns + .gitignore patterns)
{
ignores: [
'.bob/**',
'.next/**',
'.cache/**',
'**/temp/**',
'dev-test/**',
'website/**',
'examples/**',
'**/tests/test-files/**',
'**/tests/test-documents/**',
'**/react-app-env.d.ts',
'packages/presets/swc-plugin/tests/fixtures/simple-uppercase-operation-name.js',
'packages/presets/swc-plugin/tests/fixtures/simple-uppercase-operation-name.other-dir.js',
'**/build/**',
'**/dist/**',
'**/*.json',
],
},
// @theguild base config (via FlatCompat)
// Patch: replace broken CJS-resolved unicorn plugin with the properly imported ESM version
...theGuildIndex.map(config =>
config.plugins?.unicorn ? { ...config, plugins: { ...config.plugins, unicorn } } : config,
),
// Tailwind CSS plugin (flat config)
...tailwindcss.configs['flat/recommended'],
// Project-level rule overrides
{
plugins: {
import: importPlugin,
},
rules: {
'no-empty': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/ban-types': 'off',
'import/no-extraneous-dependencies': 'error',
// todo: enable
'unicorn/filename-case': 'off',
'import/extensions': 'off',
'import/no-default-export': 'off',
// todo: enable in v3
'unicorn/prefer-node-protocol': 'off',
'prefer-object-has-own': 'off',
// Rules introduced/tightened by updated plugins in ESLint 10 migration
'preserve-caught-error': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'no-useless-assignment': 'off',
},
},
// Node environment for all files
...compat.env({ node: true }),
// Website files: extend @theguild react config
...compat
.config({
extends: ['./node_modules/@theguild/eslint-config/src/react.js'],
})
.map(config => ({ ...config, files: ['website/**'] })),
// Test files
{
files: [
'**/*.spec.ts',
'**/tests/**/*.{js,ts,tsx,cjs}',
'**/graphql-codegen-testing/**/*.ts',
'**/vitest.config.ts',
'**/vitest.setup.ts',
'**/__mocks__/*',
],
rules: {
'import/no-extraneous-dependencies': 'off',
'@typescript-eslint/no-require-imports': 'off',
},
},
// Test fixtures
{
files: ['**/tests/fixtures/*.{ts,js}'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
},
},
// Scripts and config files
{
files: ['scripts/*.{ts,js}', 'prettier.config.cjs'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
},
];