Skip to content

Commit 804f66a

Browse files
authored
Merge pull request #9 from code-pushup/chore/update-nx
chore: update nx an add testing helper
2 parents bc33ae0 + 9b86fae commit 804f66a

File tree

149 files changed

+21665
-11990
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+21665
-11990
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.json

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

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,8 @@ testem.log
4040
Thumbs.db
4141

4242
.nx
43+
44+
vite.config.*.timestamp*
45+
vitest.config.*.timestamp*
46+
.cursor/rules/nx-rules.mdc
47+
.github/instructions/nx.instructions.md

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24.1.0

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"eslint.validate": ["json"]
2+
"eslint.validate": ["json"],
3+
"kiroAgent.configureMCP": "Disabled"
34
}

eslint.config.js

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
import nxEslintPlugin from '@nx/eslint-plugin';
2+
import jestExtendedPlugin from 'eslint-plugin-jest-extended';
3+
import jsoncParser from 'jsonc-eslint-parser';
4+
import fs from 'node:fs';
5+
import tseslint from 'typescript-eslint';
6+
import node from '@code-pushup/eslint-config/node.js';
7+
import typescript from '@code-pushup/eslint-config/typescript.js';
8+
import vitest from '@code-pushup/eslint-config/vitest.js';
9+
10+
export default tseslint.config(
11+
...typescript,
12+
...node,
13+
...vitest,
14+
{
15+
settings: {
16+
'import/resolver': {
17+
typescript: {
18+
project: 'tsconfig.base.json',
19+
alwaysTryTypes: true,
20+
extensions: ['.ts', '.tsx', '.d.ts', '.js', '.jsx'],
21+
},
22+
node: {
23+
extensions: ['.ts', '.tsx', '.d.ts', '.js', '.jsx'],
24+
},
25+
},
26+
},
27+
},
28+
{ plugins: { '@nx': nxEslintPlugin } },
29+
{
30+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
31+
rules: {
32+
'@nx/enforce-module-boundaries': [
33+
'error',
34+
{
35+
enforceBuildableLibDependency: true,
36+
allow: [
37+
String.raw`^.*/eslint(\.base)?\.config\.[cm]?js$`,
38+
String.raw`^.*/code-pushup\.(config|preset)(\.m?[jt]s)?$`,
39+
'^[./]+/tools/.*$',
40+
String.raw`^[./]+/(testing/)?test-setup-config/src/index\.js$`,
41+
],
42+
depConstraints: [
43+
{
44+
sourceTag: 'scope:shared',
45+
onlyDependOnLibsWithTags: ['scope:shared'],
46+
},
47+
{
48+
sourceTag: 'scope:core',
49+
onlyDependOnLibsWithTags: ['scope:core', 'scope:shared'],
50+
},
51+
{
52+
sourceTag: 'scope:plugin',
53+
onlyDependOnLibsWithTags: ['scope:shared'],
54+
},
55+
{
56+
sourceTag: 'scope:tooling',
57+
onlyDependOnLibsWithTags: ['scope:tooling', 'scope:shared'],
58+
},
59+
{
60+
sourceTag: 'type:e2e',
61+
onlyDependOnLibsWithTags: [
62+
'type:app',
63+
'type:feature',
64+
'type:util',
65+
'type:testing',
66+
],
67+
},
68+
{
69+
sourceTag: 'type:app',
70+
onlyDependOnLibsWithTags: [
71+
'type:feature',
72+
'type:util',
73+
'type:testing',
74+
],
75+
},
76+
{
77+
sourceTag: 'type:feature',
78+
onlyDependOnLibsWithTags: [
79+
'type:feature',
80+
'type:util',
81+
'type:testing',
82+
],
83+
},
84+
{
85+
sourceTag: 'type:util',
86+
onlyDependOnLibsWithTags: ['type:util', 'type:testing'],
87+
},
88+
{
89+
sourceTag: 'type:testing',
90+
onlyDependOnLibsWithTags: ['type:util', 'type:testing'],
91+
},
92+
],
93+
},
94+
],
95+
},
96+
},
97+
{
98+
files: ['**/*.test.ts', '**/*.spec.ts'],
99+
plugins: { 'jest-extended': jestExtendedPlugin },
100+
rules: {
101+
'vitest/consistent-test-filename': [
102+
'warn',
103+
{
104+
pattern: String.raw`.*\.(bench|type|unit|int|e2e)\.test\.[tj]sx?$`,
105+
},
106+
],
107+
'jest-extended/prefer-to-be-array': 'warn',
108+
'jest-extended/prefer-to-be-false': 'warn',
109+
'jest-extended/prefer-to-be-object': 'warn',
110+
'jest-extended/prefer-to-be-true': 'warn',
111+
'jest-extended/prefer-to-have-been-called-once': 'warn',
112+
},
113+
},
114+
{
115+
files: ['**/*.type.test.ts'],
116+
rules: {
117+
'vitest/expect-expect': 'off',
118+
},
119+
},
120+
{
121+
files: ['**/*.json'],
122+
languageOptions: { parser: jsoncParser },
123+
},
124+
{
125+
files: ['**/*.ts', '**/*.js'],
126+
rules: {
127+
'n/file-extension-in-import': ['error', 'always'],
128+
'unicorn/number-literal-case': 'off',
129+
},
130+
},
131+
{
132+
files: ['**/perf/**/*.ts'],
133+
rules: {
134+
'@typescript-eslint/no-magic-numbers': 'off',
135+
'sonarjs/no-duplicate-string': 'off',
136+
},
137+
},
138+
{
139+
// tests need only be compatible with local Node version
140+
// publishable packages should pick up version range from "engines" in their package.json
141+
files: ['e2e/**/*.ts', 'testing/**/*.ts', '**/*.test.ts'],
142+
settings: {
143+
node: {
144+
version: fs.readFileSync('.node-version', 'utf8'),
145+
},
146+
},
147+
},
148+
{
149+
ignores: [
150+
'**/*.mock.*',
151+
'**/code-pushup.config.ts',
152+
'**/mocks/fixtures/**',
153+
'**/__snapshots__/**',
154+
'**/dist',
155+
'**/*.md',
156+
],
157+
},
158+
);

