Skip to content

chore: fix nx usage with lifecycle scripts across all projects #10765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
9a4219c
chore: fix `nx` usage with lifecycle scripts across all projects
aryaemami59 Feb 3, 2025
0b88f6b
Add `clean` task for `repo`
aryaemami59 Mar 7, 2025
357a124
Fix `dependsOn` for `repo` tasks
aryaemami59 Mar 7, 2025
86496db
Fix `dependsOn` for `integration-tests:typecheck`
aryaemami59 Mar 7, 2025
f6476f3
Fix `dependsOn` for `eslint-plugin:generate-breaking-changes`
aryaemami59 Mar 7, 2025
72a8f70
Fix `@nx/eslint:lint` usage
aryaemami59 Mar 7, 2025
fc955b7
Fix `clean` task for `repo`
aryaemami59 Mar 10, 2025
c875823
Fix `clean` scripts and remove `postclean` scripts
aryaemami59 Mar 10, 2025
e75b663
Fix `integration-tests:typecheck` task
aryaemami59 Mar 10, 2025
cfc639a
Fix `typecheck` task
aryaemami59 Mar 15, 2025
a9c1542
chore: remove '@nx/js' from `ignoreDependencies` in `knip.ts`
aryaemami59 Mar 15, 2025
958779b
Fix `ast-spec:test`
aryaemami59 Mar 16, 2025
1d8fbd9
Fix `eslint-plugin:generate-breaking-changes` task
aryaemami59 Mar 16, 2025
067a609
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Mar 27, 2025
fb9df03
Change `yarn run --top-level` to `yarn run -T`
aryaemami59 Mar 27, 2025
93793f7
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Mar 31, 2025
8f9c46a
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Mar 31, 2025
7396ec1
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 2, 2025
d30aa8c
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 5, 2025
1d6afe0
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 7, 2025
c01bcf7
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 7, 2025
f526d38
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 10, 2025
1639036
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 10, 2025
23968fd
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 11, 2025
f897cfa
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 11, 2025
ed3dbde
chore: remove unused `downlevel-dts`
aryaemami59 Apr 11, 2025
6d056e8
Fix scripts names to avoid containing `:`
aryaemami59 Apr 11, 2025
33d45aa
Switch `yarn run -T nx` to `yarn run -BT nx`
aryaemami59 Apr 11, 2025
7071f04
Change `outDir` from `jest` to `vitest`
aryaemami59 Apr 11, 2025
9d646a7
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 11, 2025
6bf8521
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 11, 2025
5be3174
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 11, 2025
2e2d763
Run `ast-spec:typecheck` during `postinstall`
aryaemami59 Apr 11, 2025
cb52d66
Remove `jiti`
aryaemami59 Apr 11, 2025
84105fa
Update `typecheck` output path in `nx.json`
aryaemami59 Apr 12, 2025
d5dfb24
Fix `vitest` coverage output when run with `nx`
aryaemami59 Apr 12, 2025
50b548b
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 23, 2025
e871f8c
Fix `eslint-plugin:test-single` task
aryaemami59 Apr 23, 2025
9b9a6c8
Remove duplicate `ast-spec:test`
aryaemami59 Apr 23, 2025
d9c0bd6
Add missing `test` tasks
aryaemami59 Apr 23, 2025
c833461
Resolve remaining `nx` related issues
aryaemami59 Apr 23, 2025
5862135
Fix `tsBuildInfoFile` for root `tsconfig.json` file
aryaemami59 Apr 23, 2025
4170d88
Fix unit-tests for `eslint-plugin`
aryaemami59 Apr 23, 2025
31b2413
Remove remaining `jest` references
aryaemami59 Apr 23, 2025
2e4f1af
Replace `pretty-format` usage in `parser` with `vitest`
aryaemami59 Apr 23, 2025
4ce8f77
Fix lint issues for `eslint-plugin`
aryaemami59 Apr 23, 2025
65ce1a1
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 28, 2025
d85a56c
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 28, 2025
9953fdd
fix issues for `ast-spec`
aryaemami59 Apr 29, 2025
1aee400
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 Apr 30, 2025
1ce427e
Merge branch 'main' of https://github.com/typescript-eslint/typescrip…
aryaemami59 May 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/prepare-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ runs:
if: steps['build-cache'].outputs.cache-hit == 'true'
shell: bash
run: |
npx nx run types:build
yarn nx run types:build
env:
SKIP_AST_SPEC_REBUILD: true

