Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
697ede1
chore: setup knip to lint the workspace
beaussan Mar 11, 2024
8674c68
Merge branch 'main' into feat/setup-knip
beaussan Mar 11, 2024
72a0fce
chore: update lockfile
beaussan Mar 11, 2024
1eafe08
wip
BioPhoton Mar 12, 2024
10e8839
feat(examples-plugins): add knip reporter for code-pushup
BioPhoton Mar 13, 2024
cec3372
feat(examples-plugins): adopt knip config and tests
BioPhoton Mar 13, 2024
73776cd
fix package json
BioPhoton Mar 13, 2024
cfd0bcf
wip
BioPhoton Mar 14, 2024
383a1ac
wip
BioPhoton Mar 14, 2024
f0a2106
wip
BioPhoton Mar 14, 2024
a979ef6
wip
BioPhoton Mar 14, 2024
afec00d
Merge branch 'main' into feat/setup-knip
BioPhoton Mar 14, 2024
ec5a1c6
setup in CI
BioPhoton Mar 14, 2024
4d73674
polish
BioPhoton Mar 14, 2024
3965ea8
polish
BioPhoton Mar 14, 2024
90d2cbf
refactor(plugin-lighthouse): add unit tests for utils
BioPhoton Mar 15, 2024
eeec23a
refactor(example-plugins): move knip plugin into new PR
BioPhoton Mar 15, 2024
6245b52
remove mocks
BioPhoton Mar 15, 2024
cf438d1
Apply suggestions from code review
BioPhoton Mar 15, 2024
7eb55c1
Apply suggestions from code review
BioPhoton Mar 15, 2024
5155cc9
Apply suggestions from code review
BioPhoton Mar 15, 2024
e24ae22
chore: update knip and ignore external configs
beaussan Apr 7, 2024
a05a0ac
Merge branch 'feat/setup-knip' of https://github.com/beaussan/cli int…
beaussan Apr 7, 2024
29044ec
Merge branch 'refs/heads/main' into feat/setup-knip
beaussan Apr 16, 2024
ab254c4
chore: update knip
beaussan Apr 16, 2024
438aab6
chore: update knip config
beaussan Apr 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions knip.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import {
KnipConfigPlugin,
combineNxKnipPlugins,
withEsbuildApps,
withEsbuildPublishableLibs,
withEslint,
withLibraryMapper,
withLocalNxPlugins,
withNxTsPaths,
withVitest,
} from '@beaussan/nx-knip';

const withIgnoreMockInLibs = () =>
withLibraryMapper({
mapperFn: ({ rootFolder }) => {
return {
ignore: [rootFolder + '/mocks/**', rootFolder + '/perf/**'],
entry: [rootFolder + '/src/bin.ts', rootFolder + '/perf/**/index.ts'],
};
},
});

const withExamplePlugins = (): KnipConfigPlugin => () => {
return {
// Given there is no publish target, thoes libs were not picked up by the auto discovery
entry: [
'examples/plugins/src/index.ts',
'packages/plugin-lighthouse/src/index.ts',
],
};
};

const withReactExample = (): KnipConfigPlugin => () => {
return {
entry: [
'examples/react-todos-app/src/index.jsx',
'examples/react-todos-app/test-setup.js',
],
eslint: {
// Given there is no lint target on the project, we need to manually specify the entry point
config: ['examples/react-todos-app/.eslintrc.js'],
},
};
};

const withNxStandards = (): KnipConfigPlugin => () => {
return {
project: ['**/*.{ts,js,tsx,jsx}'],
ignore: ['tmp/**', 'node_modules/**'],
commitlint: {
config: ['commitlint.config.js'],
},
exclude: ['duplicates'],
entry: [
// unknown why this is needed, it should be picked up by knip from the vitest setup files
'testing/test-utils/src/index.ts',
'testing/test-utils/src/lib/fixtures/configs/*.ts',
'testing/test-setup/src/index.ts',
'testing/test-setup/src/lib/**/*.{js,mjs,ts,cjs,mts,cts}',
'global-setup.ts',
'global-setup.e2e.ts',
'examples/react-todos-app/code-pushup.config.js',
'examples/plugins/code-pushup.config.ts',
'testing/test-utils/src/lib/fixtures/configs/code-pushup.config.js',
'testing/test-utils/src/lib/fixtures/configs/code-pushup.empty.config.js',
'examples/plugins/src/package-json/src/index.ts',
// missing knip plugin for now, so this is in the root entry
'packages/models/zod2md.config.ts',
'code-pushup.config.ts',
'esbuild.config.js',
'tools/**/*.{js,mjs,ts,cjs,mts,cts}',
],
ignoreDependencies: [
'prettier',
'@swc/helpers',
'@swc/cli',
'@nx/plugin',
'@nx/workspace',
// Same issue as the other vitest related, it should be picked up by knip from the vitest setup files
// 'global-setup.ts',
// 'global-setup.e2e.ts',

// Knip should be able to pick up this
'tsx',
// Not a npm library, and resolved in a different typescript path than the global import one
'@example/custom-plugin',

// Prettier magic resolve is not picked up by knip
'@trivago/prettier-plugin-sort-imports',
],
};
};

export default combineNxKnipPlugins(
withNxTsPaths(),
withLocalNxPlugins({ pluginNames: ['nx-plugin'] }),
withEsbuildApps(),
withEsbuildPublishableLibs(),
withVitest(),
withIgnoreMockInLibs(),
withEslint(),
withReactExample(),
withExamplePlugins(),
withNxStandards(),
);
Loading