Skip to content

chore: add knip #8192

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

Merged
merged 50 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d0896c6
chore: add knip
auvred Jan 5, 2024
f3bd554
chore: sync lockfile
auvred Jan 5, 2024
2d7afbc
Merge branch 'main' into chore/add-knip
auvred Jan 5, 2024
a9b3dd1
chore: bump knip
auvred Jan 5, 2024
77d0279
ci: run knip in ci workflow
auvred Jan 5, 2024
f074fd7
ci: run knip as part of lint job
auvred Jan 6, 2024
27163a2
refactor: replace `testRegex` with `testMatch`
auvred Jan 6, 2024
919867d
refactor: use satisfies in knip config
auvred Jan 6, 2024
3f3abce
chore: fix path to rule-tester fixtures
auvred Jan 6, 2024
2b53d17
chore: add dummypkg as knip workspace
auvred Jan 6, 2024
6f32a3e
chore: get rid of json-schema
auvred Jan 6, 2024
47d2703
chore: fix knip issues in packages/website
auvred Jan 6, 2024
56a6d1f
chore: merge main
auvred Jan 6, 2024
8b9e441
chore: merge main 2
auvred Jan 6, 2024
b24377d
chore: sync lockfile
auvred Jan 6, 2024
5a1255a
chore: add missed merge stuff
auvred Jan 6, 2024
64cb8c4
chore: install @jest/types in the root workspace
auvred Jan 6, 2024
91c9909
chore: partially fix issues for website-eslint
auvred Jan 6, 2024
1348b52
chore: fix knip issues for packages/website-eslint
auvred Jan 6, 2024
e7a204c
auvred Jan 6, 2024
5d37ea8
chore: add ncp resolution to the root package.json
auvred Jan 7, 2024
85df506
Merge branch 'main' into chore/add-knip
auvred Jan 7, 2024
eea474d
chore: wip wip wip
auvred Jan 7, 2024
de23db8
chore: fix misspelling + handle few knip issues
auvred Jan 7, 2024
19e22c5
chore: finally (?)
auvred Jan 7, 2024
5025e67
chore: expand ignoreDependencies regular expressions
auvred Jan 7, 2024
6dad589
chore: revert unrelated changes
auvred Jan 7, 2024
fda5336
chore: merge main
auvred Jan 8, 2024
e7a7201
chore: try to minimise docusaurus-related changes
auvred Jan 8, 2024
aab75cf
chore: remove extra entry
auvred Jan 8, 2024
e062dd1
chore: merge master
auvred Jan 17, 2024
3ebf3e7
chore: bump knip to 4.0.2
auvred Jan 17, 2024
9a605ca
chore: merge main
auvred Apr 16, 2024
9e2e27d
wip
auvred Apr 16, 2024
7879dd0
add types to jest config
auvred Apr 16, 2024
9975158
yarn lint --fix
auvred Apr 16, 2024
2c5ee6b
add knip to ci
auvred Apr 16, 2024
f54babd
chore: resolve conflicts with v7.7.1
auvred Apr 23, 2024
36fa481
!!!
auvred Apr 23, 2024
814c162
Revert "!!!"
auvred Apr 23, 2024
5c56b50
revert yarn dedupe
auvred Apr 23, 2024
4d163a2
sed -i 's| -p tsconfig.json||g'
auvred Apr 23, 2024
263b528
update todo comment in eslint.config.js
auvred Apr 23, 2024
7e58b47
Update knip.ts
auvred Apr 23, 2024
c7c1114
oops
auvred Apr 23, 2024
c65abae
Merge branch 'main' into chore/add-knip
auvred Apr 24, 2024
7bea876
chore: merge main
auvred Apr 30, 2024
81a6914
Merge branch 'main' into chore/add-knip
auvred May 3, 2024
3506094
Merge branch 'main' into chore/add-knip
auvred May 11, 2024
2188ef8
Merge branch 'main' into chore/add-knip
auvred May 13, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
lint-task: ['lint', 'typecheck']
lint-task: ['lint', 'typecheck', 'knip']
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
3 changes: 1 addition & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @ts-check

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

