forked from webpro-nl/knip
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
33 lines (25 loc) · 1.07 KB
/
Copy pathindex.ts
File metadata and controls
33 lines (25 loc) · 1.07 KB
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
29
30
31
32
33
import { timerify } from '../../util/Performance.js';
import { hasDependency, load } from '../../util/plugin.js';
import type { IsPluginEnabledCallback, GenericPluginCallback } from '../../types/plugins.js';
// https://commitlint.js.org
// https://github.com/conventional-changelog/commitlint#config
type CommitLintConfig = {
extends: string[];
};
export const NAME = 'commitlint';
/** @public */
export const ENABLERS = ['@commitlint/cli'];
export const isEnabled: IsPluginEnabledCallback = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
export const CONFIG_FILE_PATTERNS = [
'.commitlintrc',
'.commitlintrc.{json,yaml,yml,js,cjs,ts,cts}',
'commitlint.config.{js,cjs,ts,cts}',
'package.json',
];
const findCommitLintDependencies: GenericPluginCallback = async (configFilePath, { manifest }) => {
const config: CommitLintConfig = configFilePath.endsWith('package.json')
? manifest.commitlint
: await load(configFilePath);
return config?.extends ? [config.extends].flat() : [];
};
export const findDependencies = timerify(findCommitLintDependencies);