Skip to content

Commit f6f5c42

Browse files
authored
Migrate Nx and convert ESLint to flat config (#374)
* Migrate Nx to 21 * Convert to flat ESLint
1 parent 6144c14 commit f6f5c42

File tree

15 files changed

+2126
-1336
lines changed

15 files changed

+2126
-1336
lines changed

.eslintignore

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

.eslintrc.json

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

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ Thumbs.db
3939

4040
.nx/cache
4141
.nx/workspace-data
42+
.cursor/rules/nx-rules.mdc
43+
.github/instructions/nx.instructions.md

eslint.config.mjs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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';
6+
7+
const compat = new FlatCompat({
8+
baseDirectory: dirname(fileURLToPath(import.meta.url)),
9+
recommendedConfig: js.configs.recommended,
10+
});
11+
12+
export default [
13+
{
14+
ignores: ['**/dist'],
15+
},
16+
{ plugins: { '@nx': nxEslintPlugin } },
17+
{
18+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
19+
rules: {
20+
'@nx/enforce-module-boundaries': [
21+
'error',
22+
{
23+
enforceBuildableLibDependency: true,
24+
allow: [],
25+
depConstraints: [
26+
{
27+
sourceTag: '*',
28+
onlyDependOnLibsWithTags: ['*'],
29+
},
30+
],
31+
},
32+
],
33+
},
34+
},
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+
})),
74+
{
75+
files: ['**/*.json'],
76+
// Override or add rules here
77+
rules: {},
78+
languageOptions: {
79+
parser: await import('jsonc-eslint-parser'),
80+
},
81+
},
82+
{
83+
ignores: [
84+
'packages/typescript-resolver-files-e2e/src/**/*.generated.*',
85+
'packages/typescript-resolver-files-e2e/src/**/*.gen.*',
86+
],
87+
},
88+
];

nx.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
}
2424
},
2525
"@nx/eslint:lint": {
26-
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"],
26+
"inputs": [
27+
"default",
28+
"{workspaceRoot}/.eslintrc.json",
29+
"{workspaceRoot}/eslint.config.mjs"
30+
],
2731
"cache": true,
2832
"outputs": ["{options.outputFile}"],
2933
"options": {
@@ -42,7 +46,8 @@
4246
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
4347
"!{projectRoot}/tsconfig.spec.json",
4448
"!{projectRoot}/jest.config.[jt]s",
45-
"!{projectRoot}/src/test-setup.[jt]s"
49+
"!{projectRoot}/src/test-setup.[jt]s",
50+
"!{projectRoot}/eslint.config.mjs"
4651
],
4752
"sharedGlobals": [
4853
"{workspaceRoot}/package.json",
@@ -52,6 +57,5 @@
5257
"workspaceLayout": {
5358
"appsDir": "packages",
5459
"libsDir": "packages"
55-
},
56-
"useLegacyCache": true
60+
}
5761
}

package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,45 @@
1313
"@changesets/cli": "2.27.1",
1414
"@eddeee888/eslint-plugin": "0.0.1",
1515
"@eddeee888/nx-graphql-code-generator": "2.0.0",
16+
"@eslint/eslintrc": "3.3.1",
1617
"@graphql-codegen/add": "5.0.3",
1718
"@graphql-codegen/cli": "5.0.4",
1819
"@graphql-codegen/plugin-helpers": "5.1.0",
1920
"@graphql-codegen/schema-ast": "4.1.0",
2021
"@graphql-codegen/typescript": "4.1.3",
2122
"@graphql-codegen/typescript-resolvers": "4.4.2",
2223
"@graphql-tools/merge": "9.0.4",
23-
"@nx/devkit": "20.3.0",
24-
"@nx/eslint": "20.3.0",
25-
"@nx/eslint-plugin": "20.3.0",
26-
"@nx/jest": "20.3.0",
27-
"@nx/js": "20.3.0",
28-
"@nx/node": "20.3.0",
29-
"@nx/plugin": "20.3.0",
30-
"@nx/workspace": "20.3.0",
24+
"@nx/devkit": "21.3.1",
25+
"@nx/eslint": "21.3.1",
26+
"@nx/eslint-plugin": "21.3.1",
27+
"@nx/jest": "21.3.1",
28+
"@nx/js": "21.3.1",
29+
"@nx/node": "21.3.1",
30+
"@nx/plugin": "21.3.1",
31+
"@nx/workspace": "21.3.1",
3132
"@swc-node/register": "1.9.2",
3233
"@swc/core": "1.5.7",
3334
"@swc/helpers": "0.5.12",
34-
"@types/jest": "29.5.14",
35+
"@types/jest": "30.0.0",
3536
"@types/micromatch": "4.0.6",
3637
"@types/node": "22.0.3",
37-
"@typescript-eslint/eslint-plugin": "7.18.0",
38-
"@typescript-eslint/parser": "7.18.0",
39-
"eslint": "8.57.0",
40-
"eslint-config-prettier": "9.0.0",
38+
"eslint": "9.31.0",
39+
"eslint-config-prettier": "10.1.8",
4140
"graphql": "16.10.0",
4241
"graphql-scalars": "1.24.0",
43-
"jest": "29.7.0",
44-
"jest-environment-jsdom": "29.7.0",
45-
"jest-environment-node": "^29.4.3",
42+
"jest": "30.0.4",
43+
"jest-environment-jsdom": "30.0.4",
44+
"jest-environment-node": "30.0.4",
4645
"jsonc-eslint-parser": "^2.1.0",
4746
"micromatch": "4.0.5",
48-
"nx": "20.3.0",
47+
"nx": "21.3.1",
4948
"prettier": "^2.6.2",
5049
"rimraf": "5.0.0",
5150
"ts-jest": "29.1.0",
5251
"ts-morph": "22.0.0",
5352
"ts-node": "10.9.1",
54-
"typescript": "5.6.3"
53+
"typescript": "5.8.3",
54+
"typescript-eslint": "8.37.0"
5555
},
5656
"workspaces": [
5757
"packages/**"

packages/server-config/.eslintrc.json

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { FlatCompat } from '@eslint/eslintrc';
2+
import { dirname } from 'path';
3+
import { fileURLToPath } from 'url';
4+
import js from '@eslint/js';
5+
import baseConfig from '../../eslint.config.mjs';
6+
7+
const compat = new FlatCompat({
8+
baseDirectory: dirname(fileURLToPath(import.meta.url)),
9+
recommendedConfig: js.configs.recommended,
10+
});
11+
12+
export default [
13+
{
14+
ignores: ['**/dist'],
15+
},
16+
...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+
},
37+
{
38+
files: ['**/*.json'],
39+
rules: {
40+
'@nx/dependency-checks': 'error',
41+
},
42+
languageOptions: {
43+
parser: await import('jsonc-eslint-parser'),
44+
},
45+
},
46+
];

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

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import baseConfig from '../../eslint.config.mjs';
2+
3+
export default [
4+
{
5+
ignores: ['**/dist'],
6+
},
7+
...baseConfig,
8+
{
9+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
10+
// Override or add rules here
11+
rules: {},
12+
},
13+
{
14+
files: ['**/*.ts', '**/*.tsx'],
15+
// Override or add rules here
16+
rules: {},
17+
languageOptions: {
18+
parserOptions: {
19+
project: ['packages/typescript-resolver-files-e2e/tsconfig(.*)?.json'],
20+
},
21+
},
22+
},
23+
{
24+
files: ['**/*.js', '**/*.jsx'],
25+
// Override or add rules here
26+
rules: {},
27+
},
28+
];

0 commit comments

Comments
 (0)