knip 5.2.0 → 5.2.1

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.
@@ -46,8 +46,8 @@ export class IssueFixer {
46
46
  if (exportPositions.length > 0) {
47
47
  const sourceFileText = exportPositions.reduce((text, [start, end]) => text.substring(0, start) + text.substring(end), await readFile(filePath, 'utf-8'));
48
48
  const withoutEmptyReExports = sourceFileText
49
- .replaceAll(/export \{[ ,]+\} from ('|")[^'"]+('|");?\n?/g, '')
50
- .replaceAll(/export \{[ ,]+\};?\n?/g, '');
49
+ .replaceAll(/export \{[ ,]+\} from ('|")[^'"]+('|");?\r?\n?/g, '')
50
+ .replaceAll(/export \{[ ,]+\};?\r?\n?/g, '');
51
51
  await writeFile(filePath, withoutEmptyReExports);
52
52
  }
53
53
  }
package/dist/constants.js CHANGED
@@ -53,6 +53,7 @@ export const IGNORED_DEPENDENCIES = new Set(['knip', 'typescript']);
53
53
  export const IGNORED_RUNTIME_DEPENDENCIES = new Set(['bun']);
54
54
  export const FOREIGN_FILE_EXTENSIONS = new Set([
55
55
  '.avif',
56
+ '.css',
56
57
  '.eot',
57
58
  '.gif',
58
59
  '.html',
package/dist/index.js CHANGED
@@ -434,7 +434,7 @@ export const main = async (unresolvedConfiguration) => {
434
434
  if (getReExportingEntryFile(importsForExport, identifier))
435
435
  continue;
436
436
  }
437
- exportLookupLog(-1, `Looking up export ${identifier} from`, filePath);
437
+ exportLookupLog(-1, `Looking up ${identifier} export from`, filePath);
438
438
  if (isIdentifierReferenced(filePath, identifier, importsForExport)) {
439
439
  if (exportedItem.type === 'enum') {
440
440
  exportedItem.members?.forEach(member => {
@@ -7,8 +7,9 @@ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
7
  const config = ['package.json'];
8
8
  const entry = ['mockServiceWorker.js'];
9
9
  const resolveEntryPaths = async (localConfig) => {
10
- const workerDirectory = localConfig?.workerDirectory ?? '.';
11
- return entry.map(pattern => toEntryPattern(join(workerDirectory, pattern)));
10
+ const workerDirectory = localConfig?.workerDirectory;
11
+ const dir = workerDirectory ? [workerDirectory].flat()[0] : '.';
12
+ return entry.map(pattern => toEntryPattern(join(dir, pattern)));
12
13
  };
13
14
  export default {
14
15
  title,
@@ -92,20 +92,22 @@ export default visit(() => true, (node, { isFixExports, isFixTypes }) => {
92
92
  };
93
93
  }
94
94
  if (ts.isTypeAliasDeclaration(node)) {
95
+ const identifier = defaultKeyword ? 'default' : node.name.getText();
95
96
  const fix = isFixTypes ? [exportKeyword.getStart(), exportKeyword.getEnd() + 1] : undefined;
96
97
  return {
97
98
  node,
98
- identifier: node.name.getText(),
99
+ identifier,
99
100
  type: SymbolType.TYPE,
100
101
  pos: node.name.getStart(),
101
102
  fix,
102
103
  };
103
104
  }
104
105
  if (ts.isInterfaceDeclaration(node)) {
106
+ const identifier = defaultKeyword ? 'default' : node.name.getText();
105
107
  const fix = isFixTypes ? [exportKeyword.getStart(), exportKeyword.getEnd() + 1] : undefined;
106
108
  return {
107
109
  node,
108
- identifier: node.name.getText(),
110
+ identifier,
109
111
  type: SymbolType.INTERFACE,
110
112
  pos: node.name.getStart(),
111
113
  fix,
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.2.0";
1
+ export declare const version = "5.2.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.2.0';
1
+ export const version = '5.2.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.2.0",
3
+ "version": "5.2.1",
4
4
  "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {