Skip to content
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

chore: update to latest nx and use project references first approach #10361

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ jobs:
'eslint-plugin-internal',
'parser',
'rule-tester',
'rule-schema-to-typescript-types',
'scope-manager',
'type-utils',
'typescript-eslint',
Expand Down
1 change: 1 addition & 0 deletions .nxignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# see comment in the file
packages/ast-spec/tests/util/parsers/typescript-estree-import.ts
packages/integration-tests/fixtures/**/*
39 changes: 9 additions & 30 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import eslint from '@eslint/js';
import eslintCommentsPlugin from '@eslint-community/eslint-plugin-eslint-comments/configs';
import tseslintInternalPlugin from '@typescript-eslint/eslint-plugin-internal';
import eslintCommentsPlugin from 'eslint-plugin-eslint-comments';
import eslintPluginPlugin from 'eslint-plugin-eslint-plugin';
import importPlugin from 'eslint-plugin-import';
import jestPlugin from 'eslint-plugin-jest';
Expand All @@ -30,7 +30,6 @@ export default tseslint.config(
plugins: {
['@typescript-eslint']: tseslint.plugin,
['@typescript-eslint/internal']: tseslintInternalPlugin,
['eslint-comments']: eslintCommentsPlugin,
['eslint-plugin']: eslintPluginPlugin,
['import']: importPlugin,
['jest']: jestPlugin,
Expand All @@ -40,6 +39,8 @@ export default tseslint.config(
['perfectionist']: perfectionistPlugin,
// https://github.com/facebook/react/issues/28313
['react']: reactPlugin,
// @ts-expect-error -- Temporary types incompatibility pending flat config support
// https://github.com/facebook/react/pull/30774
['react-hooks']: fixupPluginRules(reactHooksPlugin),
['regexp']: regexpPlugin,
['unicorn']: unicornPlugin,
Expand Down Expand Up @@ -82,6 +83,7 @@ export default tseslint.config(
},

// extends ...
eslintCommentsPlugin.recommended,
eslint.configs.recommended,
tseslint.configs.strictTypeChecked,
tseslint.configs.stylisticTypeChecked,
Expand Down Expand Up @@ -244,35 +246,9 @@ export default tseslint.config(
// eslint-plugin-eslint-comment
//

// require a eslint-enable comment for every eslint-disable comment
'eslint-comments/disable-enable-pair': [
'@eslint-community/eslint-comments/disable-enable-pair': [
'error',
{
allowWholeFile: true,
},
],
// disallow a eslint-enable comment for multiple eslint-disable comments
'eslint-comments/no-aggregating-enable': 'error',
// disallow duplicate eslint-disable comments
'eslint-comments/no-duplicate-disable': 'error',
// disallow eslint-disable comments without rule names
'eslint-comments/no-unlimited-disable': 'error',
// disallow unused eslint-disable comments
'eslint-comments/no-unused-disable': 'error',
// disallow unused eslint-enable comments
'eslint-comments/no-unused-enable': 'error',
// disallow ESLint directive-comments
'eslint-comments/no-use': [
'error',
{
allow: [
'eslint-disable',
'eslint-disable-line',
'eslint-disable-next-line',
'eslint-enable',
'global',
],
},
{ allowWholeFile: true },
],

//
Expand Down Expand Up @@ -565,8 +541,11 @@ export default tseslint.config(
{
extends: [
jsxA11yPlugin.flatConfigs.recommended,
// https://github.com/facebook/react/pull/30774
// @ts-expect-error -- Temporary types incompatibility pending flat config support
reactPlugin.configs.flat.recommended,
// https://github.com/facebook/react/pull/30774
// @ts-expect-error -- Temporary types incompatibility pending flat config support
fixupConfigRules(compat.config(reactHooksPlugin.configs.recommended)),
],
files: ['packages/website/**/*.{ts,tsx,mts,cts,js,jsx}'],
Expand Down
34 changes: 29 additions & 5 deletions knip.ts
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg Dec 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect a lot of the seemingly unnecessary includes in this file are due to webpro-nl/knip#873. Once that's resolved & released, if they're still there, we should file an issue over on Knip.

Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ 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',
'husky',
Expand All @@ -38,32 +40,44 @@ export default {
// @typescript-eslint/typescript-estree is not listed in dependencies to avoid circular dependency errors
// You can check a more detailed explanation in this file
'tests/util/parsers/typescript-estree-import.ts',
'typings/global.d.ts',
],
},
'packages/eslint-plugin': {
ignore: ['tests/fixtures/**'],
ignore: [
'tests/fixtures/**',
'typings/eslint-rules.d.ts',
'typings/typescript.d.ts',
],
},
'packages/eslint-plugin-internal': {
ignore: ['tests/fixtures/**'],
},
'packages/integration-tests': {
ignore: ['fixtures/**'],
ignore: ['fixtures/**', 'typings/global.d.ts'],
},
'packages/parser': {
ignore: ['tests/fixtures/**'],
},
'packages/rule-tester': {
ignore: ['typings/eslint.d.ts'],
},
'packages/scope-manager': {
ignore: ['tests/fixtures/**'],
},
'packages/type-utils': {
ignore: ['tests/fixtures/**'],
ignore: ['tests/fixtures/**', 'typings/typescript.d.ts'],
},
'packages/typescript-estree': {
entry: ['src/use-at-your-own-risk.ts'],
ignore: ['tests/fixtures/**'],
ignore: ['tests/fixtures/**', 'typings/typescript.d.ts'],
},
'packages/utils': {
ignore: ['tests/**/*.type-test.ts'],
ignore: [
'tests/**/*.type-test.ts',
'typings/eslint.d.ts',
'typings/eslint-community-eslint-utils.d.ts',
],
},
'packages/website': {
entry: [
Expand All @@ -77,13 +91,22 @@ export default {
'src/theme/**/*.tsx',
'src/theme/prism-include-languages.js',
],
ignore: [
'src/globals.d.ts',
'src/hooks/*',
'src/types.d.ts',
'typings/*',
],
ignoreDependencies: [
// used in MDX docs
'raw-loader',

// it's imported only as type (esquery types are forked and defined in packages/website/typings/esquery.d.ts)
'esquery',

// Referenced in webpack via the CopyPlugin
'@typescript-eslint/website-eslint',

'@docusaurus/mdx-loader',
'@docusaurus/types',
'@docusaurus/plugin-content-docs',
Expand All @@ -97,6 +120,7 @@ export default {
'@docusaurus/BrowserOnly',
'@docusaurus/module-type-aliases',
'@generated/docusaurus.config',
'^@site/.*',
'^@theme/.*',
'^@theme-original/.*',
'docusaurus-plugin-typedoc',
Expand Down
15 changes: 15 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"nxCloudAccessToken": "YjIzMmMxMWItMjhiMS00NWY2LTk1NWYtYWU3YWQ0YjE4YjBlfHJlYWQ=",
"plugins": [
{
"plugin": "@nx/js/typescript",
"exclude": [".", "packages/integration-tests/fixtures/**"],
"options": {
"typecheck": {
"targetName": "typecheck"
},
"build": {
"targetName": "build",
"configName": "tsconfig.build.json"
}
}
}
],
"release": {
"projects": [
"!repo",
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"@babel/eslint-parser": "^7.24.1",
"@babel/parser": "^7.24.4",
"@babel/types": "^7.24.0",
"@eslint/compat": "^1.2.3",
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
"@eslint/compat": "^1.2.4",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.15.0",
"@jest/types": "29.6.3",
Expand All @@ -71,6 +72,8 @@
"@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/eslint__eslintrc": "^2.1.2",
"@types/is-glob": "^4.0.4",
"@types/jest": "29.5.13",
"@types/jest-specific-snapshot": "^0.5.9",
Expand All @@ -91,14 +94,13 @@
"cspell": "^8.15.2",
"downlevel-dts": ">=0.11.0",
"eslint": "^9.15.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-eslint-plugin": "^6.3.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.9.0",
"eslint-plugin-jsdoc": "^50.5.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-perfectionist": "^3.9.1",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react": "^7.37.3",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-regexp": "^2.7.0",
"eslint-plugin-unicorn": "^56.0.0",
Expand All @@ -108,7 +110,7 @@
"husky": "^9.1.4",
"jest": "29.7.0",
"jest-specific-snapshot": "^8.0.0",
"knip": "^5.9.4",
"knip": "^5.41.1",
"lint-staged": "^15.2.2",
"make-dir": "^4.0.0",
"markdownlint-cli": "^0.43.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/ast-spec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"files": [
"dist",
"!*.tsbuildinfo",
"package.json",
"README.md",
"LICENSE"
Expand All @@ -37,7 +38,7 @@
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"lint": "npx nx lint",
"test": "jest",
"typecheck": "tsc --noEmit"
"_typecheck": "npx nx typecheck"
},
"funding": {
"type": "opencollective",
Expand All @@ -49,6 +50,7 @@
"@babel/eslint-parser": "*",
"@jest/types": "29.6.3",
"@microsoft/api-extractor": "^7.47.11",
"@typescript-eslint/typescript-estree": "8.19.0",
"glob": "*",
"jest": "29.7.0",
"jest-diff": "^29.7.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ast-spec/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ast-spec",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"type": "library",
"implicitDependencies": [],
"implicitDependencies": ["!typescript-estree"],
"targets": {
"build": {
"executor": "nx:run-commands",
Expand Down
21 changes: 14 additions & 7 deletions packages/ast-spec/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"jsx": "preserve",
"outDir": "./dist",
"rootDir": "./src",
"resolveJsonModule": true
"baseUrl": ".",
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",
Comment on lines +6 to +7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"outDir": "dist",
"tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo",

could possibly reduce some boilerplate by putting this:

    "outDir": "${configDir}/dist",
    "tsBuildInfoFile": "${configDir}/dist/tsconfig.build.tsbuildinfo",

into

../../tsconfig.base.json

"emitDeclarationOnly": false,
"types": ["node"]
},
"include": ["src", "typings"],
"exclude": ["**/fixtures/**"]
"include": ["src/**/*.ts"],
"exclude": [
"jest.config.js",
"src/**/*.spec.ts",
"src/**/*.test.ts",
"**/fixtures/**"
],
"references": []
}
19 changes: 11 additions & 8 deletions packages/ast-spec/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"composite": false,
"rootDir": "."
},
"include": ["src", "typings", "tests", "tools", "**/fixtures/**/config.ts"],
"exclude": ["**/fixtures/**/fixture.ts", "**/fixtures/**/fixture.tsx"],
"references": [{ "path": "../typescript-estree/tsconfig.build.json" }]
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.build.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
24 changes: 24 additions & 0 deletions packages/ast-spec/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc/packages/ast-spec",
"module": "NodeNext",
"types": ["jest", "node"]
},
"include": [
"jest.config.js",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts",
"tests",
"typings"
],
"references": [
{
"path": "../typescript-estree/tsconfig.build.json"
},
{
"path": "./tsconfig.build.json"
}
]
}
23 changes: 0 additions & 23 deletions packages/ast-spec/typings/babel-eslint-parser.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/eslint-plugin-internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"lint": "npx nx lint",
"test": "jest --coverage",
"typecheck": "npx tsc --noEmit"
"_typecheck": "npx nx typecheck"
},
"dependencies": {
"@prettier/sync": "^0.5.1",
Expand Down
Loading
Loading