@prunr/prunr 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +21 -9
  2. package/package.json +6 -6
  3. package/schema.json +8 -0
package/README.md CHANGED
@@ -33,8 +33,10 @@ scripts.
33
33
  - **ESM and TypeScript in the same graph**, with `tsconfig.json` `paths` and CJS/ESM interop the
34
34
  way Node does it.
35
35
  - **Knows your stack** with no setup: Jest, Vitest, Mocha, `node --test`, tap, AVA, Playwright,
36
- Vite, React, Next.js, NestJS, Drizzle Kit, PostCSS and monorepos (npm, yarn, pnpm, bun, lerna,
37
- rush, nx, turbo).
36
+ Cypress, Storybook, Vite, React, Next.js, NestJS, Nuxt, SvelteKit, Astro, React Router/Remix,
37
+ VitePress, TypeScript (`tsconfig`), `.vue`/`.svelte`/`.astro`/`.mdx` files, ESLint, Prettier,
38
+ Babel, commitlint, husky, lint-staged, Tailwind, Prisma, tsup, Rollup, webpack, Drizzle Kit,
39
+ PostCSS and monorepos (npm, yarn, pnpm, bun, lerna, rush, nx, turbo).
38
40
  - **Fixes it for you:** `prunr fix` deletes what is dead and cleans up `package.json`.
39
41
  - **Built for CI:** annotations on the PR diff, only new findings with `--since`, and a baseline
40
42
  for adopting it on legacy code.
@@ -93,7 +95,7 @@ on its own. Every option is in [Configuration](docs/guide/configuration.md).
93
95
  | `prunr check` | Lists the findings. `--json` for machines, `--github` for PR annotations, `--sarif` for code scanning, `--codeclimate` for GitLab Code Quality, `--markdown` for a PR comment, `--since <ref>` for only what is new, `--production` for only what ships. |
94
96
  | `prunr fix` | Removes dead code and unused dependencies. `--dry-run` shows the changes without making them. |
95
97
  | `prunr why <target>` | Explains a file (the chain of imports from an entry), a `file:export` (who uses it) or a package (the files, scripts and tools that need it). |
96
- | `prunr init` | Creates a `prunr.json` from `package.json`. |
98
+ | `prunr init` | Creates a `prunr.json` from `package.json`, and from the Knip config when there is one. |
97
99
  | `prunr baseline` | Records the current findings, to adopt prunr without fixing everything at once. |
98
100
  | `prunr schema` | Prints the JSON Schema of `prunr.json`. |
99
101
 
@@ -106,10 +108,14 @@ findings, and `2` when it cannot run.
106
108
  |---|---|
107
109
  | `unused-file` | No production entry reaches the file. |
108
110
  | `unused-export` | No production code uses the export. |
111
+ | `unused-enum-member` | No production code reads the member of an exported enum. |
112
+ | `unused-class-member` | No production code calls the method of an exported class, in an application. |
113
+ | `duplicate-export` | The same binding is exported under more than one name. |
109
114
  | `unused-import` | A `require` or `import` brings in a name the file never uses. |
110
115
  | `unused-dependency` | Nothing imports the package and no script runs it. |
111
116
  | `misplaced-dependency` | The package is in `dependencies`, but only the tests use it. |
112
117
  | `missing-dependency` | The code imports a package `package.json` does not declare. |
118
+ | `missing-binary` | A script runs a binary of a package `package.json` does not declare. |
113
119
  | `circular-import` | There is an import cycle. |
114
120
  | `unused-ignore` | A `prunr-ignore` comment that no longer ignores anything. |
115
121
  | `unresolved-require` | Warning: a `require` prunr cannot follow. |
@@ -128,6 +134,13 @@ each are in [Findings](docs/guide/checks.md).
128
134
  - run: npx prunr check --github --since origin/${{ github.base_ref }}
