feat: adding linter for commits

This commit is contained in:
Carlos Gutierrez
2021-11-22 09:39:27 -06:00
commit 2c7c117aa1
3093 changed files with 1215197 additions and 0 deletions

View File

@ -0,0 +1,7 @@
export interface LoadConfigResult {
config: unknown;
filepath: string;
isEmpty?: boolean;
}
export declare function loadConfig(cwd: string, configPath?: string): Promise<LoadConfigResult | null>;
//# sourceMappingURL=load-config.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../src/utils/load-config.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,UAAU,CAC/B,GAAG,EAAE,MAAM,EACX,UAAU,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAmClC"}

43
node_modules/@commitlint/load/lib/utils/load-config.js generated vendored Normal file
View File

@ -0,0 +1,43 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadConfig = void 0;
const path_1 = __importDefault(require("path"));
const cosmiconfig_1 = require("cosmiconfig");
const cosmiconfig_typescript_loader_1 = __importDefault(require("@endemolshinegroup/cosmiconfig-typescript-loader"));
async function loadConfig(cwd, configPath) {
const moduleName = 'commitlint';
const explorer = (0, cosmiconfig_1.cosmiconfig)(moduleName, {
searchPlaces: [
// cosmiconfig overrides default searchPlaces if any new search place is added (For e.g. `*.ts` files),
// we need to manually merge default searchPlaces from https://github.com/davidtheclark/cosmiconfig#searchplaces
'package.json',
`.${moduleName}rc`,
`.${moduleName}rc.json`,
`.${moduleName}rc.yaml`,
`.${moduleName}rc.yml`,
`.${moduleName}rc.js`,
`.${moduleName}rc.cjs`,
`${moduleName}.config.js`,
`${moduleName}.config.cjs`,
// files supported by TypescriptLoader
`.${moduleName}rc.ts`,
`${moduleName}.config.ts`,
],
loaders: {
'.ts': cosmiconfig_typescript_loader_1.default,
},
});
const explicitPath = configPath ? path_1.default.resolve(cwd, configPath) : undefined;
const explore = explicitPath ? explorer.load : explorer.search;
const searchPath = explicitPath ? explicitPath : cwd;
const local = await explore(searchPath);
if (local) {
return local;
}
return null;
}
exports.loadConfig = loadConfig;
//# sourceMappingURL=load-config.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"load-config.js","sourceRoot":"","sources":["../../src/utils/load-config.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,6CAAwC;AACxC,qHAAgF;AAQzE,KAAK,UAAU,UAAU,CAC/B,GAAW,EACX,UAAmB;IAEnB,MAAM,UAAU,GAAG,YAAY,CAAC;IAChC,MAAM,QAAQ,GAAG,IAAA,yBAAW,EAAC,UAAU,EAAE;QACxC,YAAY,EAAE;YACb,uGAAuG;YACvG,gHAAgH;YAChH,cAAc;YACd,IAAI,UAAU,IAAI;YAClB,IAAI,UAAU,SAAS;YACvB,IAAI,UAAU,SAAS;YACvB,IAAI,UAAU,QAAQ;YACtB,IAAI,UAAU,OAAO;YACrB,IAAI,UAAU,QAAQ;YACtB,GAAG,UAAU,YAAY;YACzB,GAAG,UAAU,aAAa;YAE1B,sCAAsC;YACtC,IAAI,UAAU,OAAO;YACrB,GAAG,UAAU,YAAY;SACzB;QACD,OAAO,EAAE;YACR,KAAK,EAAE,uCAAgB;SACvB;KACD,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,UAAU,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC/D,MAAM,UAAU,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC;IACrD,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IAExC,IAAI,KAAK,EAAE;QACV,OAAO,KAAK,CAAC;KACb;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAtCD,gCAsCC"}

View File

@ -0,0 +1,3 @@
import { ParserPreset } from '@commitlint/types';
export declare function loadParserOpts(pendingParser: string | ParserPreset | Promise<ParserPreset> | undefined): Promise<ParserPreset | undefined>;
//# sourceMappingURL=load-parser-opts.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"load-parser-opts.d.ts","sourceRoot":"","sources":["../../src/utils/load-parser-opts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAc/C,wBAAsB,cAAc,CACnC,aAAa,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,SAAS,GACtE,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAsDnC"}

