-
Notifications
You must be signed in to change notification settings - Fork 15
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
feat(examples-plugins): add knip to example plugin #570
Conversation
# Conflicts: # packages/plugin-lighthouse/src/lib/utils.unit.test.ts
The Unused development dependencies audit is full of false positives, I'm afraid 😞 It doesn't seem to detect usage other than
|
True! found out prettier was excluded in the config
True. figured out perf folder is configured wrong |
This was the case since we excluded the example projects, I changed that in the base config and this is now properly reported
This is something missing on the knip side, it will only look at the extends but not the plugins array. I will make a follow up on their side to update it. In the meantime, added to the ignore array
This is a false positive, it shouldn't require a npm lib since it's a built in of vitest. I will make a pr to add it to the built in reporters on the knip side so this shouldn't occur anymore. In the meantime, I added it to the ignore dependencies array
This should have been picked up by knip, since it will look at the project json configs to detect the scripts and thrid party requirements, I will follow up with an issue on their side |
Related PRs : |
# Conflicts: # package-lock.json # package.json
# Conflicts: # code-pushup.config.ts # package-lock.json
# Conflicts: # knip.config.ts # package-lock.json # package.json
This PR is just here to showcase
knip
implementation and screenshots.This PR includes:
capital
andsingular
This PR does not include:
See the portal here: https://staging.code-pushup.dev/portal/code-pushup/cli-utils/commit/985ac7155f1f8cb8ad1b482a984740ad3d2d5e75/dashboard
Changes for a followup PR:
duplicated exports
should list last reference instead of firstunused dependencies
should link to line where package sit'sunlisted dependencies
,unused development dependencies
could list only one referencing file (otherwise we see multiple times the same issue title with a difference source but installing it ones fixes the issues)Used configuration
run
nx run-collect --onlyPlugins knip
to test it locally.Example Audit Interpretation
Legend:
Unused files (1)
Can be fixed by using it in e.g. e2e tests
Unused dependencies (1)
Can be fixed by uninstalling
cli-table3
Run
npm remove cli-table3
to remove dependencyUnused devDependencies (8)
This package is not used anywhere in the code either directly on in "scripts" or configuration files.
You can fix it by running
npm remove tsx
Same goes for the follwing dependencies
should have been picked up by the nx helper WDYT @beaussan
the following packages are (most probably) a cascade of this issue
false as it is used in
commitlint.config.js
false as a peer dependency of commit. (cascade of
commitlint-plugin-tense
)Run
npm ls conventional-changelog-angular
to list check dependent packages.Unlisted dependencies (38)
This is a peer dependency of
@nx/eslint-plugin
, but and not directly installed.If you uninstall
@nx/eslint-plugin
you don't havejsonc-eslint-parser
anymore available.Run
npm ls jsonc-eslint-parser
to list the root package:To fix it run
npm i jsonc-eslint-parser --save-dev
same is valid for all following issues of
jsonc-eslint-parser
This is used in
tools/eslint-to-code-pushup.mjs
, but and not listed inpackage.json
. The code works because other packages like@nx/devkit
haveminimatch
as peer dependency. If you would remove all related packages like@nx/devkit
,tools/eslint-to-code-pushup.mjs
would stop working.Run
npm ls minimatch
to list the root package:To fix it run
npm i minimatch --save-dev
same is valid for issues of
tslib
This is used as dummy reference in a test like this.
It can be fixed by adding the package name to the
knip.config.ts
✅ @commitlint/types commitlint.config.js
Is used in like this:
const { RuleConfigSeverity } = require('@commitlint/types');
.To fix it run
npm i @commitlint/types --save-dev
❓ basic e2e/cli-e2e/vite.config.e2e.ts
This shows no dependents when running
npm ls basic
This could be fixed by installing
basic
manually overnpm i basic -D
but seems odd as there are no deps listed.Same goes for all other issues related to
basic
basic packages/cli/vite.config.integration.ts
basic packages/cli/vite.config.unit.ts
basic packages/core/vite.config.integration.ts
basic packages/core/vite.config.unit.ts
basic packages/models/vite.config.integration.ts
basic packages/models/vite.config.unit.ts
basic packages/nx-plugin/vite.config.integration.ts
basic packages/nx-plugin/vite.config.unit.ts
basic packages/plugin-coverage/vite.config.integration.ts
basic packages/plugin-coverage/vite.config.unit.ts
basic packages/plugin-eslint/vite.config.integration.ts
basic packages/plugin-eslint/vite.config.unit.ts
basic packages/plugin-js-packages/vite.config.integration.ts
basic packages/plugin-js-packages/vite.config.unit.ts
basic packages/plugin-lighthouse/vite.config.integration.ts
basic packages/plugin-lighthouse/vite.config.unit.ts
basic packages/utils/vite.config.integration.ts
basic packages/utils/vite.config.unit.ts
basic testing/test-utils/vite.config.unit.ts
Unused exports (23)
can be fixed by removing the export form
duplicateRefsInCategoryMetricsErrorMsg
can be fixed by exporting
h
inindex.ts
can be fixed by exporting
groupMetaSchema
inindex.ts
Similar fix can be applied for the following issues.
Unused exported types (12)
can be fixed by exporting
h
inindex.ts
Same is applicable for the following issues
can be fixed by exporting
GroupMeta
inindex.ts
can be fixed by removing the export form
CliUiBase
this type is not used.
It can be fixed by using it to ensure the option names.
is unused can be fixed by exporting it. (lands in feat(cli): add history command #273)
is unused can be fixed by exporting it. (lands in feat(plugin-lighthouse): add lighthouse runner #549)
can be fixed by exporting
Yarnv2AuditAdvisory
inindex.ts
Same applies for the following exported types
Duplicate exports (2)
the audit can be fixed by only exporting the same instance 1 time. Note: also applies for the following autit.
Snippet to test fixes:
npm remove cli-table3 conventional-changelog-angular eslint-plugin-jsx-a11y tsx && npm i -D jsonc-eslint-parser lighthouse-logger debug chrome-launcher minimatch
Screenshots of the implementation in different views
Related:
webpro-nl/knip#551