@commitlint/load 19.8.0 → 20.0.0
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.
- package/lib/load.d.ts +2 -2
- package/lib/load.d.ts.map +1 -1
- package/lib/load.js +22 -22
- package/lib/load.js.map +1 -1
- package/lib/utils/load-config.js +17 -17
- package/lib/utils/load-config.js.map +1 -1
- package/lib/utils/load-parser-opts.d.ts +1 -1
- package/lib/utils/load-parser-opts.d.ts.map +1 -1
- package/lib/utils/load-parser-opts.js +7 -7
- package/lib/utils/load-plugin.d.ts +1 -1
- package/lib/utils/load-plugin.d.ts.map +1 -1
- package/lib/utils/load-plugin.js +10 -10
- package/lib/utils/load-plugin.js.map +1 -1
- package/lib/utils/plugin-errors.js +3 -3
- package/lib/utils/plugin-naming.js +11 -11
- package/package.json +7 -7
package/lib/load.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { resolveFrom, resolveFromSilent, resolveGlobalSilent } from
|
|
2
|
-
import { LoadOptions, QualifiedConfig, UserConfig } from
|
|
1
|
+
import { resolveFrom, resolveFromSilent, resolveGlobalSilent } from "@commitlint/resolve-extends";
|
|
2
|
+
import { LoadOptions, QualifiedConfig, UserConfig } from "@commitlint/types";
|
|
3
3
|
export default function load(seed?: UserConfig, options?: LoadOptions): Promise<QualifiedConfig>;
|
|
4
4
|
export { resolveFrom, resolveFromSilent, resolveGlobalSilent };
|
|
5
5
|
//# sourceMappingURL=load.d.ts.map
|
package/lib/load.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAIA,OAAuB,EACtB,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EAEnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,WAAW,EAEX,eAAe,EAEf,UAAU,EACV,MAAM,mBAAmB,CAAC;AAoB3B,wBAA8B,IAAI,CACjC,IAAI,GAAE,UAAe,EACrB,OAAO,GAAE,WAAgB,GACvB,OAAO,CAAC,eAAe,CAAC,CAmG1B;AAED,OAAO,
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAIA,OAAuB,EACtB,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EAEnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,WAAW,EAEX,eAAe,EAEf,UAAU,EACV,MAAM,mBAAmB,CAAC;AAoB3B,wBAA8B,IAAI,CACjC,IAAI,GAAE,UAAe,EACrB,OAAO,GAAE,WAAgB,GACvB,OAAO,CAAC,eAAe,CAAC,CAmG1B;AAED,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAC"}
|
package/lib/load.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import { validateConfig } from
|
|
3
|
-
import executeRule from
|
|
4
|
-
import resolveExtends, { resolveFrom, resolveFromSilent, resolveGlobalSilent, loadParserPreset, } from
|
|
5
|
-
import isPlainObject from
|
|
6
|
-
import merge from
|
|
7
|
-
import uniq from
|
|
8
|
-
import { loadConfig } from
|
|
9
|
-
import { loadParserOpts } from
|
|
10
|
-
import loadPlugin from
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { validateConfig } from "@commitlint/config-validator";
|
|
3
|
+
import executeRule from "@commitlint/execute-rule";
|
|
4
|
+
import resolveExtends, { resolveFrom, resolveFromSilent, resolveGlobalSilent, loadParserPreset, } from "@commitlint/resolve-extends";
|
|
5
|
+
import isPlainObject from "lodash.isplainobject";
|
|
6
|
+
import merge from "lodash.merge";
|
|
7
|
+
import uniq from "lodash.uniq";
|
|
8
|
+
import { loadConfig } from "./utils/load-config.js";
|
|
9
|
+
import { loadParserOpts } from "./utils/load-parser-opts.js";
|
|
10
|
+
import loadPlugin from "./utils/load-plugin.js";
|
|
11
11
|
/**
|
|
12
12
|
* formatter should be kept as is when unable to resolve it from config directory
|
|
13
13
|
*/
|
|
@@ -20,13 +20,13 @@ const resolveFormatter = (formatter, parent) => {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
export default async function load(seed = {}, options = {}) {
|
|
23
|
-
const cwd = typeof options.cwd ===
|
|
23
|
+
const cwd = typeof options.cwd === "undefined" ? process.cwd() : options.cwd;
|
|
24
24
|
const loaded = await loadConfig(cwd, options.file);
|
|
25
25
|
const baseDirectory = loaded?.filepath ? path.dirname(loaded.filepath) : cwd;
|
|
26
26
|
const configFilePath = loaded?.filepath;
|
|
27
27
|
let config = {};
|
|
28
28
|
if (loaded) {
|
|
29
|
-
validateConfig(loaded.filepath ||
|
|
29
|
+
validateConfig(loaded.filepath || "", loaded.config);
|
|
30
30
|
config = loaded.config;
|
|
31
31
|
}
|
|
32
32
|
// Merge passed config with file based options
|
|
@@ -36,7 +36,7 @@ export default async function load(seed = {}, options = {}) {
|
|
|
36
36
|
rules: {},
|
|
37
37
|
}, config, seed);
|
|
38
38
|
// Resolve parserPreset key
|
|
39
|
-
if (typeof config.parserPreset ===
|
|
39
|
+
if (typeof config.parserPreset === "string") {
|
|
40
40
|
const resolvedParserPreset = resolveFrom(config.parserPreset, configFilePath);
|
|
41
41
|
config.parserPreset = {
|
|
42
42
|
name: config.parserPreset,
|
|
@@ -45,18 +45,18 @@ export default async function load(seed = {}, options = {}) {
|
|
|
45
45
|
}
|
|
46
46
|
// Resolve extends key
|
|
47
47
|
const extended = await resolveExtends(config, {
|
|
48
|
-
prefix:
|
|
48
|
+
prefix: "commitlint-config",
|
|
49
49
|
cwd: baseDirectory,
|
|
50
50
|
parserPreset: await config.parserPreset,
|
|
51
51
|
});
|
|
52
|
-
if (!extended.formatter || typeof extended.formatter !==
|
|
53
|
-
extended.formatter =
|
|
52
|
+
if (!extended.formatter || typeof extended.formatter !== "string") {
|
|
53
|
+
extended.formatter = "@commitlint/format";
|
|
54
54
|
}
|
|
55
55
|
let plugins = {};
|
|
56
56
|
if (Array.isArray(extended.plugins)) {
|
|
57
57
|
for (const plugin of uniq(extended.plugins)) {
|
|
58
|
-
if (typeof plugin ===
|
|
59
|
-
plugins = await loadPlugin(plugins, plugin, process.env.DEBUG ===
|
|
58
|
+
if (typeof plugin === "string") {
|
|
59
|
+
plugins = await loadPlugin(plugins, plugin, process.env.DEBUG === "true");
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
62
|
plugins.local = plugin;
|
|
@@ -69,16 +69,16 @@ export default async function load(seed = {}, options = {}) {
|
|
|
69
69
|
registry[key] = value;
|
|
70
70
|
return registry;
|
|
71
71
|
}, {});
|
|
72
|
-
const helpUrl = typeof extended.helpUrl ===
|
|
72
|
+
const helpUrl = typeof extended.helpUrl === "string"
|
|
73
73
|
? extended.helpUrl
|
|
74
|
-
: typeof config.helpUrl ===
|
|
74
|
+
: typeof config.helpUrl === "string"
|
|
75
75
|
? config.helpUrl
|
|
76
|
-
:
|
|
76
|
+
: "https://github.com/conventional-changelog/commitlint/#what-is-commitlint";
|
|
77
77
|
const prompt = extended.prompt && isPlainObject(extended.prompt) ? extended.prompt : {};
|
|
78
78
|
return {
|
|
79
79
|
extends: Array.isArray(extended.extends)
|
|
80
80
|
? extended.extends
|
|
81
|
-
: typeof extended.extends ===
|
|
81
|
+
: typeof extended.extends === "string"
|
|
82
82
|
? [extended.extends]
|
|
83
83
|
: [],
|
|
84
84
|
// Resolve config-relative formatter module
|
package/lib/load.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,WAAW,MAA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gB,CAAC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;QAC/D,kCAAkC;QAClC,YAAY,EAAE,MAAM,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC;QACzD,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,OAAO;QAChB,MAAM;KACN,CAAC;AACH,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAC"}
|
package/lib/utils/load-config.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from
|
|
2
|
-
import path from
|
|
3
|
-
import { cosmiconfig, defaultLoadersSync, defaultLoaders, } from
|
|
4
|
-
import { TypeScriptLoader } from
|
|
5
|
-
const moduleName =
|
|
6
|
-
const searchStrategy =
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { cosmiconfig, defaultLoadersSync, defaultLoaders, } from "cosmiconfig";
|
|
4
|
+
import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
|
|
5
|
+
const moduleName = "commitlint";
|
|
6
|
+
const searchStrategy = "global";
|
|
7
7
|
export async function loadConfig(cwd, configPath) {
|
|
8
8
|
let tsLoaderInstance;
|
|
9
9
|
const tsLoader = (...args) => {
|
|
@@ -22,8 +22,8 @@ export async function loadConfig(cwd, configPath) {
|
|
|
22
22
|
searchPlaces: [
|
|
23
23
|
// cosmiconfig overrides default searchPlaces if any new search place is added (For e.g. `*.ts` files),
|
|
24
24
|
// we need to manually merge default searchPlaces from https://github.com/davidtheclark/cosmiconfig#searchplaces
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
"package.json",
|
|
26
|
+
"package.yaml",
|
|
27
27
|
`.${moduleName}rc`,
|
|
28
28
|
`.${moduleName}rc.json`,
|
|
29
29
|
`.${moduleName}rc.yaml`,
|
|
@@ -41,10 +41,10 @@ export async function loadConfig(cwd, configPath) {
|
|
|
41
41
|
`${moduleName}.config.cts`,
|
|
42
42
|
],
|
|
43
43
|
loaders: {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
".ts": tsLoader,
|
|
45
|
+
".cts": tsLoader,
|
|
46
|
+
".cjs": loaders[".cjs"],
|
|
47
|
+
".js": loaders[".js"],
|
|
48
48
|
},
|
|
49
49
|
});
|
|
50
50
|
const explicitPath = configPath ? path.resolve(cwd, configPath) : undefined;
|
|
@@ -61,18 +61,18 @@ export async function loadConfig(cwd, configPath) {
|
|
|
61
61
|
// - Resolution: https://github.com/nodejs/node/pull/48510 (Node v20.8.0)
|
|
62
62
|
export const isDynamicAwaitSupported = () => {
|
|
63
63
|
const [major, minor] = process.version
|
|
64
|
-
.replace(
|
|
65
|
-
.split(
|
|
64
|
+
.replace("v", "")
|
|
65
|
+
.split(".")
|
|
66
66
|
.map((val) => parseInt(val));
|
|
67
67
|
return major >= 20 && minor >= 8;
|
|
68
68
|
};
|
|
69
69
|
// Is the given directory set up to use ESM (ECMAScript Modules)?
|
|
70
70
|
export const isEsmModule = (cwd) => {
|
|
71
|
-
const packagePath = path.join(cwd,
|
|
71
|
+
const packagePath = path.join(cwd, "package.json");
|
|
72
72
|
if (!existsSync(packagePath)) {
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
|
-
const packageJSON = readFileSync(packagePath, { encoding:
|
|
76
|
-
return JSON.parse(packageJSON)?.type ===
|
|
75
|
+
const packageJSON = readFileSync(packagePath, { encoding: "utf-8" });
|
|
76
|
+
return JSON.parse(packageJSON)?.type === "module";
|
|
77
77
|
};
|
|
78
78
|
//# sourceMappingURL=load-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-config.js","sourceRoot":"","sources":["../../src/utils/load-config.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
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AAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAEnD,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IACrE,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,IAAI,KAAK,QAAQ,CAAC;AACnD,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParserPreset } from
|
|
1
|
+
import { ParserPreset } from "@commitlint/types";
|
|
2
2
|
type Awaitable<T> = T | PromiseLike<T>;
|
|
3
3
|
export declare function loadParserOpts(pendingParser: string | Awaitable<ParserPreset> | (() => Awaitable<ParserPreset>) | undefined): Promise<ParserPreset | undefined>;
|
|
4
4
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-parser-opts.d.ts","sourceRoot":"","sources":["../../src/utils/load-parser-opts.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"load-parser-opts.d.ts","sourceRoot":"","sources":["../../src/utils/load-parser-opts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAgBvC,wBAAsB,cAAc,CACnC,aAAa,EACV,MAAM,GACN,SAAS,CAAC,YAAY,CAAC,GACvB,CAAC,MAAM,SAAS,CAAC,YAAY,CAAC,CAAC,GAC/B,SAAS,GACV,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CA0DnC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
function isObjectLike(obj) {
|
|
2
|
-
return Boolean(obj) && typeof obj ===
|
|
2
|
+
return Boolean(obj) && typeof obj === "object"; // typeof null === 'object'
|
|
3
3
|
}
|
|
4
4
|
function isParserOptsFunction(obj) {
|
|
5
|
-
return typeof obj.parserOpts ===
|
|
5
|
+
return typeof obj.parserOpts === "function";
|
|
6
6
|
}
|
|
7
7
|
export async function loadParserOpts(pendingParser) {
|
|
8
|
-
if (typeof pendingParser ===
|
|
8
|
+
if (typeof pendingParser === "function") {
|
|
9
9
|
return loadParserOpts(pendingParser());
|
|
10
10
|
}
|
|
11
|
-
if (!pendingParser || typeof pendingParser !==
|
|
11
|
+
if (!pendingParser || typeof pendingParser !== "object") {
|
|
12
12
|
return undefined;
|
|
13
13
|
}
|
|
14
14
|
// Await for the module, loaded with require
|
|
@@ -18,7 +18,7 @@ export async function loadParserOpts(pendingParser) {
|
|
|
18
18
|
return parser;
|
|
19
19
|
}
|
|
20
20
|
// Pull nested parserOpts, might happen if overwritten with a module in main config
|
|
21
|
-
if (typeof parser.parserOpts ===
|
|
21
|
+
if (typeof parser.parserOpts === "object") {
|
|
22
22
|
// Await parser opts if applicable
|
|
23
23
|
parser.parserOpts = await parser.parserOpts;
|
|
24
24
|
if (isObjectLike(parser.parserOpts) &&
|
|
@@ -29,8 +29,8 @@ export async function loadParserOpts(pendingParser) {
|
|
|
29
29
|
}
|
|
30
30
|
// Create parser opts from factory
|
|
31
31
|
if (isParserOptsFunction(parser) &&
|
|
32
|
-
typeof parser.name ===
|
|
33
|
-
parser.name.startsWith(
|
|
32
|
+
typeof parser.name === "string" &&
|
|
33
|
+
parser.name.startsWith("conventional-changelog-")) {
|
|
34
34
|
return new Promise((resolve) => {
|
|
35
35
|
const result = parser.parserOpts((_, opts) => {
|
|
36
36
|
resolve({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-plugin.d.ts","sourceRoot":"","sources":["../../src/utils/load-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"load-plugin.d.ts","sourceRoot":"","sources":["../../src/utils/load-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAiB1D,wBAA8B,UAAU,CACvC,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,OAAe,GACpB,OAAO,CAAC,aAAa,CAAC,CA8DxB"}
|
package/lib/utils/load-plugin.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { createRequire } from
|
|
2
|
-
import path from
|
|
3
|
-
import { fileURLToPath, pathToFileURL } from
|
|
4
|
-
import chalk from
|
|
5
|
-
import { normalizePackageName, getShorthandName } from
|
|
6
|
-
import { WhitespacePluginError, MissingPluginError } from
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { normalizePackageName, getShorthandName } from "./plugin-naming.js";
|
|
6
|
+
import { WhitespacePluginError, MissingPluginError } from "./plugin-errors.js";
|
|
7
7
|
const require = createRequire(import.meta.url);
|
|
8
|
-
const __dirname = path.resolve(fileURLToPath(import.meta.url),
|
|
8
|
+
const __dirname = path.resolve(fileURLToPath(import.meta.url), "..");
|
|
9
9
|
const dynamicImport = async (id) => {
|
|
10
10
|
const imported = await import(path.isAbsolute(id) ? pathToFileURL(id).toString() : id);
|
|
11
|
-
return (
|
|
11
|
+
return ("default" in imported && imported.default) || imported;
|
|
12
12
|
};
|
|
13
13
|
export default async function loadPlugin(plugins, pluginName, debug = false) {
|
|
14
14
|
const longName = normalizePackageName(pluginName);
|
|
@@ -32,10 +32,10 @@ export default async function loadPlugin(plugins, pluginName, debug = false) {
|
|
|
32
32
|
catch (error) {
|
|
33
33
|
// If the plugin can't be resolved, display the missing plugin error (usually a config or install error)
|
|
34
34
|
console.error(chalk.red(`Failed to load plugin ${longName}.`));
|
|
35
|
-
const message = error?.message ||
|
|
35
|
+
const message = error?.message || "Unknown error occurred";
|
|
36
36
|
throw new MissingPluginError(pluginName, message, {
|
|
37
37
|
pluginName: longName,
|
|
38
|
-
commitlintPath: path.resolve(__dirname,
|
|
38
|
+
commitlintPath: path.resolve(__dirname, "../.."),
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
// Otherwise, the plugin exists and is throwing on module load for some reason, so print the stack trace.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-plugin.js","sourceRoot":"","sources":["../../src/utils/load-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"load-plugin.js","sourceRoot":"","sources":["../../src/utils/load-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGxD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;AAErE,MAAM,aAAa,GAAG,KAAK,EAAK,EAAU,EAAc,EAAE;IACzD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAC5B,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CACvD,CAAC;IACF,OAAO,CAAC,SAAS,IAAI,QAAQ,IAAI,QAAQ,CAAC,OAA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AAC;QACrB,CAAC;QAED,oDAAoD;QACpD,IAAI,KAAK,EAAE,CAAC;YACX,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAE/C,IAAI,OAAO,GAAG,IAAI,CAAC;YAEnB,IAAI,CAAC;gBACJ,OAAO,GAAG,OAAO,CAAC,GAAG,QAAQ,eAAe,CAAC,CAAC,OAAO,CAAC;YACvD,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACZ,aAAa;YACd,CAAC;YAED,MAAM,sBAAsB,GAAG,OAAO;gBACrC,CAAC,CAAC,GAAG,QAAQ,IAAI,OAAO,EAAE;gBAC1B,CAAC,CAAC,GAAG,QAAQ,mBAAmB,CAAC;YAElC,OAAO,CAAC,GAAG,CACV,KAAK,CAAC,IAAI,CACT,iBAAiB,UAAU,KAAK,sBAAsB,WAAW,YAAY,GAAG,CAChF,CACD,CAAC;QACH,CAAC;QAED,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;IAC7B,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export class WhitespacePluginError extends Error {
|
|
2
2
|
__proto__ = Error;
|
|
3
|
-
messageTemplate =
|
|
3
|
+
messageTemplate = "whitespace-found";
|
|
4
4
|
messageData = {};
|
|
5
5
|
constructor(pluginName, data = {}) {
|
|
6
6
|
super(`Whitespace found in plugin name '${pluginName}'`);
|
|
@@ -10,9 +10,9 @@ export class WhitespacePluginError extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
export class MissingPluginError extends Error {
|
|
12
12
|
__proto__ = Error;
|
|
13
|
-
messageTemplate =
|
|
13
|
+
messageTemplate = "plugin-missing";
|
|
14
14
|
messageData;
|
|
15
|
-
constructor(pluginName, errorMessage =
|
|
15
|
+
constructor(pluginName, errorMessage = "", data = {}) {
|
|
16
16
|
super(`Failed to load plugin ${pluginName}: ${errorMessage}`);
|
|
17
17
|
this.messageData = data;
|
|
18
18
|
Object.setPrototypeOf(this, MissingPluginError.prototype);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import path from
|
|
1
|
+
import path from "node:path";
|
|
2
2
|
// largely adapted from eslint's plugin system
|
|
3
3
|
const NAMESPACE_REGEX = /^@.*\//u;
|
|
4
4
|
// In eslint this is a parameter - we don't need to support the extra options
|
|
5
|
-
const prefix =
|
|
5
|
+
const prefix = "commitlint-plugin";
|
|
6
6
|
// Replace Windows with posix style paths
|
|
7
7
|
function convertPathToPosix(filepath) {
|
|
8
8
|
const normalizedFilepath = path.normalize(filepath);
|
|
9
|
-
const posixFilepath = normalizedFilepath.replace(/\\/gu,
|
|
9
|
+
const posixFilepath = normalizedFilepath.replace(/\\/gu, "/");
|
|
10
10
|
return posixFilepath;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
@@ -22,19 +22,19 @@ export function normalizePackageName(name) {
|
|
|
22
22
|
* Normalize to Unix first to avoid errors later on.
|
|
23
23
|
* https://github.com/eslint/eslint/issues/5644
|
|
24
24
|
*/
|
|
25
|
-
if (normalizedName.indexOf(
|
|
25
|
+
if (normalizedName.indexOf("\\") > -1) {
|
|
26
26
|
normalizedName = convertPathToPosix(normalizedName);
|
|
27
27
|
}
|
|
28
|
-
if (normalizedName.charAt(0) ===
|
|
28
|
+
if (normalizedName.charAt(0) === "@") {
|
|
29
29
|
/**
|
|
30
30
|
* it's a scoped package
|
|
31
31
|
* package name is the prefix, or just a username
|
|
32
32
|
*/
|
|
33
|
-
const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`,
|
|
33
|
+
const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`, "u"), scopedPackageNameRegex = new RegExp(`^${prefix}(?:-|$)`, "u");
|
|
34
34
|
if (scopedPackageShortcutRegex.test(normalizedName)) {
|
|
35
35
|
normalizedName = normalizedName.replace(scopedPackageShortcutRegex, `$1/${prefix}`);
|
|
36
36
|
}
|
|
37
|
-
else if (!scopedPackageNameRegex.test(normalizedName.split(
|
|
37
|
+
else if (!scopedPackageNameRegex.test(normalizedName.split("/")[1])) {
|
|
38
38
|
/**
|
|
39
39
|
* for scoped packages, insert the prefix after the first / unless
|
|
40
40
|
* the path is already @scope/eslint or @scope/eslint-xxx-yyy
|
|
@@ -53,12 +53,12 @@ export function normalizePackageName(name) {
|
|
|
53
53
|
* @returns {string} The term without prefix.
|
|
54
54
|
*/
|
|
55
55
|
export function getShorthandName(fullname) {
|
|
56
|
-
if (fullname[0] ===
|
|
57
|
-
let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`,
|
|
56
|
+
if (fullname[0] === "@") {
|
|
57
|
+
let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`, "u").exec(fullname);
|
|
58
58
|
if (matchResult) {
|
|
59
59
|
return matchResult[1];
|
|
60
60
|
}
|
|
61
|
-
matchResult = new RegExp(`^(@[^/]+)/${prefix}-(.+)$`,
|
|
61
|
+
matchResult = new RegExp(`^(@[^/]+)/${prefix}-(.+)$`, "u").exec(fullname);
|
|
62
62
|
if (matchResult) {
|
|
63
63
|
return `${matchResult[1]}/${matchResult[2]}`;
|
|
64
64
|
}
|
|
@@ -75,6 +75,6 @@ export function getShorthandName(fullname) {
|
|
|
75
75
|
*/
|
|
76
76
|
export function getNamespaceFromTerm(term) {
|
|
77
77
|
const match = NAMESPACE_REGEX.exec(term);
|
|
78
|
-
return match ? match[0] :
|
|
78
|
+
return match ? match[0] : "";
|
|
79
79
|
}
|
|
80
80
|
//# sourceMappingURL=plugin-naming.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commitlint/load",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "20.0.0",
|
|
5
5
|
"description": "Load shared commitlint configuration",
|
|
6
6
|
"main": "lib/load.js",
|
|
7
7
|
"types": "lib/load.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@commitlint/test": "^
|
|
39
|
+
"@commitlint/test": "^20.0.0",
|
|
40
40
|
"@types/lodash.isplainobject": "^4.0.8",
|
|
41
41
|
"@types/lodash.merge": "^4.6.8",
|
|
42
42
|
"@types/lodash.uniq": "^4.5.8",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"typescript": "^5.2.2"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@commitlint/config-validator": "^
|
|
49
|
-
"@commitlint/execute-rule": "^
|
|
50
|
-
"@commitlint/resolve-extends": "^
|
|
51
|
-
"@commitlint/types": "^
|
|
48
|
+
"@commitlint/config-validator": "^20.0.0",
|
|
49
|
+
"@commitlint/execute-rule": "^20.0.0",
|
|
50
|
+
"@commitlint/resolve-extends": "^20.0.0",
|
|
51
|
+
"@commitlint/types": "^20.0.0",
|
|
52
52
|
"chalk": "^5.3.0",
|
|
53
53
|
"cosmiconfig": "^9.0.0",
|
|
54
54
|
"cosmiconfig-typescript-loader": "^6.1.0",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"lodash.merge": "^4.6.2",
|
|
57
57
|
"lodash.uniq": "^4.5.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "407be6c96b1a108ee012ed5330b0d80a165952d5"
|
|
60
60
|
}
|