View File

@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadParserOpts = void 0;
function isObjectLike(obj) {
return Boolean(obj) && typeof obj === 'object'; // typeof null === 'object'
}
function isParserOptsFunction(obj) {
return typeof obj.parserOpts === 'function';
}
async function loadParserOpts(pendingParser) {
if (!pendingParser || typeof pendingParser !== 'object') {
return undefined;
}
// Await for the module, loaded with require
const parser = await pendingParser;
// exit early, no opts to resolve
if (!parser.parserOpts) {
return parser;
}
// Pull nested parserOpts, might happen if overwritten with a module in main config
if (typeof parser.parserOpts === 'object') {
// Await parser opts if applicable
parser.parserOpts = await parser.parserOpts;
if (isObjectLike(parser.parserOpts) &&
isObjectLike(parser.parserOpts.parserOpts)) {
parser.parserOpts = parser.parserOpts.parserOpts;
}
return parser;
}
// Create parser opts from factory
if (isParserOptsFunction(parser) &&
typeof parser.name === 'string' &&
parser.name.startsWith('conventional-changelog-')) {
return new Promise((resolve) => {
const result = parser.parserOpts((_, opts) => {
resolve(Object.assign(Object.assign({}, parser), { parserOpts: opts === null || opts === void 0 ? void 0 : opts.parserOpts }));
});
// If result has data or a promise, the parser doesn't support factory-init
// due to https://github.com/nodejs/promises-debugging/issues/16 it just quits, so let's use this fallback
if (result) {
Promise.resolve(result).then((opts) => {
resolve(Object.assign(Object.assign({}, parser), { parserOpts: opts === null || opts === void 0 ? void 0 : opts.parserOpts }));
});
}
return;
});
}
return parser;
}
exports.loadParserOpts = loadParserOpts;
//# sourceMappingURL=load-parser-opts.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"load-parser-opts.js","sourceRoot":"","sources":["../../src/utils/load-parser-opts.ts"],"names":[],"mappings":";;;AAEA,SAAS,YAAY,CAAC,GAAY;IACjC,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,2BAA2B;AAC5E,CAAC;AAED,SAAS,oBAAoB,CAC5B,GAAM;IAIN,OAAO,OAAO,GAAG,CAAC,UAAU,KAAK,UAAU,CAAC;AAC7C,CAAC;AAEM,KAAK,UAAU,cAAc,CACnC,aAAwE;IAExE,IAAI,CAAC,aAAa,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;QACxD,OAAO,SAAS,CAAC;KACjB;IACD,4CAA4C;IAC5C,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC;IAEnC,iCAAiC;IACjC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;QACvB,OAAO,MAAM,CAAC;KACd;IAED,mFAAmF;IACnF,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ,EAAE;QAC1C,kCAAkC;QAClC,MAAM,CAAC,UAAU,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC;QAC5C,IACC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC;YAC/B,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EACzC;YACD,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC;SACjD;QACD,OAAO,MAAM,CAAC;KACd;IAED,kCAAkC;IAClC,IACC,oBAAoB,CAAC,MAAM,CAAC;QAC5B,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ;QAC/B,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,yBAAyB,CAAC,EAChD;QACD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAQ,EAAE,IAAS,EAAE,EAAE;gBACxD,OAAO,iCACH,MAAM,KACT,UAAU,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,IAC3B,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,2EAA2E;YAC3E,0GAA0G;YAC1G,IAAI,MAAM,EAAE;gBACX,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;oBACrC,OAAO,iCACH,MAAM,KACT,UAAU,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,IAC3B,CAAC;gBACJ,CAAC,CAAC,CAAC;aACH;YACD,OAAO;QACR,CAAC,CAAC,CAAC;KACH;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAxDD,wCAwDC"}

View File

