Skip to content

Commit 2d294e8

Browse files
authored
Merge pull request #4 from code-pushup/add-knip-core-logic
feat: add knip core logic
2 parents e84eb25 + 393ba0e commit 2d294e8

File tree

93 files changed

+5785
-3050
lines changed

Some content is hidden

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

93 files changed

+5785
-3050
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ jobs:
3333
- run: git branch --track main origin/main
3434
if: ${{ github.event_name == 'pull_request' }}
3535

36-
- run: npx nx-cloud record -- nx format:check
37-
- run: npx nx affected -t lint test build
36+
- run: npx nx format:check
37+
- run: npx nx affected -t lint unit-test integration-test build

package-lock.json

Lines changed: 4086 additions & 2583 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,20 @@
4646
"packages/*"
4747
],
4848
"dependencies": {
49-
"@code-pushup/cli": "^0.47.0",
50-
"@code-pushup/core": "^0.47.0",
51-
"@code-pushup/models": "^0.47.0",
52-
"@code-pushup/utils": "^0.47.0",
49+
"@code-pushup/cli": "^0.57.0",
50+
"@code-pushup/core": "^0.57.0",
51+
"@code-pushup/models": "^0.57.0",
52+
"@code-pushup/utils": "^0.57.0",
5353
"@nx/devkit": "19.4.3",
54+
"@poppinss/cliui": "^6.4.1",
5455
"ansis": "^3.8.1",
5556
"knip": "^5.42.0",
5657
"memfs": "^4.17.0",
5758
"zod": "^3.24.1"
59+
},
60+
"optionalDependencies": {
61+
"@nx/nx-darwin-arm64": "^16.9.1",
62+
"@nx/nx-darwin-x64": "^16.10.0",
63+
"@nx/nx-linux-x64-gnu": "16.7.4"
5864
}
5965
}

packages/plugin-knip/.eslintrc.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
"files": ["*.json"],
1313
"parser": "jsonc-eslint-parser",
1414
"rules": {
15-
"@nx/dependency-checks": ["error"]
15+
"@nx/dependency-checks": [
16+
"error",
17+
{
18+
"ignoredDependencies": ["@code-pushup/test-utils"]
19+
}
20+
]
1621
}
1722
}
1823
]

packages/plugin-knip/CONTRIBUTING.MD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
The [knip](https://knip.dev/) plugin implementation is restricted due to [a bug that wont get fixed](https://github.com/webpro/knip/issues/551).
44

55
As we can't consume knip core logic because it produces an unwanted side effect (linked above), we have to implement a `RunnerConfig` instead of a `RunnerFunction`.
6-
Our current solution is to implement a [custom knip reporter](https://knip.dev/features/reporters#custom-reporters) which is bundled as an [additional entry point](./src/reporter.ts).
6+
Our current solution is to implement a [custom knip reporter](https://knip.dev/features/reporters#custom-reporters) which is bundled as an [additional entry point](src/lib/reporter.ts).
77
The produced output is internally consumed by the `RunnerConfig` and wrapped into a `PluginReport`.

packages/plugin-knip/mocks/fixtures/raw-knip.report.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const rawReport: Pick<ReporterOptions, 'report' | 'issues' | 'options'> =
150150
'configurationGenerator|default': {
151151
type: 'duplicates',
152152
filePath:
153-
'/Users/michael_hladky/WebstormProjects/quality-metrics-cli/packages/nx-plugin/src/generators/configuration/generator.ts',
153+
'/Users/username/Projects/quality-metrics-cli/packages/nx-plugin/src/generators/configuration/generator.ts',
154154
symbol: 'configurationGenerator|default',
155155
symbols: [
156156
{

packages/plugin-knip/package.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
"name": "@code-pushup/knip-plugin",
33
"version": "0.0.0",
44
"license": "MIT",
5-
"dependencies": {},
6-
"peerDependencies": {}
5+
"dependencies": {
6+
"@code-pushup/models": "^0.57.0",
7+
"@code-pushup/utils": "^0.57.0",
8+
"ansis": "^3.8.1",
9+
"knip": "^5.42.0",
10+
"memfs": "^4.17.0",
11+
"tslib": "^2.3.0",
12+
"vite": "^5.0.0",
13+
"vitest": "^1.3.1",
14+
"zod": "^3.24.1"
15+
},
16+
"peerDependencies": {},
17+
"devDependencies": {}
718
}

packages/plugin-knip/project.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727
"unit-test": {
2828
"executor": "@nx/vite:test",
2929
"options": {
30-
"config": "packages/plugin-knip/vite.config.unit.ts"
30+
"configFile": "packages/plugin-knip/vite.config.unit.ts"
3131
}
3232
},
3333
"integration-test": {
34+
"dependsOn": ["build"],
3435
"executor": "@nx/vite:test",
3536
"options": {
36-
"config": "packages/plugin-knip/vite.config.integration.ts"
37+
"configFile": "packages/plugin-knip/vite.config.integration.ts"
3738
}
3839
}
3940
},

packages/plugin-knip/src/index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { describe, expect, it } from 'vitest';
2+
import { auditSchema, groupSchema } from '@code-pushup/models';
3+
import {
4+
KNIP_AUDITS,
5+
KNIP_GROUP_ALL,
6+
KNIP_GROUP_DEPENDENCIES,
7+
KNIP_GROUP_EXPORTS,
8+
KNIP_GROUP_FILES,
9+
} from './constants';
10+
11+
describe('constants-AUDITS', () => {
12+
it.each(KNIP_AUDITS.map((audit) => [audit.slug, audit]))(
13+
'should be a valid %s audit meta info',
14+
(_, audit) => {
15+
expect(() => auditSchema.parse(audit)).not.toThrow();
16+
},
17+
);
18+
});
19+
20+
describe('constants-KNIP_GROUPS', () => {
21+
it('should be a valid file group info', () => {
22+
expect(() => groupSchema.parse(KNIP_GROUP_FILES)).not.toThrow();
23+
});
24+
25+
it('should be a valid exports group info', () => {
26+
expect(() => groupSchema.parse(KNIP_GROUP_EXPORTS)).not.toThrow();
27+
});
28+
29+
it('should be a valid dependencies group info', () => {
30+
expect(() => groupSchema.parse(KNIP_GROUP_DEPENDENCIES)).not.toThrow();
31+
});
32+
33+
it('should be a valid all group info', () => {
34+
expect(() => groupSchema.parse(KNIP_GROUP_ALL)).not.toThrow();
35+
});
36+
});

0 commit comments

Comments
 (0)