Skip to content

Commit

Permalink
Plugin housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Dec 4, 2024
1 parent 9c07294 commit 770685b
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 14 deletions.
3 changes: 0 additions & 3 deletions packages/knip/src/plugins/angular/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependenc

const config = ['angular.json'];

const production: string[] = [];

const resolveConfig: ResolveConfig<AngularCLIWorkspaceConfiguration> = async (config, options) => {
const { cwd, configFilePath } = options;

Expand Down Expand Up @@ -82,6 +80,5 @@ export default {
enablers,
isEnabled,
config,
production,
resolveConfig,
} satisfies Plugin;
2 changes: 1 addition & 1 deletion packages/knip/src/plugins/linthtml/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const enablers = ['@linthtml/linthtml'];

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

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

const resolveConfig: ResolveConfig<PluginConfig> = config => {
const extensions = config.extends ?? [];
Expand Down
2 changes: 1 addition & 1 deletion packages/knip/src/plugins/nest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const enablers = [/^@nestjs\/.*/];

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

const config: string[] = ['nest-cli.json', '.nestcli.json', '.nest-cli.json', 'nest.json'];
const config = ['nest-cli.json', '.nestcli.json', '.nest-cli.json', 'nest.json'];

const resolveConfig: ResolveConfig<NestConfig> = async config => {
const inputs = config?.collection ? [config.collection] : [];
Expand Down
4 changes: 2 additions & 2 deletions packages/knip/src/plugins/netlify/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const enablers = [/^@netlify\/plugin-/, 'netlify-cli', '@netlify/functions'];

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

const config: string[] = ['netlify.toml'];
const config = ['netlify.toml'];

const NETLIFY_FUNCTIONS_DIR = 'netlify/functions';
const NETLIFY_FUNCTIONS_EXTS = 'js,mjs,cjs,ts,mts,cts';

const production: string[] = [`${NETLIFY_FUNCTIONS_DIR}/**/*.{${NETLIFY_FUNCTIONS_EXTS}}`];
const production = [`${NETLIFY_FUNCTIONS_DIR}/**/*.{${NETLIFY_FUNCTIONS_EXTS}}`];

const resolveEntryPaths: ResolveEntryPaths<NetlifyConfig> = localConfig => {
return [
Expand Down
2 changes: 1 addition & 1 deletion packages/knip/src/plugins/simple-git-hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependenc

const packageJsonPath = 'simple-git-hooks';

const config: string[] = [
const config = [
'.simple-git-hooks.{js,cjs}',
'simple-git-hooks.{js,cjs}',
'.simple-git-hooks.json',
Expand Down
2 changes: 1 addition & 1 deletion packages/knip/src/plugins/syncpack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { IsPluginEnabled, Plugin } from '../../types/config.js';
import { toCosmiconfig } from '../../util/plugin-config.js';
import { hasDependency } from '../../util/plugin.js';

// link to syncpack docs https://jamiemason.github.io/syncpack/config/syncpackrc/
// https://jamiemason.github.io/syncpack/config/syncpackrc/

const title = 'Syncpack';

Expand Down
7 changes: 2 additions & 5 deletions packages/knip/src/plugins/xo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { hasDependency } from '../../util/plugin.js';
import { getDependencies } from '../eslint/helpers.js';
import type { XOConfig } from './types.js';

// link to xo docs: https://github.com/xojs/xo#config
// Uses custom cosmiconfig search paths
// https://github.com/xojs/xo#config
// https://github.com/xojs/xo/blob/ee9f0a3d72d55df098fc321c4d54a1ea3804e226/lib/constants.js

const title = 'xo';
Expand All @@ -14,10 +13,9 @@ const enablers = ['xo'];
const isEnabled: IsPluginEnabled = ({ dependencies, config }) =>
hasDependency(dependencies, enablers) || 'xo' in config;

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

const entry: string[] = ['.xo-config.{js,cjs}', 'xo.config.{js,cjs}'];
const entry = ['.xo-config.{js,cjs}', 'xo.config.{js,cjs}'];

const resolveConfig: ResolveConfig<XOConfig> = async (config, options) => {
const inputs = getDependencies(config, options);
Expand All @@ -28,7 +26,6 @@ export default {
title,
enablers,
isEnabled,
packageJsonPath,
entry,
config,
resolveConfig,
Expand Down

0 comments on commit 770685b

Please sign in to comment.