@ -0,0 +1,3 @@
import { PluginRecords } from '@commitlint/types';
export default function loadPlugin(plugins: PluginRecords, pluginName: string, debug?: boolean): PluginRecords;
//# sourceMappingURL=load-plugin.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"load-plugin.d.ts","sourceRoot":"","sources":["../../src/utils/load-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,OAAO,UAAU,UAAU,CACjC,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,OAAe,GACpB,aAAa,CA8Df"}

61
node_modules/@commitlint/load/lib/utils/load-plugin.js generated vendored Normal file
View File

@ -0,0 +1,61 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const chalk_1 = __importDefault(require("chalk"));
const plugin_naming_1 = require("./plugin-naming");
const plugin_errors_1 = require("./plugin-errors");
function loadPlugin(plugins, pluginName, debug = false) {
const longName = (0, plugin_naming_1.normalizePackageName)(pluginName);
const shortName = (0, plugin_naming_1.getShorthandName)(longName);
let plugin = null;
if (pluginName.match(/\s+/u)) {
throw new plugin_errors_1.WhitespacePluginError(pluginName, {
pluginName: longName,
});
}
const pluginKey = longName === pluginName ? shortName : pluginName;
if (!plugins[pluginKey]) {
try {
plugin = require(longName);
}
catch (pluginLoadErr) {
try {
// Check whether the plugin exists
require.resolve(longName);
}
catch (error) {
// If the plugin can't be resolved, display the missing plugin error (usually a config or install error)
console.error(chalk_1.default.red(`Failed to load plugin ${longName}.`));
const message = (error === null || error === void 0 ? void 0 : error.message) || 'Unknown error occurred';
throw new plugin_errors_1.MissingPluginError(pluginName, message, {
pluginName: longName,
commitlintPath: path_1.default.resolve(__dirname, '../..'),
});
}
// Otherwise, the plugin exists and is throwing on module load for some reason, so print the stack trace.
throw pluginLoadErr;
}
// This step is costly, so skip if debug is disabled
if (debug) {
const resolvedPath = require.resolve(longName);
let version = null;
try {
version = require(`${longName}/package.json`).version;
}
catch (e) {
// Do nothing
}
const loadedPluginAndVersion = version
? `${longName}@${version}`
: `${longName}, version unknown`;
console.log(chalk_1.default.blue(`Loaded plugin ${pluginName} (${loadedPluginAndVersion}) (from ${resolvedPath})`));
}
plugins[pluginKey] = plugin;
}
return plugins;
}
exports.default = loadPlugin;
//# sourceMappingURL=load-plugin.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"load-plugin.js","sourceRoot":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G,MAAM,aAAa,CAAC;SACpB;QAED,oDAAoD;QACpD,IAAI,KAAK,EAAE;YACV,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAE/C,IAAI,OAAO,GAAG,IAAI,CAAC;YAEnB,IAAI;gBACH,OAAO,GAAG,OAAO,CAAC,GAAG,QAAQ,eAAe,CAAC,CAAC,OAAO,CAAC;aACtD;YAAC,OAAO,CAAC,EAAE;gBACX,aAAa;aACb;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,eAAK,CAAC,IAAI,CACT,iBAAiB,UAAU,KAAK,sBAAsB,WAAW,YAAY,GAAG,CAChF,CACD,CAAC;SACF;QAED,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;KAC5B;IAED,OAAO,OAAO,CAAC;AAChB,CAAC;AAlED,6BAkEC"}

View File

@ -0,0 +1,2 @@
export declare const pickConfig: (input: unknown) => Record<string, unknown>;
//# sourceMappingURL=pick-config.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"pick-config.d.ts","sourceRoot":"","sources":["../../src/utils/pick-config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,UAAW,OAAO,KAAG,OAAO,MAAM,EAAE,OAAO,CAYhE,CAAC"}

10
node_modules/@commitlint/load/lib/utils/pick-config.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.pickConfig = void 0;
const pick_1 = __importDefault(require("lodash/pick"));
const pickConfig = (input) => (0, pick_1.default)(input, 'extends', 'rules', 'plugins', 'parserPreset', 'formatter', 'ignores', 'defaultIgnores', 'helpUrl', 'prompt');
exports.pickConfig = pickConfig;
//# sourceMappingURL=pick-config.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"pick-config.js","sourceRoot":"","sources":["../../src/utils/pick-config.ts"],"names":[],"mappings":";;;;;;AAAA,uDAA+B;AAExB,MAAM,UAAU,GAAG,CAAC,KAAc,EAA2B,EAAE,CACrE,IAAA,cAAI,EACH,KAAK,EACL,SAAS,EACT,OAAO,EACP,SAAS,EACT,cAAc,EACd,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,QAAQ,CACR,CAAC;AAZU,QAAA,UAAU,cAYpB"}

View File

@ -0,0 +1,13 @@
export declare class WhitespacePluginError extends Error {
__proto__: ErrorConstructor;
messageTemplate: string;
messageData: any;
constructor(pluginName?: string, data?: any);
}
export declare class MissingPluginError extends Error {
__proto__: ErrorConstructor;
messageTemplate: string;
messageData: any;
constructor(pluginName?: string, errorMessage?: string, data?: any);
}
//# sourceMappingURL=plugin-errors.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"plugin-errors.d.ts","sourceRoot":"","sources":["../../src/utils/plugin-errors.ts"],"names":[],"mappings":"AAAA,qBAAa,qBAAsB,SAAQ,KAAK;IAC/C,SAAS,mBAAS;IAEX,eAAe,EAAE,MAAM,CAAsB;IAC7C,WAAW,EAAE,GAAG,CAAM;gBAEjB,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ;CAO/C;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC5C,SAAS,mBAAS;IAEX,eAAe,EAAE,MAAM,CAAoB;IAC3C,WAAW,EAAE,GAAG,CAAC;gBAEZ,UAAU,CAAC,EAAE,MAAM,EAAE,YAAY,GAAE,MAAW,EAAE,IAAI,GAAE,GAAQ;CAO1E"}

View File

@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MissingPluginError = exports.WhitespacePluginError = void 0;
class WhitespacePluginError extends Error {
constructor(pluginName, data = {}) {
super(`Whitespace found in plugin name '${pluginName}'`);
this.__proto__ = Error;
this.messageTemplate = 'whitespace-found';
this.messageData = {};
this.messageData = data;
Object.setPrototypeOf(this, WhitespacePluginError.prototype);
}
}
exports.WhitespacePluginError = WhitespacePluginError;
class MissingPluginError extends Error {
constructor(pluginName, errorMessage = '', data = {}) {
super(`Failed to load plugin ${pluginName}: ${errorMessage}`);
this.__proto__ = Error;
this.messageTemplate = 'plugin-missing';
this.messageData = data;
Object.setPrototypeOf(this, MissingPluginError.prototype);
}
}
exports.MissingPluginError = MissingPluginError;
//# sourceMappingURL=plugin-errors.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"plugin-errors.js","sourceRoot":"","sources":["../../src/utils/plugin-errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,qBAAsB,SAAQ,KAAK;IAM/C,YAAY,UAAmB,EAAE,OAAY,EAAE;QAC9C,KAAK,CAAC,oCAAoC,UAAU,GAAG,CAAC,CAAC;QAN1D,cAAS,GAAG,KAAK,CAAC;QAEX,oBAAe,GAAW,kBAAkB,CAAC;QAC7C,gBAAW,GAAQ,EAAE,CAAC;QAK5B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAExB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;CACD;AAbD,sDAaC;AAED,MAAa,kBAAmB,SAAQ,KAAK;IAM5C,YAAY,UAAmB,EAAE,eAAuB,EAAE,EAAE,OAAY,EAAE;QACzE,KAAK,CAAC,yBAAyB,UAAU,KAAK,YAAY,EAAE,CAAC,CAAC;QAN/D,cAAS,GAAG,KAAK,CAAC;QAEX,oBAAe,GAAW,gBAAgB,CAAC;QAMjD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAExB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;CACD;AAbD,gDAaC"}

View File

