knip 4.0.2 → 4.0.3
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/dist/plugins/postcss/index.js +1 -1
- package/dist/plugins/stylelint/index.js +7 -3
- package/dist/plugins/stylelint/types.d.ts +4 -1
- package/dist/plugins/webpack/index.js +17 -12
- package/dist/typescript/visitors/dynamic-imports/jsDocType.js +1 -1
- package/dist/typescript/visitors/exports/moduleExportsAccessExpression.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { basename } from '../../util/path.js';
|
|
|
2
2
|
import { timerify } from '../../util/Performance.js';
|
|
3
3
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
4
4
|
const NAME = 'PostCSS';
|
|
5
|
-
const ENABLERS = ['postcss', 'next'];
|
|
5
|
+
const ENABLERS = ['postcss', 'postcss-cli', 'next'];
|
|
6
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
7
|
const CONFIG_FILE_PATTERNS = ['postcss.config.{cjs,js}', 'postcss.config.json', 'package.json'];
|
|
8
8
|
const findPostCSSDependencies = async (configFilePath, options) => {
|
|
@@ -5,6 +5,12 @@ const NAME = 'Stylelint';
|
|
|
5
5
|
const ENABLERS = ['stylelint'];
|
|
6
6
|
const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
7
|
const CONFIG_FILE_PATTERNS = ['.stylelintrc', '.stylelintrc.{cjs,js,json,yaml,yml}', 'stylelint.config.{cjs,mjs,js}'];
|
|
8
|
+
const findDependenciesInConfig = (config) => {
|
|
9
|
+
const extend = config.extends ? [config.extends].flat().filter(id => !isInternal(id)) : [];
|
|
10
|
+
const plugins = config.plugins ? [config.plugins].flat().filter(id => !isInternal(id)) : [];
|
|
11
|
+
const overrideConfigs = 'overrides' in config ? config.overrides.flatMap(findDependenciesInConfig) : [];
|
|
12
|
+
return [...extend, ...plugins, ...overrideConfigs];
|
|
13
|
+
};
|
|
8
14
|
const findPluginDependencies = async (configFilePath, options) => {
|
|
9
15
|
const { manifest, isProduction } = options;
|
|
10
16
|
if (isProduction)
|
|
@@ -12,9 +18,7 @@ const findPluginDependencies = async (configFilePath, options) => {
|
|
|
12
18
|
const localConfig = basename(configFilePath) === 'package.json' ? manifest.stylelint : await load(configFilePath);
|
|
13
19
|
if (!localConfig)
|
|
14
20
|
return [];
|
|
15
|
-
|
|
16
|
-
const plugins = localConfig.plugins ? [localConfig.plugins].flat().filter(plugin => !isInternal(plugin)) : [];
|
|
17
|
-
return [...extend, ...plugins];
|
|
21
|
+
return findDependenciesInConfig(localConfig);
|
|
18
22
|
};
|
|
19
23
|
const findDependencies = timerify(findPluginDependencies);
|
|
20
24
|
export default {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compact } from '../../util/array.js';
|
|
2
|
-
import { join, relative } from '../../util/path.js';
|
|
2
|
+
import { isInternal, join, relative } from '../../util/path.js';
|
|
3
3
|
import { timerify } from '../../util/Performance.js';
|
|
4
4
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
5
5
|
import { toEntryPattern, toProductionEntryPattern } from '../../util/protocols.js';
|
|
@@ -23,16 +23,16 @@ const resolveRuleSetDependencies = (rule) => {
|
|
|
23
23
|
let useItem = rule.use ?? rule.loader ?? rule;
|
|
24
24
|
if (typeof useItem === 'function')
|
|
25
25
|
useItem = useItem(info);
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
if (typeof useItem === 'string' && hasBabelOptions(rule)) {
|
|
27
|
+
return [useItem, ...getDependenciesFromConfig(rule.options)];
|
|
28
|
+
}
|
|
29
|
+
return [useItem].flat().flatMap((item) => {
|
|
30
|
+
if (!item)
|
|
28
31
|
return [];
|
|
29
|
-
if (hasBabelOptions(
|
|
30
|
-
return [
|
|
31
|
-
...resolveUseItem(useItem),
|
|
32
|
-
...getDependenciesFromConfig(useItem.options),
|
|
33
|
-
];
|
|
32
|
+
if (hasBabelOptions(item)) {
|
|
33
|
+
return [...resolveUseItem(item), ...getDependenciesFromConfig(item.options)];
|
|
34
34
|
}
|
|
35
|
-
return resolveUseItem(
|
|
35
|
+
return resolveUseItem(item);
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
const resolveUseItem = (use) => {
|
|
@@ -74,9 +74,14 @@ export const findWebpackDependenciesFromConfig = async ({ config, cwd }) => {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
entries.forEach(entry => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
if (!isInternal(entry)) {
|
|
78
|
+
dependencies.add(entry);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const item = relative(cwd, join(options.context ? options.context : cwd, entry));
|
|
82
|
+
const value = options.mode === 'development' ? toEntryPattern(item) : toProductionEntryPattern(item);
|
|
83
|
+
entryPatterns.add(value);
|
|
84
|
+
}
|
|
80
85
|
});
|
|
81
86
|
}
|
|
82
87
|
}
|
|
@@ -7,7 +7,7 @@ const getImportSpecifiers = (node) => {
|
|
|
7
7
|
const importClause = node.argument;
|
|
8
8
|
if (ts.isLiteralTypeNode(importClause) && ts.isStringLiteral(importClause.literal)) {
|
|
9
9
|
const identifier = node.qualifier && ts.isIdentifier(node.qualifier) ? String(node.qualifier.escapedText) : 'default';
|
|
10
|
-
imports.push({ specifier: importClause.literal.text, identifier, pos:
|
|
10
|
+
imports.push({ specifier: importClause.literal.text, identifier, pos: importClause.literal.pos });
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
ts.forEachChild(node, visit);
|
|
@@ -26,11 +26,11 @@ export default visit(isJS, (node, { isFixExports }) => {
|
|
|
26
26
|
if (ts.isObjectLiteralExpression(expr) && expr.properties.every(ts.isShorthandPropertyAssignment)) {
|
|
27
27
|
return expr.properties.map(node => {
|
|
28
28
|
const fix = isFixExports ? [node.getStart(), node.getEnd()] : undefined;
|
|
29
|
-
return { node, identifier: node.getText(), type: SymbolType.UNKNOWN, pos: node.
|
|
29
|
+
return { node, identifier: node.getText(), type: SymbolType.UNKNOWN, pos: node.getStart(), fix };
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
|
-
return { node, identifier: 'default', type: SymbolType.UNKNOWN, pos: expr.pos, fix: undefined };
|
|
33
|
+
return { node, identifier: 'default', type: SymbolType.UNKNOWN, pos: expr.pos + 1, fix: undefined };
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "4.0.
|
|
1
|
+
export declare const version = "4.0.3";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '4.0.
|
|
1
|
+
export const version = '4.0.3';
|