knip 1.14.0 → 1.14.2
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/configuration-validator.d.ts +160 -160
- package/dist/plugins/eslint/helpers.d.ts +10 -1
- package/dist/plugins/eslint/helpers.js +33 -17
- package/dist/plugins/eslint/index.js +1 -17
- package/dist/plugins/jest/index.js +5 -6
- package/dist/plugins/typedoc/index.js +1 -1
- package/dist/plugins/typedoc/types.d.ts +1 -1
- package/dist/util/debug.js +3 -2
- package/dist/util/path.d.ts +1 -0
- package/dist/util/path.js +1 -0
- package/dist/util/workspace.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -8
|
@@ -1115,156 +1115,6 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
1115
1115
|
ignoreBinaries?: string[] | undefined;
|
|
1116
1116
|
ignoreDependencies?: string[] | undefined;
|
|
1117
1117
|
ignoreWorkspaces?: string[] | undefined;
|
|
1118
|
-
babel?: string | false | string[] | {
|
|
1119
|
-
config?: string | string[] | undefined;
|
|
1120
|
-
entry?: string | string[] | undefined;
|
|
1121
|
-
project?: string | string[] | undefined;
|
|
1122
|
-
} | undefined;
|
|
1123
|
-
capacitor?: string | false | string[] | {
|
|
1124
|
-
config?: string | string[] | undefined;
|
|
1125
|
-
entry?: string | string[] | undefined;
|
|
1126
|
-
project?: string | string[] | undefined;
|
|
1127
|
-
} | undefined;
|
|
1128
|
-
changesets?: string | false | string[] | {
|
|
1129
|
-
config?: string | string[] | undefined;
|
|
1130
|
-
entry?: string | string[] | undefined;
|
|
1131
|
-
project?: string | string[] | undefined;
|
|
1132
|
-
} | undefined;
|
|
1133
|
-
commitlint?: string | false | string[] | {
|
|
1134
|
-
config?: string | string[] | undefined;
|
|
1135
|
-
entry?: string | string[] | undefined;
|
|
1136
|
-
project?: string | string[] | undefined;
|
|
1137
|
-
} | undefined;
|
|
1138
|
-
cypress?: string | false | string[] | {
|
|
1139
|
-
config?: string | string[] | undefined;
|
|
1140
|
-
entry?: string | string[] | undefined;
|
|
1141
|
-
project?: string | string[] | undefined;
|
|
1142
|
-
} | undefined;
|
|
1143
|
-
eslint?: string | false | string[] | {
|
|
1144
|
-
config?: string | string[] | undefined;
|
|
1145
|
-
entry?: string | string[] | undefined;
|
|
1146
|
-
project?: string | string[] | undefined;
|
|
1147
|
-
} | undefined;
|
|
1148
|
-
gatsby?: string | false | string[] | {
|
|
1149
|
-
config?: string | string[] | undefined;
|
|
1150
|
-
entry?: string | string[] | undefined;
|
|
1151
|
-
project?: string | string[] | undefined;
|
|
1152
|
-
} | undefined;
|
|
1153
|
-
'github-actions'?: string | false | string[] | {
|
|
1154
|
-
config?: string | string[] | undefined;
|
|
1155
|
-
entry?: string | string[] | undefined;
|
|
1156
|
-
project?: string | string[] | undefined;
|
|
1157
|
-
} | undefined;
|
|
1158
|
-
husky?: string | false | string[] | {
|
|
1159
|
-
config?: string | string[] | undefined;
|
|
1160
|
-
entry?: string | string[] | undefined;
|
|
1161
|
-
project?: string | string[] | undefined;
|
|
1162
|
-
} | undefined;
|
|
1163
|
-
jest?: string | false | string[] | {
|
|
1164
|
-
config?: string | string[] | undefined;
|
|
1165
|
-
entry?: string | string[] | undefined;
|
|
1166
|
-
project?: string | string[] | undefined;
|
|
1167
|
-
} | undefined;
|
|
1168
|
-
'lint-staged'?: string | false | string[] | {
|
|
1169
|
-
config?: string | string[] | undefined;
|
|
1170
|
-
entry?: string | string[] | undefined;
|
|
1171
|
-
project?: string | string[] | undefined;
|
|
1172
|
-
} | undefined;
|
|
1173
|
-
markdownlint?: string | false | string[] | {
|
|
1174
|
-
config?: string | string[] | undefined;
|
|
1175
|
-
entry?: string | string[] | undefined;
|
|
1176
|
-
project?: string | string[] | undefined;
|
|
1177
|
-
} | undefined;
|
|
1178
|
-
mocha?: string | false | string[] | {
|
|
1179
|
-
config?: string | string[] | undefined;
|
|
1180
|
-
entry?: string | string[] | undefined;
|
|
1181
|
-
project?: string | string[] | undefined;
|
|
1182
|
-
} | undefined;
|
|
1183
|
-
next?: string | false | string[] | {
|
|
1184
|
-
config?: string | string[] | undefined;
|
|
1185
|
-
entry?: string | string[] | undefined;
|
|
1186
|
-
project?: string | string[] | undefined;
|
|
1187
|
-
} | undefined;
|
|
1188
|
-
'npm-package-json-lint'?: string | false | string[] | {
|
|
1189
|
-
config?: string | string[] | undefined;
|
|
1190
|
-
entry?: string | string[] | undefined;
|
|
1191
|
-
project?: string | string[] | undefined;
|
|
1192
|
-
} | undefined;
|
|
1193
|
-
nx?: string | false | string[] | {
|
|
1194
|
-
config?: string | string[] | undefined;
|
|
1195
|
-
entry?: string | string[] | undefined;
|
|
1196
|
-
project?: string | string[] | undefined;
|
|
1197
|
-
} | undefined;
|
|
1198
|
-
nyc?: string | false | string[] | {
|
|
1199
|
-
config?: string | string[] | undefined;
|
|
1200
|
-
entry?: string | string[] | undefined;
|
|
1201
|
-
project?: string | string[] | undefined;
|
|
1202
|
-
} | undefined;
|
|
1203
|
-
playwright?: string | false | string[] | {
|
|
1204
|
-
config?: string | string[] | undefined;
|
|
1205
|
-
entry?: string | string[] | undefined;
|
|
1206
|
-
project?: string | string[] | undefined;
|
|
1207
|
-
} | undefined;
|
|
1208
|
-
postcss?: string | false | string[] | {
|
|
1209
|
-
config?: string | string[] | undefined;
|
|
1210
|
-
entry?: string | string[] | undefined;
|
|
1211
|
-
project?: string | string[] | undefined;
|
|
1212
|
-
} | undefined;
|
|
1213
|
-
prettier?: string | false | string[] | {
|
|
1214
|
-
config?: string | string[] | undefined;
|
|
1215
|
-
entry?: string | string[] | undefined;
|
|
1216
|
-
project?: string | string[] | undefined;
|
|
1217
|
-
} | undefined;
|
|
1218
|
-
'release-it'?: string | false | string[] | {
|
|
1219
|
-
config?: string | string[] | undefined;
|
|
1220
|
-
entry?: string | string[] | undefined;
|
|
1221
|
-
project?: string | string[] | undefined;
|
|
1222
|
-
} | undefined;
|
|
1223
|
-
remark?: string | false | string[] | {
|
|
1224
|
-
config?: string | string[] | undefined;
|
|
1225
|
-
entry?: string | string[] | undefined;
|
|
1226
|
-
project?: string | string[] | undefined;
|
|
1227
|
-
} | undefined;
|
|
1228
|
-
remix?: string | false | string[] | {
|
|
1229
|
-
config?: string | string[] | undefined;
|
|
1230
|
-
entry?: string | string[] | undefined;
|
|
1231
|
-
project?: string | string[] | undefined;
|
|
1232
|
-
} | undefined;
|
|
1233
|
-
rollup?: string | false | string[] | {
|
|
1234
|
-
config?: string | string[] | undefined;
|
|
1235
|
-
entry?: string | string[] | undefined;
|
|
1236
|
-
project?: string | string[] | undefined;
|
|
1237
|
-
} | undefined;
|
|
1238
|
-
sentry?: string | false | string[] | {
|
|
1239
|
-
config?: string | string[] | undefined;
|
|
1240
|
-
entry?: string | string[] | undefined;
|
|
1241
|
-
project?: string | string[] | undefined;
|
|
1242
|
-
} | undefined;
|
|
1243
|
-
storybook?: string | false | string[] | {
|
|
1244
|
-
config?: string | string[] | undefined;
|
|
1245
|
-
entry?: string | string[] | undefined;
|
|
1246
|
-
project?: string | string[] | undefined;
|
|
1247
|
-
} | undefined;
|
|
1248
|
-
stryker?: string | false | string[] | {
|
|
1249
|
-
config?: string | string[] | undefined;
|
|
1250
|
-
entry?: string | string[] | undefined;
|
|
1251
|
-
project?: string | string[] | undefined;
|
|
1252
|
-
} | undefined;
|
|
1253
|
-
typescript?: string | false | string[] | {
|
|
1254
|
-
config?: string | string[] | undefined;
|
|
1255
|
-
entry?: string | string[] | undefined;
|
|
1256
|
-
project?: string | string[] | undefined;
|
|
1257
|
-
} | undefined;
|
|
1258
|
-
vitest?: string | false | string[] | {
|
|
1259
|
-
config?: string | string[] | undefined;
|
|
1260
|
-
entry?: string | string[] | undefined;
|
|
1261
|
-
project?: string | string[] | undefined;
|
|
1262
|
-
} | undefined;
|
|
1263
|
-
webpack?: string | false | string[] | {
|
|
1264
|
-
config?: string | string[] | undefined;
|
|
1265
|
-
entry?: string | string[] | undefined;
|
|
1266
|
-
project?: string | string[] | undefined;
|
|
1267
|
-
} | undefined;
|
|
1268
1118
|
workspaces?: Record<string, {
|
|
1269
1119
|
ignore?: string | string[] | undefined;
|
|
1270
1120
|
entry?: string | string[] | undefined;
|
|
@@ -1421,16 +1271,6 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
1421
1271
|
project?: string | string[] | undefined;
|
|
1422
1272
|
} | undefined;
|
|
1423
1273
|
}> | undefined;
|
|
1424
|
-
}, {
|
|
1425
|
-
exclude?: string[] | undefined;
|
|
1426
|
-
ignore?: string | string[] | undefined;
|
|
1427
|
-
include?: string[] | undefined;
|
|
1428
|
-
entry?: string | string[] | undefined;
|
|
1429
|
-
project?: string | string[] | undefined;
|
|
1430
|
-
paths?: Record<string, string[]> | undefined;
|
|
1431
|
-
ignoreBinaries?: string[] | undefined;
|
|
1432
|
-
ignoreDependencies?: string[] | undefined;
|
|
1433
|
-
ignoreWorkspaces?: string[] | undefined;
|
|
1434
1274
|
babel?: string | false | string[] | {
|
|
1435
1275
|
config?: string | string[] | undefined;
|
|
1436
1276
|
entry?: string | string[] | undefined;
|
|
@@ -1581,6 +1421,16 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
1581
1421
|
entry?: string | string[] | undefined;
|
|
1582
1422
|
project?: string | string[] | undefined;
|
|
1583
1423
|
} | undefined;
|
|
1424
|
+
}, {
|
|
1425
|
+
exclude?: string[] | undefined;
|
|
1426
|
+
ignore?: string | string[] | undefined;
|
|
1427
|
+
include?: string[] | undefined;
|
|
1428
|
+
entry?: string | string[] | undefined;
|
|
1429
|
+
project?: string | string[] | undefined;
|
|
1430
|
+
paths?: Record<string, string[]> | undefined;
|
|
1431
|
+
ignoreBinaries?: string[] | undefined;
|
|
1432
|
+
ignoreDependencies?: string[] | undefined;
|
|
1433
|
+
ignoreWorkspaces?: string[] | undefined;
|
|
1584
1434
|
workspaces?: Record<string, {
|
|
1585
1435
|
ignore?: string | string[] | undefined;
|
|
1586
1436
|
entry?: string | string[] | undefined;
|
|
@@ -1737,4 +1587,154 @@ export declare const ConfigurationValidator: z.ZodObject<{
|
|
|
1737
1587
|
project?: string | string[] | undefined;
|
|
1738
1588
|
} | undefined;
|
|
1739
1589
|
}> | undefined;
|
|
1590
|
+
babel?: string | false | string[] | {
|
|
1591
|
+
config?: string | string[] | undefined;
|
|
1592
|
+
entry?: string | string[] | undefined;
|
|
1593
|
+
project?: string | string[] | undefined;
|
|
1594
|
+
} | undefined;
|
|
1595
|
+
capacitor?: string | false | string[] | {
|
|
1596
|
+
config?: string | string[] | undefined;
|
|
1597
|
+
entry?: string | string[] | undefined;
|
|
1598
|
+
project?: string | string[] | undefined;
|
|
1599
|
+
} | undefined;
|
|
1600
|
+
changesets?: string | false | string[] | {
|
|
1601
|
+
config?: string | string[] | undefined;
|
|
1602
|
+
entry?: string | string[] | undefined;
|
|
1603
|
+
project?: string | string[] | undefined;
|
|
1604
|
+
} | undefined;
|
|
1605
|
+
commitlint?: string | false | string[] | {
|
|
1606
|
+
config?: string | string[] | undefined;
|
|
1607
|
+
entry?: string | string[] | undefined;
|
|
1608
|
+
project?: string | string[] | undefined;
|
|
1609
|
+
} | undefined;
|
|
1610
|
+
cypress?: string | false | string[] | {
|
|
1611
|
+
config?: string | string[] | undefined;
|
|
1612
|
+
entry?: string | string[] | undefined;
|
|
1613
|
+
project?: string | string[] | undefined;
|
|
1614
|
+
} | undefined;
|
|
1615
|
+
eslint?: string | false | string[] | {
|
|
1616
|
+
config?: string | string[] | undefined;
|
|
1617
|
+
entry?: string | string[] | undefined;
|
|
1618
|
+
project?: string | string[] | undefined;
|
|
1619
|
+
} | undefined;
|
|
1620
|
+
gatsby?: string | false | string[] | {
|
|
1621
|
+
config?: string | string[] | undefined;
|
|
1622
|
+
entry?: string | string[] | undefined;
|
|
1623
|
+
project?: string | string[] | undefined;
|
|
1624
|
+
} | undefined;
|
|
1625
|
+
'github-actions'?: string | false | string[] | {
|
|
1626
|
+
config?: string | string[] | undefined;
|
|
1627
|
+
entry?: string | string[] | undefined;
|
|
1628
|
+
project?: string | string[] | undefined;
|
|
1629
|
+
} | undefined;
|
|
1630
|
+
husky?: string | false | string[] | {
|
|
1631
|
+
config?: string | string[] | undefined;
|
|
1632
|
+
entry?: string | string[] | undefined;
|
|
1633
|
+
project?: string | string[] | undefined;
|
|
1634
|
+
} | undefined;
|
|
1635
|
+
jest?: string | false | string[] | {
|
|
1636
|
+
config?: string | string[] | undefined;
|
|
1637
|
+
entry?: string | string[] | undefined;
|
|
1638
|
+
project?: string | string[] | undefined;
|
|
1639
|
+
} | undefined;
|
|
1640
|
+
'lint-staged'?: string | false | string[] | {
|
|
1641
|
+
config?: string | string[] | undefined;
|
|
1642
|
+
entry?: string | string[] | undefined;
|
|
1643
|
+
project?: string | string[] | undefined;
|
|
1644
|
+
} | undefined;
|
|
1645
|
+
markdownlint?: string | false | string[] | {
|
|
1646
|
+
config?: string | string[] | undefined;
|
|
1647
|
+
entry?: string | string[] | undefined;
|
|
1648
|
+
project?: string | string[] | undefined;
|
|
1649
|
+
} | undefined;
|
|
1650
|
+
mocha?: string | false | string[] | {
|
|
1651
|
+
config?: string | string[] | undefined;
|
|
1652
|
+
entry?: string | string[] | undefined;
|
|
1653
|
+
project?: string | string[] | undefined;
|
|
1654
|
+
} | undefined;
|
|
1655
|
+
next?: string | false | string[] | {
|
|
1656
|
+
config?: string | string[] | undefined;
|
|
1657
|
+
entry?: string | string[] | undefined;
|
|
1658
|
+
project?: string | string[] | undefined;
|
|
1659
|
+
} | undefined;
|
|
1660
|
+
'npm-package-json-lint'?: string | false | string[] | {
|
|
1661
|
+
config?: string | string[] | undefined;
|
|
1662
|
+
entry?: string | string[] | undefined;
|
|
1663
|
+
project?: string | string[] | undefined;
|
|
1664
|
+
} | undefined;
|
|
1665
|
+
nx?: string | false | string[] | {
|
|
1666
|
+
config?: string | string[] | undefined;
|
|
1667
|
+
entry?: string | string[] | undefined;
|
|
1668
|
+
project?: string | string[] | undefined;
|
|
1669
|
+
} | undefined;
|
|
1670
|
+
nyc?: string | false | string[] | {
|
|
1671
|
+
config?: string | string[] | undefined;
|
|
1672
|
+
entry?: string | string[] | undefined;
|
|
1673
|
+
project?: string | string[] | undefined;
|
|
1674
|
+
} | undefined;
|
|
1675
|
+
playwright?: string | false | string[] | {
|
|
1676
|
+
config?: string | string[] | undefined;
|
|
1677
|
+
entry?: string | string[] | undefined;
|
|
1678
|
+
project?: string | string[] | undefined;
|
|
1679
|
+
} | undefined;
|
|
1680
|
+
postcss?: string | false | string[] | {
|
|
1681
|
+
config?: string | string[] | undefined;
|
|
1682
|
+
entry?: string | string[] | undefined;
|
|
1683
|
+
project?: string | string[] | undefined;
|
|
1684
|
+
} | undefined;
|
|
1685
|
+
prettier?: string | false | string[] | {
|
|
1686
|
+
config?: string | string[] | undefined;
|
|
1687
|
+
entry?: string | string[] | undefined;
|
|
1688
|
+
project?: string | string[] | undefined;
|
|
1689
|
+
} | undefined;
|
|
1690
|
+
'release-it'?: string | false | string[] | {
|
|
1691
|
+
config?: string | string[] | undefined;
|
|
1692
|
+
entry?: string | string[] | undefined;
|
|
1693
|
+
project?: string | string[] | undefined;
|
|
1694
|
+
} | undefined;
|
|
1695
|
+
remark?: string | false | string[] | {
|
|
1696
|
+
config?: string | string[] | undefined;
|
|
1697
|
+
entry?: string | string[] | undefined;
|
|
1698
|
+
project?: string | string[] | undefined;
|
|
1699
|
+
} | undefined;
|
|
1700
|
+
remix?: string | false | string[] | {
|
|
1701
|
+
config?: string | string[] | undefined;
|
|
1702
|
+
entry?: string | string[] | undefined;
|
|
1703
|
+
project?: string | string[] | undefined;
|
|
1704
|
+
} | undefined;
|
|
1705
|
+
rollup?: string | false | string[] | {
|
|
1706
|
+
config?: string | string[] | undefined;
|
|
1707
|
+
entry?: string | string[] | undefined;
|
|
1708
|
+
project?: string | string[] | undefined;
|
|
1709
|
+
} | undefined;
|
|
1710
|
+
sentry?: string | false | string[] | {
|
|
1711
|
+
config?: string | string[] | undefined;
|
|
1712
|
+
entry?: string | string[] | undefined;
|
|
1713
|
+
project?: string | string[] | undefined;
|
|
1714
|
+
} | undefined;
|
|
1715
|
+
storybook?: string | false | string[] | {
|
|
1716
|
+
config?: string | string[] | undefined;
|
|
1717
|
+
entry?: string | string[] | undefined;
|
|
1718
|
+
project?: string | string[] | undefined;
|
|
1719
|
+
} | undefined;
|
|
1720
|
+
stryker?: string | false | string[] | {
|
|
1721
|
+
config?: string | string[] | undefined;
|
|
1722
|
+
entry?: string | string[] | undefined;
|
|
1723
|
+
project?: string | string[] | undefined;
|
|
1724
|
+
} | undefined;
|
|
1725
|
+
typescript?: string | false | string[] | {
|
|
1726
|
+
config?: string | string[] | undefined;
|
|
1727
|
+
entry?: string | string[] | undefined;
|
|
1728
|
+
project?: string | string[] | undefined;
|
|
1729
|
+
} | undefined;
|
|
1730
|
+
vitest?: string | false | string[] | {
|
|
1731
|
+
config?: string | string[] | undefined;
|
|
1732
|
+
entry?: string | string[] | undefined;
|
|
1733
|
+
project?: string | string[] | undefined;
|
|
1734
|
+
} | undefined;
|
|
1735
|
+
webpack?: string | false | string[] | {
|
|
1736
|
+
config?: string | string[] | undefined;
|
|
1737
|
+
entry?: string | string[] | undefined;
|
|
1738
|
+
project?: string | string[] | undefined;
|
|
1739
|
+
} | undefined;
|
|
1740
1740
|
}>;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { ESLintConfig } from './types.js';
|
|
2
|
-
|
|
2
|
+
import type { PackageJson } from 'type-fest';
|
|
3
|
+
type Manifest = PackageJson & {
|
|
4
|
+
eslintConfig?: ESLintConfig;
|
|
5
|
+
};
|
|
6
|
+
type GetDependenciesDeep = (configFilePath: string, dependencies: Set<string>, options: {
|
|
7
|
+
cwd: string;
|
|
8
|
+
manifest: Manifest;
|
|
9
|
+
}) => Promise<Set<string>>;
|
|
10
|
+
export declare const getDependenciesDeep: GetDependenciesDeep;
|
|
3
11
|
export declare const resolvePluginPackageName: (pluginName: string) => string;
|
|
4
12
|
export declare const getDependenciesFromSettings: (settings?: ESLintConfig['settings']) => string[];
|
|
13
|
+
export {};
|
|
@@ -2,8 +2,9 @@ import path from 'node:path';
|
|
|
2
2
|
import { compact } from '../../util/array.js';
|
|
3
3
|
import { _load } from '../../util/loader.js';
|
|
4
4
|
import { getPackageName } from '../../util/modules.js';
|
|
5
|
-
import { isAbsolute } from '../../util/path.js';
|
|
5
|
+
import { isAbsolute, isInNodeModules } from '../../util/path.js';
|
|
6
6
|
import { require } from '../../util/require.js';
|
|
7
|
+
import { fallback } from './fallback.js';
|
|
7
8
|
const getDependencies = (config) => {
|
|
8
9
|
const extend = config.extends ? [config.extends].flat().map(customResolvePluginPackageNames) : [];
|
|
9
10
|
if (extend.includes('eslint-plugin-prettier'))
|
|
@@ -12,25 +13,40 @@ const getDependencies = (config) => {
|
|
|
12
13
|
const parser = config.parser;
|
|
13
14
|
const extraParsers = config.parserOptions?.babelOptions?.presets ?? [];
|
|
14
15
|
const settings = config.settings ? getDependenciesFromSettings(config.settings) : [];
|
|
15
|
-
return compact([...extend, ...plugins, parser, ...extraParsers, ...settings])
|
|
16
|
+
return compact([...extend, ...plugins, parser, ...extraParsers, ...settings]);
|
|
16
17
|
};
|
|
17
|
-
export const getDependenciesDeep = async (configFilePath, dependencies = new Set()) => {
|
|
18
|
+
export const getDependenciesDeep = async (configFilePath, dependencies = new Set(), options) => {
|
|
18
19
|
const addAll = (deps) => deps.forEach(dependency => dependencies.add(dependency));
|
|
19
|
-
|
|
20
|
-
if (config
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
let config = configFilePath.endsWith('package.json') ? options.manifest.eslintConfig : undefined;
|
|
21
|
+
if (!config) {
|
|
22
|
+
try {
|
|
23
|
+
config = await _load(configFilePath);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
if (err instanceof Error && err.cause instanceof Error && /Failed to patch ESLint/.test(err.cause.message)) {
|
|
27
|
+
const dependencies = await fallback(configFilePath, options);
|
|
28
|
+
addAll(dependencies);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw err;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (config) {
|
|
36
|
+
if (config.extends) {
|
|
37
|
+
for (const extend of [config.extends].flat()) {
|
|
38
|
+
if (extend.startsWith('.') || (isAbsolute(extend) && !isInNodeModules(extend))) {
|
|
39
|
+
const filePath = isAbsolute(extend) ? extend : path.join(path.dirname(configFilePath), extend);
|
|
40
|
+
const extendConfigFilePath = require.resolve(filePath);
|
|
41
|
+
addAll(await getDependenciesDeep(extendConfigFilePath, dependencies, options));
|
|
42
|
+
}
|
|
27
43
|
}
|
|
28
44
|
}
|
|
45
|
+
if (config.overrides)
|
|
46
|
+
for (const override of [config.overrides].flat())
|
|
47
|
+
addAll(getDependencies(override));
|
|
48
|
+
addAll(getDependencies(config));
|
|
29
49
|
}
|
|
30
|
-
if (config.overrides)
|
|
31
|
-
for (const override of config.overrides)
|
|
32
|
-
addAll(getDependencies(override));
|
|
33
|
-
addAll(getDependencies(config));
|
|
34
50
|
return dependencies;
|
|
35
51
|
};
|
|
36
52
|
const resolvePackageName = (namespace, pluginName) => {
|
|
@@ -42,7 +58,7 @@ const resolvePackageName = (namespace, pluginName) => {
|
|
|
42
58
|
};
|
|
43
59
|
export const resolvePluginPackageName = (pluginName) => resolvePackageName('eslint-plugin', pluginName);
|
|
44
60
|
const customResolvePluginPackageNames = (extend) => {
|
|
45
|
-
if (extend
|
|
61
|
+
if (isInNodeModules(extend))
|
|
46
62
|
return getPackageName(extend);
|
|
47
63
|
if (isAbsolute(extend) || extend.startsWith('.'))
|
|
48
64
|
return;
|
|
@@ -52,7 +68,7 @@ const customResolvePluginPackageNames = (extend) => {
|
|
|
52
68
|
return;
|
|
53
69
|
return resolvePackageName('eslint-plugin', pluginName);
|
|
54
70
|
}
|
|
55
|
-
return extend.includes('eslint') ?
|
|
71
|
+
return extend.includes('eslint') ? extend : resolvePackageName('eslint-config', extend);
|
|
56
72
|
};
|
|
57
73
|
const getImportPluginDependencies = (settings) => {
|
|
58
74
|
const knownKeys = ['typescript'];
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { _load } from '../../util/loader.js';
|
|
2
1
|
import { timerify } from '../../util/performance.js';
|
|
3
2
|
import { hasDependency } from '../../util/plugin.js';
|
|
4
|
-
import { fallback } from './fallback.js';
|
|
5
3
|
import { getDependenciesDeep } from './helpers.js';
|
|
6
4
|
export const NAME = 'ESLint';
|
|
7
5
|
export const ENABLERS = ['eslint'];
|
|
@@ -9,21 +7,7 @@ export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABL
|
|
|
9
7
|
export const CONFIG_FILE_PATTERNS = ['.eslintrc', '.eslintrc.{js,json,cjs}', '.eslintrc.{yml,yaml}', 'package.json'];
|
|
10
8
|
export const ENTRY_FILE_PATTERNS = ['eslint.config.js'];
|
|
11
9
|
const findESLintDependencies = async (configFilePath, { cwd, manifest }) => {
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
config = configFilePath.endsWith('package.json') ? manifest.eslintConfig : await _load(configFilePath);
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
if (error instanceof Error && error.cause instanceof Error && /Failed to patch ESLint/.test(error.cause.message)) {
|
|
18
|
-
return fallback(configFilePath, { cwd });
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
throw error;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (!config)
|
|
25
|
-
return [];
|
|
26
|
-
const dependencies = await getDependenciesDeep(configFilePath);
|
|
10
|
+
const dependencies = await getDependenciesDeep(configFilePath, new Set(), { cwd, manifest });
|
|
27
11
|
return Array.from(dependencies);
|
|
28
12
|
};
|
|
29
13
|
export const findDependencies = timerify(findESLintDependencies);
|
|
@@ -10,13 +10,15 @@ export const ENABLERS = ['jest'];
|
|
|
10
10
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
11
11
|
export const CONFIG_FILE_PATTERNS = ['jest.config.{js,ts,mjs,cjs,json}'];
|
|
12
12
|
export const ENTRY_FILE_PATTERNS = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'];
|
|
13
|
+
const join = (base, id) => (isAbsolute(id) ? id : path.join(path.dirname(base), id));
|
|
13
14
|
const resolveExtensibleConfig = async (configFilePath) => {
|
|
14
15
|
const config = await _load(configFilePath);
|
|
15
16
|
if (config?.preset) {
|
|
16
17
|
const { preset } = config;
|
|
17
18
|
if (preset.startsWith('.') || isAbsolute(preset)) {
|
|
18
|
-
const presetConfigPath =
|
|
19
|
+
const presetConfigPath = join(configFilePath, preset);
|
|
19
20
|
const presetConfig = await resolveExtensibleConfig(presetConfigPath);
|
|
21
|
+
delete config.preset;
|
|
20
22
|
Object.assign(config, presetConfig);
|
|
21
23
|
}
|
|
22
24
|
}
|
|
@@ -30,11 +32,8 @@ const findJestDependencies = async (configFilePath, { cwd }) => {
|
|
|
30
32
|
const entryFiles = [];
|
|
31
33
|
const handleEntries = (name) => {
|
|
32
34
|
name = name.includes('<rootDir>') ? path.join(cwd, name.replace(/^.*<rootDir>/, '')) : name;
|
|
33
|
-
if (name.startsWith('.')) {
|
|
34
|
-
entryFiles.push(require.resolve(
|
|
35
|
-
}
|
|
36
|
-
else if (isAbsolute(name)) {
|
|
37
|
-
entryFiles.push(name);
|
|
35
|
+
if (name.startsWith('.') || isAbsolute(name)) {
|
|
36
|
+
entryFiles.push(require.resolve(join(configFilePath, name)));
|
|
38
37
|
}
|
|
39
38
|
else {
|
|
40
39
|
dependencies.push(name);
|
|
@@ -12,6 +12,6 @@ export const CONFIG_FILE_PATTERNS = [
|
|
|
12
12
|
];
|
|
13
13
|
const findPluginDependencies = async (configFilePath) => {
|
|
14
14
|
const config = await _load(configFilePath);
|
|
15
|
-
return config?.
|
|
15
|
+
return config?.plugin ?? [];
|
|
16
16
|
};
|
|
17
17
|
export const findDependencies = timerify(findPluginDependencies);
|
package/dist/util/debug.js
CHANGED
|
@@ -3,12 +3,13 @@ import parsedArgs from './cli-arguments.js';
|
|
|
3
3
|
const { debug, 'debug-file-filter': debugFileFilter } = parsedArgs.values;
|
|
4
4
|
const IS_ENABLED = debug ?? false;
|
|
5
5
|
const FILE_FILTER = debugFileFilter;
|
|
6
|
-
const
|
|
6
|
+
const inspectOptions = { maxArrayLength: null, depth: null, colors: true };
|
|
7
|
+
const logArray = (collection) => console.log(util.inspect(collection.sort(), inspectOptions));
|
|
7
8
|
export const debugLogObject = (name, obj) => {
|
|
8
9
|
if (!IS_ENABLED)
|
|
9
10
|
return;
|
|
10
11
|
console.log(`[knip] ${name}`);
|
|
11
|
-
console.log(util.inspect(obj,
|
|
12
|
+
console.log(util.inspect(obj, inspectOptions));
|
|
12
13
|
};
|
|
13
14
|
export const debugLogFiles = (name, filePaths) => {
|
|
14
15
|
if (!IS_ENABLED)
|
package/dist/util/path.d.ts
CHANGED
package/dist/util/path.js
CHANGED
|
@@ -3,3 +3,4 @@ const cwd = process.cwd();
|
|
|
3
3
|
export const toPosixPath = (value) => value.split(path.sep).join(path.posix.sep);
|
|
4
4
|
export const relativePosix = (from, to) => toPosixPath(path.relative(to ? from : cwd, to ?? from));
|
|
5
5
|
export const isAbsolute = (value) => /^(\/|[A-Z]:)/.test(value);
|
|
6
|
+
export const isInNodeModules = (filePath) => filePath.includes('/node_modules/');
|
package/dist/util/workspace.js
CHANGED
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.14.
|
|
1
|
+
export declare const version = "1.14.2";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.14.
|
|
1
|
+
export const version = '1.14.2';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knip",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.2",
|
|
4
4
|
"description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
|
|
5
5
|
"homepage": "https://github.com/webpro/knip",
|
|
6
6
|
"repository": "github:webpro/knip",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"bash-parser": "^0.5.0",
|
|
46
46
|
"chalk": "^5.2.0",
|
|
47
47
|
"easy-table": "^1.2.0",
|
|
48
|
-
"esbuild": "^0.17.
|
|
48
|
+
"esbuild": "^0.17.11",
|
|
49
49
|
"esbuild-register": "3.4.2",
|
|
50
50
|
"fast-glob": "^3.2.12",
|
|
51
51
|
"get-tsconfig": "^4.4.0",
|
|
@@ -60,27 +60,27 @@
|
|
|
60
60
|
"summary": "^2.1.0",
|
|
61
61
|
"ts-morph": "^17.0.1",
|
|
62
62
|
"ts-morph-helpers": "^0.6.3",
|
|
63
|
-
"zod": "^3.
|
|
63
|
+
"zod": "^3.21.4"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@jest/types": "29.
|
|
66
|
+
"@jest/types": "29.5.0",
|
|
67
67
|
"@npmcli/package-json": "3.0.0",
|
|
68
68
|
"@release-it/bumper": "4.0.2",
|
|
69
69
|
"@types/eslint": "8.21.1",
|
|
70
70
|
"@types/js-yaml": "4.0.5",
|
|
71
71
|
"@types/micromatch": "4.0.2",
|
|
72
72
|
"@types/minimist": "1.2.2",
|
|
73
|
-
"@types/node": "18.14.
|
|
73
|
+
"@types/node": "18.14.6",
|
|
74
74
|
"@types/npmcli__map-workspaces": "3.0.0",
|
|
75
75
|
"@types/webpack": "5.28.0",
|
|
76
|
-
"@typescript-eslint/eslint-plugin": "5.54.
|
|
77
|
-
"@typescript-eslint/parser": "5.54.
|
|
76
|
+
"@typescript-eslint/eslint-plugin": "5.54.1",
|
|
77
|
+
"@typescript-eslint/parser": "5.54.1",
|
|
78
78
|
"eslint": "8.35.0",
|
|
79
79
|
"eslint-import-resolver-typescript": "3.5.3",
|
|
80
80
|
"eslint-plugin-import": "2.27.5",
|
|
81
81
|
"globstar": "1.0.0",
|
|
82
82
|
"prettier": "2.8.4",
|
|
83
|
-
"release-it": "^15.
|
|
83
|
+
"release-it": "^15.7.0",
|
|
84
84
|
"remark-cli": "11.0.0",
|
|
85
85
|
"remark-preset-webpro": "0.0.1",
|
|
86
86
|
"tsx": "3.12.3",
|