migrations.json

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,40 @@
11
{
22
"migrations": [
33
{
4-
"cli": "nx",
5-
"version": "19.2.0-beta.2",
6-
"description": "Updates the default workspace data directory to .nx/workspace-data",
7-
"implementation": "./src/migrations/update-19-2-0/move-workspace-data-directory",
4+
"version": "22.0.0-beta.1",
5+
"description": "Updates release version config based on the breaking changes in Nx v22",
6+
"implementation": "./src/migrations/update-22-0-0/release-version-config-changes",
7+
"package": "nx",
8+
"name": "22-0-0-release-version-config-changes"
9+
},
10+
{
11+
"version": "22.0.0-beta.2",
12+
"description": "Consolidates releaseTag* options into nested releaseTag object structure",
13+
"implementation": "./src/migrations/update-22-0-0/consolidate-release-tag-config",
814
"package": "nx",
9-
"name": "19-2-0-move-graph-cache-directory"
15+
"name": "22-0-0-consolidate-release-tag-config"
1016
},
1117
{
1218
"cli": "nx",
13-
"version": "19.2.2-beta.0",
19+
"version": "22.1.0-beta.5",
1420
"description": "Updates the nx wrapper.",
15-
"implementation": "./src/migrations/update-17-3-0/update-nxw",
21+
"implementation": "./src/migrations/update-22-1-0/update-nx-wrapper",
1622
"package": "nx",
17-
"name": "19-2-2-update-nx-wrapper"
23+
"name": "22-1-0-update-nx-wrapper"
1824
},
1925
{
20-
"version": "19.2.4-beta.0",
21-
"description": "Set project name in nx.json explicitly",
22-
"implementation": "./src/migrations/update-19-2-4/set-project-name",
23-
"x-repair-skip": true,
24-
"package": "nx",
25-
"name": "19-2-4-set-project-name"
26+
"version": "22.0.0-beta.0",
27+
"description": "Remove the deprecated `external` and `externalBuildTargets` options from the `@nx/js:swc` and `@nx/js:tsc` executors.",
28+
"factory": "./src/migrations/update-22-0-0/remove-external-options-from-js-executors",
29+
"package": "@nx/js",
30+
"name": "remove-external-options-from-js-executors"
31+
},
32+
{
33+
"version": "22.1.0-rc.1",
34+
"description": "Removes redundant TypeScript project references from project's tsconfig.json files when runtime tsconfig files (e.g., tsconfig.lib.json, tsconfig.app.json) exist.",
35+
"factory": "./src/migrations/update-22-1-0/remove-redundant-ts-project-references",
36+
"package": "@nx/js",
37+
"name": "remove-redundant-ts-project-references"
2638
}
2739
]
2840
}

nx.json

