knip 6.45.0 → 6.45.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.
@@ -8,11 +8,16 @@ const resolveConfig = config => {
8
8
  const presets = (config.presets ?? []).filter((preset) => typeof preset === 'string');
9
9
  return [...presets.map(id => toDeferResolve(id)), toDependency('postcss')];
10
10
  };
11
+ const args = {
12
+ binaries: ['panda', 'pandacss'],
13
+ config: true,
14
+ };
11
15
  const plugin = {
12
16
  title,
13
17
  enablers,
14
18
  isEnabled,
15
19
  config,
16
20
  resolveConfig,
21
+ args,
17
22
  };
18
23
  export default plugin;
@@ -1,29 +1,34 @@
1
1
  import { toDependency } from '../../util/input.js';
2
+ import { isAbsolute } from '../../util/path.js';
2
3
  import { hasDependency } from '../../util/plugin.js';
4
+ import { resolvePackageManifestPath } from '../../util/resolve.js';
3
5
  const title = 'WebdriverIO';
4
6
  const enablers = ['@wdio/cli'];
5
7
  const isEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);
6
8
  const config = ['wdio.conf.{js,cjs,mjs,ts,cts,mts}'];
7
- const resolveConfig = async (config) => {
9
+ const getNames = (plugins = []) => plugins.flatMap(plugin => {
10
+ const name = Array.isArray(plugin) ? plugin[0] : plugin;
11
+ return typeof name === 'string' && !name.startsWith('file://') && !isAbsolute(name) ? [name] : [];
12
+ });
13
+ const toPluginDependency = (name, type, dir) => {
14
+ if (name.startsWith('@'))
15
+ return toDependency(name);
16
+ const scoped = `@wdio/${name.toLowerCase()}-${type}`;
17
+ const community = `wdio-${name.toLowerCase()}-${type}`;
18
+ const isCommunity = !resolvePackageManifestPath(scoped, dir) && resolvePackageManifestPath(community, dir);
19
+ return toDependency(isCommunity ? community : scoped);
20
+ };
21
+ const resolveConfig = async (config, options) => {
8
22
  const cfg = config?.config;
9
23
  if (!cfg)
10
24
  return [];
11
- const frameworks = cfg.framework ? [`@wdio/${cfg.framework}-framework`] : [];
12
- const runners = cfg.runner && cfg.runner !== 'local'
13
- ? [`@wdio/${Array.isArray(cfg.runner) ? cfg.runner[0] : cfg.runner}-runner`]
14
- : [];
15
- const reporters = cfg.reporters
16
- ? cfg.reporters
17
- .flatMap(reporter => {
18
- if (typeof reporter === 'string')
19
- return [reporter];
20
- if (Array.isArray(reporter) && typeof reporter[0] === 'string')
21
- return [reporter[0]];
22
- return [];
23
- })
24
- .map(reporter => `@wdio/${reporter}-reporter`)
25
- : [];
26
- return [...frameworks, ...runners, ...reporters].map(id => toDependency(id));
25
+ const toInputs = (plugins, type) => getNames(plugins).map(name => toPluginDependency(name, type, options.configFileDir));
26
+ return [
27
+ ...toInputs([cfg.framework], 'framework'),
28
+ ...toInputs([cfg.runner ?? 'local'], 'runner'),
29
+ ...toInputs(cfg.reporters, 'reporter'),
30
+ ...toInputs(cfg.services, 'service'),
31
+ ];
27
32
  };
28
33
  const plugin = {
29
34
  title,
@@ -1,7 +1,8 @@
1
1
  export type WebdriverIOConfig = {
2
2
  config: {
3
3
  framework?: string;
4
- runner?: string;
5
- reporters?: string[];
4
+ runner?: string | [string, unknown];
5
+ reporters?: unknown[];
6
+ services?: unknown[];
6
7
  };
7
8
  };
@@ -9,4 +9,5 @@ export { createOptions, type MainOptions } from '../util/create-options.ts';
9
9
  export { buildFileDescriptor, type FileDescriptorOptions } from './file-descriptor.ts';
10
10
  export { buildPackageJsonDescriptor, type PackageJsonFile } from './package-json-descriptor.ts';
11
11
  export { createSession, type Session } from './session.ts';
12
+ export { version } from '../version.ts';
12
13
  export type { ContentionDetails, ContentionKind, ContentionOrigin, ContentionSite, Export, File, SourceLocation, } from './types.ts';
@@ -5,3 +5,4 @@ export { createOptions } from '../util/create-options.js';
5
5
  export { buildFileDescriptor } from './file-descriptor.js';
6
6
  export { buildPackageJsonDescriptor } from './package-json-descriptor.js';
7
7
  export { createSession } from './session.js';
8
+ export { version } from '../version.js';
@@ -491,7 +491,7 @@ export const collectAugmentationRefs = (node) => {
491
491
  export function extractEnumMembers(decl, options, lineStarts, getJSDocTags) {
492
492
  if (!decl.body?.members)
493
493
  return [];
494
- return decl.body.members.map((member) => {
494
+ const members = decl.body.members.map((member) => {
495
495
  const name = member.id.type === 'Identifier'
496
496
  ? member.id.name
497
497
  : member.id.type === 'Literal'
@@ -517,4 +517,50 @@ export function extractEnumMembers(decl, options, lineStarts, getJSDocTags) {
517
517
  flags: 0,
518
518
  };
519
519
  });
520
+ markEnumMemberRefs(decl.body.members, members);
521
+ return members;
520
522
  }
523
+ const markEnumMemberRefs = (enumMembers, members) => {
524
+ let byIdentifier;
525
+ const visit = (node) => {
526
+ const type = node?.type;
527
+ if (!type)
528
+ return;
529
+ if (type === 'Identifier') {
530
+ const member = byIdentifier?.get(node.name);
531
+ if (member)
532
+ member.hasRefsInFile = true;
533
+ return;
534
+ }
535
+ if (type === 'MemberExpression' && !node.computed) {
536
+ visit(node.object);
537
+ return;
538
+ }
539
+ const keys = visitorKeys[type];
540
+ if (!keys)
541
+ return;
542
+ for (const key of keys) {
543
+ const val = node[key];
544
+ if (!val)
545
+ continue;
546
+ if (Array.isArray(val)) {
547
+ for (const item of val)
548
+ if (item)
549
+ visit(item);
550
+ }
551
+ else
552
+ visit(val);
553
+ }
554
+ };
555
+ for (const member of enumMembers) {
556
+ const initializer = member.initializer;
557
+ if (!initializer || initializer.type === 'Literal')
558
+ continue;
559
+ if (!byIdentifier) {
560
+ byIdentifier = new Map();
561
+ for (const m of members)
562
+ byIdentifier.set(m.identifier, m);
563
+ }
564
+ visit(initializer);
565
+ }
566
+ };
@@ -23,6 +23,7 @@ export const getIncludedIssueTypes = (options) => {
23
23
  _exclude.push('devDependencies');
24
24
  _exclude.push('catalog');
25
25
  _exclude.push('catalogReferences');
26
+ _exclude.push('subpaths');
26
27
  }
27
28
  else {
28
29
  if (_include.includes('dependencies'))
@@ -1,4 +1,13 @@
1
1
  const isRegexLikeMatch = /[*+\\(|{^$]/;
2
2
  const isRegexLike = (value) => isRegexLikeMatch.test(value);
3
- export const toRegexOrString = (value) => typeof value === 'string' && isRegexLike(value) ? new RegExp(value) : value;
3
+ export const toRegexOrString = (value) => {
4
+ if (typeof value !== 'string' || !isRegexLike(value))
5
+ return value;
6
+ try {
7
+ return new RegExp(value);
8
+ }
9
+ catch {
10
+ return value;
11
+ }
12
+ };
4
13
  export const findMatch = (haystack, needle) => haystack.find(n => (typeof n === 'string' ? n === needle : n.test(needle)));
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "6.45.0";
1
+ export declare const version = "6.45.1";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const version = '6.45.0';
1
+ export const version = '6.45.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "knip",
3
- "version": "6.45.0",
3
+ "version": "6.45.1",
4
4
  "description": "Find and fix unused dependencies, exports and files in your TypeScript and JavaScript projects",
5
5
  "keywords": [
6
6
  "analysis",