Skip to content

Commit fdf9675

Browse files
authored
Merge pull request #2 from code-pushup/setup-knip
2 parents bc5c4f2 + da304d3 commit fdf9675

File tree

12 files changed

+195
-3
lines changed

12 files changed

+195
-3
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx"],
7+
"parserOptions": {
8+
"project": ["packages/plugin-knip/tsconfig.*?.json"]
9+
}
10+
},
11+
{
12+
"files": ["*.json"],
13+
"parser": "jsonc-eslint-parser",
14+
"rules": {
15+
"@nx/dependency-checks": ["error"]
16+
}
17+
}
18+
]
19+
}

packages/plugin-knip/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# @code-pushup/knip-plugin
2+
3+
[![npm](https://img.shields.io/npm/v/%40code-pushup%2Feslint-plugin.svg)](https://www.npmjs.com/package/@code-pushup/knip-plugin)
4+
[![downloads](https://img.shields.io/npm/dm/%40code-pushup%2Feslint-plugin)](https://npmtrends.com/@code-pushup/knip-plugin)
5+
[![dependencies](https://img.shields.io/librariesio/release/npm/%40code-pushup/knip-plugin)](https://www.npmjs.com/package/@code-pushup/knip-plugin?activeTab=dependencies)
6+
7+
🕵️ **Code PushUp plugin to detect dependency and code usage.** ✂️
8+
9+
---
10+
11+
TBD

packages/plugin-knip/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "@code-pushup/knip-plugin",
3+
"version": "0.0.0",
4+
"license": "MIT",
5+
"dependencies": {},
6+
"peerDependencies": {}
7+
}

packages/plugin-knip/project.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "plugin-knip",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "packages/plugin-knip/src",
5+
"projectType": "library",
6+
"targets": {
7+
"build": {
8+
"executor": "@nx/js:tsc",
9+
"outputs": ["{options.outputPath}"],
10+
"options": {
11+
"outputPath": "dist/packages/plugin-knip",
12+
"main": "packages/plugin-knip/src/index.ts",
13+
"tsConfig": "packages/plugin-knip/tsconfig.lib.json",
14+
"assets": ["packages/plugin-knip/*.md"]
15+
}
16+
},
17+
"lint": {
18+
"executor": "@nx/linter:eslint",
19+
"outputs": ["{options.outputFile}"],
20+
"options": {
21+
"lintFilePatterns": [
22+
"packages/plugin-knip/**/*.ts",
23+
"packages/plugin-knip/package.json"
24+
]
25+
}
26+
},
27+
"unit-test": {
28+
"executor": "@nx/vite:test",
29+
"options": {
30+
"config": "packages/plugin-knip/vite.config.unit.ts"
31+
}
32+
},
33+
"integration-test": {
34+
"executor": "@nx/vite:test",
35+
"options": {
36+
"config": "packages/plugin-knip/vite.config.integration.ts"
37+
}
38+
}
39+
},
40+
"tags": ["scope:plugin", "type:feature"]
41+
}

packages/plugin-knip/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const KNIP_PLUGIN_SLUG = 'knip';

packages/plugin-knip/tsconfig.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "ESNext",
5+
"forceConsistentCasingInFileNames": true,
6+
"strict": true,
7+
"noImplicitOverride": true,
8+
"noPropertyAccessFromIndexSignature": true,
9+
"noImplicitReturns": true,
10+
"noFallthroughCasesInSwitch": true,
11+
"types": ["vitest"]
12+
},
13+
"files": [],
14+
"include": [],
15+
"references": [
16+
{
17+
"path": "./tsconfig.lib.json"
18+
},
19+
{
20+
"path": "./tsconfig.test.json"
21+
}
22+
]
23+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"declaration": true,
6+
"types": ["node"]
7+
},
8+
"include": ["src/**/*.ts"],
9+
"exclude": [
10+
"vite.config.unit.ts",
11+
"vite.config.integration.ts",
12+
"src/**/*.test.ts",
13+
"src/**/*.mock.ts",
14+
"mocks/**/*.ts"
15+
]
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../dist/out-tsc",
5+
"types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"]
6+
},
7+
"include": [
8+
"vite.config.unit.ts",
9+
"vite.config.integration.ts",
10+
"mocks/**/*.ts",
11+
"src/**/*.test.ts",
12+
"src/**/*.test.tsx",
13+
"src/**/*.test.js",
14+
"src/**/*.test.jsx",
15+
"src/**/*.d.ts"
16+
]
17+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// <reference types="vitest" />
2+
import { defineConfig } from 'vite';
3+
import { tsconfigPathAliases } from '../../tooling/vitest-tsconfig-path-aliases';
4+
5+
export default defineConfig({
6+
cacheDir: '../../node_modules/.vite/plugin-knip',
7+
test: {
8+
reporters: ['basic'],
9+
globals: true,
10+
cache: {
11+
dir: '../../node_modules/.vitest/plugin-knip',
12+
},
13+
alias: tsconfigPathAliases(),
14+
pool: 'threads',
15+
poolOptions: { threads: { singleThread: true } },
16+
coverage: {
17+
reporter: ['text', 'lcov'],
18+
reportsDirectory: '../../coverage/plugin-knip/integration-tests',
19+
exclude: ['mocks/**', '**/types.ts'],
20+
},
21+
environment: 'node',
22+
include: ['src/**/*.integration.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
23+
globalSetup: ['../../global-setup.ts'],
24+
setupFiles: [
25+
'../../testing/test-setup/src/lib/console.mock.ts',
26+
'../../testing/test-setup/src/lib/reset.mocks.ts',
27+
],
28+
},
29+
});
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/// <reference types="vitest" />
2+
import { defineConfig } from 'vite';
3+
import { tsconfigPathAliases } from '../../tooling/vitest-tsconfig-path-aliases';
4+
5+
export default defineConfig({
6+
cacheDir: '../../node_modules/.vite/plugin-knip',
7+
test: {
8+
reporters: ['basic'],
9+
globals: true,
10+
cache: {
11+
dir: '../../node_modules/.vitest/plugin-knip',
12+
},
13+
alias: tsconfigPathAliases(),
14+
pool: 'threads',
15+
poolOptions: { threads: { singleThread: true } },
16+
coverage: {
17+
reporter: ['text', 'lcov'],
18+
reportsDirectory: '../../coverage/plugin-knip/unit-tests',
19+
exclude: ['mocks/**', '**/types.ts'],
20+
},
21+
environment: 'node',
22+
include: ['src/**/*.unit.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
23+
globalSetup: ['../../global-setup.ts'],
24+
setupFiles: [
25+
'../../testing/test-setup/src/lib/console.mock.ts',
26+
'../../testing/test-setup/src/lib/fs.mock.ts',
27+
'../../testing/test-setup/src/lib/reset.mocks.ts',
28+
],
29+
},
30+
});

0 commit comments

Comments
 (0)