Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
62
Frontend-Learner/node_modules/eslint-plugin-regexp/dist/rules/prefer-named-replacement.js
generated
vendored
Normal file
62
Frontend-Learner/node_modules/eslint-plugin-regexp/dist/rules/prefer-named-replacement.js
generated
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("../utils");
|
||||
exports.default = (0, utils_1.createRule)("prefer-named-replacement", {
|
||||
meta: {
|
||||
docs: {
|
||||
description: "enforce using named replacement",
|
||||
category: "Stylistic Issues",
|
||||
recommended: false,
|
||||
},
|
||||
fixable: "code",
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
strictTypes: { type: "boolean" },
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
messages: {
|
||||
unexpected: "Unexpected indexed reference in replacement string.",
|
||||
},
|
||||
type: "suggestion",
|
||||
},
|
||||
create(context) {
|
||||
var _a, _b;
|
||||
const strictTypes = (_b = (_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.strictTypes) !== null && _b !== void 0 ? _b : true;
|
||||
const sourceCode = context.sourceCode;
|
||||
function createVisitor(regexpContext) {
|
||||
const { node, getAllCapturingGroups, getCapturingGroupReferences } = regexpContext;
|
||||
const capturingGroups = getAllCapturingGroups();
|
||||
if (!capturingGroups.length) {
|
||||
return {};
|
||||
}
|
||||
for (const ref of getCapturingGroupReferences({ strictTypes })) {
|
||||
if (ref.type === "ReplacementRef" &&
|
||||
ref.kind === "index" &&
|
||||
ref.range) {
|
||||
const cgNode = capturingGroups[ref.ref - 1];
|
||||
if (cgNode && cgNode.name) {
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: sourceCode.getLocFromIndex(ref.range[0]),
|
||||
end: sourceCode.getLocFromIndex(ref.range[1]),
|
||||
},
|
||||
messageId: "unexpected",
|
||||
fix(fixer) {
|
||||
return fixer.replaceTextRange(ref.range, `$<${cgNode.name}>`);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
return (0, utils_1.defineRegexpVisitor)(context, {
|
||||
createVisitor,
|
||||
});
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue