knip 5.72.0 → 5.73.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.
@@ -327,6 +327,16 @@ export declare class ConfigurationChief {
327
327
  entry?: string | string[] | undefined;
328
328
  project?: string | string[] | undefined;
329
329
  } | undefined;
330
+ 'next-intl'?: string | boolean | string[] | {
331
+ config?: string | string[] | undefined;
332
+ entry?: string | string[] | undefined;
333
+ project?: string | string[] | undefined;
334
+ } | undefined;
335
+ 'next-mdx'?: string | boolean | string[] | {
336
+ config?: string | string[] | undefined;
337
+ entry?: string | string[] | undefined;
338
+ project?: string | string[] | undefined;
339
+ } | undefined;
330
340
  node?: string | boolean | string[] | {
331
341
  config?: string | string[] | undefined;
332
342
  entry?: string | string[] | undefined;
@@ -728,6 +738,8 @@ export declare class ConfigurationChief {
728
738
  nest?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
729
739
  netlify?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
730
740
  next?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
741
+ "next-intl"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
742
+ "next-mdx"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
731
743
  "node-modules-inspector"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
732
744
  nodemon?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
733
745
  "npm-package-json-lint"?: (boolean | import("./types/config.js").EnsuredPluginConfiguration) | undefined;
@@ -279,6 +279,16 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
279
279
  entry?: string | string[] | undefined;
280
280
  project?: string | string[] | undefined;
281
281
  } | undefined;
282
+ 'next-intl'?: string | boolean | string[] | {
283
+ config?: string | string[] | undefined;
284
+ entry?: string | string[] | undefined;
285
+ project?: string | string[] | undefined;
286
+ } | undefined;
287
+ 'next-mdx'?: string | boolean | string[] | {
288
+ config?: string | string[] | undefined;
289
+ entry?: string | string[] | undefined;
290
+ project?: string | string[] | undefined;
291
+ } | undefined;
282
292
  node?: string | boolean | string[] | {
283
293
  config?: string | string[] | undefined;
284
294
  entry?: string | string[] | undefined;
@@ -880,6 +890,16 @@ export declare const partitionCompilers: (rawLocalConfig: RawConfiguration) => {
880
890
  entry?: string | string[] | undefined;
881
891
  project?: string | string[] | undefined;
882
892
  } | undefined;
893
+ 'next-intl'?: string | boolean | string[] | {
894
+ config?: string | string[] | undefined;
895
+ entry?: string | string[] | undefined;
896
+ project?: string | string[] | undefined;
897
+ } | undefined;
898
+ 'next-mdx'?: string | boolean | string[] | {
899
+ config?: string | string[] | undefined;
900
+ entry?: string | string[] | undefined;
901
+ project?: string | string[] | undefined;
902
+ } | undefined;
883
903
  node?: string | boolean | string[] | {
884
904
  config?: string | string[] | undefined;
885
905
  entry?: string | string[] | undefined;
package/dist/constants.js CHANGED
@@ -34,6 +34,7 @@ export const IGNORED_GLOBAL_BINARIES = new Set([
34
34
  'chmod',
35
35
  'chown',
36
36
  'cksum',
37
+ 'clear',
37
38
  'cmd',
38
39
  'comm',
39
40
  'command',
@@ -54,6 +54,8 @@ export declare const Plugins: {
54
54
  nest: import("../types/config.js").Plugin;
55
55
  netlify: import("../types/config.js").Plugin;
56
56
  next: import("../types/config.js").Plugin;
57
+ 'next-intl': import("../types/config.js").Plugin;
58
+ 'next-mdx': import("../types/config.js").Plugin;
57
59
  node: import("../types/config.js").Plugin;
58
60
  'node-modules-inspector': import("../types/config.js").Plugin;
59
61
  nodemon: import("../types/config.js").Plugin;
@@ -53,6 +53,8 @@ import { default as nanoStaged } from './nano-staged/index.js';
53
53
  import { default as nest } from './nest/index.js';
54
54
  import { default as netlify } from './netlify/index.js';
55
55
  import { default as next } from './next/index.js';
56
+ import { default as nextIntl } from './next-intl/index.js';
57
+ import { default as nextMdx } from './next-mdx/index.js';
56
58
  import { default as node } from './node/index.js';
57
59
  import { default as nodeModulesInspector } from './node-modules-inspector/index.js';
58
60
  import { default as nodemon } from './nodemon/index.js';
@@ -174,6 +176,8 @@ export const Plugins = {
174
176
  nest,
175
177
  netlify,
176
178
  next,
179
+ 'next-intl': nextIntl,
180
+ 'next-mdx': nextMdx,
177
181
  node,
178
182
  'node-modules-inspector': nodeModulesInspector,
179
183
  nodemon,
@@ -1,6 +1,6 @@
1
- import { toDependency, toProductionEntry } from '../../util/input.js';
1
+ import { toProductionEntry } from '../../util/input.js';
2
2
  import { hasDependency } from '../../util/plugin.js';
3
- import { getMdxPlugins, getPageExtensions } from './resolveFromAST.js';
3
+ import { getPageExtensions } from './resolveFromAST.js';
4
4
  const title = 'Next.js';
5
5
  const enablers = ['next'];
6
6
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
@@ -12,7 +12,6 @@ const productionEntryFilePatterns = [
12
12
  'app/**/sitemap.{js,ts}',
13
13
  'app/**/{icon,apple-icon}.{js,jsx,ts,tsx}',
14
14
  'app/**/{opengraph,twitter}-image.{js,jsx,ts,tsx}',
15
- 'mdx-components.{js,jsx,ts,tsx}',
16
15
  ];
17
16
  const getEntryFilePatterns = (pageExtensions = defaultPageExtensions) => {
18
17
  const patterns = [...productionEntryFilePatterns];
@@ -26,8 +25,7 @@ const resolveFromAST = sourceFile => {
26
25
  const pageExtensions = getPageExtensions(sourceFile);
27
26
  const extensions = pageExtensions.length > 0 ? pageExtensions : defaultPageExtensions;
28
27
  const patterns = getEntryFilePatterns(extensions);
29
- const mdxPlugins = getMdxPlugins(sourceFile);
30
- return [...patterns.map(id => toProductionEntry(id)), ...Array.from(mdxPlugins).map(id => toDependency(id))];
28
+ return patterns.map(id => toProductionEntry(id));
31
29
  };
32
30
  const plugin = {
33
31
  title,
@@ -1,3 +1,2 @@
1
1
  import ts from 'typescript';
2
2
  export declare const getPageExtensions: (sourceFile: ts.SourceFile) => string[];
3
- export declare const getMdxPlugins: (sourceFile: ts.SourceFile) => Set<string>;
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import { getDefaultImportName, getImportMap, getPropertyValues, stripQuotes } from '../../typescript/ast-helpers.js';
2
+ import { getPropertyValues } from '../../typescript/ast-helpers.js';
3
3
  export const getPageExtensions = (sourceFile) => {
4
4
  const pageExtensions = new Set();
5
5
  function visit(node) {
@@ -13,44 +13,3 @@ export const getPageExtensions = (sourceFile) => {
13
13
  visit(sourceFile);
14
14
  return Array.from(pageExtensions);
15
15
  };
16
- const isNamedProp = (prop, name) => ts.isPropertyAssignment(prop) && prop.name.getText() === name;
17
- export const getMdxPlugins = (sourceFile) => {
18
- const plugins = new Set();
19
- const importMap = getImportMap(sourceFile);
20
- const mdxImportName = getDefaultImportName(importMap, '@next/mdx');
21
- if (!mdxImportName)
22
- return plugins;
23
- function visit(node) {
24
- if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === mdxImportName) {
25
- if (node.arguments.length > 0 && ts.isObjectLiteralExpression(node.arguments[0])) {
26
- const options = node.arguments[0]?.properties.find(prop => isNamedProp(prop, 'options'));
27
- if (options && ts.isPropertyAssignment(options)) {
28
- if (ts.isObjectLiteralExpression(options.initializer)) {
29
- for (const pluginType of ['remarkPlugins', 'rehypePlugins', 'recmaPlugins']) {
30
- const props = options.initializer.properties.find(prop => isNamedProp(prop, pluginType));
31
- if (props && ts.isPropertyAssignment(props)) {
32
- if (ts.isArrayLiteralExpression(props.initializer)) {
33
- for (const element of props.initializer.elements) {
34
- if (ts.isStringLiteral(element)) {
35
- plugins.add(stripQuotes(element.text));
36
- }
37
- else if (ts.isArrayLiteralExpression(element) && element.elements.length > 0) {
38
- const firstElement = element.elements[0];
39
- if (ts.isStringLiteral(firstElement)) {
40
- plugins.add(stripQuotes(firstElement.text));
41
- }
42
- }
43
- }
44
- }
45
- }
46
- }
47
- }
48
- }
49
- }
50
- return true;
51
- }
52
- return ts.forEachChild(node, visit) ?? false;
53
- }
54
- visit(sourceFile);
55
- return plugins;
56
- };
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.js';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,12 @@
1
+ import { hasDependency } from '../../util/plugin.js';
2
+ const title = 'next-intl';
3
+ const enablers = ['next-intl'];
4
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
5
+ const production = ['{src/,}i18n/request.{js,jsx,ts,tsx}'];
6
+ const plugin = {
7
+ title,
8
+ enablers,
9
+ isEnabled,
10
+ production,
11
+ };
12
+ export default plugin;
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '../../types/config.js';
2
+ declare const plugin: Plugin;
3
+ export default plugin;
@@ -0,0 +1,21 @@
1
+ import { toDependency, toProductionEntry } from '../../util/input.js';
2
+ import { hasDependency } from '../../util/plugin.js';
3
+ import { getMdxPlugins } from './resolveFromAST.js';
4
+ const title = 'Next.js MDX';
5
+ const enablers = ['@next/mdx'];
6
+ const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
7
+ const config = ['next.config.{js,ts,cjs,mjs}'];
8
+ const production = ['{src/,}mdx-components.{js,jsx,ts,tsx}'];
9
+ const resolveFromAST = sourceFile => {
10
+ const mdxPlugins = getMdxPlugins(sourceFile);
11
+ return [...production.map(id => toProductionEntry(id)), ...Array.from(mdxPlugins).map(id => toDependency(id))];
12
+ };
13
+ const plugin = {
14
+ title,
15
+ enablers,
16
+ isEnabled,
17
+ config,
18
+ production,
19
+ resolveFromAST,
20
+ };
21
+ export default plugin;
@@ -0,0 +1,2 @@
1
+ import ts from 'typescript';
2
+ export declare const getMdxPlugins: (sourceFile: ts.SourceFile) => Set<string>;
@@ -0,0 +1,43 @@
1
+ import ts from 'typescript';
2
+ import { getDefaultImportName, getImportMap, stripQuotes } from '../../typescript/ast-helpers.js';
3
+ const isNamedProp = (prop, name) => ts.isPropertyAssignment(prop) && prop.name.getText() === name;
4
+ export const getMdxPlugins = (sourceFile) => {
5
+ const plugins = new Set();
6
+ const importMap = getImportMap(sourceFile);
7
+ const mdxImportName = getDefaultImportName(importMap, '@next/mdx');
8
+ if (!mdxImportName)
9
+ return plugins;
10
+ function visit(node) {
11
+ if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === mdxImportName) {
12
+ if (node.arguments.length > 0 && ts.isObjectLiteralExpression(node.arguments[0])) {
13
+ const options = node.arguments[0]?.properties.find(prop => isNamedProp(prop, 'options'));
14
+ if (options && ts.isPropertyAssignment(options)) {
15
+ if (ts.isObjectLiteralExpression(options.initializer)) {
16
+ for (const pluginType of ['remarkPlugins', 'rehypePlugins', 'recmaPlugins']) {
17
+ const props = options.initializer.properties.find(prop => isNamedProp(prop, pluginType));
18
+ if (props && ts.isPropertyAssignment(props)) {
19
+ if (ts.isArrayLiteralExpression(props.initializer)) {
20
+ for (const element of props.initializer.elements) {
21
+ if (ts.isStringLiteral(element)) {
22
+ plugins.add(stripQuotes(element.text));
23
+ }
24
+ else if (ts.isArrayLiteralExpression(element) && element.elements.length > 0) {
25
+ const firstElement = element.elements[0];
26
+ if (ts.isStringLiteral(firstElement)) {
27
+ plugins.add(stripQuotes(firstElement.text));
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
37
+ return true;
38
+ }
39
+ return ts.forEachChild(node, visit) ?? false;
40
+ }
41
+ visit(sourceFile);
42
+ return plugins;
43
+ };
@@ -277,6 +277,16 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
277
277
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
278
278
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
279
279
  }, z.core.$strip>]>>;
280
+ 'next-intl': z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
281
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
282
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
283
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
284
+ }, z.core.$strip>]>>;
285
+ 'next-mdx': z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
286
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
287
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
288
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
289
+ }, z.core.$strip>]>>;
280
290
  node: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
281
291
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
282
292
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -878,6 +888,16 @@ export declare const knipConfigurationSchema: z.ZodMiniObject<{
878
888
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
879
889
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
880
890
  }, z.core.$strip>]>>;
891
+ 'next-intl': z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
892
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
893
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
894
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
895
+ }, z.core.$strip>]>>;
896
+ 'next-mdx': z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
897
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
898
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
899
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
900
+ }, z.core.$strip>]>>;
881
901
  node: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
882
902
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
883
903
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -281,6 +281,16 @@ export declare const pluginsSchema: z.ZodMiniObject<{
281
281
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
282
282
  project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
283
283
  }, z.core.$strip>]>;
284
+ 'next-intl': z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
285
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
286
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
287
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
288
+ }, z.core.$strip>]>;
289
+ 'next-mdx': z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
290
+ config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
291
+ entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
292
+ project: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
293
+ }, z.core.$strip>]>;
284
294
  node: z.ZodMiniUnion<readonly [z.ZodMiniBoolean<boolean>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>, z.ZodMiniObject<{
285
295
  config: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
286
296
  entry: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniString<string>>]>>;
@@ -65,6 +65,8 @@ export const pluginsSchema = z.object({
65
65
  nest: pluginSchema,
66
66
  netlify: pluginSchema,
67
67
  next: pluginSchema,
68
+ 'next-intl': pluginSchema,
69
+ 'next-mdx': pluginSchema,
68
70
  node: pluginSchema,
69
71
  'node-modules-inspector': pluginSchema,
70
72
  nodemon: pluginSchema,
@@ -1,2 +1,2 @@
1
- export type PluginName = 'angular' | 'astro' | 'astro-db' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'expo' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'oxlint' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'svgo' | 'svgr' | 'syncpack' | 'tailwind' | 'taskfile' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie';
2
- export declare const pluginNames: readonly ["angular", "astro", "astro-db", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "expo", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "oxlint", "playwright", "playwright-ct", "playwright-test", "plop", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "svgo", "svgr", "syncpack", "tailwind", "taskfile", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie"];
1
+ export type PluginName = 'angular' | 'astro' | 'astro-db' | 'ava' | 'babel' | 'biome' | 'bumpp' | 'bun' | 'c8' | 'capacitor' | 'changelogen' | 'changelogithub' | 'changesets' | 'commitizen' | 'commitlint' | 'convex' | 'create-typescript-app' | 'cspell' | 'cucumber' | 'cypress' | 'danger' | 'dependency-cruiser' | 'docusaurus' | 'dotenv' | 'drizzle' | 'eleventy' | 'eslint' | 'expo' | 'gatsby' | 'github-action' | 'github-actions' | 'glob' | 'graphql-codegen' | 'hardhat' | 'husky' | 'i18next-parser' | 'jest' | 'karma' | 'ladle' | 'lefthook' | 'lint-staged' | 'linthtml' | 'lockfile-lint' | 'lost-pixel' | 'markdownlint' | 'mdx' | 'mdxlint' | 'metro' | 'mocha' | 'moonrepo' | 'msw' | 'nano-staged' | 'nest' | 'netlify' | 'next' | 'next-intl' | 'next-mdx' | 'node' | 'node-modules-inspector' | 'nodemon' | 'npm-package-json-lint' | 'nuxt' | 'nx' | 'nyc' | 'oclif' | 'oxlint' | 'playwright' | 'playwright-ct' | 'playwright-test' | 'plop' | 'pnpm' | 'postcss' | 'preconstruct' | 'prettier' | 'prisma' | 'react-cosmos' | 'react-router' | 'relay' | 'release-it' | 'remark' | 'remix' | 'rollup' | 'rsbuild' | 'rslib' | 'rspack' | 'rstest' | 'semantic-release' | 'sentry' | 'simple-git-hooks' | 'size-limit' | 'sst' | 'starlight' | 'storybook' | 'stryker' | 'stylelint' | 'svelte' | 'svgo' | 'svgr' | 'syncpack' | 'tailwind' | 'taskfile' | 'travis' | 'ts-node' | 'tsdown' | 'tsup' | 'tsx' | 'typedoc' | 'typescript' | 'unbuild' | 'unocss' | 'vercel-og' | 'vike' | 'vite' | 'vitest' | 'vue' | 'webdriver-io' | 'webpack' | 'wireit' | 'wrangler' | 'xo' | 'yarn' | 'yorkie';
2
+ export declare const pluginNames: readonly ["angular", "astro", "astro-db", "ava", "babel", "biome", "bumpp", "bun", "c8", "capacitor", "changelogen", "changelogithub", "changesets", "commitizen", "commitlint", "convex", "create-typescript-app", "cspell", "cucumber", "cypress", "danger", "dependency-cruiser", "docusaurus", "dotenv", "drizzle", "eleventy", "eslint", "expo", "gatsby", "github-action", "github-actions", "glob", "graphql-codegen", "hardhat", "husky", "i18next-parser", "jest", "karma", "ladle", "lefthook", "lint-staged", "linthtml", "lockfile-lint", "lost-pixel", "markdownlint", "mdx", "mdxlint", "metro", "mocha", "moonrepo", "msw", "nano-staged", "nest", "netlify", "next", "next-intl", "next-mdx", "node", "node-modules-inspector", "nodemon", "npm-package-json-lint", "nuxt", "nx", "nyc", "oclif", "oxlint", "playwright", "playwright-ct", "playwright-test", "plop", "pnpm", "postcss", "preconstruct", "prettier", "prisma", "react-cosmos", "react-router", "relay", "release-it", "remark", "remix", "rollup", "rsbuild", "rslib", "rspack", "rstest", "semantic-release", "sentry", "simple-git-hooks", "size-limit", "sst", "starlight", "storybook", "stryker", "stylelint", "svelte", "svgo", "svgr", "syncpack", "tailwind", "taskfile", "travis", "ts-node", "tsdown", "tsup", "tsx", "typedoc", "typescript", "unbuild", "unocss", "vercel-og", "vike", "vite", "vitest", "vue", "webdriver-io", "webpack", "wireit", "wrangler", "xo", "yarn", "yorkie"];
@@ -54,6 +54,8 @@ export const pluginNames = [
54
54
  'nest',
55
55
  'netlify',
56
56
  'next',
57
+ 'next-intl',
58
+ 'next-mdx',
57
59
  'node',
58
60
  'node-modules-inspector',
59
61
  'nodemon',
@@ -1,12 +1,13 @@
1
1
  import ts from 'typescript';
2
2
  import { IMPORT_MODIFIERS, IMPORT_STAR } from '../../../constants.js';
3
3
  import { findAncestor, findDescendants, isModuleExportsAccess, isRequireCall, isTopLevel } from '../../ast-helpers.js';
4
+ import { isNotJS } from '../helpers.js';
4
5
  import { importVisitor as visit } from '../index.js';
5
6
  export default visit(() => true, node => {
6
7
  if (isRequireCall(node)) {
7
8
  if (ts.isStringLiteralLike(node.arguments[0])) {
8
9
  const specifier = node.arguments[0].text;
9
- const modifiers = IMPORT_MODIFIERS.NONE;
10
+ const modifiers = isNotJS(node.getSourceFile()) ? IMPORT_MODIFIERS.ENTRY : IMPORT_MODIFIERS.NONE;
10
11
  if (specifier) {
11
12
  const propertyAccessExpression = findAncestor(node, _node => {
12
13
  if (ts.isExpressionStatement(_node) || ts.isCallExpression(_node))
@@ -316,6 +316,16 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
316
316
  entry?: string | string[] | undefined;
317
317
  project?: string | string[] | undefined;
318
318
  } | undefined;
319
+ 'next-intl'?: string | boolean | string[] | {
320
+ config?: string | string[] | undefined;
321
+ entry?: string | string[] | undefined;
322
+ project?: string | string[] | undefined;
323
+ } | undefined;
324
+ 'next-mdx'?: string | boolean | string[] | {
325
+ config?: string | string[] | undefined;
326
+ entry?: string | string[] | undefined;
327
+ project?: string | string[] | undefined;
328
+ } | undefined;
319
329
  node?: string | boolean | string[] | {
320
330
  config?: string | string[] | undefined;
321
331
  entry?: string | string[] | undefined;
@@ -917,6 +927,16 @@ export declare const createOptions: (options: CreateOptions) => Promise<{
917
927
  entry?: string | string[] | undefined;
918
928
  project?: string | string[] | undefined;
919
929
  } | undefined;
930
+ 'next-intl'?: string | boolean | string[] | {
931
+ config?: string | string[] | undefined;
932
+ entry?: string | string[] | undefined;
933
+ project?: string | string[] | undefined;
934
+ } | undefined;
935
+ 'next-mdx'?: string | boolean | string[] | {
936
+ config?: string | string[] | undefined;
937
+ entry?: string | string[] | undefined;
938
+ project?: string | string[] | undefined;
939
+ } | undefined;
920
940
  node?: string | boolean | string[] | {
921
941
  config?: string | string[] | undefined;
922
942
  entry?: string | string[] | undefined;
@@ -45,13 +45,17 @@ const CHAR_COLON = 58;
45
45
  const CHAR_HASH = 35;
46
46
  const CHAR_QUESTION = 63;
47
47
  export const sanitizeSpecifier = (specifier) => {
48
- if (isBuiltin(specifier) || isAbsolute(specifier) || specifier.startsWith(PROTOCOL_VIRTUAL))
48
+ if (isBuiltin(specifier) ||
49
+ isAbsolute(specifier) ||
50
+ specifier.charCodeAt(0) === CHAR_COLON ||
51
+ specifier.startsWith(PROTOCOL_VIRTUAL)) {
49
52
  return specifier;
53
+ }
50
54
  const len = specifier.length;
51
55
  let start = 0;
52
56
  let end = len;
53
57
  let colon = -1;
54
- let sawSlash = false;
58
+ let hasSlash = false;
55
59
  for (let i = 0; i < len; i++) {
56
60
  const ch = specifier.charCodeAt(i);
57
61
  if (i === start && (ch === CHAR_EXCLAMATION || ch === CHAR_DASH)) {
@@ -59,9 +63,9 @@ export const sanitizeSpecifier = (specifier) => {
59
63
  continue;
60
64
  }
61
65
  if (ch === CHAR_SLASH && colon === -1) {
62
- sawSlash = true;
66
+ hasSlash = true;
63
67
  }
64
- if (colon === -1 && ch === CHAR_COLON && !sawSlash) {
68
+ if (colon === -1 && ch === CHAR_COLON && !hasSlash) {
65
69
  colon = i;
66
70
  }
67
71
  if (ch === CHAR_EXCLAMATION || ch === CHAR_QUESTION || (ch === CHAR_HASH && i > start)) {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.72.0";
1
+ export declare const version = "5.73.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.72.0';
1
+ export const version = '5.73.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.72.0",
3
+ "version": "5.73.0",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {
package/schema.json CHANGED
@@ -554,6 +554,14 @@
554
554
  "title": "Next.js plugin configuration (https://knip.dev/reference/plugins/main)",
555
555
  "$ref": "#/definitions/plugin"
556
556
  },
557
+ "next-intl": {
558
+ "title": "next-intl plugin configuration (https://knip.dev/reference/plugins/next-intl)",
559
+ "$ref": "#/definitions/plugin"
560
+ },
561
+ "next-mdx": {
562
+ "title": "next-mdx plugin configuration (https://knip.dev/reference/plugins/next-mdx)",
563
+ "$ref": "#/definitions/plugin"
564
+ },
557
565
  "node": {
558
566
  "title": "node plugin configuration (https://knip.dev/reference/plugins/node)",
559
567
  "$ref": "#/definitions/plugin"