Skip to content

Commit d93c747

Browse files
authoredFeb 26, 2024
Added support for eslint.config.cjs and eslint.config.mjs files (#525)
1 parent 862be7b commit d93c747

File tree

1 file changed

+8
-2
lines changed
  • packages/knip/src/plugins/eslint

1 file changed

+8
-2
lines changed
 

‎packages/knip/src/plugins/eslint/index.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const isEnabled: IsPluginEnabledCallback = ({ dependencies, manifest, config })
2222
export const PACKAGE_JSON_PATH = 'eslintConfig';
2323

2424
const CONFIG_FILE_PATTERNS = [
25-
'eslint.config.js',
25+
'eslint.config.{js,cjs,mjs}',
2626
'.eslintrc',
2727
'.eslintrc.{js,json,cjs}',
2828
'.eslintrc.{yml,yaml}',
@@ -33,7 +33,13 @@ const findESLintDependencies: GenericPluginCallback = async (configFilePath, { c
3333
if (isProduction) return [];
3434

3535
// The new configuration format does not need custom dependency resolving (it has only imports)
36-
if (basename(configFilePath) === 'eslint.config.js') return [];
36+
const baseFilePath = basename(configFilePath);
37+
if (
38+
baseFilePath === 'eslint.config.js' ||
39+
baseFilePath === 'eslint.config.cjs' ||
40+
baseFilePath === 'eslint.config.mjs'
41+
)
42+
return [];
3743

3844
const dependencies = await getDependenciesDeep(configFilePath, { cwd, manifest });
3945
return Array.from(dependencies);

0 commit comments

Comments
 (0)
Please sign in to comment.