@ -0,0 +1,20 @@
/**
* Brings package name to correct format based on prefix
* @param {string} name The name of the package.
* @returns {string} Normalized name of the package
* @private
*/
export declare function normalizePackageName(name: string): string;
/**
* Removes the prefix from a fullname.
* @param {string} fullname The term which may have the prefix.
* @returns {string} The term without prefix.
*/
export declare function getShorthandName(fullname: string): string;
/**
* Gets the scope (namespace) of a term.
* @param {string} term The term which may have the namespace.
* @returns {string} The namepace of the term if it has one.
*/
export declare function getNamespaceFromTerm(term: string): string;
//# sourceMappingURL=plugin-naming.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"plugin-naming.d.ts","sourceRoot":"","sources":["../../src/utils/plugin-naming.ts"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,UA2ChD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,UAiBhD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,UAIhD"}

View File

@ -0,0 +1,89 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNamespaceFromTerm = exports.getShorthandName = exports.normalizePackageName = void 0;
const path_1 = __importDefault(require("path"));
// largely adapted from eslint's plugin system
const NAMESPACE_REGEX = /^@.*\//iu;
// In eslint this is a parameter - we don't need to support the extra options
const prefix = 'commitlint-plugin';
// Replace Windows with posix style paths
function convertPathToPosix(filepath) {
const normalizedFilepath = path_1.default.normalize(filepath);
const posixFilepath = normalizedFilepath.replace(/\\/gu, '/');
return posixFilepath;
}
/**
* Brings package name to correct format based on prefix
* @param {string} name The name of the package.
* @returns {string} Normalized name of the package
* @private
*/
function normalizePackageName(name) {
let normalizedName = name;
/**
* On Windows, name can come in with Windows slashes instead of Unix slashes.
* Normalize to Unix first to avoid errors later on.
* https://github.com/eslint/eslint/issues/5644
*/
if (normalizedName.indexOf('\\') > -1) {
normalizedName = convertPathToPosix(normalizedName);
}
if (normalizedName.charAt(0) === '@') {
/**
* it's a scoped package
* package name is the prefix, or just a username
*/
const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`, 'u'), scopedPackageNameRegex = new RegExp(`^${prefix}(-|$)`, 'u');
if (scopedPackageShortcutRegex.test(normalizedName)) {
normalizedName = normalizedName.replace(scopedPackageShortcutRegex, `$1/${prefix}`);
}
else if (!scopedPackageNameRegex.test(normalizedName.split('/')[1])) {
/**
* for scoped packages, insert the prefix after the first / unless
* the path is already @scope/eslint or @scope/eslint-xxx-yyy
*/
normalizedName = normalizedName.replace(/^@([^/]+)\/(.*)$/u, `@$1/${prefix}-$2`);
}
}
else if (normalizedName.indexOf(`${prefix}-`) !== 0) {
normalizedName = `${prefix}-${normalizedName}`;
}
return normalizedName;
}
exports.normalizePackageName = normalizePackageName;
/**
* Removes the prefix from a fullname.
* @param {string} fullname The term which may have the prefix.
* @returns {string} The term without prefix.
*/
function getShorthandName(fullname) {
if (fullname[0] === '@') {
let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`, 'u').exec(fullname);
if (matchResult) {
return matchResult[1];
}
matchResult = new RegExp(`^(@[^/]+)/${prefix}-(.+)$`, 'u').exec(fullname);
if (matchResult) {
return `${matchResult[1]}/${matchResult[2]}`;
}
}
else if (fullname.startsWith(`${prefix}-`)) {
return fullname.slice(prefix.length + 1);
}
return fullname;
}
exports.getShorthandName = getShorthandName;
/**
* Gets the scope (namespace) of a term.
* @param {string} term The term which may have the namespace.
* @returns {string} The namepace of the term if it has one.
*/
function getNamespaceFromTerm(term) {
const match = term.match(NAMESPACE_REGEX);
return match ? match[0] : '';
}
exports.getNamespaceFromTerm = getNamespaceFromTerm;
//# sourceMappingURL=plugin-naming.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"plugin-naming.js","sourceRoot":"","sources":["../../src/utils/plugin-naming.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,8CA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