@saashub/qoq-knip 0.9.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.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/package.json +59 -0
- package/qoq.config.js +3 -0
- package/rollup.config.mjs +28 -0
- package/src/index.ts +16 -0
- package/src/knipConfig.spec.ts +85 -0
- package/src/knipConfig.ts +18 -0
- package/tsconfig.json +7 -0
- package/vitest.config.mjs +3 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Łukasz Adamczyk
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# @saashub/qoq-knip
|
package/package.json
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
{
|
2
|
+
"name": "@saashub/qoq-knip",
|
3
|
+
"description": "Knip configs template",
|
4
|
+
"license": "MIT",
|
5
|
+
"version": "0.9.0",
|
6
|
+
"main": "./lib/index.cjs",
|
7
|
+
"module": "./lib/index.mjs",
|
8
|
+
"types": "./lib/index.d.js",
|
9
|
+
"exports": {
|
10
|
+
".": {
|
11
|
+
"types": "./lib/index.d.ts",
|
12
|
+
"module": "./lib/index.mjs",
|
13
|
+
"import": "./lib/index.mjs",
|
14
|
+
"require": "./lib/index.cjs",
|
15
|
+
"default": "./lib/index.mjs"
|
16
|
+
},
|
17
|
+
"./knipConfig": {
|
18
|
+
"types": "./lib/knipConfig.d.ts",
|
19
|
+
"module": "./lib/knipConfig.mjs",
|
20
|
+
"import": "./lib/knipConfig.mjs",
|
21
|
+
"require": "./lib/knipConfig.cjs",
|
22
|
+
"default": "./lib/knipConfig.mjs"
|
23
|
+
}
|
24
|
+
},
|
25
|
+
"publishConfig": {
|
26
|
+
"access": "public"
|
27
|
+
},
|
28
|
+
"scripts": {
|
29
|
+
"build": "rimraf ./lib && rollup -c --silent",
|
30
|
+
"test": "vitest run --coverage",
|
31
|
+
"qoq:check": "qoq --check",
|
32
|
+
"qoq:fix": "qoq --fix"
|
33
|
+
},
|
34
|
+
"dependencies": {
|
35
|
+
"knip": "5.30.1",
|
36
|
+
"lodash": "4.17.21"
|
37
|
+
},
|
38
|
+
"devDependencies": {
|
39
|
+
"@saashub/qoq-cli": "^0.9.0",
|
40
|
+
"@types/lodash": "4.17.7",
|
41
|
+
"rimraf": "6.0.1",
|
42
|
+
"rollup": "4.21.2",
|
43
|
+
"typescript": "5.6.2",
|
44
|
+
"vitest": "2.0.5"
|
45
|
+
},
|
46
|
+
"keywords": [
|
47
|
+
"Knip template",
|
48
|
+
"saashub",
|
49
|
+
"qoq",
|
50
|
+
"QualityOverQuantity"
|
51
|
+
],
|
52
|
+
"repository": {
|
53
|
+
"type": "git",
|
54
|
+
"url": "git+ssh://git@github.com/saashub-it/qoq.git",
|
55
|
+
"directory": "packages/knip"
|
56
|
+
},
|
57
|
+
"homepage": "https://github.com/saashub-it/qoq/tree/master/packages/knip",
|
58
|
+
"gitHead": "a66c128699cdadbf669da44c674cc6d312a8311a"
|
59
|
+
}
|
package/qoq.config.js
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
import typescript from '@rollup/plugin-typescript';
|
2
|
+
|
3
|
+
const sourceDir = './src';
|
4
|
+
const outputDir = './lib';
|
5
|
+
const input = {
|
6
|
+
index: `${sourceDir}/index.ts`,
|
7
|
+
knipConfig: `${sourceDir}/knipConfig.ts`,
|
8
|
+
};
|
9
|
+
const plugins = [typescript({
|
10
|
+
exclude: ['**/*.spec.{js,ts}']
|
11
|
+
})];
|
12
|
+
|
13
|
+
export default {
|
14
|
+
input,
|
15
|
+
plugins,
|
16
|
+
output: [
|
17
|
+
{
|
18
|
+
dir: outputDir,
|
19
|
+
format: 'esm',
|
20
|
+
entryFileNames: '[name].mjs',
|
21
|
+
},
|
22
|
+
{
|
23
|
+
dir: outputDir,
|
24
|
+
format: 'cjs',
|
25
|
+
entryFileNames: '[name].cjs',
|
26
|
+
},
|
27
|
+
],
|
28
|
+
};
|
package/src/index.ts
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
import { getKnipConfig } from './knipConfig';
|
2
|
+
|
3
|
+
export const jsConfig = getKnipConfig();
|
4
|
+
export const jsReactConfig = getKnipConfig('.src', ['.src/index.jsx'], ['.src/**/*.{js,jsx}']);
|
5
|
+
export const tsConfig = getKnipConfig(
|
6
|
+
'.src',
|
7
|
+
['.src/index.ts'],
|
8
|
+
['.src/**/*.{js,ts}'],
|
9
|
+
['package.json', 'tsconfig.json', '**/*.d.ts']
|
10
|
+
);
|
11
|
+
export const tsReactConfig = getKnipConfig(
|
12
|
+
'.src',
|
13
|
+
['.src/index.tsx'],
|
14
|
+
['.src/**/*.{js,jsx,ts,tsx}'],
|
15
|
+
['package.json', 'tsconfig.json', '**/*.d.ts']
|
16
|
+
);
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
2
|
+
|
3
|
+
import { getKnipConfig } from './knipConfig';
|
4
|
+
|
5
|
+
describe('getKnipConfig', () => {
|
6
|
+
it('should return default values', () => {
|
7
|
+
const result = getKnipConfig();
|
8
|
+
expect(result).toEqual({
|
9
|
+
entry: ['.src/index.js'],
|
10
|
+
project: ['.src/**/*.js'],
|
11
|
+
ignore: ['package.json'],
|
12
|
+
ignoreDependencies: [],
|
13
|
+
});
|
14
|
+
});
|
15
|
+
|
16
|
+
it('should return custom srcPath', () => {
|
17
|
+
const srcPath = 'custom-src';
|
18
|
+
const result = getKnipConfig(srcPath);
|
19
|
+
expect(result).toEqual({
|
20
|
+
entry: [`${srcPath}/index.js`],
|
21
|
+
project: [`${srcPath}/**/*.js`],
|
22
|
+
ignore: ['package.json'],
|
23
|
+
ignoreDependencies: [],
|
24
|
+
});
|
25
|
+
});
|
26
|
+
|
27
|
+
it('should return custom entry', () => {
|
28
|
+
const entry = ['custom-entry.js'];
|
29
|
+
const result = getKnipConfig(undefined, entry);
|
30
|
+
expect(result).toEqual({
|
31
|
+
entry,
|
32
|
+
project: ['.src/**/*.js'],
|
33
|
+
ignore: ['package.json'],
|
34
|
+
ignoreDependencies: [],
|
35
|
+
});
|
36
|
+
});
|
37
|
+
|
38
|
+
it('should return custom project', () => {
|
39
|
+
const project = ['custom-project.js'];
|
40
|
+
const result = getKnipConfig(undefined, undefined, project);
|
41
|
+
expect(result).toEqual({
|
42
|
+
entry: ['.src/index.js'],
|
43
|
+
project,
|
44
|
+
ignore: ['package.json'],
|
45
|
+
ignoreDependencies: [],
|
46
|
+
});
|
47
|
+
});
|
48
|
+
|
49
|
+
it('should return custom ignore', () => {
|
50
|
+
const ignore = ['custom-ignore.js'];
|
51
|
+
const result = getKnipConfig(undefined, undefined, undefined, ignore);
|
52
|
+
expect(result).toEqual({
|
53
|
+
entry: ['.src/index.js'],
|
54
|
+
project: ['.src/**/*.js'],
|
55
|
+
ignore,
|
56
|
+
ignoreDependencies: [],
|
57
|
+
});
|
58
|
+
});
|
59
|
+
|
60
|
+
it('should return custom ignoreDependencies', () => {
|
61
|
+
const ignoreDependencies = ['custom-ignore-dependencies.js'];
|
62
|
+
const result = getKnipConfig(undefined, undefined, undefined, undefined, ignoreDependencies);
|
63
|
+
expect(result).toEqual({
|
64
|
+
entry: ['.src/index.js'],
|
65
|
+
project: ['.src/**/*.js'],
|
66
|
+
ignore: ['package.json'],
|
67
|
+
ignoreDependencies,
|
68
|
+
});
|
69
|
+
});
|
70
|
+
|
71
|
+
it('should return multiple custom values', () => {
|
72
|
+
const srcPath = 'custom-src';
|
73
|
+
const entry = ['custom-entry.js'];
|
74
|
+
const project = ['custom-project.js'];
|
75
|
+
const ignore = ['custom-ignore.js'];
|
76
|
+
const ignoreDependencies = ['custom-ignore-dependencies.js'];
|
77
|
+
const result = getKnipConfig(srcPath, entry, project, ignore, ignoreDependencies);
|
78
|
+
expect(result).toEqual({
|
79
|
+
entry,
|
80
|
+
project,
|
81
|
+
ignore,
|
82
|
+
ignoreDependencies,
|
83
|
+
});
|
84
|
+
});
|
85
|
+
});
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export const getKnipConfig: (
|
2
|
+
srcPath?: string,
|
3
|
+
entry?: string[],
|
4
|
+
project?: string[],
|
5
|
+
ignore?: string[],
|
6
|
+
ignoreDependencies?: string[]
|
7
|
+
) => { entry: string[]; project: string[]; ignore: string[]; ignoreDependencies: string[] } = (
|
8
|
+
srcPath = '.src',
|
9
|
+
entry = [`${srcPath}/index.js`],
|
10
|
+
project = [`${srcPath}/**/*.js`],
|
11
|
+
ignore = ['package.json'],
|
12
|
+
ignoreDependencies = []
|
13
|
+
) => ({
|
14
|
+
entry,
|
15
|
+
project,
|
16
|
+
ignore,
|
17
|
+
ignoreDependencies,
|
18
|
+
});
|
package/tsconfig.json
ADDED