Skip to content

Commit 6b92aa5

Browse files
chore: reorg repo level utils, lint and typecheck repo files (#9618)
Co-authored-by: Abraham Guo <[email protected]>
1 parent 9fb79b4 commit 6b92aa5

File tree

131 files changed

+380
-1252
lines changed

Some content is hidden

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

131 files changed

+380
-1252
lines changed

.cspell.json

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"destructures",
8484
"discoverability",
8585
"dprint",
86+
"dummypkg",
8687
"errored",
8788
"erroring",
8889
"ESLint",

.github/actions/breaking-pr-check/index.js

+22-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
// @ts-check
2+
/* eslint-disable jsdoc/no-types */
3+
14
const core = require('@actions/core');
25
const github = require('@actions/github');
36

4-
function raiseError(message) {
5-
throw new Error(message);
6-
}
7-
87
async function getPullRequest() {
9-
const client = github.getOctokit(process.env.GITHUB_TOKEN);
8+
const token = process.env.GITHUB_TOKEN;
9+
if (!token) {
10+
throw new Error(
11+
'The GITHUB_TOKEN environment variable is required to run this action.',
12+
);
13+
}
14+
const client = github.getOctokit(token);
1015

1116
const pr = github.context.payload.pull_request;
1217
if (!pr) {
@@ -27,27 +32,34 @@ async function getPullRequest() {
2732
return data;
2833
}
2934

35+
/**
36+
* @param {string} title The PR title to check
37+
*/
3038
function checkTitle(title) {
3139
if (/^[a-z]+(\([a-z-]+\))?!: /.test(title)) {
32-
raiseError(
40+
throw new Error(
3341
`Do not use exclamation mark ('!') to indicate breaking change in the PR Title.`,
3442
);
3543
}
3644
}
3745

46+
/**
47+
* @param {string} body The body of the PR
48+
* @param {any[]} labels The labels applied to the PR
49+
*/
3850
function checkDescription(body, labels) {
3951
if (!labels.some(label => label.name === 'breaking change')) {
4052
return;
4153
}
4254
const [firstLine, secondLine] = body.split(/\r?\n/);
4355

4456
if (!firstLine || !/^BREAKING CHANGE:/.test(firstLine)) {
45-
raiseError(
57+
throw new Error(
4658
`Breaking change PR body should start with "BREAKING CHANGE:". See https://typescript-eslint.io/maintenance/releases#2-merging-breaking-changes.`,
4759
);
4860
}
4961
if (!secondLine) {
50-
raiseError(
62+
throw new Error(
5163
`The description of breaking change is missing. See https://typescript-eslint.io/maintenance/releases#2-merging-breaking-changes.`,
5264
);
5365
}
@@ -57,8 +69,8 @@ async function run() {
5769
const pullRequest = await getPullRequest();
5870
try {
5971
checkTitle(pullRequest.title);
60-
checkDescription(pullRequest.body, pullRequest.labels);
61-
} catch (e) {
72+
checkDescription(pullRequest.body ?? '', pullRequest.labels);
73+
} catch (/** @type {any} */ e) {
6274
core.setFailed(e.message);
6375
}
6476
}

.github/actions/wait-for-netlify/action.yml

-15
This file was deleted.

.github/actions/wait-for-netlify/index.js

-108
This file was deleted.

.github/workflows/ci.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ jobs:
171171
'eslint-plugin',
172172
'eslint-plugin-internal',
173173
'parser',
174-
'repo-tools',
175174
'rule-schema-to-typescript-types',
176175
'scope-manager',
177176
'type-utils',
@@ -292,7 +291,7 @@ jobs:
292291
uses: ./.github/actions/prepare-build
293292

294293
- name: Figure out and apply the next canary version
295-
run: npx nx run repo-tools:apply-canary-version
294+
run: npx tsx tools/release/apply-canary-version.mts
296295

297296
- name: Publish all packages to npm with the canary tag
298297
# NOTE: this needs to be npx, rather than yarn, to make sure the authenticated npm registry is used
@@ -325,7 +324,7 @@ jobs:
325324
uses: ./.github/actions/prepare-build
326325

327326
- name: Figure out and apply the next canary version
328-
run: OVERRIDE_MAJOR_VERSION=8 npx nx run repo-tools:apply-canary-version
327+
run: OVERRIDE_MAJOR_VERSION=8 npx tsx tools/release/apply-canary-version.mts
329328

330329
- name: Publish all packages to npm with the canary tag
331330
# NOTE: this needs to be npx, rather than yarn, to make sure the authenticated npm registry is used

eslint.config.mjs

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default tseslint.config(
2626
// register all of the plugins up-front
2727
{
2828
// note - intentionally uses computed syntax to make it easy to sort the keys
29+
/* eslint-disable no-useless-computed-key */
2930
plugins: {
3031
['@typescript-eslint']: tseslint.plugin,
3132
['@typescript-eslint/internal']: tseslintInternalPlugin,
@@ -41,6 +42,7 @@ export default tseslint.config(
4142
['simple-import-sort']: simpleImportSortPlugin,
4243
['unicorn']: unicornPlugin,
4344
},
45+
/* eslint-enable no-useless-computed-key */
4446
},
4547
{
4648
// config with just ignores is the replacement for `.eslintignore`
@@ -53,6 +55,8 @@ export default tseslint.config(
5355
'**/__snapshots__/**',
5456
'**/.docusaurus/**',
5557
'**/build/**',
58+
'.nx/*',
59+
'.yarn/*',
5660
// Files copied as part of the build
5761
'packages/types/src/generated/**/*.ts',
5862
// Playground types downloaded from the web
@@ -404,7 +408,6 @@ export default tseslint.config(
404408
files: [
405409
'**/tools/**/*.{ts,tsx,cts,mts}',
406410
'**/tests/**/*.{ts,tsx,cts,mts}',
407-
'packages/repo-tools/**/*.{ts,tsx,cts,mts}',
408411
'packages/integration-tests/**/*.{ts,tsx,cts,mts}',
409412
],
410413
rules: {

knip.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { KnipConfig } from 'knip';
1+
import type { KnipConfig } from 'knip' with { 'resolution-mode': 'import' };
22

33
export default {
44
rules: {
@@ -20,18 +20,14 @@ export default {
2020
'@babel/parser',
2121
'@babel/types',
2222
'@nx/workspace',
23-
'cross-fetch',
2423
'glob',
2524
'husky',
2625
'jest-specific-snapshot',
2726
'make-dir',
2827
'ncp',
2928
'tmp',
30-
31-
// imported in eslint.config.js
32-
'@typescript-eslint/utils',
3329
],
34-
entry: ['tools/release/changelog-renderer.js'],
30+
entry: ['tools/release/changelog-renderer.js', 'tools/scripts/**/*.mts'],
3531
ignoreBinaries: [
3632
// https://github.com/webpro/knip/issues/433
3733
'stylelint',

nx.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "./node_modules/nx/schemas/nx-schema.json",
33
"nxCloudAccessToken": "YjIzMmMxMWItMjhiMS00NWY2LTk1NWYtYWU3YWQ0YjE4YjBlfHJlYWQ=",
44
"release": {
5-
"projects": ["*"],
5+
"projects": ["*", "!repo"],
66
"changelog": {
77
"workspaceChangelog": {
88
"createRelease": "github",

package.json

+25-18
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,30 @@
2424
},
2525
"homepage": "https://typescript-eslint.io",
2626
"scripts": {
27-
"build": "npx nx run-many --target=build --parallel --exclude website --exclude website-eslint",
27+
"build": "npx nx run-many --target=build --exclude website --exclude website-eslint",
2828
"check-clean-workspace-after-install": "git diff --quiet --exit-code",
2929
"check-format": "prettier --check .",
3030
"check-spelling": "cspell --config=.cspell.json \"**/*.{md,mdx,ts,mts,cts,js,cjs,mjs,tsx,jsx}\" --no-progress --show-context --show-suggestions",
3131
"clean": "nx run-many --target=clean",
3232
"format": "prettier --write .",
3333
"generate-breaking-changes": "npx nx run eslint-plugin:generate-breaking-changes",
34-
"generate-configs": "npx nx run repo-tools:generate-configs",
35-
"generate-contributors": "npx nx run repo-tools:generate-contributors",
36-
"generate-sponsors": "npx nx run repo-tools:generate-sponsors",
34+
"generate-configs": "nx generate-configs",
35+
"generate-contributors": "nx generate-contributors",
36+
"generate-lib": "nx generate-lib",
37+
"generate-sponsors": "nx generate-sponsors",
3738
"generate-website-dts": "npx nx run website:generate-website-dts",
38-
"generate-lib": "npx nx run repo-tools:generate-lib",
3939
"lint-fix": "yarn lint --fix",
4040
"lint-markdown-fix": "yarn lint-markdown --fix",
4141
"lint-markdown": "markdownlint \"**/*.md\" --config=.markdownlint.json --ignore-path=.markdownlintignore",
4242
"lint-stylelint": "npx nx lint website stylelint",
43-
"lint": "npx nx lint eslint-plugin --skip-nx-cache && npx nx run-many --target=lint --parallel --exclude eslint-plugin",
44-
"postinstall": "npx nx run repo-tools:postinstall-script",
43+
"lint": "npx nx lint eslint-plugin --skip-nx-cache && npx nx run-many --target=lint --exclude eslint-plugin",
44+
"postinstall": "tsx tools/scripts/postinstall.mts",
4545
"pre-commit": "yarn lint-staged",
4646
"release": "tsx tools/release/release.mts",
4747
"start": "npx nx run website:start",
48-
"test": "npx nx run-many --target=test --parallel --exclude integration-tests --exclude website --exclude website-eslint",
48+
"test": "npx nx run-many --target=test --exclude integration-tests --exclude website --exclude website-eslint",
4949
"test-integration": "npx nx run integration-tests:test",
50-
"typecheck": "npx nx run-many --target=typecheck --parallel"
50+
"typecheck": "nx run-many --target=typecheck"
5151
},
5252
"engines": {
5353
"node": "^18.18.0 || >=20.0.0"
@@ -63,9 +63,10 @@
6363
"@eslint/eslintrc": "^2.1.4",
6464
"@eslint/js": "^8.57.0",
6565
"@jest/types": "29.6.3",
66-
"@nx/eslint": "19.4.0",
67-
"@nx/jest": "19.4.0",
68-
"@nx/workspace": "19.4.0",
66+
"@nx/devkit": "19.5.2",
67+
"@nx/eslint": "19.5.2",
68+
"@nx/jest": "19.5.2",
69+
"@nx/workspace": "19.5.2",
6970
"@swc/core": "^1.4.12",
7071
"@swc/jest": "^0.2.36",
7172
"@types/babel__code-frame": "^7.0.6",
@@ -80,7 +81,12 @@
8081
"@types/semver": "^7.5.8",
8182
"@types/tmp": "^0.2.6",
8283
"@types/yargs": "^17.0.32",
84+
"@typescript-eslint/eslint-plugin": "workspace:^",
8385
"@typescript-eslint/eslint-plugin-internal": "workspace:^",
86+
"@typescript-eslint/scope-manager": "workspace:^",
87+
"@typescript-eslint/types": "workspace:^",
88+
"@typescript-eslint/typescript-estree": "workspace:^",
89+
"@typescript-eslint/utils": "workspace:^",
8490
"console-fail-test": "^0.2.3",
8591
"cross-fetch": "^4.0.0",
8692
"cspell": "^8.6.1",
@@ -108,11 +114,11 @@
108114
"make-dir": "^4.0.0",
109115
"markdownlint-cli": "^0.41.0",
110116
"ncp": "^2.0.0",
111-
"netlify": "^13.1.14",
112-
"nx": "19.4.0",
117+
"nx": "19.5.2",
113118
"prettier": "3.3.2",
114119
"pretty-format": "^29.7.0",
115120
"rimraf": "^5.0.5",
121+
"semver": "7.6.2",
116122
"tmp": "^0.2.1",
117123
"tsx": "*",
118124
"typescript": ">=4.7.4 <5.6.0",
@@ -139,9 +145,10 @@
139145
"tmp": "0.2.1",
140146
"tsx": "^4.7.2",
141147
"typescript": "5.5.2",
142-
"eslint-plugin-eslint-plugin@^5.5.0": "patch:eslint-plugin-eslint-plugin@npm%3A5.5.1#./.yarn/patches/eslint-plugin-eslint-plugin-npm-5.5.1-4206c2506d.patch",
143-
"@nx/[email protected]": "patch:@nx/eslint@npm%3A19.3.0-canary.20240611-1600875#./.yarn/patches/@nx-eslint-npm-19.3.0-canary.20240611-1600875-f5cb695794.patch",
144-
"[email protected]": "patch:nx@npm%3A19.3.0-canary.20240611-1600875#./.yarn/patches/nx-npm-19.3.0-canary.20240611-1600875-bd96520563.patch"
148+
"eslint-plugin-eslint-plugin@^5.5.0": "patch:eslint-plugin-eslint-plugin@npm%3A5.5.1#./.yarn/patches/eslint-plugin-eslint-plugin-npm-5.5.1-4206c2506d.patch"
145149
},
146-
"packageManager": "[email protected]"
150+
"packageManager": "[email protected]",
151+
"nx": {
152+
"includedScripts": []
153+
}
147154
}

0 commit comments

Comments
 (0)