Expand All @@ -31,6 +31,6 @@ runs:
shell: bash
# Website will be built by the Netlify GitHub App
run: |
npx nx run-many --target=build --parallel --exclude=website --exclude=website-eslint
yarn nx run-many --target=build --parallel --exclude=website --exclude=website-eslint
env:
SKIP_AST_SPEC_REBUILD: true
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ jobs:
# we don't collect coverage on other node versions so they run faster
- name: Run unit tests with coverage for ${{ matrix.package }}
if: env.PRIMARY_NODE_VERSION == matrix.node-version && matrix.os == 'ubuntu-latest'
run: npx nx run ${{ matrix.package }}:test -- --coverage
run: yarn nx run ${{ matrix.package }}:test -- --coverage
env:
CI: true
- name: Run unit tests for ${{ matrix.package }}
if: env.PRIMARY_NODE_VERSION != matrix.node-version || matrix.os != 'ubuntu-latest'
run: npx nx test ${{ matrix.package }}
run: yarn nx test ${{ matrix.package }}
env:
CI: true

Expand Down Expand Up @@ -238,7 +238,7 @@ jobs:
- name: Build
uses: ./.github/actions/prepare-build
- name: Run unit tests for ${{ matrix.package }}
run: npx nx test ${{ matrix.package }} --coverage=false
run: yarn nx test ${{ matrix.package }} --coverage=false
env:
CI: true
TYPESCRIPT_ESLINT_PROJECT_SERVICE: true
Expand Down
15 changes: 6 additions & 9 deletions knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,17 @@ export default {
workspaces: {
'.': {
entry: ['tools/release/changelog-renderer.js', 'tools/scripts/**/*.mts'],
ignore: ['tools/scripts/typings/typescript.d.ts', 'typings/*.d.ts'],
ignoreDependencies: [
'@babel/code-frame',
'@babel/core',
'@babel/eslint-parser',
'@babel/parser',
'@babel/types',
'@nx/js',
'@nx/workspace',
'glob',
'make-dir',
// imported for type purposes only
'website',
],

project: [
'tools/scripts/**/*.mts',
'!tools/scripts/typings/typescript.d.ts',
'!typings/*.d.ts',
],
},
'packages/ast-spec': {
ignore: [
Expand Down
22 changes: 14 additions & 8 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@
"outputs": ["{projectRoot}/coverage"],
"cache": true
},
"@nx/eslint:lint": {
"dependsOn": ["eslint-plugin-internal:build", "typescript-eslint:build"],
"options": {
"noEslintrc": true,
"cache": true,
"eslintConfig": "{workspaceRoot}/eslint.config.mjs"
},
"outputs": ["{options.outputFile}"],
"cache": true
},
"@nx/vite:test": {
"dependsOn": ["^build"],
"inputs": [
Expand All @@ -84,14 +94,9 @@
},
"lint": {
"executor": "@nx/eslint:lint",
"dependsOn": [
"eslint-plugin:build",
"eslint-plugin-internal:build",
"typescript-eslint:build"
],
"dependsOn": ["eslint-plugin-internal:build", "typescript-eslint:build"],
"inputs": [
"default",
"{workspaceRoot}/eslint.config.js",
"{workspaceRoot}/eslint.config.mjs",
{
"dependentTasksOutputFiles": "**/*.js",
Expand Down Expand Up @@ -124,9 +129,10 @@
],
"production": [
"default",
"!{projectRoot}/**/?(*.)+(test).[jt]s?(x)?(.snap)",
"!{projectRoot}/**/?(*.)+(test).?(m|c)[jt]s?(x)?(.snap|.shot)",
"!{projectRoot}/tests",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/vitest.config.m[jt]s",
"!{projectRoot}/vitest.config.mts",
"!{projectRoot}/src/test-setup.[jt]s"
]
}
Expand Down
46 changes: 18 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,53 +22,47 @@
},
"homepage": "https://typescript-eslint.io",
"scripts": {
"build": "npx nx run-many --target=build --exclude website --exclude website-eslint",
"build": "nx run-many --target=build --exclude website --exclude website-eslint",
"check-clean-workspace-after-install": "git diff --quiet --exit-code",
"check-format": "prettier --check .",
"check-spelling": "cspell --config=.cspell.json \"**/*.{md,mdx,ts,mts,cts,js,cjs,mjs,tsx,jsx}\" --no-progress --show-context --show-suggestions",
"clean": "npx nx run-many --target=clean",
"format": "prettier --write .",
"generate-breaking-changes": "npx nx run eslint-plugin:generate-breaking-changes",
"generate-configs": "npx nx generate-configs",
"generate-contributors": "npx nx generate-contributors",
"generate-lib": "npx nx generate-lib",
"generate-sponsors": "npx nx generate-sponsors",
"generate-website-dts": "npx nx run website:generate-website-dts",
"clean": "nx run-many --target=clean --parallel=20",
"format": "prettier --ignore-path=$PROJECT_CWD/.prettierignore --config=$PROJECT_CWD/.prettierrc.json --write $INIT_CWD",
"generate-breaking-changes": "nx run eslint-plugin:generate-breaking-changes",
"generate-configs": "nx generate-configs",
"generate-contributors": "nx generate-contributors",
"generate-lib": "nx generate-lib",
"generate-sponsors": "nx generate-sponsors",
"generate-website-dts": "nx run website:generate-website-dts",
"lint-fix": "yarn lint --fix",
"lint-markdown-fix": "yarn lint-markdown --fix",
"lint-markdown": "markdownlint \"**/*.md\" --config=.markdownlint.json --ignore-path=.markdownlintignore",
"lint-stylelint": "npx nx lint website stylelint",
"lint": "npx nx lint eslint-plugin --skip-nx-cache && npx nx run-many --target=lint --exclude eslint-plugin",
"lint-stylelint": "nx lint website stylelint",
"lint": "nx run-many --target=lint",
"postinstall": "tsx tools/scripts/postinstall.mts",
"pre-commit": "yarn lint-staged",
"pre-commit": "lint-staged",
"release": "tsx tools/release/release.mts",
"start": "npx nx run website:start",
"test": "npx nx run-many --target=test --exclude integration-tests --exclude website --exclude website-eslint",
"test-integration": "npx nx run integration-tests:test",
"typecheck": "npx nx run-many --target=typecheck"
"start": "nx run website:start",
"test": "nx run-many --target=test --exclude integration-tests --exclude website --exclude website-eslint",
"test-integration": "nx run integration-tests:test",
"typecheck": "nx run-many --target=typecheck"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"devDependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@babel/code-frame": "^7.24.2",
"@babel/core": "^7.24.4",
"@babel/eslint-parser": "^7.24.1",
"@babel/parser": "^7.24.4",
"@babel/types": "^7.24.0",
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
"@eslint/compat": "^1.2.4",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.15.0",
"@nx/devkit": "20.7.2",
"@nx/eslint": "20.7.2",
"@nx/js": "20.7.2",
"@nx/vite": "20.7.2",
"@nx/workspace": "20.7.2",
"@swc/core": "^1.4.12",
"@types/babel__code-frame": "^7.0.6",
"@types/babel__core": "^7.20.5",
"@types/debug": "^4.1.12",
"@types/eslint-plugin-jsx-a11y": "^6.10.0",
"@types/is-glob": "^4.0.4",
Expand All @@ -78,6 +72,7 @@
"@types/yargs": "^17.0.32",
"@typescript-eslint/eslint-plugin": "workspace:^",
"@typescript-eslint/eslint-plugin-internal": "workspace:^",
"@typescript-eslint/parser": "workspace:^",
"@typescript-eslint/scope-manager": "workspace:^",
"@typescript-eslint/types": "workspace:^",
"@typescript-eslint/typescript-estree": "workspace:^",
Expand All @@ -98,17 +93,13 @@
"eslint-plugin-regexp": "^2.7.0",
"eslint-plugin-unicorn": "^56.0.0",
"execa": "7.2.0",
"glob": "^10.3.12",
"globals": "^15.0.0",
"husky": "^9.1.4",
"jiti": "2.4.2",
"knip": "^5.41.1",
"lint-staged": "^15.2.2",
"make-dir": "^4.0.0",
"markdownlint-cli": "^0.44.0",
"nx": "20.7.2",
"prettier": "3.5.0",
"pretty-format": "^29.7.0",
"rimraf": "^5.0.5",
"semver": "7.7.0",
"tsx": "*",
Expand All @@ -128,7 +119,6 @@
"prettier": "3.5.0",
"pretty-format": "^29",
"react-split-pane@^0.1.92": "patch:react-split-pane@npm%3A0.1.92#./.yarn/patches/react-split-pane-npm-0.1.92-93dbf51dff.patch",
"tmp": "0.2.1",
"tsx": "^4.7.2",
"typescript": "5.8.2",
"@eslint/config-helpers": "^0.2.0"
Expand Down
21 changes: 11 additions & 10 deletions packages/ast-spec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,30 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc -b tsconfig.build.json && api-extractor run --local",
"clean": "tsc -b tsconfig.build.json --clean",
"postclean": "rimraf dist/ coverage/",
"build": "tsc -b tsconfig.build.json && api-extractor run --local --config=$INIT_CWD/api-extractor.json",
"clean": "rimraf dist/ coverage/",
"clean-fixtures": "rimraf -g \"./src/**/fixtures/**/snapshots\"",
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"lint": "npx nx lint",
"format": "yarn run -T format",
"lint": "yarn run -BT nx lint",
"test": "vitest --run --config=$INIT_CWD/vitest.config.mts",
"check-types": "npx nx typecheck"
"check-types": "yarn run -BT nx typecheck"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"devDependencies": {
"@babel/code-frame": "*",
"@babel/core": "*",
"@babel/eslint-parser": "*",
"@babel/code-frame": "^7.24.2",
"@babel/core": "^7.24.4",
"@babel/eslint-parser": "^7.24.1",
"@microsoft/api-extractor": "^7.47.11",
"@types/babel__code-frame": "^7.0.6",
"@types/babel__core": "^7.20.5",
"@typescript-eslint/typescript-estree": "workspace:*",
"@vitest/coverage-v8": "^3.1.1",
"eslint": "*",
"glob": "*",
"jest-diff": "^29.7.0",
"prettier": "^3.2.5",
"pretty-format": "*",
"rimraf": "*",
"typescript": "*",
Expand Down
3 changes: 1 addition & 2 deletions packages/ast-spec/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"outputs": ["{projectRoot}/dist/**/*.ts"]
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
"executor": "@nx/eslint:lint"
},
"test": {
"executor": "@nx/vite:test",
Expand Down
11 changes: 5 additions & 6 deletions packages/eslint-plugin-internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
"homepage": "https://typescript-eslint.io",
"license": "MIT",
"scripts": {
"build": "npx tsc -b tsconfig.build.json",
"clean": "npx tsc -b tsconfig.build.json --clean",
"postclean": "rimraf dist/ coverage/",
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"lint": "npx nx lint",
"build": "tsc -b tsconfig.build.json",
"clean": "rimraf dist/ coverage/",
"format": "yarn run -T format",
"lint": "yarn run -BT nx lint",
"test": "vitest --run --config=$INIT_CWD/vitest.config.mts",
"check-types": "npx nx typecheck"
"check-types": "yarn run -BT nx typecheck"
},
"dependencies": {
"@prettier/sync": "^0.5.1",
Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-plugin-internal/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"sourceRoot": "packages/eslint-plugin-internal/src",
"targets": {
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
"executor": "@nx/eslint:lint"
},
"test": {
"executor": "@nx/vite:test"
Expand Down
17 changes: 8 additions & 9 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"clean": "tsc -b tsconfig.build.json --clean",
"postclean": "rimraf dist && rimraf coverage",
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"generate:breaking-changes": "tsx tools/generate-breaking-changes.mts",
"generate:configs": "npx nx generate-configs repo",
"lint": "npx nx lint",
"clean": "rimraf dist/ coverage/",
"format": "yarn run -T format",
"generate-breaking-changes": "tsx tools/generate-breaking-changes.mts",
"generate-configs": "yarn run -T generate-configs",
"lint": "yarn run -BT nx lint",
"test": "vitest --run --config=$INIT_CWD/vitest.config.mts",
"test-single": "vitest --run --config=$INIT_CWD/vitest.config.mts",
"check-types": "npx nx typecheck"
"test-single": "vitest --run --config=$INIT_CWD/vitest.config.mts --no-coverage",
"check-types": "yarn run -BT nx typecheck"
},
"dependencies": {
"@eslint-community/regexpp": "^4.10.0",
Expand Down Expand Up @@ -87,7 +86,7 @@
"mdast-util-from-markdown": "^2.0.0",
"mdast-util-mdx": "^3.0.0",
"micromark-extension-mdxjs": "^3.0.0",
"prettier": "^3.2.5",
"prettier": "^3.5.3",
"rimraf": "*",
"title-case": "^3.0.3",
"tsx": "*",
Expand Down
21 changes: 16 additions & 5 deletions packages/eslint-plugin/project.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
{
"name": "eslint-plugin",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"type": "library",
"implicitDependencies": [],
"projectType": "library",
"root": "packages/eslint-plugin",
"sourceRoot": "packages/eslint-plugin/src",
"targets": {
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
"executor": "@nx/eslint:lint"
},
"test-single": {
"cache": false,
"executor": "@nx/vite:test",
"options": {
"coverage": false
}
},
"test": {
"executor": "@nx/vite:test"
},
"generate-breaking-changes": {
"dependsOn": ["type-utils:build"],
"executor": "nx:run-script",
"options": {
"script": "generate:breaking-changes"
"script": "generate-breaking-changes"
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions packages/eslint-plugin/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ describe('eslint-plugin ("./src/index.ts")', () => {
const eslintPluginRuleKeys = Object.keys(eslintPlugin.rules);

const eslintrcConfigs = fs
.readdirSync('./src/configs/eslintrc')
.readdirSync(path.join(__dirname, '..', 'src', 'configs', 'eslintrc'), {
encoding: 'utf-8',
})
.filter(file => ['.json', '.ts'].includes(path.extname(file).toLowerCase()))
.map(file => path.basename(file, path.extname(file)));

const flatConfigs = fs
.readdirSync('./src/configs/flat')
.readdirSync(path.join(__dirname, '..', 'src', 'configs', 'flat'), {
encoding: 'utf-8',
})
.filter(file => ['.json', '.ts'].includes(path.extname(file).toLowerCase()))
.map(file => path.basename(file, path.extname(file)))
.map(file => `flat/${file}`);
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin/tests/rules/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'node:fs';
import * as path from 'node:path';

import rules from '../../src/rules';

Expand All @@ -7,7 +8,7 @@ describe('./src/rules/index.ts', () => {
.map(name => `${name}.ts`)
.sort();
const files = fs
.readdirSync('./src/rules')
.readdirSync(path.join(__dirname, '..', '..', 'src', 'rules'))
.filter(file => file !== 'index.ts' && file.endsWith('.ts'));

it('imports all available rule modules', () => {
Expand Down
Loading