forked from webpro-nl/knip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
28 lines (21 loc) · 959 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { timerify } from '../../util/Performance.js';
import { hasDependency, load } from '../../util/plugin.js';
import type { PluginConfig } from './types.js';
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
// https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell#customization
export const NAME = 'cspell';
/** @public */
export const ENABLERS = ['cspell'];
export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
export const CONFIG_FILE_PATTERNS = [
'cspell.config.{js,cjs,json,yaml,yml}',
'cspell.{json,yaml,yml}',
'.c{s,S}pell.json',
'cSpell.json',
];
const findCspellDependencies: GenericPluginCallback = async configFilePath => {
const config: PluginConfig = await load(configFilePath);
const imports = config?.import ?? [];
return imports;
};
export const findDependencies = timerify(findCspellDependencies);