Skip to content

Commit

Permalink
Fix knip
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklafrance committed May 10, 2024
1 parent cf980fa commit 8e46c5c
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ const ignoreBrowserslist: KnipTransformer = ({ ignoreDependencies, ...config })
};
};

const ignoreEslint: KnipTransformer = ({ ignoreDependencies, ...config }) => {
return {
...config,
ignoreDependencies: [
...(ignoreDependencies as string[] ?? []),
// Browserlist isn't supported by plugins.
"@workleap/eslint-plugin",
// Ignoring until the TS config files using ESM features known issue is fixed: https://knip.dev/reference/known-issues.
"eslint"
]
};
};

const configurePostcss: KnipTransformer = config => {
return {
...config,
Expand Down Expand Up @@ -87,7 +100,6 @@ const configureTsup: KnipTransformer = config => {
const configurePackage: KnipTransformer = config => {
return {
...config,
eslint: true
};
};

Expand All @@ -99,7 +111,7 @@ const configureSample: KnipTransformer = ({ entry, ...config }) => {
"src/index.ts",
"src/index.tsx"
],
eslint: true,
// eslint: true,
stylelint: true
};
};
Expand All @@ -111,11 +123,14 @@ const rootConfig = defineWorkspace({
// Installed once for all the workspace's projects
"ts-node"
]
});
}, [
ignoreEslint
]);

const packagesConfig: KnipWorkspaceConfig = defineWorkspace({}, [
configurePackage,
configureTsup
configureTsup,
ignoreEslint
]);

const swcConfig: KnipWorkspaceConfig = defineWorkspace({
Expand All @@ -127,7 +142,8 @@ const swcConfig: KnipWorkspaceConfig = defineWorkspace({
]
}, [
configurePackage,
configureTsup
configureTsup,
ignoreEslint
]);

const webpackConfig: KnipWorkspaceConfig = defineWorkspace({
Expand All @@ -139,15 +155,21 @@ const webpackConfig: KnipWorkspaceConfig = defineWorkspace({
]
}, [
configurePackage,
configureTsup
configureTsup,
ignoreEslint
]);

const typescriptConfig: KnipWorkspaceConfig = defineWorkspace({}, [
configurePackage
]);

const sampleAppConfig = defineWorkspace({}, [
configureSample,
ignoreBrowserslist,
configurePostcss,
configureWebpack,
configureMsw
configureMsw,
ignoreEslint
]);

const sampleComponentsConfig = defineWorkspace({}, [
Expand All @@ -157,7 +179,8 @@ const sampleComponentsConfig = defineWorkspace({}, [

const sampleUtilsConfig = defineWorkspace({}, [
configureSample,
configureTsup
configureTsup,
ignoreEslint
]);

const config: KnipConfig = {
Expand All @@ -166,13 +189,16 @@ const config: KnipConfig = {
"packages/*": packagesConfig,
"packages/swc-configs": swcConfig,
"packages/webpack-configs": webpackConfig,
"packages/typescript-configs": typescriptConfig,
"sample/app": sampleAppConfig,
"sample/components": sampleComponentsConfig,
"sample/utils": sampleUtilsConfig
},
ignoreWorkspaces: [
// Until it supports ESM.
"packages/stylelint-configs"
"packages/stylelint-configs",
// Ignoring until the TS config files using ESM features known issue is fixed: https://knip.dev/reference/known-issues.
"packages/eslint-plugin"
],
exclude: [
// It cause issues with config like Jest "projects".
Expand Down

0 comments on commit 8e46c5c

Please sign in to comment.