Skip to content

Commit fc1e886

Browse files
authored
Update ESLint config to use flat config (#399)
* Fully convert to flat config * Bump eslint plugin * Fix eslint config * Fix lint issues, remove lint target from e2e projects
1 parent 9363b97 commit fc1e886

13 files changed

Lines changed: 1449 additions & 172 deletions

File tree

eslint.config.mjs

Lines changed: 23 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1-
import { FlatCompat } from '@eslint/eslintrc';
2-
import { dirname } from 'path';
3-
import { fileURLToPath } from 'url';
4-
import js from '@eslint/js';
5-
import nxEslintPlugin from '@nx/eslint-plugin';
1+
import { defineConfig } from 'eslint/config';
2+
import nx from '@nx/eslint-plugin';
3+
import my from '@eddeee888/eslint-plugin';
64

7-
const compat = new FlatCompat({
8-
baseDirectory: dirname(fileURLToPath(import.meta.url)),
9-
recommendedConfig: js.configs.recommended,
10-
});
11-
12-
export default [
5+
export default defineConfig(
6+
...nx.configs['flat/base'],
7+
...nx.configs['flat/typescript'],
8+
...nx.configs['flat/javascript'],
9+
...my.configs.typescript,
1310
{
14-
ignores: ['**/dist'],
11+
languageOptions: {
12+
parserOptions: {
13+
projectService: true,
14+
},
15+
},
16+
},
17+
{
18+
ignores: [
19+
'**/dist',
20+
'eslint.config.mjs',
21+
'packages/typescript-resolver-files-e2e/src/**/*.generated.*',
22+
'packages/typescript-resolver-files-e2e/src/**/*.gen.*',
23+
],
1524
},
16-
{ plugins: { '@nx': nxEslintPlugin } },
1725
{
1826
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
1927
rules: {
@@ -32,57 +40,12 @@ export default [
3240
],
3341
},
3442
},
35-
...compat
36-
.config({
37-
extends: [
38-
'plugin:@nx/typescript',
39-
// FIXME: change to flat config
40-
//'plugin:@eddeee888/typescript'
41-
],
42-
})
43-
.map((config) => ({
44-
...config,
45-
files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'],
46-
rules: {
47-
...config.rules,
48-
},
49-
})),
50-
...compat
51-
.config({
52-
extends: ['plugin:@nx/javascript'],
53-
})
54-
.map((config) => ({
55-
...config,
56-
files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],
57-
rules: {
58-
...config.rules,
59-
},
60-
})),
61-
...compat
62-
.config({
63-
env: {
64-
jest: true,
65-
},
66-
})
67-
.map((config) => ({
68-
...config,
69-
files: ['**/*.spec.ts', '**/*.spec.tsx', '**/*.spec.js', '**/*.spec.jsx'],
70-
rules: {
71-
...config.rules,
72-
},
73-
})),
7443
{
7544
files: ['**/*.json'],
7645
// Override or add rules here
7746
rules: {},
7847
languageOptions: {
7948
parser: await import('jsonc-eslint-parser'),
8049
},
81-
},
82-
{
83-
ignores: [
84-
'packages/typescript-resolver-files-e2e/src/**/*.generated.*',
85-
'packages/typescript-resolver-files-e2e/src/**/*.gen.*',
86-
],
87-
},
88-
];
50+
}
51+
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"devDependencies": {
1313
"@changesets/cli": "2.29.5",
14-
"@eddeee888/eslint-plugin": "0.0.1",
14+
"@eddeee888/eslint-plugin": "1.0.0",
1515
"@eddeee888/nx-graphql-code-generator": "2.0.0",
1616
"@eslint/eslintrc": "3.3.1",
1717
"@graphql-codegen/add": "6.0.0",

packages/operation-location-migration-e2e/eslint.config.mjs

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/operation-location-migration-e2e/project.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@
128128
"parallel": false
129129
},
130130
"dependsOn": ["^build"]
131-
},
132-
"lint": {
133-
"executor": "@nx/eslint:lint"
134131
}
135132
}
136133
}

packages/operation-location-migration/eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ export default [
1616
parser: await import('jsonc-eslint-parser'),
1717
},
1818
},
19+
{
20+
ignores: ['**/out-tsc'],
21+
},
1922
];

packages/operation-location-migration/src/preset.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ const createGqlTagImport = ({
384384
baseOutputDir: string;
385385
presetConfig: TypedPresetConfig;
386386
tsSourceFile: SourceFile;
387-
}) => {
387+
}): void => {
388388
const gqlTagModule =
389389
presetConfig.gqlTag.importType === 'absolute'
390390
? presetConfig.gqlTag.importFrom
@@ -428,7 +428,7 @@ const createDoc = ({
428428
documentNodeName: string;
429429
documentSDL: string;
430430
exportDoc: boolean;
431-
}) => {
431+
}): void => {
432432
const importDeclarations = tsSourceFile.getImportDeclarations();
433433

434434
// Find insertIndex, which is after the last import declaration
Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,22 @@
1-
import { FlatCompat } from '@eslint/eslintrc';
2-
import { dirname } from 'path';
3-
import { fileURLToPath } from 'url';
4-
import js from '@eslint/js';
51
import baseConfig from '../../eslint.config.mjs';
62

7-
const compat = new FlatCompat({
8-
baseDirectory: dirname(fileURLToPath(import.meta.url)),
9-
recommendedConfig: js.configs.recommended,
10-
});
11-
123
export default [
13-
{
14-
ignores: ['**/dist'],
15-
},
164
...baseConfig,
17-
{
18-
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
19-
// Override or add rules here
20-
rules: {},
21-
},
22-
{
23-
files: ['**/*.ts', '**/*.tsx'],
24-
// Override or add rules here
25-
rules: {},
26-
languageOptions: {
27-
parserOptions: {
28-
project: ['packages/server-config/tsconfig(.*)?.json'],
29-
},
30-
},
31-
},
32-
{
33-
files: ['**/*.js', '**/*.jsx'],
34-
// Override or add rules here
35-
rules: {},
36-
},
375
{
386
files: ['**/*.json'],
397
rules: {
40-
'@nx/dependency-checks': 'error',
8+
'@nx/dependency-checks': [
9+
'error',
10+
{
11+
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}'],
12+
},
13+
],
4114
},
4215
languageOptions: {
4316
parser: await import('jsonc-eslint-parser'),
4417
},
4518
},
19+
{
20+
ignores: ['**/out-tsc'],
21+
},
4622
];

packages/typescript-resolver-files-e2e/eslint.config.mjs

Lines changed: 0 additions & 28 deletions
This file was deleted.

packages/typescript-resolver-files-e2e/project.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,6 @@
298298
"parallel": false
299299
},
300300
"dependsOn": ["^build"]
301-
},
302-
"lint": {
303-
"executor": "@nx/eslint:lint"
304301
}
305302
}
306303
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export { generateResolverFiles } from './generateResolverFiles';
2-
export * from './types';
2+
export type * from './types';

0 commit comments

Comments
 (0)