Skip to content

Commit

Permalink
Minor housekeeping 🔍
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Jan 8, 2025
1 parent 0c49689 commit 4a9ff56
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 27 deletions.
2 changes: 1 addition & 1 deletion packages/knip/src/plugins/expo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const enablers = ['expo'];

const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);

const config: string[] = ['app.json', 'app.config.{ts,js}'];
const config = ['app.json', 'app.config.{ts,js}'];

const resolveEntryPaths: ResolveEntryPaths<ExpoConfig> = async (expoConfig, { manifest }) => {
const config = 'expo' in expoConfig ? expoConfig.expo : expoConfig;
Expand Down
4 changes: 2 additions & 2 deletions packages/knip/src/plugins/linthtml/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { IsPluginEnabled, Plugin, ResolveConfig } from '../../types/config.
import { toDeferResolve } from '../../util/input.js';
import { toCosmiconfig } from '../../util/plugin-config.js';
import { hasDependency } from '../../util/plugin.js';
import type { PluginConfig } from './types.js';
import type { LintHTMLConfig } from './types.js';

// https://linthtml.vercel.app/

Expand All @@ -16,7 +16,7 @@ const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependenc

const config = ['package.json', ...toCosmiconfig('linthtml')];

const resolveConfig: ResolveConfig<PluginConfig> = config => {
const resolveConfig: ResolveConfig<LintHTMLConfig> = config => {
const extensions = config.extends ?? [];
const plugins = config.plugins ?? [];
return [extensions, plugins].flat().map(toDeferResolve);
Expand Down
2 changes: 1 addition & 1 deletion packages/knip/src/plugins/linthtml/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type PluginConfig = {
export type LintHTMLConfig = {
extends?: string | string[];
plugins?: string[];
};
5 changes: 1 addition & 4 deletions packages/knip/src/plugins/metro/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ const enablers = ['metro', 'react-native'];

const isEnabled: IsPluginEnabled = options => hasDependency(options.dependencies, enablers);

const packageJsonPath = 'metro';

const config: string[] = ['metro.config.{js,cjs,json}', 'package.json'];
const config = ['metro.config.{js,cjs,json}', 'package.json'];

const DEFAULT_PLATFORMS = ['ios', 'android', 'windows', 'web'];
const PLATFORMS = [...DEFAULT_PLATFORMS, 'native', 'default'];
Expand Down Expand Up @@ -57,7 +55,6 @@ export default {
note,
enablers,
isEnabled,
packageJsonPath,
config,
production,
resolveEntryPaths,
Expand Down
3 changes: 0 additions & 3 deletions packages/knip/src/plugins/release-it/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ const enablers = ['release-it'];

const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);

const packageJsonPath = 'release-it';

const config = ['.release-it.{json,js,cjs,ts,yml,yaml,toml}', 'package.json'];

const resolveConfig: ResolveConfig<ReleaseItConfig> = (config, options) => {
Expand All @@ -35,7 +33,6 @@ export default {
title,
enablers,
isEnabled,
packageJsonPath,
config,
resolveConfig,
} satisfies Plugin;
15 changes: 3 additions & 12 deletions packages/knip/src/plugins/simple-git-hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IsPluginEnabled, Plugin, ResolveConfig } from '../../types/config.js';
import type { Input } from '../../util/input.js';
import { hasDependency } from '../../util/plugin.js';
import type { PluginConfig } from './types.js';
import type { SimpleGitHooksConfig } from './types.js';

// https://github.com/toplenboren/simple-git-hooks

Expand All @@ -11,17 +11,9 @@ const enablers = ['simple-git-hooks'];

const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);

const packageJsonPath = 'simple-git-hooks';
const config = ['.simple-git-hooks.{js,cjs,json}', 'simple-git-hooks.{js,cjs,json}', 'package.json'];

const config = [
'.simple-git-hooks.{js,cjs}',
'simple-git-hooks.{js,cjs}',
'.simple-git-hooks.json',
'simple-git-hooks.json',
'package.json',
];

const resolveConfig: ResolveConfig<PluginConfig> = async (config, options) => {
const resolveConfig: ResolveConfig<SimpleGitHooksConfig> = async (config, options) => {
if (typeof config === 'function') config = config();

if (!config) return [];
Expand All @@ -39,7 +31,6 @@ export default {
title,
enablers,
isEnabled,
packageJsonPath,
config,
resolveConfig,
} satisfies Plugin;
2 changes: 1 addition & 1 deletion packages/knip/src/plugins/simple-git-hooks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
// }
type Config = Record<string, string>;

export type PluginConfig = Config | (() => Config);
export type SimpleGitHooksConfig = Config | (() => Config);
3 changes: 0 additions & 3 deletions packages/knip/src/plugins/wireit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ const enablers = ['wireit'];

const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependencies, enablers);

const packageJsonPath = 'wireit';

const config = ['package.json'];

const resolveConfig: ResolveConfig<WireitConfig> = (localConfig, options) => {
Expand All @@ -26,7 +24,6 @@ export default {
title,
enablers,
isEnabled,
packageJsonPath,
config,
resolveConfig,
} satisfies Plugin;

0 comments on commit 4a9ff56

Please sign in to comment.