knip 5.37.0 → 5.37.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.
@@ -1,4 +1,5 @@
1
1
  import type { SyncCompilerFn } from './types.js';
2
- export declare const importMatcher: RegExp;
3
2
  export declare const fencedCodeBlockMatcher: RegExp;
3
+ export declare const importMatcher: RegExp;
4
4
  export declare const importsWithinScripts: SyncCompilerFn;
5
+ export declare const tsScriptBodies: SyncCompilerFn;
@@ -1,6 +1,6 @@
1
+ export const fencedCodeBlockMatcher = /```[\s\S]*?```/g;
1
2
  const scriptExtractor = /<script\b[^>]*>([\s\S]*?)<\/script>/gm;
2
3
  export const importMatcher = /import[^'"]+['"]([^'"]+)['"]/g;
3
- export const fencedCodeBlockMatcher = /```[\s\S]*?```/g;
4
4
  export const importsWithinScripts = (text) => {
5
5
  const scripts = [];
6
6
  let scriptMatch;
@@ -11,3 +11,13 @@ export const importsWithinScripts = (text) => {
11
11
  }
12
12
  return scripts.join(';\n');
13
13
  };
14
+ const tsScriptExtractor = /<script\b[^>]*lang="ts"[^>]*>(?<body>[\s\S]*?)<\/script>/gm;
15
+ export const tsScriptBodies = (text) => {
16
+ const scripts = [];
17
+ let scriptMatch;
18
+ while ((scriptMatch = tsScriptExtractor.exec(text))) {
19
+ if (scriptMatch.groups?.body)
20
+ scripts.push(scriptMatch.groups.body);
21
+ }
22
+ return scripts.join(';\n');
23
+ };
@@ -1,4 +1,4 @@
1
- import { importsWithinScripts } from './compilers.js';
1
+ import { tsScriptBodies } from './compilers.js';
2
2
  const condition = (hasDependency) => hasDependency('vue') || hasDependency('nuxt');
3
- const compiler = importsWithinScripts;
3
+ const compiler = tsScriptBodies;
4
4
  export default { condition, compiler };
@@ -1,10 +1,10 @@
1
1
  import { isBuiltin } from 'node:module';
2
2
  import ts from 'typescript';
3
- import { ALIAS_TAG, ANONYMOUS, DEFAULT_EXTENSIONS, IMPORT_STAR, PROTOCOL_VIRTUAL } from '../constants.js';
3
+ import { ALIAS_TAG, ANONYMOUS, IMPORT_STAR, PROTOCOL_VIRTUAL } from '../constants.js';
4
4
  import { timerify } from '../util/Performance.js';
5
5
  import { addNsValue, addValue, createImports } from '../util/dependency-graph.js';
6
6
  import { getPackageNameFromFilePath, isStartsLikePackageName, sanitizeSpecifier } from '../util/modules.js';
7
- import { extname, isInNodeModules } from '../util/path.js';
7
+ import { isInNodeModules } from '../util/path.js';
8
8
  import { shouldIgnore } from '../util/tag.js';
9
9
  import { getAccessMembers, getDestructuredIds, getJSDocTags, getLineAndCharacterOfPosition, getTypeName, isAccessExpression, isConsiderReferencedNS, isDestructuring, isImportSpecifier, isObjectEnumerationCallExpressionArgument, isReferencedInExport, } from './ast-helpers.js';
10
10
  import { findInternalReferences, isType } from './find-internal-references.js';
@@ -108,9 +108,8 @@ const getImportsAndExports = (sourceFile, resolveModule, typeChecker, options) =
108
108
  else if (identifier !== ANONYMOUS && identifier !== IMPORT_STAR) {
109
109
  addValue(imports.imported, identifier, sourceFile.fileName);
110
110
  }
111
- if (symbol && DEFAULT_EXTENSIONS.includes(extname(sourceFile.fileName))) {
111
+ if (symbol)
112
112
  importedInternalSymbols.set(symbol, filePath);
113
- }
114
113
  }
115
114
  };
116
115
  const addImport = (options, node) => {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.37.0";
1
+ export declare const version = "5.37.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.37.0';
1
+ export const version = '5.37.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.37.0",
3
+ "version": "5.37.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": {