/** @type {import('@typescript-eslint/utils/ts-eslint').FlatConfig.ConfigPromise} */
const config = (async () => (await import('./eslint.config.mjs')).default)();
Expand Down
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

// @ts-check
Copy link
Member

Choose a reason for hiding this comment

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

[Praise] Nice, +1 to getting // @ts-check in here.

const { getJestProjects } = require('@nx/jest');

/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
projects: getJestProjects(),
};
128 changes: 128 additions & 0 deletions knip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import type { KnipConfig } from 'knip';

export default {
rules: {
classMembers: 'off',
duplicates: 'off',
enumMembers: 'off',
exports: 'off',
nsExports: 'off',
nsTypes: 'off',
types: 'off',
unresolved: 'off',
},
workspaces: {
'.': {
ignoreDependencies: [
'@babel/code-frame',
'@babel/core',
'@babel/eslint-parser',
'@babel/parser',
'@babel/types',
'@nx/workspace',
'cross-fetch',
'glob',
'husky',
'jest-specific-snapshot',
'make-dir',
'ncp',
'tmp',

// imported in eslint.config.js
'@typescript-eslint/utils',
// imported in eslint.config.mjs
'@typescript-eslint/eslint-plugin-internal',
],
entry: ['tools/release/changelog-renderer.js'],
ignoreBinaries: [
// https://github.com/webpro/knip/issues/433
'stylelint',
],
},
'packages/ast-spec': {
ignore: [
'src/**/fixtures/**',
'tests/*.type-test.ts',
// @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',
],
},
'packages/eslint-plugin': {
ignore: ['tests/fixtures/**'],
},
'packages/eslint-plugin-internal': {
ignore: ['tests/fixtures/**'],
},
'packages/integration-tests': {
ignore: ['fixtures/**'],
},
'packages/parser': {
ignore: ['tests/fixtures/**'],
},
'packages/scope-manager': {
ignore: ['tests/fixtures/**'],
},
'packages/type-utils': {
ignore: ['tests/fixtures/**'],
},
'packages/typescript-estree': {
entry: ['src/use-at-your-own-risk.ts'],
ignore: ['tests/fixtures/**'],
},
'packages/website': {
entry: [
'docusaurus.config.mts',
'src/pages/**/*.tsx',

// imported in MDX docs
'src/components/**/*.tsx',

// used by Docusaurus
'src/theme/**/*.tsx',
'src/theme/prism-include-languages.js',
],
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',

'@babel/runtime',
'@docusaurus/mdx-loader',
'@docusaurus/types',
'@docusaurus/plugin-content-docs',
'@docusaurus/theme-search-algolia',
'@docusaurus/ExecutionEnvironment',
'@docusaurus/Link',
'@docusaurus/router',
'@docusaurus/useDocusaurusContext',
'@docusaurus/useBaseUrl',
'@docusaurus/BrowserOnly',
'@docusaurus/theme-classic',
'@generated/docusaurus.config',
'^@theme/.*',
'^@theme-original/.*',
],
},
'packages/website-eslint': {
ignoreDependencies: [
// virtual module
'vt',
],
entry: [
'src/index.js',
'src/mock/assert.js',
'src/mock/empty.js',
'src/mock/eslint-rules.js',
'src/mock/eslint.js',
'src/mock/lru-cache.js',
'src/mock/path.js',
'src/mock/typescript.js',
'src/mock/util.js',
Copy link
Member

Choose a reason for hiding this comment

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

You know, as a followup I bet we could switch these over to plain .ts files, and remove the need for the requireResolved that's tripping up Knip... Not blocking at all IMO.

],
},
'tools/dummypkg': {},
},
} satisfies KnipConfig;
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@babel/types": "^7.24.0",
"@eslint/eslintrc": "^2.1.4",
"@eslint/js": "^8.57.0",
"@jest/types": "29.6.3",
"@nx/eslint": "18.2.3",
"@nx/jest": "18.2.3",
"@nx/workspace": "18.2.3",
Expand All @@ -75,7 +76,6 @@
"@types/is-glob": "^4.0.4",
"@types/jest": "29.5.12",
"@types/jest-specific-snapshot": "^0.5.9",
"@types/marked": "^5.0.2",
"@types/natural-compare": "^1.4.3",
"@types/ncp": "^2.0.8",
"@types/node": "^20.12.5",
Expand Down Expand Up @@ -104,9 +104,8 @@
"globals": "^15.0.0",
"husky": "^8.0.3",
"jest": "29.7.0",
"jest-diff": "^29.7.0",
"jest-snapshot": "^29.7.0",
"jest-specific-snapshot": "^8.0.0",
"knip": "^5.9.4",
"lint-staged": "^15.2.2",
"make-dir": "^4.0.0",
"markdownlint-cli": "^0.39.0",
Expand All @@ -115,7 +114,6 @@
"nx": "18.2.3",
"prettier": "3.2.5",
"pretty-format": "^29.7.0",
"raw-loader": "^4.0.2",
"rimraf": "^5.0.5",
"tmp": "^0.2.3",
"tsx": "*",
Expand Down
5 changes: 2 additions & 3 deletions packages/ast-spec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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 -p tsconfig.json --noEmit"
"typecheck": "tsc --noEmit"
},
"funding": {
"type": "opencollective",
Expand All @@ -47,12 +47,11 @@
"@babel/code-frame": "*",
"@babel/core": "*",
"@babel/eslint-parser": "*",
"@babel/parser": "*",
"@jest/types": "29.6.3",
"@microsoft/api-extractor": "^7.43.0",
"glob": "*",
"jest": "29.7.0",
"jest-diff": "^29.7.0",
"jest-snapshot": "^29.7.0",
"jest-specific-snapshot": "^8.0.0",
"make-dir": "*",
"prettier": "^3.2.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin-internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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": "tsc -p tsconfig.json --noEmit"
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@prettier/sync": "^0.5.1",
Expand All @@ -22,6 +22,7 @@
"prettier": "^3.2.5"
},
"devDependencies": {
"@jest/types": "29.6.3",
"jest": "29.7.0",
"rimraf": "*"
}
Expand Down
13 changes: 5 additions & 8 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,39 +53,36 @@
"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": "yarn tsx tools/generate-breaking-changes.mts",
"generate:breaking-changes": "tsx tools/generate-breaking-changes.mts",
"generate:configs": "npx nx run repo-tools:generate-configs",
"lint": "npx nx lint",
"test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --coverage --logHeapUsage",
"test-single": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --no-coverage",
"typecheck": "tsc -p tsconfig.json --noEmit"
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@eslint-community/regexpp": "^4.10.0",
"@typescript-eslint/scope-manager": "7.8.0",
"@typescript-eslint/type-utils": "7.8.0",
"@typescript-eslint/utils": "7.8.0",
"@typescript-eslint/visitor-keys": "7.8.0",
"debug": "^4.3.4",
Copy link
Member Author