Lines changed: 89 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,102 @@
1010
"appsDir": "packages",
1111
"libsDir": "packages"
1212
},
13+
"namedInputs": {
14+
"default": ["{projectRoot}/**/*", "sharedGlobals"],
15+
"os": [{ "runtime": "node -e \"console.log(require('os').platform())\"" }],
16+
"production": [
17+
"default",
18+
"!{projectRoot}/README.md",
19+
"!{projectRoot}/CHANGELOG.md",
20+
"!{projectRoot}/perf/**/*",
21+
"!{projectRoot}/tools/**/*",
22+
"!{projectRoot}/zod2md.config.ts",
23+
"!{projectRoot}/eslint.config.?(c)js",
24+
"!{workspaceRoot}/**/.code-pushup/**/*",
25+
"!{projectRoot}/code-pushup.config.?(m)[jt]s",
26+
"!{projectRoot}/code-pushup.config.bundled_*.mjs",
27+
"!{projectRoot}/@(test|mocks|mock)/**/*",
28+
"!{projectRoot}/**/?(*.)test.[jt]s?(x)?(.snap)",
29+
"!{projectRoot}/**/?(*.)mocks.[jt]s?(x)",
30+
"!{projectRoot}/**/?(*.)mock.[jt]s?(x)",
31+
"!{projectRoot}/vitest.@(unit|int|e2e).config.[jt]s",
32+
"!{projectRoot}/dist/**/*",
33+
"!{projectRoot}/tsconfig.@(test|tools).json",
34+
"!{workspaceRoot}/**/(*.)coverage/**/*"
35+
],
36+
"test-vitest-inputs": [
37+
"os",
38+
{ "env": "NX_VERBOSE_LOGGING" },
39+
{ "externalDependencies": ["vitest"] }
40+
],
41+
"lint-eslint-inputs": [{ "externalDependencies": ["eslint"] }],
42+
"typecheck-typescript-inputs": [{ "externalDependencies": ["typescript"] }],
43+
"code-pushup-inputs": [
44+
{ "env": "NODE_OPTIONS" },
45+
{ "env": "TSX_TSCONFIG_PATH" }
46+
],
47+
"sharedGlobals": [{ "runtime": "node -v" }, { "runtime": "npm -v" }]
48+
},
1349
"targetDefaults": {
14-
"@nx/esbuild:esbuild": {
50+
"lint": {
51+
"inputs": ["default", "lint-eslint-inputs"],
52+
"outputs": ["{projectRoot}/.eslint/**/*"],
1553
"cache": true,
54+
"executor": "nx:run-commands",
55+
"options": {
56+
"command": "eslint",
57+
"args": [
58+
"'{projectRoot}/**/*.ts'",
59+
"{projectRoot}/package.json",
60+
"--config={projectRoot}/eslint.config.js",
61+
"--max-warnings=0",
62+
"--error-on-unmatched-pattern=false"
63+
]
64+
}
65+
},
66+
"build": {
1667
"dependsOn": ["^build"],
17-
"inputs": ["default", "^default"]
68+
"inputs": ["production", "^production"],
69+
"cache": true,
70+
"executor": "@nx/js:tsc",
71+
"outputs": ["{options.outputPath}"],
72+
"options": {
73+
"outputPath": "{projectRoot}/dist",
74+
"main": "{projectRoot}/src/index.ts",
75+
"tsConfig": "{projectRoot}/tsconfig.lib.json",
76+
"assets": ["{projectRoot}/*.md"]
77+
}
1878
},
19-
"@nx/vite:test": {
79+
"unit-test": {
2080
"cache": true,
21-
"inputs": ["default", "^default"]
81+
"inputs": ["default", "^production", "test-vitest-inputs"],
82+
"outputs": [
83+
"{workspaceRoot}/coverage/{projectName}/unit-tests/lcov.info"
84+
],
85+
"executor": "@nx/vitest:test",
86+
"options": {
87+
"configFile": "{projectRoot}/vitest.unit.config.ts",
88+
"coverage": {
89+
"enabled": true
90+
}
91+
}
2292
},
23-
"@nx/js:tsc": {
93+
"int-test": {
2494
"cache": true,
25-
"dependsOn": ["^build"],
26-
"inputs": ["default", "^default"]
95+
"inputs": ["default", "^production", "test-vitest-inputs"],
96+
"outputs": ["{workspaceRoot}/coverage/{projectName}/int-tests/lcov.info"],
97+
"executor": "@nx/vitest:test",
98+
"options": {
99+
"configFile": "{projectRoot}/vitest.int.config.ts",
100+
"coverage": {
101+
"enabled": true
102+
}
103+
}
104+
},
105+
"e2e": {
106+
"cache": true,
107+
"inputs": ["default", "test-vitest-inputs"],
108+
"dependsOn": ["^build"]
27109
}
28110
},
29111
"plugins": []

0 commit comments

Comments
 (0)