Skip to content

Commit f53fece

Browse files
chore: add knip (#8192)
* chore: add knip * chore: sync lockfile * chore: bump knip * ci: run knip in ci workflow * ci: run knip as part of lint job * refactor: replace `testRegex` with `testMatch` * refactor: use satisfies in knip config * chore: fix path to rule-tester fixtures * chore: add dummypkg as knip workspace * chore: get rid of json-schema * chore: fix knip issues in packages/website * chore: sync lockfile * chore: add missed merge stuff * chore: install @jest/types in the root workspace * chore: partially fix issues for website-eslint * chore: fix knip issues for packages/website-eslint * chore: add ncp resolution to the root package.json * chore: wip wip wip * chore: fix misspelling + handle few knip issues * chore: finally (?) * chore: expand ignoreDependencies regular expressions * chore: revert unrelated changes * chore: try to minimise docusaurus-related changes * chore: remove extra entry * chore: bump knip to 4.0.2 * wip * add types to jest config * yarn lint --fix * add knip to ci * !!! * Revert "!!!" This reverts commit 36fa481. * revert yarn dedupe * sed -i 's| -p tsconfig.json||g' * update todo comment in eslint.config.js * Update knip.ts Co-authored-by: Josh Goldberg ✨ <[email protected]> * oops --------- Co-authored-by: Josh Goldberg ✨ <[email protected]>
1 parent 8acb8d4 commit f53fece

File tree

27 files changed

+642
-213
lines changed

27 files changed

+642
-213
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
runs-on: ubuntu-latest
104104
strategy:
105105
matrix:
106-
lint-task: ['lint', 'typecheck']
106+
lint-task: ['lint', 'typecheck', 'knip']
107107
steps:
108108
- name: Checkout
109109
uses: actions/checkout@v4

eslint.config.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// @ts-check
22

3-
// TODO - https://github.com/eslint/eslint/pull/17909
4-
// either it gets back-ported (https://github.com/eslint/eslint/issues/17966) or we wait till v9
3+
// TODO - https://github.com/nrwl/nx/issues/22576
54

65
/** @type {import('@typescript-eslint/utils/ts-eslint').FlatConfig.ConfigPromise} */
76
const config = (async () => (await import('./eslint.config.mjs')).default)();

jest.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
'use strict';
2+
3+
// @ts-check
14
const { getJestProjects } = require('@nx/jest');
25

6+
/** @type {import('@jest/types').Config.InitialOptions} */
37
module.exports = {
48
projects: getJestProjects(),
59
};

knip.ts

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import type { KnipConfig } from 'knip';
2+
3+
export default {
4+
rules: {
5+
classMembers: 'off',
6+
duplicates: 'off',
7+
enumMembers: 'off',
8+
exports: 'off',
9+
nsExports: 'off',
10+
nsTypes: 'off',
11+
types: 'off',
12+
unresolved: 'off',
13+
},
14+
workspaces: {
15+
'.': {
16+
ignoreDependencies: [
17+
'@babel/code-frame',
18+
'@babel/core',
19+
'@babel/eslint-parser',
20+
'@babel/parser',
21+
'@babel/types',
22+
'@nx/workspace',
23+
'cross-fetch',
24+
'glob',
25+
'husky',
26+
'jest-specific-snapshot',
27+
'make-dir',
28+
'ncp',
29+
'tmp',
30+
31+
// imported in eslint.config.js
32+
'@typescript-eslint/utils',
33+
// imported in eslint.config.mjs
34+
'@typescript-eslint/eslint-plugin-internal',
35+
],
36+
entry: ['tools/release/changelog-renderer.js'],
37+
ignoreBinaries: [
38+
// https://github.com/webpro/knip/issues/433
39+
'stylelint',
40+
],
41+
},
42+
'packages/ast-spec': {
43+
ignore: [
44+
'src/**/fixtures/**',
45+
'tests/*.type-test.ts',
46+
// @typescript-eslint/typescript-estree is not listed in dependencies to avoid circular dependency errors
47+
// You can check a more detailed explanation in this file
48+
'tests/util/parsers/typescript-estree-import.ts',
49+
],
50+
},
51+
'packages/eslint-plugin': {
52+
ignore: ['tests/fixtures/**'],
53+
},
54+
'packages/eslint-plugin-internal': {
55+
ignore: ['tests/fixtures/**'],
56+
},
57+
'packages/integration-tests': {
58+
ignore: ['fixtures/**'],
59+
},
60+
'packages/parser': {
61+
ignore: ['tests/fixtures/**'],
62+
},
63+
'packages/scope-manager': {
64+
ignore: ['tests/fixtures/**'],
65+
},
66+
'packages/type-utils': {
67+
ignore: ['tests/fixtures/**'],
68+
},
69+
'packages/typescript-estree': {
70+
entry: ['src/use-at-your-own-risk.ts'],
71+
ignore: ['tests/fixtures/**'],
72+
},
73+
'packages/website': {
74+
entry: [
75+
'docusaurus.config.mts',
76+
'src/pages/**/*.tsx',
77+
78+
// imported in MDX docs
79+
'src/components/**/*.tsx',
80+
81+
// used by Docusaurus
82+
'src/theme/**/*.tsx',
83+
'src/theme/prism-include-languages.js',
84+
],
85+
ignoreDependencies: [
86+
// used in MDX docs
87+
'raw-loader',
88+
89+
// it's imported only as type (esquery types are forked and defined in packages/website/typings/esquery.d.ts)
90+
'esquery',
91+
92+
'@babel/runtime',
93+
'@docusaurus/mdx-loader',
94+
'@docusaurus/types',
95+
'@docusaurus/plugin-content-docs',
96+
'@docusaurus/theme-search-algolia',
97+
'@docusaurus/ExecutionEnvironment',
98+
'@docusaurus/Link',
99+
'@docusaurus/router',
100+
'@docusaurus/useDocusaurusContext',
101+
'@docusaurus/useBaseUrl',
102+
'@docusaurus/BrowserOnly',
103+
'@docusaurus/theme-classic',
104+
'@generated/docusaurus.config',
105+
'^@theme/.*',
106+
'^@theme-original/.*',
107+
],
108+
},
109+
'packages/website-eslint': {
110+
ignoreDependencies: [
111+
// virtual module
112+
'vt',
113+
],
114+
entry: [
115+
'src/index.js',
116+
'src/mock/assert.js',
117+
'src/mock/empty.js',
118+
'src/mock/eslint-rules.js',
119+
'src/mock/eslint.js',
120+
'src/mock/lru-cache.js',
121+
'src/mock/path.js',
122+
'src/mock/typescript.js',
123+
'src/mock/util.js',
124+
],
125+
},
126+
'tools/dummypkg': {},
127+
},
128+
} satisfies KnipConfig;

package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"@babel/types": "^7.24.0",
6565
"@eslint/eslintrc": "^2.1.4",
6666
"@eslint/js": "^8.57.0",
67+
"@jest/types": "29.6.3",
6768
"@nx/eslint": "18.2.3",
6869
"@nx/jest": "18.2.3",
6970
"@nx/workspace": "18.2.3",
@@ -75,7 +76,6 @@
7576
"@types/is-glob": "^4.0.4",
7677
"@types/jest": "29.5.12",
7778
"@types/jest-specific-snapshot": "^0.5.9",
78-
"@types/marked": "^5.0.2",
7979
"@types/natural-compare": "^1.4.3",
8080
"@types/ncp": "^2.0.8",
8181
"@types/node": "^20.12.5",
@@ -104,9 +104,8 @@
104104
"globals": "^15.0.0",
105105
"husky": "^8.0.3",
106106
"jest": "29.7.0",
107-
"jest-diff": "^29.7.0",
108-
"jest-snapshot": "^29.7.0",
109107
"jest-specific-snapshot": "^8.0.0",
108+
"knip": "^5.9.4",
110109
"lint-staged": "^15.2.2",
111110
"make-dir": "^4.0.0",
112111
"markdownlint-cli": "^0.39.0",
@@ -115,7 +114,6 @@
115114
"nx": "18.2.3",
116115
"prettier": "3.2.5",
117116
"pretty-format": "^29.7.0",
118-
"raw-loader": "^4.0.2",
119117
"rimraf": "^5.0.5",
120118
"tmp": "^0.2.3",
121119
"tsx": "*",

packages/ast-spec/package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
3838
"lint": "npx nx lint",
3939
"test": "jest",
40-
"typecheck": "tsc -p tsconfig.json --noEmit"
40+
"typecheck": "tsc --noEmit"
4141
},
4242
"funding": {
4343
"type": "opencollective",
@@ -47,12 +47,11 @@
4747
"@babel/code-frame": "*",
4848
"@babel/core": "*",
4949
"@babel/eslint-parser": "*",
50-
"@babel/parser": "*",
50+
"@jest/types": "29.6.3",
5151
"@microsoft/api-extractor": "^7.43.0",
5252
"glob": "*",
5353
"jest": "29.7.0",
5454
"jest-diff": "^29.7.0",
55-
"jest-snapshot": "^29.7.0",
5655
"jest-specific-snapshot": "^8.0.0",
5756
"make-dir": "*",
5857
"prettier": "^3.2.5",

packages/eslint-plugin-internal/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
1212
"lint": "npx nx lint",
1313
"test": "jest --coverage",
14-
"typecheck": "tsc -p tsconfig.json --noEmit"
14+
"typecheck": "tsc --noEmit"
1515
},
1616
"dependencies": {
1717
"@prettier/sync": "^0.5.1",
@@ -22,6 +22,7 @@
2222
"prettier": "^3.2.5"
2323
},
2424
"devDependencies": {
25+
"@jest/types": "29.6.3",
2526
"jest": "29.7.0",
2627
"rimraf": "*"
2728
}