Choose a reason for hiding this comment

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

Unused after #3658

"graphemer": "^1.4.0",
"ignore": "^5.3.1",
"natural-compare": "^1.4.0",
"semver": "^7.6.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

Unused after #8377

"ts-api-utils": "^1.3.0"
},
"devDependencies": {
"@types/debug": "*",
"@types/marked": "*",
"@jest/types": "29.6.3",
"@types/marked": "^5.0.2",
"@types/mdast": "^4.0.3",
"@types/natural-compare": "*",
"@typescript-eslint/rule-schema-to-typescript-types": "7.8.0",
"@typescript-eslint/rule-tester": "7.8.0",
"ajv": "^6.12.6",
"chalk": "^5.3.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

"cross-env": "^7.0.3",
"cross-fetch": "*",
"eslint": "*",
"grapheme-splitter": "^1.0.4",
Copy link
Member Author

Choose a reason for hiding this comment

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

Unused after faea3ff8b

"espree": "^10.0.1",
Copy link
Member Author

Choose a reason for hiding this comment

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

Required by

"jest": "29.7.0",
"jest-specific-snapshot": "^8.0.0",
"json-schema": "*",
Expand Down
3 changes: 2 additions & 1 deletion packages/integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"lint": "npx nx lint",
"test": "jest --no-coverage",
"typecheck": "tsc -p tsconfig.json --noEmit"
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@jest/types": "29.6.3",
"jest": "29.7.0",
"ncp": "*",
"tmp": "*",
Expand Down
3 changes: 2 additions & 1 deletion packages/parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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": "tsc -p tsconfig.json --noEmit"
"typecheck": "tsc --noEmit"
},
"peerDependencies": {
"eslint": "^8.56.0"
Expand All @@ -59,6 +59,7 @@
"debug": "^4.3.4"
},
"devDependencies": {
"@jest/types": "29.6.3",
"@types/glob": "*",
"downlevel-dts": "*",
"glob": "*",
Expand Down
11 changes: 8 additions & 3 deletions packages/repo-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@typescript-eslint/repo-tools",
"version": "7.8.0",
"private": true,
"//": "NOTE: intentionally no build step in this package",
"scripts": {
"//": "NOTE: intentionally no build step in this package",
"apply-canary-version": "npx tsx ./src/apply-canary-version.mts",
"format": "npx prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"generate-configs": "npx tsx ./src/generate-configs.mts",
Expand All @@ -13,16 +13,21 @@
"lint": "npx nx lint",
"postinstall-script": "npx tsx ./src/postinstall.mts",
"test": "npx jest --coverage",
"typecheck": "npx tsc -p tsconfig.json --noEmit"
"typecheck": "npx tsc --noEmit"

This comment was marked as resolved.

This comment was marked as resolved.

},
"devDependencies": {
"@jest/types": "29.6.3",
"@nx/devkit": "*",
"@typescript-eslint/eslint-plugin": "7.8.0",
"@typescript-eslint/scope-manager": "7.8.0",
"@typescript-eslint/types": "7.8.0",
"@typescript-eslint/typescript-estree": "7.8.0",
"@typescript-eslint/utils": "7.8.0",
"cross-fetch": "*",
"execa": "*",
"prettier": "^3.2.5",
"rimraf": "*",
"semver": "7.6.0",
"tmp": "*",
"typescript": "*"
}
}
5 changes: 4 additions & 1 deletion packages/rule-schema-to-typescript-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@
"lint": "npx nx lint",
"postinstall-script": "tsx ./src/postinstall.ts",
"test": "npx jest --coverage",
"typecheck": "tsc -p tsconfig.json --noEmit"
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@typescript-eslint/type-utils": "7.8.0",
"@typescript-eslint/utils": "7.8.0",
"natural-compare": "^1.4.0",
"prettier": "^3.2.5"
},
"devDependencies": {
"@jest/types": "29.6.3"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
Expand Down
6 changes: 5 additions & 1 deletion packages/rule-tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"pretest-eslint-base": "tsc -b tsconfig.build.json",
"test-eslint-base": "mocha --require source-map-support/register ./tests/eslint-base/eslint-base.test.js",
"test": "npx jest --coverage",
"typecheck": "tsc -p tsconfig.json --noEmit"
"typecheck": "tsc --noEmit"
},
"//": "NOTE - AJV is out-of-date, but it's intentionally synced with ESLint - https://github.com/eslint/eslint/blob/ad9dd6a933fd098a0d99c6a9aa059850535c23ee/package.json#L70",
"dependencies": {
Expand All @@ -59,9 +59,13 @@
"eslint": "^8.56.0"
},
"devDependencies": {
"@jest/types": "29.6.3",
"@types/lodash.merge": "4.6.9",
"@typescript-eslint/parser": "7.8.0",
"chai": "^4.4.1",
"eslint-visitor-keys": "^4.0.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

"espree": "^10.0.1",
Copy link
Member Author

Choose a reason for hiding this comment

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

"esprima": "^4.0.1",
Copy link
Member Author

Choose a reason for hiding this comment

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

"mocha": "^10.4.0",
"sinon": "^16.1.3",
"source-map-support": "^0.5.21",
Expand Down
1 change: 1 addition & 0 deletions packages/scope-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@typescript-eslint/visitor-keys": "7.8.0"
},
"devDependencies": {
"@jest/types": "29.6.3",
"@types/glob": "*",
"@typescript-eslint/typescript-estree": "7.8.0",
"glob": "*",
Expand Down
Loading
Loading