knip 2.42.0 → 2.43.0
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/babel/helpers.d.ts +1 -2
- package/dist/plugins/babel/helpers.js +28 -20
- package/dist/plugins/babel/index.js +6 -8
- package/dist/types/issues.js +1 -1
- package/dist/typescript/visitors/exports/exportDeclaration.js +6 -1
- package/dist/util/parseArgs.d.ts +0 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const resolvePresetName: (pluginName: string) => string;
|
|
1
|
+
export declare const resolveName: (identifier: string, namespace: 'preset' | 'plugin') => string;
|
|
3
2
|
export declare const api: {
|
|
4
3
|
assertVersion: () => boolean;
|
|
5
4
|
cache: {
|
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { isAbsolute, isInternal } from '../../util/path.js';
|
|
2
|
+
export const resolveName = (identifier, namespace) => {
|
|
3
|
+
if (isAbsolute(identifier) || isInternal(identifier))
|
|
4
|
+
return identifier;
|
|
5
|
+
if (identifier.startsWith('module:'))
|
|
6
|
+
return identifier.replace(/^module:/, '');
|
|
7
|
+
if (identifier.startsWith('@')) {
|
|
8
|
+
const [scope, name, ...rest] = identifier.split('/');
|
|
9
|
+
if (rest.length > 0)
|
|
10
|
+
return identifier;
|
|
11
|
+
if (scope) {
|
|
12
|
+
if (!name)
|
|
13
|
+
return [scope, `babel-${namespace}`].join('/');
|
|
14
|
+
if (scope === '@babel') {
|
|
15
|
+
if (name.startsWith(namespace))
|
|
16
|
+
return identifier;
|
|
17
|
+
return `@babel/${namespace}-${name}`;
|
|
18
|
+
}
|
|
19
|
+
if (name.includes(`babel-${namespace}`))
|
|
20
|
+
return identifier;
|
|
21
|
+
return [scope, `babel-${namespace}-${name}`].join('/');
|
|
22
|
+
}
|
|
9
23
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
if (pluginName.startsWith('@babel/preset'))
|
|
17
|
-
return pluginName;
|
|
18
|
-
const [, name] = pluginName.split('/');
|
|
19
|
-
return `@babel/preset-${name}`;
|
|
20
|
-
}
|
|
21
|
-
return pluginName;
|
|
24
|
+
const [name, ...rest] = identifier.split('/');
|
|
25
|
+
if (rest.length > 0)
|
|
26
|
+
return identifier;
|
|
27
|
+
if (name.startsWith(`babel-${namespace}`))
|
|
28
|
+
return identifier;
|
|
29
|
+
return `babel-${namespace}-${name}`;
|
|
22
30
|
};
|
|
23
31
|
const cacheFn = () => void 0;
|
|
24
32
|
cacheFn.forever = () => cacheFn;
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { compact } from '../../util/array.js';
|
|
2
2
|
import { timerify } from '../../util/Performance.js';
|
|
3
3
|
import { hasDependency, load } from '../../util/plugin.js';
|
|
4
|
-
import {
|
|
4
|
+
import { resolveName, api } from './helpers.js';
|
|
5
5
|
export const NAME = 'Babel';
|
|
6
6
|
export const ENABLERS = [/^@babel\//];
|
|
7
7
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
8
8
|
export const CONFIG_FILE_PATTERNS = [
|
|
9
|
-
'babel.config.json',
|
|
10
|
-
'
|
|
11
|
-
'.babelrc.json',
|
|
12
|
-
'.babelrc.js',
|
|
9
|
+
'babel.config.{json,js,cjs,mjs,cts}',
|
|
10
|
+
'.babelrc.{json,js,cjs,mjs,cts}',
|
|
13
11
|
'.babelrc',
|
|
14
12
|
'package.json',
|
|
15
13
|
];
|
|
16
|
-
const
|
|
14
|
+
const getName = (value) => typeof value === 'string' ? [value] : Array.isArray(value) ? [value[0]] : [];
|
|
17
15
|
export const getDependenciesFromConfig = (config) => {
|
|
18
|
-
const presets = config.presets?.flatMap(
|
|
19
|
-
const plugins = config.plugins?.flatMap(
|
|
16
|
+
const presets = config.presets?.flatMap(getName).map(name => resolveName(name, 'preset')) ?? [];
|
|
17
|
+
const plugins = config.plugins?.flatMap(getName).map(name => resolveName(name, 'plugin')) ?? [];
|
|
20
18
|
const nested = config.env ? Object.values(config.env).flatMap(getDependenciesFromConfig) : [];
|
|
21
19
|
return compact([...presets, ...plugins, ...nested]);
|
|
22
20
|
};
|
package/dist/types/issues.js
CHANGED
|
@@ -6,7 +6,12 @@ export default visit(() => true, node => {
|
|
|
6
6
|
if (node.exportClause && ts.isNamedExports(node.exportClause)) {
|
|
7
7
|
const type = node.isTypeOnly ? SymbolType.TYPE : SymbolType.UNKNOWN;
|
|
8
8
|
return node.exportClause.elements.map(element => {
|
|
9
|
-
return {
|
|
9
|
+
return {
|
|
10
|
+
node: element,
|
|
11
|
+
identifier: element.name.getText(),
|
|
12
|
+
type,
|
|
13
|
+
pos: element.name.flowNode?.node?.pos ?? element.name.pos,
|
|
14
|
+
};
|
|
10
15
|
});
|
|
11
16
|
}
|
|
12
17
|
}
|
package/dist/util/parseArgs.d.ts
CHANGED
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.
|
|
1
|
+
export declare const version = "2.43.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.43.0';
|
package/package.json
CHANGED