packages/eslint-plugin/package.json

+5-8
Original file line numberDiff line numberDiff line change
@@ -53,39 +53,36 @@
5353
"clean": "tsc -b tsconfig.build.json --clean",
5454
"postclean": "rimraf dist && rimraf coverage",
5555
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
56-
"generate:breaking-changes": "yarn tsx tools/generate-breaking-changes.mts",
56+
"generate:breaking-changes": "tsx tools/generate-breaking-changes.mts",
5757
"generate:configs": "npx nx run repo-tools:generate-configs",
5858
"lint": "npx nx lint",
5959
"test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --coverage --logHeapUsage",
6060
"test-single": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --no-coverage",
61-
"typecheck": "tsc -p tsconfig.json --noEmit"
61+
"typecheck": "tsc --noEmit"
6262
},
6363
"dependencies": {
6464
"@eslint-community/regexpp": "^4.10.0",
6565
"@typescript-eslint/scope-manager": "7.8.0",
6666
"@typescript-eslint/type-utils": "7.8.0",
6767
"@typescript-eslint/utils": "7.8.0",
6868
"@typescript-eslint/visitor-keys": "7.8.0",
69-
"debug": "^4.3.4",
7069
"graphemer": "^1.4.0",
7170
"ignore": "^5.3.1",
7271
"natural-compare": "^1.4.0",
73-
"semver": "^7.6.0",
7472
"ts-api-utils": "^1.3.0"
7573
},
7674
"devDependencies": {
77-
"@types/debug": "*",
78-
"@types/marked": "*",
75+
"@jest/types": "29.6.3",
76+
"@types/marked": "^5.0.2",
7977
"@types/mdast": "^4.0.3",
8078
"@types/natural-compare": "*",
8179
"@typescript-eslint/rule-schema-to-typescript-types": "7.8.0",
8280
"@typescript-eslint/rule-tester": "7.8.0",
8381
"ajv": "^6.12.6",
84-
"chalk": "^5.3.0",
8582
"cross-env": "^7.0.3",
8683
"cross-fetch": "*",
8784
"eslint": "*",
88-
"grapheme-splitter": "^1.0.4",
85+
"espree": "^10.0.1",
8986
"jest": "29.7.0",
9087
"jest-specific-snapshot": "^8.0.0",
9188
"json-schema": "*",

packages/integration-tests/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
77
"lint": "npx nx lint",
88
"test": "jest --no-coverage",
9-
"typecheck": "tsc -p tsconfig.json --noEmit"
9+
"typecheck": "tsc --noEmit"
1010
},
1111
"devDependencies": {
12+
"@jest/types": "29.6.3",
1213
"jest": "29.7.0",
1314
"ncp": "*",
1415
"tmp": "*",

packages/parser/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
4747
"lint": "npx nx lint",
4848
"test": "jest --coverage",
49-
"typecheck": "tsc -p tsconfig.json --noEmit"
49+
"typecheck": "tsc --noEmit"
5050
},
5151
"peerDependencies": {
5252
"eslint": "^8.56.0"
@@ -59,6 +59,7 @@
5959
"debug": "^4.3.4"
6060
},
6161
"devDependencies": {
62+
"@jest/types": "29.6.3",
6263
"@types/glob": "*",
6364
"downlevel-dts": "*",
6465
"glob": "*",

packages/repo-tools/package.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"name": "@typescript-eslint/repo-tools",
33
"version": "7.8.0",
44
"private": true,
5+
"//": "NOTE: intentionally no build step in this package",
56
"scripts": {
6-
"//": "NOTE: intentionally no build step in this package",
77
"apply-canary-version": "npx tsx ./src/apply-canary-version.mts",
88
"format": "npx prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
99
"generate-configs": "npx tsx ./src/generate-configs.mts",
@@ -13,16 +13,21 @@
1313
"lint": "npx nx lint",
1414
"postinstall-script": "npx tsx ./src/postinstall.mts",
1515
"test": "npx jest --coverage",
16-
"typecheck": "npx tsc -p tsconfig.json --noEmit"
16+
"typecheck": "npx tsc --noEmit"
1717
},
1818
"devDependencies": {
19+
"@jest/types": "29.6.3",
1920
"@nx/devkit": "*",
21+
"@typescript-eslint/eslint-plugin": "7.8.0",
22+
"@typescript-eslint/scope-manager": "7.8.0",
23+
"@typescript-eslint/types": "7.8.0",
24+
"@typescript-eslint/typescript-estree": "7.8.0",
25+
"@typescript-eslint/utils": "7.8.0",
2026
"cross-fetch": "*",
2127
"execa": "*",
2228
"prettier": "^3.2.5",
2329
"rimraf": "*",
2430
"semver": "7.6.0",
25-
"tmp": "*",
2631
"typescript": "*"
2732
}
2833
}

