knip 2.11.0 → 2.12.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.
@@ -1,9 +1,9 @@
1
1
  import { timerify } from '../../util/Performance.js';
2
2
  import { hasDependency, load } from '../../util/plugin.js';
3
3
  export const NAME = 'PostCSS';
4
- export const ENABLERS = ['postcss'];
4
+ export const ENABLERS = ['postcss', 'next'];
5
5
  export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
6
- export const CONFIG_FILE_PATTERNS = ['postcss.config.js', 'package.json'];
6
+ export const CONFIG_FILE_PATTERNS = ['postcss.config.js', 'postcss.config.json', 'package.json'];
7
7
  const findPostCSSDependencies = async (configFilePath, { manifest }) => {
8
8
  const config = configFilePath.endsWith('package.json')
9
9
  ? manifest?.postcss
@@ -13,6 +13,7 @@ const findStorybookDependencies = async (configFilePath) => {
13
13
  const addons = config.addons?.map(addon => (typeof addon === 'string' ? addon : addon.name)) ?? [];
14
14
  const builder = config?.core?.builder;
15
15
  const builderPackages = builder && /webpack/.test(builder) ? [`@storybook/builder-${builder}`, `@storybook/manager-${builder}`] : [];
16
- return [...addons, ...builderPackages];
16
+ const frameworks = config.framework?.name ? [config.framework.name] : [];
17
+ return [...addons, ...builderPackages, ...frameworks];
17
18
  };
18
19
  export const findDependencies = timerify(findStorybookDependencies);
@@ -5,4 +5,7 @@ export type StorybookConfig = {
5
5
  core?: {
6
6
  builder?: string;
7
7
  };
8
+ framework?: {
9
+ name?: string;
10
+ };
8
11
  };
package/dist/util/fs.d.ts CHANGED
@@ -3,5 +3,5 @@ export declare const findFile: (workingDir: string, fileName: string) => string
3
3
  export declare const loadFile: (filePath: string) => Promise<string>;
4
4
  export declare const loadJSON: (filePath: string) => Promise<any>;
5
5
  export declare const loadYAML: (filePath: string) => Promise<unknown>;
6
- export declare const parseJSON: (contents: string) => Promise<any>;
6
+ export declare const parseJSON: (filePath: string, contents: string) => Promise<any>;
7
7
  export declare const parseYAML: (contents: string) => Promise<unknown>;
package/dist/util/fs.js CHANGED
@@ -23,14 +23,19 @@ export const loadFile = async (filePath) => {
23
23
  };
24
24
  export const loadJSON = async (filePath) => {
25
25
  const contents = await loadFile(filePath);
26
- return parseJSON(contents);
26
+ return parseJSON(filePath, contents);
27
27
  };
28
28
  export const loadYAML = async (filePath) => {
29
29
  const contents = await loadFile(filePath);
30
30
  return parseYAML(contents);
31
31
  };
32
- export const parseJSON = async (contents) => {
33
- return JSON.parse(stripJsonComments(contents, { trailingCommas: true }));
32
+ export const parseJSON = async (filePath, contents) => {
33
+ try {
34
+ return JSON.parse(stripJsonComments(contents, { trailingCommas: true }));
35
+ }
36
+ catch (error) {
37
+ throw new LoaderError(`Error loading ${filePath}`, { cause: error });
38
+ }
34
39
  };
35
40
  export const parseYAML = async (contents) => {
36
41
  return yaml.load(contents);
@@ -9,7 +9,7 @@ const load = async (filePath) => {
9
9
  const ext = extname(filePath);
10
10
  if (/rc$/.test(filePath)) {
11
11
  const contents = await loadFile(filePath);
12
- return parseYAML(contents).catch(() => parseJSON(contents));
12
+ return parseYAML(contents).catch(() => parseJSON(filePath, contents));
13
13
  }
14
14
  if (ext === '.json' || ext === '.jsonc') {
15
15
  return loadJSON(filePath);
@@ -1,3 +1,3 @@
1
+ export { _load as load } from './loader.js';
1
2
  export declare const toCamelCase: (name: string) => string;
2
3
  export declare const hasDependency: (dependencies: Set<string>, values: (string | RegExp)[]) => boolean;
3
- export declare const load: (filePath: string) => Promise<any>;
@@ -1,5 +1,4 @@
1
- import { _load } from './loader.js';
2
- import { timerify } from './Performance.js';
1
+ export { _load as load } from './loader.js';
3
2
  export const toCamelCase = (name) => name.toLowerCase().replace(/(-[a-z])/g, group => group.toUpperCase().replace('-', ''));
4
3
  export const hasDependency = (dependencies, values) => values.some(value => {
5
4
  if (typeof value === 'string') {
@@ -13,4 +12,3 @@ export const hasDependency = (dependencies, values) => values.some(value => {
13
12
  }
14
13
  return false;
15
14
  });
16
- export const load = timerify(_load);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "2.11.0";
1
+ export declare const version = "2.12.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '2.11.0';
1
+ export const version = '2.12.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
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",
@@ -67,23 +67,23 @@
67
67
  "@types/js-yaml": "4.0.5",
68
68
  "@types/micromatch": "4.0.2",
69
69
  "@types/minimist": "1.2.2",
70
- "@types/node": "20.1.7",
70
+ "@types/node": "20.2.1",
71
71
  "@types/npmcli__map-workspaces": "3.0.1",
72
72
  "@types/webpack": "5.28.1",
73
73
  "@typescript-eslint/eslint-plugin": "5.59.6",
74
74
  "@typescript-eslint/parser": "5.59.6",
75
75
  "c8": "7.13.0",
76
- "eslint": "8.40.0",
76
+ "eslint": "8.41.0",
77
77
  "eslint-import-resolver-typescript": "3.5.5",
78
78
  "eslint-plugin-import": "2.27.5",
79
79
  "eslint-plugin-n": "16.0.0",
80
- "glob": "10.2.4",
80
+ "glob": "10.2.6",
81
81
  "prettier": "2.8.8",
82
82
  "release-it": "15.10.3",
83
83
  "remark-cli": "11.0.0",
84
84
  "remark-preset-webpro": "0.0.2",
85
85
  "tsx": "3.12.7",
86
- "type-fest": "3.10.0"
86
+ "type-fest": "3.11.0"
87
87
  },
88
88
  "engines": {
89
89
  "node": ">=16.17.0 <17 || >=18.6.0"