diff --git a/packages/knip/fixtures/plugins/stylelint/.stylelintrc b/packages/knip/fixtures/plugins/stylelint/.stylelintrc index a8f56ffc5..d226d0bc9 100644 --- a/packages/knip/fixtures/plugins/stylelint/.stylelintrc +++ b/packages/knip/fixtures/plugins/stylelint/.stylelintrc @@ -1,4 +1,5 @@ { + "customSyntax": "postcss-less", "extends": ["stylelint-config-standard", "./myExtendableConfig"], "plugins": ["stylelint-order"], "rules": { diff --git a/packages/knip/src/plugins/stylelint/index.ts b/packages/knip/src/plugins/stylelint/index.ts index 794611228..119988172 100644 --- a/packages/knip/src/plugins/stylelint/index.ts +++ b/packages/knip/src/plugins/stylelint/index.ts @@ -14,10 +14,11 @@ const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependenc const config = ['package.json', ...toCosmiconfig('stylelint')]; const resolve = (config: StyleLintConfig | BaseStyleLintConfig): string[] => { - const extend = config.extends ? [config.extends].flat().filter(id => !isInternal(id)) : []; - const plugins = config.plugins ? [config.plugins].flat().filter(id => !isInternal(id)) : []; + const extend = config.extends ? [config.extends].flat() : []; + const plugins = config.plugins ? [config.plugins].flat() : []; + const customSyntax = config.customSyntax ? [config.customSyntax] : []; const overrideConfigs = 'overrides' in config ? config.overrides.flatMap(resolve) : []; - return [...extend, ...plugins, ...overrideConfigs]; + return [...extend, ...plugins, ...overrideConfigs, ...customSyntax].filter(id => !isInternal(id)); }; const resolveConfig: ResolveConfig = config => resolve(config); diff --git a/packages/knip/src/plugins/stylelint/types.ts b/packages/knip/src/plugins/stylelint/types.ts index 4bae02528..10e37c971 100644 --- a/packages/knip/src/plugins/stylelint/types.ts +++ b/packages/knip/src/plugins/stylelint/types.ts @@ -1,4 +1,5 @@ export type BaseStyleLintConfig = { + customSyntax?: string; extends?: string | string[]; plugins?: string[]; }; diff --git a/packages/knip/test/plugins/stylelint.test.ts b/packages/knip/test/plugins/stylelint.test.ts index 8066a7219..f0b86a921 100644 --- a/packages/knip/test/plugins/stylelint.test.ts +++ b/packages/knip/test/plugins/stylelint.test.ts @@ -14,6 +14,7 @@ test('Find dependencies with the stylelint plugin', async () => { }); assert(issues.devDependencies['package.json']['stylelint']); + assert(issues.unlisted['.stylelintrc']['postcss-less']); assert(issues.unlisted['.stylelintrc']['stylelint-config-standard']); assert(issues.unlisted['.stylelintrc']['stylelint-order']); assert(issues.unlisted['.stylelintrc']['stylelint-config-html/html']); @@ -21,7 +22,7 @@ test('Find dependencies with the stylelint plugin', async () => { assert.deepEqual(counters, { ...baseCounters, devDependencies: 1, - unlisted: 3, + unlisted: 4, processed: 0, total: 0, });