knip 5.43.4 → 5.43.6

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/README.md CHANGED
@@ -9,15 +9,15 @@
9
9
 
10
10
  <div align="center">
11
11
 
12
- [![NPM Version](https://img.shields.io/npm/v/knip)][1]
13
- [![NPM Downloads](https://img.shields.io/npm/dm/knip)][1]
14
- [![GitHub Repo stars](https://img.shields.io/github/stars/webpro-nl/knip)][2]
12
+ [![NPM Version](https://img.shields.io/npm/v/knip)][1]
13
+ [![NPM Downloads](https://img.shields.io/npm/dm/knip)][1]
14
+ [![GitHub Repo stars](https://img.shields.io/github/stars/webpro-nl/knip)][2]
15
15
 
16
16
  </div>
17
17
 
18
- Knip finds **unused files, dependencies and exports** in your JavaScript and
19
- TypeScript projects. Less code and dependencies lead to improved performance,
20
- less maintenance and easier refactorings.
18
+ Knip finds and fixes **unused files, dependencies and exports** in your
19
+ JavaScript and TypeScript projects. Less code and dependencies lead to improved
20
+ performance, less maintenance and easier refactorings.
21
21
 
22
22
  - Website: [knip.dev][3]
23
23
  - GitHub repo: [webpro-nl/knip][2]
package/dist/index.js CHANGED
@@ -358,6 +358,8 @@ export const main = async (unresolvedConfiguration) => {
358
358
  printTrace(traceNode, filePath, identifier);
359
359
  if (isReferenced) {
360
360
  if (report.enumMembers && exportedItem.type === 'enum') {
361
+ if (!report.nsTypes && importsForExport.refs.has(identifier))
362
+ continue;
361
363
  if (hasStrictlyEnumReferences(importsForExport, identifier))
362
364
  continue;
363
365
  for (const member of exportedItem.members) {
@@ -1,4 +1,20 @@
1
- import type { PluginOptions } from '../../types/config.js';
2
- import { type Input } from '../../util/input.js';
1
+ import type { PluginOptions, ResolveConfig } from '../../types/config.js';
3
2
  import type { ExpoConfig } from './types.js';
4
- export declare const getDependencies: (localConfig: ExpoConfig, { manifest }: PluginOptions) => Promise<Input[]>;
3
+ export declare const getConfig: (localConfig: ExpoConfig, options: PluginOptions) => {
4
+ platforms?: ("ios" | "android" | "web")[];
5
+ notification?: Record<string, unknown>;
6
+ updates?: {
7
+ enabled?: boolean;
8
+ };
9
+ backgroundColor?: string;
10
+ userInterfaceStyle?: "automatic" | "light" | "dark";
11
+ ios?: {
12
+ backgroundColor?: string;
13
+ };
14
+ android?: {
15
+ userInterfaceStyle?: "automatic" | "light" | "dark";
16
+ };
17
+ androidNavigationBar?: Record<string, unknown>;
18
+ plugins?: (string | [string, Record<string, unknown>])[];
19
+ };
20
+ export declare const getDependencies: ResolveConfig<ExpoConfig>;
@@ -1,8 +1,21 @@
1
1
  import { toDependency, toProductionDependency } from '../../util/input.js';
2
2
  import { getPackageNameFromModuleSpecifier } from '../../util/modules.js';
3
- export const getDependencies = async (localConfig, { manifest }) => {
4
- const expoConfig = typeof localConfig === 'function' ? localConfig() : localConfig;
5
- const config = 'expo' in expoConfig ? expoConfig.expo : expoConfig;
3
+ import { join } from '../../util/path.js';
4
+ const getDummyConfigContext = (options) => ({
5
+ projectRoot: options.cwd,
6
+ staticConfigPath: null,
7
+ packageJsonPath: join(options.cwd, 'package.json'),
8
+ config: {
9
+ plugins: [],
10
+ },
11
+ });
12
+ export const getConfig = (localConfig, options) => {
13
+ const expoConfig = typeof localConfig === 'function' ? localConfig(getDummyConfigContext(options)) : localConfig;
14
+ return 'expo' in expoConfig ? expoConfig.expo : expoConfig;
15
+ };
16
+ export const getDependencies = async (localConfig, options) => {
17
+ const { manifest } = options;
18
+ const config = getConfig(localConfig, options);
6
19
  const platforms = config.platforms ?? ['ios', 'android'];
7
20
  const pluginPackages = config.plugins
8
21
  ?.map(plugin => {
@@ -1,16 +1,16 @@
1
1
  import { toProductionEntry } from '../../util/input.js';
2
2
  import { join } from '../../util/path.js';
3
3
  import { hasDependency } from '../../util/plugin.js';
4
- import { getDependencies } from './helpers.js';
4
+ import { getConfig, getDependencies } from './helpers.js';
5
5
  const title = 'Expo';
6
6
  const enablers = ['expo'];
7
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
8
8
  const config = ['app.json', 'app.config.{ts,js}'];
9
9
  const production = ['app/**/*.{js,jsx,ts,tsx}', 'src/app/**/*.{js,jsx,ts,tsx}'];
10
10
  export const docs = { production };
11
- const resolveEntryPaths = async (localConfig, { manifest }) => {
12
- const expoConfig = typeof localConfig === 'function' ? localConfig() : localConfig;
13
- const config = 'expo' in expoConfig ? expoConfig.expo : expoConfig;
11
+ const resolveEntryPaths = async (localConfig, options) => {
12
+ const { manifest } = options;
13
+ const config = getConfig(localConfig, options);
14
14
  if (manifest.main === 'expo-router/entry') {
15
15
  let patterns = [...production];
16
16
  const normalizedPlugins = config.plugins?.map(plugin => (Array.isArray(plugin) ? plugin : [plugin])) ?? [];
@@ -1,4 +1,4 @@
1
- type AppConfig = {
1
+ type BaseConfig = {
2
2
  platforms?: ('ios' | 'android' | 'web')[];
3
3
  notification?: Record<string, unknown>;
4
4
  updates?: {
@@ -15,8 +15,14 @@ type AppConfig = {
15
15
  androidNavigationBar?: Record<string, unknown>;
16
16
  plugins?: (string | [string, Record<string, unknown>])[];
17
17
  };
18
- type Config = AppConfig | {
19
- expo: AppConfig;
18
+ type ConfigContext = {
19
+ projectRoot: string;
20
+ staticConfigPath: string | null;
21
+ packageJsonPath: string | null;
22
+ config: Partial<BaseConfig>;
20
23
  };
21
- export type ExpoConfig = Config | (() => Config);
24
+ type ExpoConfigOrProp = BaseConfig | {
25
+ expo: BaseConfig;
26
+ };
27
+ export type ExpoConfig = ExpoConfigOrProp | ((cfg: ConfigContext) => ExpoConfigOrProp);
22
28
  export {};
@@ -3,7 +3,7 @@ import { hasDependency } from '../../util/plugin.js';
3
3
  const title = 'nyc';
4
4
  const enablers = ['nyc'];
5
5
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
- const config = ['.nycrc', '.nycrc.json', '.nycrc.{yml,yaml}', 'nyc.config.js', 'package.json'];
6
+ const config = ['.nycrc', '.nycrc.{json,yml,yaml}', 'nyc.config.js', 'package.json'];
7
7
  const resolveConfig = config => {
8
8
  const extend = config?.extends ?? [];
9
9
  const requires = config?.require ?? [];
@@ -14,7 +14,6 @@ export interface ConfigInput extends Input {
14
14
  pluginName: PluginName;
15
15
  }
16
16
  type Options = {
17
- production?: boolean;
18
17
  optional?: boolean;
19
18
  dir?: string;
20
19
  containingFilePath?: string;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "5.43.4";
1
+ export declare const version = "5.43.6";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '5.43.4';
1
+ export const version = '5.43.6';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "5.43.4",
4
- "description": "Find unused files, dependencies and exports in your TypeScript and JavaScript projects",
3
+ "version": "5.43.6",
4
+ "description": "Find and fix unused files, dependencies and exports in your TypeScript and JavaScript projects",
5
5
  "homepage": "https://knip.dev",
6
6
  "repository": {
7
7
  "type": "git",