129
135
  ```
130
136
 
137
+ Or with the Action, which needs no install step:
138
+
139
+ ```yaml
140
+ - uses: actions/checkout@v4
141
+ - uses: ViniciusDev26/prunr@v0
142
+ ```
143
+
131
144
  Each new finding becomes an annotation on the right line of the diff. For legacy code, start
132
145
  with `prunr baseline`: what is already there does not fail, and anything that shows up later
133
146
  does. See [CI and legacy code](docs/guide/ci.md).
@@ -139,8 +152,8 @@ The guide is in Portuguese for now.
139
152
  - [Configuration](docs/guide/configuration.md): `prunr.json` and the `scripts` of `package.json`.
140
153
  - [Findings](docs/guide/checks.md): what each one means, ESM and TypeScript, dynamic `require`.
141
154
  - [`prunr fix`](docs/guide/fix.md): what it removes and what it leaves to you.
142
- - [Frameworks](docs/guide/frameworks.md): Jest, Vitest, Playwright, Vite, React, Next.js,
143
- NestJS, Drizzle Kit and PostCSS.
155
+ - [Frameworks and tools](docs/guide/frameworks.md): test runners, frameworks, single-file
156
+ components and the tool configs prunr reads.
144
157
  - [Monorepos](docs/guide/monorepos.md): how packages are found and checked.
145
158
  - [Ignoring in code](docs/guide/ignore.md): exports that are public on purpose.
146
159
  - [CI and legacy code](docs/guide/ci.md): annotations, `--since` and the baseline.
@@ -151,8 +164,8 @@ The guide is in Portuguese for now.
151
164
  `noUnusedVariables` and `noUnusedPrivateClassMembers` in [Biome](https://biomejs.dev/):
152
165
  together with prunr's `unused-import`, they cover what `tsc`'s `noUnusedLocals` catches.
153
166
  - **Formatting, style and types:** use Biome and `tsc --noEmit`.
154
- - **Dependencies named only in another tool's config** (ESLint plugins, Babel presets) show up
155
- as `unused-dependency`. List them in `dependencies.ignore`.
167
+ - **Dependencies named only in the config of a tool prunr does not know** show up as
168
+ `unused-dependency`. List them in `dependencies.ignore`.
156
169
 
157
170
  What comes next is in the [roadmap](docs/roadmap/).
158
171
 
@@ -209,8 +222,7 @@ Playwright, Vite...) are read as text, never executed.
209
222
  deletes dead code and cleans up `package.json`.
210
223
 
211
224
  **When Knip is the better choice.** On a project that is only ESM and TypeScript, Knip has many
212
- more plugins (prunr knows Jest, Vitest, Playwright, Vite, React, Next.js, NestJS, Drizzle Kit
213
- and PostCSS) and more mileage. prunr pays off when there is CommonJS in the mix, or when speed
225
+ more plugins (prunr knows about 40 tools and frameworks; Knip, over a hundred) and more mileage. prunr pays off when there is CommonJS in the mix, or when speed
214
226
  and a single tool matter more.
215
227
 
216
228
  ## Contributing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prunr/prunr",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Dead code detector for Node.js, with CommonJS as a first-class citizen",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,10 +26,10 @@
26
26
  "node": ">=18"
27
27
  },
28
28
  "optionalDependencies": {
29
- "@prunr/darwin-arm64": "0.5.0",
30
- "@prunr/darwin-x64": "0.5.0",
31
- "@prunr/linux-arm64": "0.5.0",
32
- "@prunr/linux-x64": "0.5.0",
33
- "@prunr/win32-x64": "0.5.0"
29
+ "@prunr/darwin-arm64": "0.6.0",
30
+ "@prunr/darwin-x64": "0.6.0",
31
+ "@prunr/linux-arm64": "0.6.0",
32
+ "@prunr/linux-x64": "0.6.0",
33
+ "@prunr/win32-x64": "0.6.0"
34
34
  }
35
35
  }
package/schema.json CHANGED
@@ -18,6 +18,14 @@
18
18
  "dependencies": {
19
19
  "$ref": "#/$defs/Dependencies"
20
20
  },
21
+ "plugins": {
22
+ "description": "Plugins turned off (`false`) or on (`true`) by name, whatever `package.json` declares:\neach one is turned on by the package it is named after.",
23
+ "type": "object",
24
+ "additionalProperties": {
25
+ "type": "boolean"
26
+ },
27
+ "default": {}
28
+ },
21
29
  "baseline": {
22
30
  "description": "The baseline file, relative to the root: findings the project already had. They do not\nfail the check, and `prunr baseline` rewrites the file.",
23
31
  "type": [