packages/rule-schema-to-typescript-types/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@
3131
"lint": "npx nx lint",
3232
"postinstall-script": "tsx ./src/postinstall.ts",
3333
"test": "npx jest --coverage",
34-
"typecheck": "tsc -p tsconfig.json --noEmit"
34+
"typecheck": "tsc --noEmit"
3535
},
3636
"dependencies": {
3737
"@typescript-eslint/type-utils": "7.8.0",
3838
"@typescript-eslint/utils": "7.8.0",
3939
"natural-compare": "^1.4.0",
4040
"prettier": "^3.2.5"
4141
},
42+
"devDependencies": {
43+
"@jest/types": "29.6.3"
44+
},
4245
"funding": {
4346
"type": "opencollective",
4447
"url": "https://opencollective.com/typescript-eslint"

packages/rule-tester/package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"pretest-eslint-base": "tsc -b tsconfig.build.json",
4545
"test-eslint-base": "mocha --require source-map-support/register ./tests/eslint-base/eslint-base.test.js",
4646
"test": "npx jest --coverage",
47-
"typecheck": "tsc -p tsconfig.json --noEmit"
47+
"typecheck": "tsc --noEmit"
4848
},
4949
"//": "NOTE - AJV is out-of-date, but it's intentionally synced with ESLint - https://github.com/eslint/eslint/blob/ad9dd6a933fd098a0d99c6a9aa059850535c23ee/package.json#L70",
5050
"dependencies": {
@@ -59,9 +59,13 @@
5959
"eslint": "^8.56.0"
6060
},
6161
"devDependencies": {
62+
"@jest/types": "29.6.3",
6263
"@types/lodash.merge": "4.6.9",
6364
"@typescript-eslint/parser": "7.8.0",
6465
"chai": "^4.4.1",
66+
"eslint-visitor-keys": "^4.0.0",
67+
"espree": "^10.0.1",
68+
"esprima": "^4.0.1",
6569
"mocha": "^10.4.0",
6670
"sinon": "^16.1.3",
6771
"source-map-support": "^0.5.21",

packages/scope-manager/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@typescript-eslint/visitor-keys": "7.8.0"
5151
},
5252
"devDependencies": {
53+
"@jest/types": "29.6.3",
5354
"@types/glob": "*",
5455
"@typescript-eslint/typescript-estree": "7.8.0",
5556
"glob": "*",

0 commit comments

Comments
 (0)