eslint-plugin-regexp
Advanced tools
Comparing version
@@ -5,3 +5,3 @@ "use strict"; | ||
const regexp_ast_analysis_1 = require("regexp-ast-analysis"); | ||
exports.default = utils_1.createRule("confusing-quantifier", { | ||
exports.default = (0, utils_1.createRule)("confusing-quantifier", { | ||
meta: { | ||
@@ -24,7 +24,7 @@ docs: { | ||
onQuantifierEnter(qNode) { | ||
if (qNode.min > 0 && regexp_ast_analysis_1.isPotentiallyEmpty(qNode.element)) { | ||
const proposal = utils_1.quantToString(Object.assign(Object.assign({}, qNode), { min: 0 })); | ||
if (qNode.min > 0 && (0, regexp_ast_analysis_1.isPotentiallyEmpty)(qNode.element)) { | ||
const proposal = (0, utils_1.quantToString)(Object.assign(Object.assign({}, qNode), { min: 0 })); | ||
context.report({ | ||
node, | ||
loc: getRegexpLocation(qNode, utils_1.getQuantifierOffsets(qNode)), | ||
loc: getRegexpLocation(qNode, (0, utils_1.getQuantifierOffsets)(qNode)), | ||
messageId: "confusing", | ||
@@ -40,3 +40,3 @@ data: { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -43,0 +43,0 @@ }); |
@@ -15,3 +15,3 @@ "use strict"; | ||
function isRegExpLiteralAt({ node, patternSource }, at) { | ||
if (utils_2.isRegexpLiteral(node)) { | ||
if ((0, utils_2.isRegexpLiteral)(node)) { | ||
return true; | ||
@@ -25,3 +25,3 @@ } | ||
} | ||
exports.default = utils_1.createRule("control-character-escape", { | ||
exports.default = (0, utils_1.createRule)("control-character-escape", { | ||
meta: { | ||
@@ -64,3 +64,3 @@ docs: { | ||
data: { | ||
actual: mention_1.mentionChar(cNode), | ||
actual: (0, mention_1.mentionChar)(cNode), | ||
expected: expectedRaw, | ||
@@ -73,3 +73,3 @@ }, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -76,0 +76,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("hexadecimal-escape", { | ||
exports.default = (0, utils_1.createRule)("hexadecimal-escape", { | ||
meta: { | ||
@@ -64,3 +64,3 @@ docs: { | ||
} | ||
const kind = utils_1.getEscapeSequenceKind(cNode.raw); | ||
const kind = (0, utils_1.getEscapeSequenceKind)(cNode.raw); | ||
if (!kind) { | ||
@@ -73,3 +73,3 @@ return; | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -76,0 +76,0 @@ }); |
@@ -34,3 +34,3 @@ "use strict"; | ||
}; | ||
exports.default = utils_1.createRule("letter-case", { | ||
exports.default = (0, utils_1.createRule)("letter-case", { | ||
meta: { | ||
@@ -80,3 +80,3 @@ docs: { | ||
if (CODE_POINT_CASE_CHECKER[options.caseInsensitive](cNode.value) || | ||
!utils_1.isLetter(cNode.value)) { | ||
!(0, utils_1.isLetter)(cNode.value)) { | ||
return; | ||
@@ -91,5 +91,5 @@ } | ||
if (CODE_POINT_CASE_CHECKER[options.caseInsensitive](ccrNode.min.value) || | ||
!utils_1.isLetter(ccrNode.min.value) || | ||
!(0, utils_1.isLetter)(ccrNode.min.value) || | ||
CODE_POINT_CASE_CHECKER[options.caseInsensitive](ccrNode.max.value) || | ||
!utils_1.isLetter(ccrNode.max.value)) { | ||
!(0, utils_1.isLetter)(ccrNode.max.value)) { | ||
return; | ||
@@ -103,7 +103,7 @@ } | ||
} | ||
const parts = /^(\\u\{?)(.*)(\}?)$/u.exec(cNode.raw); | ||
if (STRING_CASE_CHECKER[options.unicodeEscape](parts[2])) { | ||
const parts = /^(?<prefix>\\u\{?)(?<code>.*)(?<suffix>\}?)$/u.exec(cNode.raw); | ||
if (STRING_CASE_CHECKER[options.unicodeEscape](parts.groups.code)) { | ||
return; | ||
} | ||
report(regexpContext, cNode, options.unicodeEscape, (converter) => `${parts[1]}${converter(parts[2])}${parts[3]}`); | ||
report(regexpContext, cNode, options.unicodeEscape, (converter) => `${parts.groups.prefix}${converter(parts.groups.code)}${parts.groups.suffix}`); | ||
} | ||
@@ -114,7 +114,7 @@ function verifyCharacterInHexadecimalEscape(regexpContext, cNode) { | ||
} | ||
const parts = /^\\x(.*)$/u.exec(cNode.raw); | ||
if (STRING_CASE_CHECKER[options.hexadecimalEscape](parts[1])) { | ||
const parts = /^\\x(?<code>.*)$/u.exec(cNode.raw); | ||
if (STRING_CASE_CHECKER[options.hexadecimalEscape](parts.groups.code)) { | ||
return; | ||
} | ||
report(regexpContext, cNode, options.hexadecimalEscape, (converter) => `\\x${converter(parts[1])}`); | ||
report(regexpContext, cNode, options.hexadecimalEscape, (converter) => `\\x${converter(parts.groups.code)}`); | ||
} | ||
@@ -125,7 +125,7 @@ function verifyCharacterInControl(regexpContext, cNode) { | ||
} | ||
const parts = /^\\c(.*)$/u.exec(cNode.raw); | ||
if (STRING_CASE_CHECKER[options.controlEscape](parts[1])) { | ||
const parts = /^\\c(?<code>.*)$/u.exec(cNode.raw); | ||
if (STRING_CASE_CHECKER[options.controlEscape](parts.groups.code)) { | ||
return; | ||
} | ||
report(regexpContext, cNode, options.controlEscape, (converter) => `\\c${converter(parts[1])}`); | ||
report(regexpContext, cNode, options.controlEscape, (converter) => `\\c${converter(parts.groups.code)}`); | ||
} | ||
@@ -138,3 +138,3 @@ function createVisitor(regexpContext) { | ||
} | ||
const escapeKind = utils_1.getEscapeSequenceKind(cNode.raw); | ||
const escapeKind = (0, utils_1.getEscapeSequenceKind)(cNode.raw); | ||
if (escapeKind === utils_1.EscapeSequenceKind.unicode || | ||
@@ -158,3 +158,3 @@ escapeKind === utils_1.EscapeSequenceKind.unicodeCodePoint) { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -161,0 +161,0 @@ }); |
@@ -11,3 +11,3 @@ "use strict"; | ||
const OPTION_DOTALL = "dotAll"; | ||
exports.default = utils_1.createRule("match-any", { | ||
exports.default = (0, utils_1.createRule)("match-any", { | ||
meta: { | ||
@@ -65,3 +65,3 @@ docs: { | ||
} | ||
if (!utils_2.isRegexpLiteral(node)) { | ||
if (!(0, utils_2.isRegexpLiteral)(node)) { | ||
return null; | ||
@@ -106,3 +106,3 @@ } | ||
data: { | ||
expr: mention_1.mention(csNode), | ||
expr: (0, mention_1.mention)(csNode), | ||
}, | ||
@@ -116,3 +116,3 @@ fix(fixer) { | ||
onCharacterClassEnter(ccNode) { | ||
if (regexp_ast_analysis_1.matchesAllCharacters(ccNode, flags) && | ||
if ((0, regexp_ast_analysis_1.matchesAllCharacters)(ccNode, flags) && | ||
!allows.has(ccNode.raw)) { | ||
@@ -124,3 +124,3 @@ context.report({ | ||
data: { | ||
expr: mention_1.mention(ccNode), | ||
expr: (0, mention_1.mention)(ccNode), | ||
}, | ||
@@ -135,3 +135,3 @@ fix(fixer) { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -138,0 +138,0 @@ }); |
@@ -5,3 +5,3 @@ "use strict"; | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("negation", { | ||
exports.default = (0, utils_1.createRule)("negation", { | ||
meta: { | ||
@@ -32,4 +32,4 @@ docs: { | ||
if (flags.ignoreCase && element.kind === "property") { | ||
const ccSet = regexp_ast_analysis_1.toCharSet(ccNode, flags); | ||
const negatedElementSet = regexp_ast_analysis_1.toCharSet(Object.assign(Object.assign({}, element), { negate: !element.negate }), flags); | ||
const ccSet = (0, regexp_ast_analysis_1.toCharSet)(ccNode, flags); | ||
const negatedElementSet = (0, regexp_ast_analysis_1.toCharSet)(Object.assign(Object.assign({}, element), { negate: !element.negate }), flags); | ||
if (!ccSet.equals(negatedElementSet)) { | ||
@@ -50,3 +50,3 @@ return; | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -53,0 +53,0 @@ }); |
@@ -8,3 +8,3 @@ "use strict"; | ||
const no_empty_capturing_group_1 = __importDefault(require("./no-empty-capturing-group")); | ||
exports.default = utils_1.createRule("no-assertion-capturing-group", { | ||
exports.default = (0, utils_1.createRule)("no-assertion-capturing-group", { | ||
meta: Object.assign(Object.assign({}, no_empty_capturing_group_1.default.meta), { docs: Object.assign(Object.assign({}, no_empty_capturing_group_1.default.meta.docs), { recommended: false, replacedBy: ["no-empty-capturing-group"] }), deprecated: true }), | ||
@@ -11,0 +11,0 @@ create(context) { |
@@ -8,3 +8,3 @@ "use strict"; | ||
if (assertion.kind !== "word") { | ||
if (regexp_ast_analysis_1.getMatchingDirectionFromAssertionKind(assertion.kind) !== dir) { | ||
if ((0, regexp_ast_analysis_1.getMatchingDirectionFromAssertionKind)(assertion.kind) !== dir) { | ||
return true; | ||
@@ -14,11 +14,11 @@ } | ||
if (assertion.kind === "lookahead" || assertion.kind === "lookbehind") { | ||
if (regexp_ast_analysis_1.isPotentiallyEmpty(assertion.alternatives)) { | ||
if ((0, regexp_ast_analysis_1.isPotentiallyEmpty)(assertion.alternatives)) { | ||
return true; | ||
} | ||
} | ||
const look = regexp_ast_analysis_1.FirstConsumedChars.toLook(regexp_ast_analysis_1.getFirstConsumedChar(assertion, dir, flags)); | ||
const look = regexp_ast_analysis_1.FirstConsumedChars.toLook((0, regexp_ast_analysis_1.getFirstConsumedChar)(assertion, dir, flags)); | ||
if (look.char.isEmpty || look.char.isAll) { | ||
return true; | ||
} | ||
const after = regexp_ast_analysis_1.getFirstCharAfter(assertion, dir, flags); | ||
const after = (0, regexp_ast_analysis_1.getFirstCharAfter)(assertion, dir, flags); | ||
if (!after.edge) { | ||
@@ -57,3 +57,3 @@ if (look.exact && look.char.isSupersetOf(after.char)) { | ||
yield e; | ||
if (!regexp_ast_analysis_1.isZeroLength(e)) { | ||
if (!(0, regexp_ast_analysis_1.isZeroLength)(e)) { | ||
return; | ||
@@ -66,3 +66,3 @@ } | ||
(grandParent.type === "Assertion" && | ||
regexp_ast_analysis_1.getMatchingDirectionFromAssertionKind(grandParent.kind) !== | ||
(0, regexp_ast_analysis_1.getMatchingDirectionFromAssertionKind)(grandParent.kind) !== | ||
dir)) && | ||
@@ -94,3 +94,3 @@ grandParent.alternatives.length === 1) { | ||
(element.kind === "lookahead" || element.kind === "lookbehind") && | ||
regexp_ast_analysis_1.getMatchingDirectionFromAssertionKind(element.kind) === dir) { | ||
(0, regexp_ast_analysis_1.getMatchingDirectionFromAssertionKind)(element.kind) === dir) { | ||
element.alternatives.forEach((a) => tryFindContradictionInAlternative(a, dir, condition)); | ||
@@ -112,3 +112,3 @@ } | ||
} | ||
if (!regexp_ast_analysis_1.isZeroLength(e)) { | ||
if (!(0, regexp_ast_analysis_1.isZeroLength)(e)) { | ||
break; | ||
@@ -125,3 +125,3 @@ } | ||
} | ||
exports.default = utils_1.createRule("no-contradiction-with-assertion", { | ||
exports.default = (0, utils_1.createRule)("no-contradiction-with-assertion", { | ||
meta: { | ||
@@ -151,3 +151,3 @@ docs: { | ||
} | ||
const assertionLook = regexp_ast_analysis_1.FirstConsumedChars.toLook(regexp_ast_analysis_1.getFirstConsumedChar(assertion, dir, flags)); | ||
const assertionLook = regexp_ast_analysis_1.FirstConsumedChars.toLook((0, regexp_ast_analysis_1.getFirstConsumedChar)(assertion, dir, flags)); | ||
for (const element of getNextElements(assertion, dir)) { | ||
@@ -159,7 +159,7 @@ if (tryFindContradictionIn(element, dir, contradicts)) { | ||
function contradictsAlternative(alternative) { | ||
let consumed = regexp_ast_analysis_1.getFirstConsumedChar(alternative, dir, flags); | ||
let consumed = (0, regexp_ast_analysis_1.getFirstConsumedChar)(alternative, dir, flags); | ||
if (consumed.empty) { | ||
consumed = regexp_ast_analysis_1.FirstConsumedChars.concat([ | ||
consumed, | ||
regexp_ast_analysis_1.getFirstConsumedCharAfter(alternative, dir, flags), | ||
(0, regexp_ast_analysis_1.getFirstConsumedCharAfter)(alternative, dir, flags), | ||
], flags); | ||
@@ -174,4 +174,4 @@ } | ||
data: { | ||
assertion: mention_1.mention(assertion), | ||
alt: mention_1.mention(alternative), | ||
assertion: (0, mention_1.mention)(assertion), | ||
alt: (0, mention_1.mention)(alternative), | ||
}, | ||
@@ -190,3 +190,3 @@ }); | ||
} | ||
const consumed = regexp_ast_analysis_1.getFirstConsumedChar(quant.element, dir, flags); | ||
const consumed = (0, regexp_ast_analysis_1.getFirstConsumedChar)(quant.element, dir, flags); | ||
const look = regexp_ast_analysis_1.FirstConsumedChars.toLook(consumed); | ||
@@ -199,4 +199,4 @@ if (disjoint(assertionLook, look)) { | ||
data: { | ||
assertion: mention_1.mention(assertion), | ||
quant: mention_1.mention(quant), | ||
assertion: (0, mention_1.mention)(assertion), | ||
quant: (0, mention_1.mention)(quant), | ||
}, | ||
@@ -212,5 +212,5 @@ suggest: [ | ||
} | ||
const after = regexp_ast_analysis_1.getFirstCharAfter(quant, dir, flags); | ||
const after = (0, regexp_ast_analysis_1.getFirstCharAfter)(quant, dir, flags); | ||
if (disjoint(assertionLook, after)) { | ||
const newQuant = utils_1.quantToString(Object.assign(Object.assign({}, quant), { min: 1 })); | ||
const newQuant = (0, utils_1.quantToString)(Object.assign(Object.assign({}, quant), { min: 1 })); | ||
context.report({ | ||
@@ -221,4 +221,4 @@ node, | ||
data: { | ||
assertion: mention_1.mention(assertion), | ||
quant: mention_1.mention(quant), | ||
assertion: (0, mention_1.mention)(assertion), | ||
quant: (0, mention_1.mention)(quant), | ||
newQuant, | ||
@@ -258,3 +258,3 @@ }, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -261,0 +261,0 @@ }); |
@@ -14,4 +14,4 @@ "use strict"; | ||
]); | ||
const ALLOWED_CONTROL_CHARS = /^\\[0fnrtv]$/; | ||
exports.default = utils_1.createRule("no-control-character", { | ||
const ALLOWED_CONTROL_CHARS = /^\\[0fnrtv]$/u; | ||
exports.default = (0, utils_1.createRule)("no-control-character", { | ||
meta: { | ||
@@ -33,3 +33,3 @@ docs: { | ||
function createVisitor(regexpContext) { | ||
const { node, patternSource, getRegexpLocation, fixReplaceNode, } = regexpContext; | ||
const { node, patternSource, getRegexpLocation, fixReplaceNode } = regexpContext; | ||
function isBadEscapeRaw(raw, cp) { | ||
@@ -67,3 +67,3 @@ return (raw.codePointAt(0) === cp || | ||
messageId: "escape", | ||
data: { escape: mention_1.mention(allowedEscape) }, | ||
data: { escape: (0, mention_1.mention)(allowedEscape) }, | ||
fix: fixReplaceNode(cNode, allowedEscape), | ||
@@ -76,3 +76,3 @@ }); | ||
messageId: "unexpected", | ||
data: { char: mention_1.mentionChar(cNode) }, | ||
data: { char: (0, mention_1.mentionChar)(cNode) }, | ||
suggest, | ||
@@ -84,3 +84,3 @@ }); | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -87,0 +87,0 @@ }); |
@@ -22,3 +22,3 @@ "use strict"; | ||
for (const e of elements) { | ||
const charSet = regexp_ast_analysis_1.toCharSet(e, flags); | ||
const charSet = (0, regexp_ast_analysis_1.toCharSet)(e, flags); | ||
if (e.type === "Character") { | ||
@@ -60,3 +60,3 @@ const key = charSet.ranges[0].min; | ||
const textAfter = parent.raw.slice(element.end - parent.start); | ||
if (utils_1.mightCreateNewElement(textBefore, textAfter)) { | ||
if ((0, utils_1.mightCreateNewElement)(textBefore, textAfter)) { | ||
return null; | ||
@@ -82,3 +82,3 @@ } | ||
} | ||
exports.default = utils_1.createRule("no-dupe-characters-character-class", { | ||
exports.default = (0, utils_1.createRule)("no-dupe-characters-character-class", { | ||
meta: { | ||
@@ -110,3 +110,3 @@ type: "suggestion", | ||
data: { | ||
duplicate: mention_1.mentionChar(duplicate), | ||
duplicate: (0, mention_1.mentionChar)(duplicate), | ||
}, | ||
@@ -122,4 +122,4 @@ fix: fixRemove(regexpContext, duplicate), | ||
data: { | ||
duplicate: mention_1.mentionChar(duplicate), | ||
element: mention_1.mentionChar(element), | ||
duplicate: (0, mention_1.mentionChar)(duplicate), | ||
element: (0, mention_1.mentionChar)(element), | ||
}, | ||
@@ -136,4 +136,4 @@ fix: fixRemove(regexpContext, duplicate), | ||
data: { | ||
elementA: mention_1.mentionChar(element), | ||
elementB: mention_1.mentionChar(intersectElement), | ||
elementA: (0, mention_1.mentionChar)(element), | ||
elementB: (0, mention_1.mentionChar)(intersectElement), | ||
overlap, | ||
@@ -150,4 +150,4 @@ }, | ||
data: { | ||
subsetElement: mention_1.mentionChar(subsetElement), | ||
element: mention_1.mentionChar(element), | ||
subsetElement: (0, mention_1.mentionChar)(subsetElement), | ||
element: (0, mention_1.mentionChar)(element), | ||
}, | ||
@@ -164,3 +164,3 @@ fix: fixRemove(regexpContext, subsetElement), | ||
data: { | ||
subsetElement: mention_1.mentionChar(subsetElement), | ||
subsetElement: (0, mention_1.mentionChar)(subsetElement), | ||
elements: `'${elements | ||
@@ -186,3 +186,3 @@ .map((e) => e.raw) | ||
for (const other of rangesAndSets) { | ||
if (regexp_ast_analysis_1.toCharSet(other, flags).has(char.value)) { | ||
if ((0, regexp_ast_analysis_1.toCharSet)(other, flags).has(char.value)) { | ||
reportSubset(regexpContext, char, other); | ||
@@ -199,3 +199,3 @@ subsets.add(char); | ||
} | ||
if (regexp_ast_analysis_1.toCharSet(element, flags).isSubsetOf(regexp_ast_analysis_1.toCharSet(other, flags))) { | ||
if ((0, regexp_ast_analysis_1.toCharSet)(element, flags).isSubsetOf((0, regexp_ast_analysis_1.toCharSet)(other, flags))) { | ||
reportSubset(regexpContext, element, other); | ||
@@ -207,3 +207,3 @@ subsets.add(element); | ||
} | ||
const characterTotal = regexp_ast_analysis_1.toCharSet(characters.filter((c) => !subsets.has(c)), flags); | ||
const characterTotal = (0, regexp_ast_analysis_1.toCharSet)(characters.filter((c) => !subsets.has(c)), flags); | ||
for (const element of rangesAndSets) { | ||
@@ -215,8 +215,8 @@ if (subsets.has(element)) { | ||
.filter((e) => !subsets.has(e) && e !== element) | ||
.map((e) => regexp_ast_analysis_1.toCharSet(e, flags))); | ||
const elementCharSet = regexp_ast_analysis_1.toCharSet(element, flags); | ||
.map((e) => (0, regexp_ast_analysis_1.toCharSet)(e, flags))); | ||
const elementCharSet = (0, regexp_ast_analysis_1.toCharSet)(element, flags); | ||
if (elementCharSet.isSubsetOf(totalOthers)) { | ||
const superSetElements = ccNode.elements | ||
.filter((e) => !subsets.has(e) && e !== element) | ||
.filter((e) => !regexp_ast_analysis_1.toCharSet(e, flags).isDisjointWith(elementCharSet)); | ||
.filter((e) => !(0, regexp_ast_analysis_1.toCharSet)(e, flags).isDisjointWith(elementCharSet)); | ||
reportSubsetOfMany(regexpContext, element, superSetElements); | ||
@@ -236,3 +236,3 @@ subsets.add(element); | ||
} | ||
const intersection = regexp_ast_analysis_1.toCharSet(range, flags).intersect(regexp_ast_analysis_1.toCharSet(other, flags)); | ||
const intersection = (0, regexp_ast_analysis_1.toCharSet)(range, flags).intersect((0, regexp_ast_analysis_1.toCharSet)(other, flags)); | ||
if (intersection.isEmpty) { | ||
@@ -245,3 +245,3 @@ continue; | ||
if (!interest.isEmpty) { | ||
reportOverlap(regexpContext, range, other, utils_1.toCharSetSource(interest, flags)); | ||
reportOverlap(regexpContext, range, other, (0, utils_1.toCharSetSource)(interest, flags)); | ||
break; | ||
@@ -254,3 +254,3 @@ } | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -257,0 +257,0 @@ }); |
@@ -12,3 +12,3 @@ "use strict"; | ||
function isStared(node) { | ||
let max = regexp_ast_analysis_1.getEffectiveMaximumRepetition(node); | ||
let max = (0, regexp_ast_analysis_1.getEffectiveMaximumRepetition)(node); | ||
if (node.type === "Quantifier") { | ||
@@ -20,3 +20,3 @@ max *= node.max; | ||
function hasNothingAfterNode(node) { | ||
const md = regexp_ast_analysis_1.getMatchingDirection(node); | ||
const md = (0, regexp_ast_analysis_1.getMatchingDirection)(node); | ||
for (let p = node;; p = p.parent) { | ||
@@ -44,3 +44,3 @@ if (p.type === "Assertion" || p.type === "Pattern") { | ||
try { | ||
refa_1.visitAst(expression, { | ||
(0, refa_1.visitAst)(expression, { | ||
onAssertionEnter() { | ||
@@ -58,3 +58,3 @@ throw new Error(); | ||
try { | ||
refa_1.visitAst(expression, { | ||
(0, refa_1.visitAst)(expression, { | ||
onAssertionEnter() { | ||
@@ -77,3 +77,3 @@ throw new Error(); | ||
}; | ||
const assertionTransformer = refa_1.combineTransformers([ | ||
const assertionTransformer = (0, refa_1.combineTransformers)([ | ||
refa_1.Transformers.applyAssertions(creationOption), | ||
@@ -92,3 +92,3 @@ refa_1.Transformers.removeUnnecessaryAssertions(creationOption), | ||
if (containsAssertions(expression)) { | ||
e = refa_1.transform(assertionTransformer, expression); | ||
e = (0, refa_1.transform)(assertionTransformer, expression); | ||
} | ||
@@ -214,3 +214,3 @@ else { | ||
const other = alternatives[j]; | ||
if (regexp_ast_1.isEqualNodes(other, alternative, flags, shortCircuit)) { | ||
if ((0, regexp_ast_1.isEqualNodes)(other, alternative, flags, shortCircuit)) { | ||
yield { type: "Duplicate", alternative, others: [other] }; | ||
@@ -234,4 +234,4 @@ } | ||
const other = alternatives[j]; | ||
if (regexp_ast_1.isCoveredNode(other, alternative, isCoveredOptions)) { | ||
if (regexp_ast_1.isEqualNodes(other, alternative, flags)) { | ||
if ((0, regexp_ast_1.isCoveredNode)(other, alternative, isCoveredOptions)) { | ||
if ((0, regexp_ast_1.isEqualNodes)(other, alternative, flags)) { | ||
yield { | ||
@@ -244,3 +244,3 @@ type: "Duplicate", | ||
else if (hasNothingAfter && | ||
!regexp_ast_1.isCoveredNode(other, alternative, isCoveredOptionsNoPrefix)) { | ||
!(0, regexp_ast_1.isCoveredNode)(other, alternative, isCoveredOptionsNoPrefix)) { | ||
yield { | ||
@@ -309,3 +309,3 @@ type: "PrefixSubset", | ||
case 3: { | ||
const reorder = reorder_alternatives_1.canReorder([alternative, ...others], flags); | ||
const reorder = (0, reorder_alternatives_1.canReorder)([alternative, ...others], flags); | ||
if (reorder) { | ||
@@ -386,3 +386,3 @@ for (const other of others) { | ||
} | ||
exports.default = utils_1.createRule("no-dupe-disjunctions", { | ||
exports.default = (0, utils_1.createRule)("no-dupe-disjunctions", { | ||
meta: { | ||
@@ -431,3 +431,3 @@ docs: { | ||
flags: new regexpp_1.RegExpParser().parseFlags([ | ||
...new Set((flagsString || "").replace(/[^gimsuy]/g, "")), | ||
...new Set((flagsString || "").replace(/[^gimsuy]/gu, "")), | ||
].join("")), | ||
@@ -555,6 +555,6 @@ }); | ||
} | ||
const cap = regexp_ast_analysis_1.hasSomeDescendant(result.alternative, (d) => d.type === "CapturingGroup") | ||
const cap = (0, regexp_ast_analysis_1.hasSomeDescendant)(result.alternative, (d) => d.type === "CapturingGroup") | ||
? " Careful! This alternative contains capturing groups which might be difficult to remove." | ||
: ""; | ||
const others = mention_1.mention(result.others.map((a) => a.raw).join("|")); | ||
const others = (0, mention_1.mention)(result.others.map((a) => a.raw).join("|")); | ||
switch (result.type) { | ||
@@ -602,3 +602,3 @@ case "Duplicate": | ||
others, | ||
expr: mention_1.mention(faToSource(result.overlap, flags)), | ||
expr: (0, mention_1.mention)(faToSource(result.overlap, flags)), | ||
}, | ||
@@ -623,3 +623,3 @@ }); | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -626,0 +626,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("no-empty-alternative", { | ||
exports.default = (0, utils_1.createRule)("no-empty-alternative", { | ||
meta: { | ||
@@ -52,3 +52,3 @@ docs: { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -55,0 +55,0 @@ }); |
@@ -5,3 +5,3 @@ "use strict"; | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("no-empty-capturing-group", { | ||
exports.default = (0, utils_1.createRule)("no-empty-capturing-group", { | ||
meta: { | ||
@@ -23,3 +23,3 @@ docs: { | ||
onCapturingGroupEnter(cgNode) { | ||
if (regexp_ast_analysis_1.isZeroLength(cgNode)) { | ||
if ((0, regexp_ast_analysis_1.isZeroLength)(cgNode)) { | ||
context.report({ | ||
@@ -34,3 +34,3 @@ node, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -37,0 +37,0 @@ }); |
@@ -5,3 +5,3 @@ "use strict"; | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("no-empty-character-class", { | ||
exports.default = (0, utils_1.createRule)("no-empty-character-class", { | ||
meta: { | ||
@@ -25,3 +25,3 @@ docs: { | ||
onCharacterClassEnter(ccNode) { | ||
if (regexp_ast_analysis_1.matchesNoCharacters(ccNode, flags)) { | ||
if ((0, regexp_ast_analysis_1.matchesNoCharacters)(ccNode, flags)) { | ||
context.report({ | ||
@@ -38,3 +38,3 @@ node, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -41,0 +41,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("no-empty-group", { | ||
exports.default = (0, utils_1.createRule)("no-empty-group", { | ||
meta: { | ||
@@ -37,3 +37,3 @@ docs: { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -40,0 +40,0 @@ }); |
@@ -5,3 +5,3 @@ "use strict"; | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("no-empty-lookarounds-assertion", { | ||
exports.default = (0, utils_1.createRule)("no-empty-lookarounds-assertion", { | ||
meta: { | ||
@@ -27,3 +27,3 @@ docs: { | ||
} | ||
if (regexp_ast_analysis_1.isPotentiallyEmpty(aNode.alternatives)) { | ||
if ((0, regexp_ast_analysis_1.isPotentiallyEmpty)(aNode.alternatives)) { | ||
context.report({ | ||
@@ -42,3 +42,3 @@ node, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -45,0 +45,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("no-escape-backspace", { | ||
exports.default = (0, utils_1.createRule)("no-escape-backspace", { | ||
meta: { | ||
@@ -31,3 +31,3 @@ docs: { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -34,0 +34,0 @@ }); |
@@ -11,3 +11,3 @@ "use strict"; | ||
} | ||
exports.default = utils_1.createRule("no-invalid-regexp", { | ||
exports.default = (0, utils_1.createRule)("no-invalid-regexp", { | ||
meta: { | ||
@@ -45,4 +45,4 @@ docs: { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { visitInvalid }); | ||
return (0, utils_1.defineRegexpVisitor)(context, { visitInvalid }); | ||
}, | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("no-invisible-character", { | ||
exports.default = (0, utils_1.createRule)("no-invisible-character", { | ||
meta: { | ||
@@ -26,4 +26,4 @@ docs: { | ||
} | ||
if (cNode.raw.length === 1 && utils_1.isInvisible(cNode.value)) { | ||
const instead = utils_1.toCharSetSource(cNode.value, flags); | ||
if (cNode.raw.length === 1 && (0, utils_1.isInvisible)(cNode.value)) { | ||
const instead = (0, utils_1.toCharSetSource)(cNode.value, flags); | ||
context.report({ | ||
@@ -50,4 +50,4 @@ node, | ||
const cp = c.codePointAt(0); | ||
if (utils_1.isInvisible(cp)) { | ||
const instead = utils_1.toCharSetSource(cp, flags); | ||
if ((0, utils_1.isInvisible)(cp)) { | ||
const instead = (0, utils_1.toCharSetSource)(cp, flags); | ||
const range = [ | ||
@@ -75,3 +75,3 @@ node.range[0] + index, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createLiteralVisitor, | ||
@@ -78,0 +78,0 @@ createSourceVisitor(regexpContext) { |
@@ -32,3 +32,3 @@ "use strict"; | ||
} | ||
exports.default = utils_1.createRule("no-lazy-ends", { | ||
exports.default = (0, utils_1.createRule)("no-lazy-ends", { | ||
meta: { | ||
@@ -98,3 +98,3 @@ docs: { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -101,0 +101,0 @@ }); |
@@ -28,3 +28,3 @@ "use strict"; | ||
const PROTOTYPE_METHODS = ["compile"]; | ||
exports.default = utils_1.createRule("no-legacy-features", { | ||
exports.default = (0, utils_1.createRule)("no-legacy-features", { | ||
meta: { | ||
@@ -64,3 +64,3 @@ docs: { | ||
const prototypeMethods = (_d = (_c = context.options[0]) === null || _c === void 0 ? void 0 : _c.prototypeMethods) !== null && _d !== void 0 ? _d : PROTOTYPE_METHODS; | ||
const typeTracer = type_tracker_1.createTypeTracker(context); | ||
const typeTracer = (0, type_tracker_1.createTypeTracker)(context); | ||
return Object.assign(Object.assign({}, (staticProperties.length | ||
@@ -67,0 +67,0 @@ ? { |
@@ -33,3 +33,3 @@ "use strict"; | ||
const e = alt.elements[i]; | ||
if (e.type === "Character" && !utils_1.isEscapeSequence(e.raw)) { | ||
if (e.type === "Character" && !(0, utils_1.isEscapeSequence)(e.raw)) { | ||
start = e.start; | ||
@@ -101,3 +101,3 @@ } | ||
} | ||
exports.default = utils_1.createRule("no-misleading-unicode-character", { | ||
exports.default = (0, utils_1.createRule)("no-misleading-unicode-character", { | ||
meta: { | ||
@@ -154,3 +154,3 @@ docs: { | ||
const graphemes = problems | ||
.map((p) => mention_1.mention(p.grapheme)) | ||
.map((p) => (0, mention_1.mention)(p.grapheme)) | ||
.join(", "); | ||
@@ -174,4 +174,4 @@ const uFlag = problems.every((p) => p.problem === "Surrogate"); | ||
context.report(Object.assign({ node, loc: getRegexpLocation(qNode), messageId: `quantifier${problem}`, data: { | ||
grapheme: mention_1.mention(grapheme), | ||
last: mention_1.mentionChar(qNode.element), | ||
grapheme: (0, mention_1.mention)(grapheme), | ||
last: (0, mention_1.mentionChar)(qNode.element), | ||
} }, makeFix((fixer) => { | ||
@@ -186,7 +186,7 @@ const range = patternSource.getReplaceRange({ | ||
return range.replace(fixer, `(?:${grapheme})`); | ||
}, "fixQuantifier", { grapheme: mention_1.mention(grapheme) }))); | ||
}, "fixQuantifier", { grapheme: (0, mention_1.mention)(grapheme) }))); | ||
}, | ||
}; | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -193,0 +193,0 @@ }); |
@@ -5,3 +5,3 @@ "use strict"; | ||
const STANDARD_FLAGS = "dgimsuy"; | ||
exports.default = utils_1.createRule("no-non-standard-flag", { | ||
exports.default = (0, utils_1.createRule)("no-non-standard-flag", { | ||
meta: { | ||
@@ -33,3 +33,3 @@ docs: { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor(regexpContext) { | ||
@@ -36,0 +36,0 @@ visit(regexpContext); |
@@ -6,3 +6,3 @@ "use strict"; | ||
const mention_1 = require("../utils/mention"); | ||
exports.default = utils_1.createRule("no-obscure-range", { | ||
exports.default = (0, utils_1.createRule)("no-obscure-range", { | ||
meta: { | ||
@@ -18,3 +18,3 @@ docs: { | ||
properties: { | ||
allowed: char_ranges_1.getAllowedCharValueSchema(), | ||
allowed: (0, char_ranges_1.getAllowedCharValueSchema)(), | ||
}, | ||
@@ -31,3 +31,3 @@ additionalProperties: false, | ||
var _a; | ||
const allowedRanges = char_ranges_1.getAllowedCharRanges((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.allowed, context); | ||
const allowedRanges = (0, char_ranges_1.getAllowedCharRanges)((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.allowed, context); | ||
function createVisitor({ node, getRegexpLocation, }) { | ||
@@ -40,15 +40,15 @@ return { | ||
} | ||
if (utils_1.isControlEscape(min.raw) && utils_1.isControlEscape(max.raw)) { | ||
if ((0, utils_1.isControlEscape)(min.raw) && (0, utils_1.isControlEscape)(max.raw)) { | ||
return; | ||
} | ||
if (utils_1.isOctalEscape(min.raw) && utils_1.isOctalEscape(max.raw)) { | ||
if ((0, utils_1.isOctalEscape)(min.raw) && (0, utils_1.isOctalEscape)(max.raw)) { | ||
return; | ||
} | ||
if ((utils_1.isUseHexEscape(min.raw) || min.value === 0) && | ||
utils_1.isUseHexEscape(max.raw)) { | ||
if (((0, utils_1.isUseHexEscape)(min.raw) || min.value === 0) && | ||
(0, utils_1.isUseHexEscape)(max.raw)) { | ||
return; | ||
} | ||
if (!utils_1.isEscapeSequence(min.raw) && | ||
!utils_1.isEscapeSequence(max.raw) && | ||
char_ranges_1.inRange(allowedRanges, min.value, max.value)) { | ||
if (!(0, utils_1.isEscapeSequence)(min.raw) && | ||
!(0, utils_1.isEscapeSequence)(max.raw) && | ||
(0, char_ranges_1.inRange)(allowedRanges, min.value, max.value)) { | ||
return; | ||
@@ -61,3 +61,3 @@ } | ||
data: { | ||
range: mention_1.mentionChar(rNode), | ||
range: (0, mention_1.mentionChar)(rNode), | ||
}, | ||
@@ -68,3 +68,3 @@ }); | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -71,0 +71,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("no-octal", { | ||
exports.default = (0, utils_1.createRule)("no-octal", { | ||
meta: { | ||
@@ -26,3 +26,3 @@ docs: { | ||
} | ||
if (!utils_1.isOctalEscape(cNode.raw)) { | ||
if (!(0, utils_1.isOctalEscape)(cNode.raw)) { | ||
return; | ||
@@ -56,3 +56,3 @@ } | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -59,0 +59,0 @@ }); |
@@ -17,3 +17,3 @@ "use strict"; | ||
} | ||
if (!regexp_ast_analysis_1.isZeroLength(e)) { | ||
if (!(0, regexp_ast_analysis_1.isZeroLength)(e)) { | ||
return false; | ||
@@ -28,3 +28,3 @@ } | ||
else { | ||
if (parent.max > 1 && !regexp_ast_analysis_1.isZeroLength(parent)) { | ||
if (parent.max > 1 && !(0, regexp_ast_analysis_1.isZeroLength)(parent)) { | ||
return false; | ||
@@ -37,3 +37,3 @@ } | ||
} | ||
exports.default = utils_1.createRule("no-optional-assertion", { | ||
exports.default = (0, utils_1.createRule)("no-optional-assertion", { | ||
meta: { | ||
@@ -80,3 +80,3 @@ docs: { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -83,0 +83,0 @@ }); |
@@ -5,3 +5,3 @@ "use strict"; | ||
const regexp_ast_analysis_1 = require("regexp-ast-analysis"); | ||
exports.default = utils_1.createRule("no-potentially-useless-backreference", { | ||
exports.default = (0, utils_1.createRule)("no-potentially-useless-backreference", { | ||
meta: { | ||
@@ -24,6 +24,6 @@ docs: { | ||
onBackreferenceEnter(backreference) { | ||
if (regexp_ast_analysis_1.isEmptyBackreference(backreference)) { | ||
if ((0, regexp_ast_analysis_1.isEmptyBackreference)(backreference)) { | ||
return; | ||
} | ||
if (!regexp_ast_analysis_1.isStrictBackreference(backreference)) { | ||
if (!(0, regexp_ast_analysis_1.isStrictBackreference)(backreference)) { | ||
context.report({ | ||
@@ -38,3 +38,3 @@ node, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -41,0 +41,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("no-standalone-backslash", { | ||
exports.default = (0, utils_1.createRule)("no-standalone-backslash", { | ||
meta: { | ||
@@ -31,3 +31,3 @@ docs: { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -34,0 +34,0 @@ }); |
@@ -43,3 +43,3 @@ "use strict"; | ||
} | ||
exports.default = utils_1.createRule("no-super-linear-backtracking", { | ||
exports.default = (0, utils_1.createRule)("no-super-linear-backtracking", { | ||
meta: { | ||
@@ -78,3 +78,3 @@ docs: { | ||
const { node, patternAst, flags, getRegexpLocation, fixReplaceNode, getUsageOfPattern, } = regexpContext; | ||
const result = scslre_1.analyse(getParsedLiteral(regexpContext), { | ||
const result = (0, scslre_1.analyse)(getParsedLiteral(regexpContext), { | ||
reportTypes: { Move: false }, | ||
@@ -100,3 +100,3 @@ assumeRejectingSuffix: reportUncertain && | ||
attack, | ||
parent: mention_1.mention(report.parentQuant), | ||
parent: (0, mention_1.mention)(report.parentQuant), | ||
}, | ||
@@ -114,4 +114,4 @@ fix, | ||
attack, | ||
start: mention_1.mention(report.startQuant), | ||
end: mention_1.mention(report.endQuant), | ||
start: (0, mention_1.mention)(report.startQuant), | ||
end: (0, mention_1.mention)(report.endQuant), | ||
}, | ||
@@ -124,3 +124,3 @@ fix, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -127,0 +127,0 @@ }); |
@@ -63,3 +63,3 @@ "use strict"; | ||
case "Alternative": { | ||
const dir = regexp_ast_analysis_1.getMatchingDirection(node); | ||
const dir = (0, regexp_ast_analysis_1.getMatchingDirection)(node); | ||
for (let i = 0; i < node.elements.length; i++) { | ||
@@ -69,3 +69,3 @@ const elementIndex = dir === "ltr" ? i : node.elements.length - 1 - i; | ||
yield* findReachableQuantifiers(element); | ||
if (!regexp_ast_analysis_1.isPotentiallyEmpty(element)) { | ||
if (!(0, regexp_ast_analysis_1.isPotentiallyEmpty)(element)) { | ||
break; | ||
@@ -84,3 +84,3 @@ } | ||
}; | ||
const PASS_1 = refa_1.combineTransformers([ | ||
const PASS_1 = (0, refa_1.combineTransformers)([ | ||
refa_1.Transformers.inline(TRANFORMER_OPTIONS), | ||
@@ -94,3 +94,3 @@ refa_1.Transformers.removeDeadBranches(TRANFORMER_OPTIONS), | ||
]); | ||
const PASS_2 = refa_1.combineTransformers([ | ||
const PASS_2 = (0, refa_1.combineTransformers)([ | ||
refa_1.Transformers.inline(TRANFORMER_OPTIONS), | ||
@@ -100,3 +100,3 @@ refa_1.Transformers.removeDeadBranches(TRANFORMER_OPTIONS), | ||
]); | ||
exports.default = utils_1.createRule("no-super-linear-move", { | ||
exports.default = (0, utils_1.createRule)("no-super-linear-move", { | ||
meta: { | ||
@@ -137,3 +137,3 @@ docs: { | ||
const { flags } = regexpContext; | ||
const result = scslre_1.analyse(getParsedLiteral(regexpContext, true), { | ||
const result = (0, scslre_1.analyse)(getParsedLiteral(regexpContext, true), { | ||
reportTypes: { Move: true, Self: false, Trade: false }, | ||
@@ -167,4 +167,4 @@ assumeRejectingSuffix, | ||
}).expression; | ||
e = refa_1.transform(PASS_1, e); | ||
e = refa_1.transform(PASS_2, e); | ||
e = (0, refa_1.transform)(PASS_1, e); | ||
e = (0, refa_1.transform)(PASS_2, e); | ||
if (e.alternatives.length === 0) { | ||
@@ -174,3 +174,3 @@ continue; | ||
let hasCharacters = false; | ||
refa_1.visitAst(e, { | ||
(0, refa_1.visitAst)(e, { | ||
onCharacterClassEnter() { | ||
@@ -184,3 +184,3 @@ hasCharacters = true; | ||
if (!assumeRejectingSuffix) { | ||
const after = regexp_ast_analysis_1.getFirstConsumedCharAfter(q, regexp_ast_analysis_1.getMatchingDirection(q), flags); | ||
const after = (0, regexp_ast_analysis_1.getFirstConsumedCharAfter)(q, (0, regexp_ast_analysis_1.getMatchingDirection)(q), flags); | ||
if (after.empty && after.look.char.isAll) { | ||
@@ -201,3 +201,3 @@ continue; | ||
function createVisitor(regexpContext) { | ||
const { node, flags, getRegexpLocation, getUsageOfPattern, } = regexpContext; | ||
const { node, flags, getRegexpLocation, getUsageOfPattern } = regexpContext; | ||
if (ignoreSticky && flags.sticky) { | ||
@@ -224,3 +224,3 @@ return {}; | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -227,0 +227,0 @@ }); |
@@ -34,3 +34,3 @@ "use strict"; | ||
} | ||
exports.default = utils_1.createRule("no-trivially-nested-assertion", { | ||
exports.default = (0, utils_1.createRule)("no-trivially-nested-assertion", { | ||
meta: { | ||
@@ -66,3 +66,3 @@ docs: { | ||
nested.negate && | ||
regexp_ast_analysis_1.hasSomeDescendant(nested, (d) => d.type === "CapturingGroup")) { | ||
(0, regexp_ast_analysis_1.hasSomeDescendant)(nested, (d) => d.type === "CapturingGroup")) { | ||
return; | ||
@@ -85,3 +85,3 @@ } | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -88,0 +88,0 @@ }); |
@@ -58,3 +58,3 @@ "use strict"; | ||
} | ||
exports.default = utils_1.createRule("no-trivially-nested-quantifier", { | ||
exports.default = (0, utils_1.createRule)("no-trivially-nested-quantifier", { | ||
meta: { | ||
@@ -95,3 +95,3 @@ docs: { | ||
} | ||
const quantStr = utils_1.quantToString(quant); | ||
const quantStr = (0, utils_1.quantToString)(quant); | ||
const replacement = child.element.raw + quantStr; | ||
@@ -129,3 +129,3 @@ context.report({ | ||
messageId: "childSimpler", | ||
data: { quant: utils_1.quantToString(quant) }, | ||
data: { quant: (0, utils_1.quantToString)(quant) }, | ||
fix: fixReplaceQuant(child, quant), | ||
@@ -139,3 +139,3 @@ }); | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -142,0 +142,0 @@ }); |
@@ -9,5 +9,5 @@ "use strict"; | ||
} | ||
return `number ${regexp_ast_analysis_1.getCapturingGroupNumber(group)}`; | ||
return `number ${(0, regexp_ast_analysis_1.getCapturingGroupNumber)(group)}`; | ||
} | ||
exports.default = utils_1.createRule("no-unused-capturing-group", { | ||
exports.default = (0, utils_1.createRule)("no-unused-capturing-group", { | ||
meta: { | ||
@@ -52,3 +52,3 @@ docs: { | ||
const fix = fixableGroups.has(cgNode) | ||
? fixReplaceNode(cgNode, cgNode.raw.replace(/^\((?:\?<[^<>]+>)?/, "(?:")) | ||
? fixReplaceNode(cgNode, cgNode.raw.replace(/^\((?:\?<[^<>]+>)?/u, "(?:")) | ||
: null; | ||
@@ -140,3 +140,3 @@ context.report({ | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -143,0 +143,0 @@ }); |
@@ -17,3 +17,3 @@ "use strict"; | ||
}; | ||
exports.default = utils_1.createRule("no-useless-assertions", { | ||
exports.default = (0, utils_1.createRule)("no-useless-assertions", { | ||
meta: { | ||
@@ -36,8 +36,8 @@ docs: { | ||
messageId, | ||
data: Object.assign({ assertion: mention_1.mention(assertion) }, data), | ||
data: Object.assign({ assertion: (0, mention_1.mention)(assertion) }, data), | ||
}); | ||
} | ||
function verifyStartOrEnd(assertion) { | ||
const direction = regexp_ast_analysis_1.getMatchingDirectionFromAssertionKind(assertion.kind); | ||
const next = regexp_ast_analysis_1.getFirstCharAfter(assertion, direction, flags); | ||
const direction = (0, regexp_ast_analysis_1.getMatchingDirectionFromAssertionKind)(assertion.kind); | ||
const next = (0, regexp_ast_analysis_1.getFirstCharAfter)(assertion, direction, flags); | ||
const followedOrPreceded = assertion.kind === "end" ? "followed" : "preceded"; | ||
@@ -65,4 +65,4 @@ if (!next.edge) { | ||
const word = regexp_ast_analysis_1.Chars.word(flags); | ||
const next = regexp_ast_analysis_1.getFirstCharAfter(assertion, "ltr", flags); | ||
const prev = regexp_ast_analysis_1.getFirstCharAfter(assertion, "rtl", flags); | ||
const next = (0, regexp_ast_analysis_1.getFirstCharAfter)(assertion, "ltr", flags); | ||
const prev = (0, regexp_ast_analysis_1.getFirstCharAfter)(assertion, "rtl", flags); | ||
if (prev.edge || next.edge) { | ||
@@ -103,11 +103,11 @@ return; | ||
function verifyLookaround(assertion) { | ||
if (regexp_ast_analysis_1.isPotentiallyEmpty(assertion.alternatives)) { | ||
if ((0, regexp_ast_analysis_1.isPotentiallyEmpty)(assertion.alternatives)) { | ||
return; | ||
} | ||
const direction = regexp_ast_analysis_1.getMatchingDirectionFromAssertionKind(assertion.kind); | ||
const after = regexp_ast_analysis_1.getFirstCharAfter(assertion, direction, flags); | ||
const direction = (0, regexp_ast_analysis_1.getMatchingDirectionFromAssertionKind)(assertion.kind); | ||
const after = (0, regexp_ast_analysis_1.getFirstCharAfter)(assertion, direction, flags); | ||
if (after.edge) { | ||
return; | ||
} | ||
const firstOf = regexp_ast_analysis_1.FirstConsumedChars.toLook(regexp_ast_analysis_1.getFirstConsumedChar(assertion.alternatives, direction, flags)); | ||
const firstOf = regexp_ast_analysis_1.FirstConsumedChars.toLook((0, regexp_ast_analysis_1.getFirstConsumedChar)(assertion.alternatives, direction, flags)); | ||
const accept = assertion.negate ? "reject" : "accept"; | ||
@@ -123,4 +123,4 @@ const reject = assertion.negate ? "accept" : "reject"; | ||
} | ||
if (!regexp_ast_analysis_1.hasSomeDescendant(assertion, (d) => d !== assertion && d.type === "Assertion")) { | ||
const range = regexp_ast_analysis_1.getLengthRange(assertion.alternatives); | ||
if (!(0, regexp_ast_analysis_1.hasSomeDescendant)(assertion, (d) => d !== assertion && d.type === "Assertion")) { | ||
const range = (0, regexp_ast_analysis_1.getLengthRange)(assertion.alternatives); | ||
if (range && range.max === 1) { | ||
@@ -158,3 +158,3 @@ if (firstOf.exact && | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -161,0 +161,0 @@ }); |
@@ -18,3 +18,3 @@ "use strict"; | ||
const group = backRef.resolved; | ||
const closestAncestor = regexp_ast_analysis_1.getClosestAncestor(backRef, group); | ||
const closestAncestor = (0, regexp_ast_analysis_1.getClosestAncestor)(backRef, group); | ||
if (closestAncestor === group) { | ||
@@ -29,3 +29,3 @@ return "nested"; | ||
} | ||
const matchingDir = regexp_ast_analysis_1.getMatchingDirection(closestAncestor); | ||
const matchingDir = (0, regexp_ast_analysis_1.getMatchingDirection)(closestAncestor); | ||
if (matchingDir === "ltr" && backRef.end <= group.start) { | ||
@@ -37,3 +37,3 @@ return "forward"; | ||
} | ||
if (regexp_ast_analysis_1.isZeroLength(group)) { | ||
if ((0, regexp_ast_analysis_1.isZeroLength)(group)) { | ||
return "empty"; | ||
@@ -43,3 +43,3 @@ } | ||
} | ||
exports.default = utils_1.createRule("no-useless-backreference", { | ||
exports.default = (0, utils_1.createRule)("no-useless-backreference", { | ||
meta: { | ||
@@ -73,4 +73,4 @@ docs: { | ||
data: { | ||
bref: mention_1.mention(backRef), | ||
group: mention_1.mention(backRef.resolved), | ||
bref: (0, mention_1.mention)(backRef), | ||
group: (0, mention_1.mention)(backRef.resolved), | ||
}, | ||
@@ -82,3 +82,3 @@ }); | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -85,0 +85,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("no-useless-character-class", { | ||
exports.default = (0, utils_1.createRule)("no-useless-character-class", { | ||
meta: { | ||
@@ -53,3 +53,3 @@ docs: { | ||
} | ||
if (/^\\\d+$/.test(element.raw) && | ||
if (/^\\\d+$/u.test(element.raw) && | ||
!element.raw.startsWith("\\0")) { | ||
@@ -62,3 +62,3 @@ return; | ||
} | ||
if (!utils_1.canUnwrapped(ccNode, element.raw)) { | ||
if (!(0, utils_1.canUnwrapped)(ccNode, element.raw)) { | ||
return; | ||
@@ -106,3 +106,3 @@ } | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -109,0 +109,0 @@ }); |
@@ -8,5 +8,5 @@ "use strict"; | ||
function extractDollarReplacements(context, node) { | ||
return ast_utils_1.parseReplacements(context, node).filter((e) => e.type === "ReferenceElement"); | ||
return (0, ast_utils_1.parseReplacements)(context, node).filter((e) => e.type === "ReferenceElement"); | ||
} | ||
exports.default = utils_1.createRule("no-useless-dollar-replacements", { | ||
exports.default = (0, utils_1.createRule)("no-useless-dollar-replacements", { | ||
meta: { | ||
@@ -28,6 +28,6 @@ docs: { | ||
create(context) { | ||
const typeTracer = type_tracker_1.createTypeTracker(context); | ||
const typeTracer = (0, type_tracker_1.createTypeTracker)(context); | ||
const sourceCode = context.getSourceCode(); | ||
function verify(patternNode, replacement) { | ||
const captures = regexp_ast_1.extractCaptures(patternNode); | ||
const captures = (0, regexp_ast_1.extractCaptures)(patternNode); | ||
for (const dollarReplacement of extractDollarReplacements(context, replacement)) { | ||
@@ -73,3 +73,3 @@ if (typeof dollarReplacement.ref === "number") { | ||
CallExpression(node) { | ||
if (!ast_utils_1.isKnownMethodCall(node, { replace: 2, replaceAll: 2 })) { | ||
if (!(0, ast_utils_1.isKnownMethodCall)(node, { replace: 2, replaceAll: 2 })) { | ||
return; | ||
@@ -83,3 +83,3 @@ } | ||
} | ||
const patternNode = regexp_ast_1.getRegExpNodeFromExpression(node.arguments[0], context); | ||
const patternNode = (0, regexp_ast_1.getRegExpNodeFromExpression)(node.arguments[0], context); | ||
if (!patternNode) { | ||
@@ -86,0 +86,0 @@ return; |
@@ -27,3 +27,3 @@ "use strict"; | ||
const POTENTIAL_ESCAPE_SEQUENCE = new Set("uxkpP"); | ||
exports.default = utils_1.createRule("no-useless-escape", { | ||
exports.default = (0, utils_1.createRule)("no-useless-escape", { | ||
meta: { | ||
@@ -84,3 +84,3 @@ docs: { | ||
} | ||
if (!utils_1.canUnwrapped(cNode, char)) { | ||
if (!(0, utils_1.canUnwrapped)(cNode, char)) { | ||
return; | ||
@@ -94,3 +94,3 @@ } | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -97,0 +97,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("no-useless-exactly-quantifier", { | ||
exports.default = (0, utils_1.createRule)("no-useless-exactly-quantifier", { | ||
meta: { | ||
@@ -25,3 +25,3 @@ docs: { | ||
(qNode.min === 0 || qNode.min === 1)) { | ||
const [startOffset, endOffset] = utils_1.getQuantifierOffsets(qNode); | ||
const [startOffset, endOffset] = (0, utils_1.getQuantifierOffsets)(qNode); | ||
const text = qNode.raw.slice(startOffset, endOffset); | ||
@@ -43,3 +43,3 @@ context.report({ | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -46,0 +46,0 @@ }); |
@@ -92,5 +92,5 @@ "use strict"; | ||
function createUselessIgnoreCaseFlagVisitor(context) { | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor(regExpContext) { | ||
const { flags, regexpNode, ownsFlags, getFlagLocation, } = regExpContext; | ||
const { flags, regexpNode, ownsFlags, getFlagLocation } = regExpContext; | ||
if (!flags.ignoreCase || !ownsFlags) { | ||
@@ -101,3 +101,3 @@ return {}; | ||
onPatternLeave(pattern) { | ||
if (!case_variation_1.isCaseVariant(pattern, flags, false)) { | ||
if (!(0, case_variation_1.isCaseVariant)(pattern, flags, false)) { | ||
context.report({ | ||
@@ -116,5 +116,5 @@ node: regexpNode, | ||
function createUselessMultilineFlagVisitor(context) { | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor(regExpContext) { | ||
const { flags, regexpNode, ownsFlags, getFlagLocation, } = regExpContext; | ||
const { flags, regexpNode, ownsFlags, getFlagLocation } = regExpContext; | ||
if (!flags.multiline || !ownsFlags) { | ||
@@ -145,5 +145,5 @@ return {}; | ||
function createUselessDotAllFlagVisitor(context) { | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor(regExpContext) { | ||
const { flags, regexpNode, ownsFlags, getFlagLocation, } = regExpContext; | ||
const { flags, regexpNode, ownsFlags, getFlagLocation } = regExpContext; | ||
if (!flags.dotAll || !ownsFlags) { | ||
@@ -323,3 +323,3 @@ return {}; | ||
function createRegExpReferenceExtractVisitor(context, { flag, exit, isUsedShortCircuit, strictTypes, }) { | ||
const typeTracer = type_tracker_1.createTypeTracker(context); | ||
const typeTracer = (0, type_tracker_1.createTypeTracker)(context); | ||
let stack = null; | ||
@@ -358,3 +358,3 @@ const regExpReferenceMap = new Map(); | ||
} | ||
return utils_1.compositingVisitors(utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.compositingVisitors)((0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor(regExpContext) { | ||
@@ -366,3 +366,3 @@ const { flags, regexpNode } = regExpContext; | ||
regExpReferenceMap.set(regexpNode, regExpReference); | ||
for (const ref of ast_utils_1.extractExpressionReferences(regexpNode, context)) { | ||
for (const ref of (0, ast_utils_1.extractExpressionReferences)(regexpNode, context)) { | ||
if (ref.type === "argument" || ref.type === "member") { | ||
@@ -428,3 +428,3 @@ regExpReferenceMap.set(ref.node, regExpReference); | ||
} | ||
if (!ast_utils_1.isKnownMethodCall(node, { | ||
if (!(0, ast_utils_1.isKnownMethodCall)(node, { | ||
search: 1, | ||
@@ -462,3 +462,3 @@ split: 1, | ||
function removeFlags(node) { | ||
const newFlags = node.regex.flags.replace(/[^u]+/g, ""); | ||
const newFlags = node.regex.flags.replace(/[^u]+/gu, ""); | ||
if (newFlags === node.regex.flags) { | ||
@@ -469,6 +469,6 @@ return; | ||
node, | ||
loc: utils_1.getFlagsLocation(sourceCode, node, node), | ||
loc: (0, utils_1.getFlagsLocation)(sourceCode, node, node), | ||
messageId: "uselessFlagsOwned", | ||
fix(fixer) { | ||
const range = utils_1.getFlagsRange(node); | ||
const range = (0, utils_1.getFlagsRange)(node); | ||
return fixer.replaceTextRange(range, newFlags); | ||
@@ -478,3 +478,3 @@ }, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createSourceVisitor(regExpContext) { | ||
@@ -515,3 +515,3 @@ var _a; | ||
} | ||
exports.default = utils_1.createRule("no-useless-flag", { | ||
exports.default = (0, utils_1.createRule)("no-useless-flag", { | ||
meta: { | ||
@@ -559,19 +559,19 @@ docs: { | ||
if (!ignore.has("i")) { | ||
visitor = utils_1.compositingVisitors(visitor, createUselessIgnoreCaseFlagVisitor(context)); | ||
visitor = (0, utils_1.compositingVisitors)(visitor, createUselessIgnoreCaseFlagVisitor(context)); | ||
} | ||
if (!ignore.has("m")) { | ||
visitor = utils_1.compositingVisitors(visitor, createUselessMultilineFlagVisitor(context)); | ||
visitor = (0, utils_1.compositingVisitors)(visitor, createUselessMultilineFlagVisitor(context)); | ||
} | ||
if (!ignore.has("s")) { | ||
visitor = utils_1.compositingVisitors(visitor, createUselessDotAllFlagVisitor(context)); | ||
visitor = (0, utils_1.compositingVisitors)(visitor, createUselessDotAllFlagVisitor(context)); | ||
} | ||
if (!ignore.has("g")) { | ||
visitor = utils_1.compositingVisitors(visitor, createUselessGlobalFlagVisitor(context, strictTypes)); | ||
visitor = (0, utils_1.compositingVisitors)(visitor, createUselessGlobalFlagVisitor(context, strictTypes)); | ||
} | ||
if (!ignore.has("y")) { | ||
visitor = utils_1.compositingVisitors(visitor, createUselessStickyFlagVisitor(context, strictTypes)); | ||
visitor = (0, utils_1.compositingVisitors)(visitor, createUselessStickyFlagVisitor(context, strictTypes)); | ||
} | ||
visitor = utils_1.compositingVisitors(visitor, createOwnedRegExpFlagsVisitor(context)); | ||
visitor = (0, utils_1.compositingVisitors)(visitor, createOwnedRegExpFlagsVisitor(context)); | ||
return visitor; | ||
}, | ||
}); |
@@ -24,3 +24,3 @@ "use strict"; | ||
} | ||
exports.default = utils_1.createRule("no-useless-lazy", { | ||
exports.default = (0, utils_1.createRule)("no-useless-lazy", { | ||
meta: { | ||
@@ -57,6 +57,6 @@ docs: { | ||
} | ||
const matchingDir = regexp_ast_analysis_1.getMatchingDirection(qNode); | ||
const firstChar = regexp_ast_analysis_1.getFirstConsumedChar(qNode.element, matchingDir, flags); | ||
const matchingDir = (0, regexp_ast_analysis_1.getMatchingDirection)(qNode); | ||
const firstChar = (0, regexp_ast_analysis_1.getFirstConsumedChar)(qNode.element, matchingDir, flags); | ||
if (!firstChar.empty) { | ||
const after = regexp_ast_analysis_1.getFirstCharAfter(qNode, matchingDir, flags); | ||
const after = (0, regexp_ast_analysis_1.getFirstCharAfter)(qNode, matchingDir, flags); | ||
if (firstChar.char.isDisjointWith(after.char)) { | ||
@@ -74,3 +74,3 @@ context.report({ | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -77,0 +77,0 @@ }); |
@@ -16,3 +16,3 @@ "use strict"; | ||
} | ||
exports.default = utils_1.createRule("no-useless-non-capturing-group", { | ||
exports.default = (0, utils_1.createRule)("no-useless-non-capturing-group", { | ||
meta: { | ||
@@ -85,3 +85,3 @@ docs: { | ||
} | ||
if (!utils_1.canUnwrapped(gNode, alt.raw)) { | ||
if (!(0, utils_1.canUnwrapped)(gNode, alt.raw)) { | ||
return; | ||
@@ -115,3 +115,3 @@ } | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -118,0 +118,0 @@ }); |
@@ -8,3 +8,3 @@ "use strict"; | ||
const no_useless_lazy_1 = __importDefault(require("./no-useless-lazy")); | ||
exports.default = utils_1.createRule("no-useless-non-greedy", { | ||
exports.default = (0, utils_1.createRule)("no-useless-non-greedy", { | ||
meta: Object.assign(Object.assign({}, no_useless_lazy_1.default.meta), { docs: Object.assign(Object.assign({}, no_useless_lazy_1.default.meta.docs), { recommended: false, replacedBy: ["no-useless-lazy"] }), deprecated: true }), | ||
@@ -11,0 +11,0 @@ create(context) { |
@@ -5,3 +5,3 @@ "use strict"; | ||
const regexp_ast_analysis_1 = require("regexp-ast-analysis"); | ||
exports.default = utils_1.createRule("no-useless-quantifier", { | ||
exports.default = (0, utils_1.createRule)("no-useless-quantifier", { | ||
meta: { | ||
@@ -31,3 +31,3 @@ docs: { | ||
const text = qNode.element.raw; | ||
return utils_1.canUnwrapped(qNode, text) ? text : null; | ||
return (0, utils_1.canUnwrapped)(qNode, text) ? text : null; | ||
}); | ||
@@ -42,3 +42,3 @@ } | ||
const text = qNode.element.raw; | ||
return utils_1.canUnwrapped(qNode, text) ? text : null; | ||
return (0, utils_1.canUnwrapped)(qNode, text) ? text : null; | ||
}), | ||
@@ -58,3 +58,3 @@ }; | ||
} | ||
if (regexp_ast_analysis_1.isEmpty(qNode.element)) { | ||
if ((0, regexp_ast_analysis_1.isEmpty)(qNode.element)) { | ||
context.report({ | ||
@@ -71,3 +71,3 @@ node, | ||
qNode.greedy && | ||
regexp_ast_analysis_1.isPotentiallyEmpty(qNode.element)) { | ||
(0, regexp_ast_analysis_1.isPotentiallyEmpty)(qNode.element)) { | ||
context.report({ | ||
@@ -81,3 +81,3 @@ node, | ||
} | ||
if (qNode.min >= 1 && regexp_ast_analysis_1.isZeroLength(qNode.element)) { | ||
if (qNode.min >= 1 && (0, regexp_ast_analysis_1.isZeroLength)(qNode.element)) { | ||
context.report({ | ||
@@ -93,3 +93,3 @@ node, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -96,0 +96,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("no-useless-range", { | ||
exports.default = (0, utils_1.createRule)("no-useless-range", { | ||
meta: { | ||
@@ -34,3 +34,3 @@ docs: { | ||
const rawAfter = parent.raw.slice(ccrNode.end - parent.start); | ||
if (/\\(?:x[\dA-Fa-f]?|u[\dA-Fa-f]{0,3})?$/.test(rawBefore)) { | ||
if (/\\(?:x[\dA-Fa-f]?|u[\dA-Fa-f]{0,3})?$/u.test(rawBefore)) { | ||
return null; | ||
@@ -56,3 +56,3 @@ } | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -59,0 +59,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("no-useless-two-nums-quantifier", { | ||
exports.default = (0, utils_1.createRule)("no-useless-two-nums-quantifier", { | ||
meta: { | ||
@@ -23,3 +23,3 @@ docs: { | ||
if (qNode.min === qNode.max) { | ||
const [startOffset, endOffset] = utils_1.getQuantifierOffsets(qNode); | ||
const [startOffset, endOffset] = (0, utils_1.getQuantifierOffsets)(qNode); | ||
const text = qNode.raw.slice(startOffset, endOffset); | ||
@@ -45,3 +45,3 @@ if (!/^\{\d+,\d+\}$/u.test(text)) { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -48,0 +48,0 @@ }); |
@@ -5,3 +5,3 @@ "use strict"; | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("no-zero-quantifier", { | ||
exports.default = (0, utils_1.createRule)("no-zero-quantifier", { | ||
meta: { | ||
@@ -24,7 +24,7 @@ docs: { | ||
function createVisitor(regexpContext) { | ||
const { node, getRegexpLocation, fixReplaceNode, patternAst, } = regexpContext; | ||
const { node, getRegexpLocation, fixReplaceNode, patternAst } = regexpContext; | ||
return { | ||
onQuantifierEnter(qNode) { | ||
if (qNode.max === 0) { | ||
const containCapturingGroup = regexp_ast_analysis_1.hasSomeDescendant(qNode, (n) => n.type === "CapturingGroup"); | ||
const containCapturingGroup = (0, regexp_ast_analysis_1.hasSomeDescendant)(qNode, (n) => n.type === "CapturingGroup"); | ||
if (containCapturingGroup) { | ||
@@ -45,3 +45,3 @@ context.report({ | ||
} | ||
else if (utils_1.canUnwrapped(qNode, "")) { | ||
else if ((0, utils_1.canUnwrapped)(qNode, "")) { | ||
suggest.push({ | ||
@@ -63,3 +63,3 @@ messageId: "remove", | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -66,0 +66,0 @@ }); |
@@ -14,3 +14,3 @@ "use strict"; | ||
if (last.min !== last.max) { | ||
if (regexp_ast_analysis_1.hasSomeDescendant(last.element, (d) => d.type === "CapturingGroup")) { | ||
if ((0, regexp_ast_analysis_1.hasSomeDescendant)(last.element, (d) => d.type === "CapturingGroup")) { | ||
} | ||
@@ -35,3 +35,3 @@ else { | ||
}; | ||
exports.default = utils_1.createRule("optimal-lookaround-quantifier", { | ||
exports.default = (0, utils_1.createRule)("optimal-lookaround-quantifier", { | ||
meta: { | ||
@@ -70,3 +70,3 @@ docs: { | ||
data: { | ||
expr: mention_1.mention(q), | ||
expr: (0, mention_1.mention)(q), | ||
endOrStart, | ||
@@ -81,3 +81,3 @@ replacer, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -84,0 +84,0 @@ }); |
@@ -8,3 +8,3 @@ "use strict"; | ||
function hasCapturingGroup(node) { | ||
return regexp_ast_analysis_1.hasSomeDescendant(node, (d) => d.type === "CapturingGroup"); | ||
return (0, regexp_ast_analysis_1.hasSomeDescendant)(node, (d) => d.type === "CapturingGroup"); | ||
} | ||
@@ -31,3 +31,3 @@ const EMPTY_UTF16 = { | ||
return { | ||
char: regexp_ast_analysis_1.toCharSet(element, flags), | ||
char: (0, regexp_ast_analysis_1.toCharSet)(element, flags), | ||
complete: true, | ||
@@ -61,3 +61,3 @@ }; | ||
} | ||
return element.raw + utils_1.quantToString(quant); | ||
return element.raw + (0, utils_1.quantToString)(quant); | ||
} | ||
@@ -87,6 +87,6 @@ function isGroupOrCharacter(element) { | ||
? lSingle.char | ||
: regexp_ast_1.getPossiblyConsumedChar(left.element, flags).char; | ||
: (0, regexp_ast_1.getPossiblyConsumedChar)(left.element, flags).char; | ||
const rPossibleChar = rSingle.complete | ||
? rSingle.char | ||
: regexp_ast_1.getPossiblyConsumedChar(right.element, flags).char; | ||
: (0, regexp_ast_1.getPossiblyConsumedChar)(right.element, flags).char; | ||
const greedy = left.greedy; | ||
@@ -184,3 +184,3 @@ let lQuant, rQuant; | ||
} | ||
const raw = elementRaw + utils_1.quantToString(quant); | ||
const raw = elementRaw + (0, utils_1.quantToString)(quant); | ||
return { type: "Both", messageId: "combine", raw }; | ||
@@ -199,3 +199,3 @@ } | ||
} | ||
const nestedPossible = regexp_ast_1.getPossiblyConsumedChar(nested.element, flags); | ||
const nestedPossible = (0, regexp_ast_1.getPossiblyConsumedChar)(nested.element, flags); | ||
if (single.char.isSupersetOf(nestedPossible.char)) { | ||
@@ -309,3 +309,3 @@ const { min } = nested; | ||
} | ||
exports.default = utils_1.createRule("optimal-quantifier-concatenation", { | ||
exports.default = (0, utils_1.createRule)("optimal-quantifier-concatenation", { | ||
meta: { | ||
@@ -331,3 +331,3 @@ docs: { | ||
function createVisitor(regexpContext) { | ||
const { node, flags, getRegexpLocation, fixReplaceNode, } = regexpContext; | ||
const { node, flags, getRegexpLocation, fixReplaceNode } = regexpContext; | ||
return { | ||
@@ -352,5 +352,5 @@ onAlternativeEnter(aNode) { | ||
data: { | ||
left: mention_1.mention(left), | ||
right: mention_1.mention(right), | ||
fix: mention_1.mention(replacement.raw), | ||
left: (0, mention_1.mention)(left), | ||
right: (0, mention_1.mention)(right), | ||
fix: (0, mention_1.mention)(replacement.raw), | ||
cap, | ||
@@ -374,5 +374,5 @@ }, | ||
data: { | ||
nested: mention_1.mention(replacement.nested), | ||
dominate: mention_1.mention(replacement.dominate), | ||
fix: mention_1.mention(replacement.raw), | ||
nested: (0, mention_1.mention)(replacement.nested), | ||
dominate: (0, mention_1.mention)(replacement.dominate), | ||
fix: (0, mention_1.mention)(replacement.raw), | ||
cap, | ||
@@ -392,3 +392,3 @@ }, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -395,0 +395,0 @@ }); |
@@ -8,3 +8,3 @@ "use strict"; | ||
const sort_character_class_elements_1 = __importDefault(require("./sort-character-class-elements")); | ||
exports.default = utils_1.createRule("order-in-character-class", { | ||
exports.default = (0, utils_1.createRule)("order-in-character-class", { | ||
meta: Object.assign(Object.assign({}, sort_character_class_elements_1.default.meta), { docs: Object.assign(Object.assign({}, sort_character_class_elements_1.default.meta.docs), { recommended: false, replacedBy: ["sort-character-class-elements"] }), deprecated: true }), | ||
@@ -11,0 +11,0 @@ create(context) { |
@@ -73,3 +73,3 @@ "use strict"; | ||
element, | ||
char: regexp_ast_analysis_1.toCharSet(element, flags), | ||
char: (0, regexp_ast_analysis_1.toCharSet)(element, flags), | ||
}; | ||
@@ -121,3 +121,3 @@ } | ||
elements, | ||
char: regexp_ast_analysis_1.toCharSet(a.element, flags), | ||
char: (0, regexp_ast_analysis_1.toCharSet)(a.element, flags), | ||
raw: a.alternative.raw, | ||
@@ -129,3 +129,3 @@ }; | ||
isCharacter: false, | ||
firstChar: regexp_ast_analysis_1.getFirstConsumedChar(a.alternative, regexp_ast_analysis_1.getMatchingDirection(a.alternative), flags), | ||
firstChar: (0, regexp_ast_analysis_1.getFirstConsumedChar)(a.alternative, (0, regexp_ast_analysis_1.getMatchingDirection)(a.alternative), flags), | ||
raw: a.alternative.raw, | ||
@@ -206,6 +206,6 @@ }; | ||
if (total === undefined) { | ||
total = regexp_ast_analysis_1.toCharSet(a.element, flags); | ||
total = (0, regexp_ast_analysis_1.toCharSet)(a.element, flags); | ||
} | ||
else { | ||
total = total.union(regexp_ast_analysis_1.toCharSet(a.element, flags)); | ||
total = total.union((0, regexp_ast_analysis_1.toCharSet)(a.element, flags)); | ||
} | ||
@@ -254,3 +254,3 @@ } | ||
} | ||
exports.default = utils_1.createRule("prefer-character-class", { | ||
exports.default = (0, utils_1.createRule)("prefer-character-class", { | ||
meta: { | ||
@@ -271,3 +271,3 @@ docs: { | ||
function createVisitor(regexpContext) { | ||
const { node, flags, getRegexpLocation, fixReplaceNode, } = regexpContext; | ||
const { node, flags, getRegexpLocation, fixReplaceNode } = regexpContext; | ||
function fixReplaceAlternatives(n, newAlternatives) { | ||
@@ -291,4 +291,3 @@ const [prefix, suffix] = getParentPrefixAndSuffix(n); | ||
const alts = categorizeRawAlts(n.alternatives, flags); | ||
const characterAltsCount = alts.filter((a) => a.isCharacter) | ||
.length; | ||
const characterAltsCount = alts.filter((a) => a.isCharacter).length; | ||
if (characterAltsCount < 2) { | ||
@@ -348,3 +347,3 @@ return; | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -351,0 +350,0 @@ }); |
@@ -14,3 +14,3 @@ "use strict"; | ||
} | ||
exports.default = utils_1.createRule("prefer-d", { | ||
exports.default = (0, utils_1.createRule)("prefer-d", { | ||
meta: { | ||
@@ -46,3 +46,3 @@ docs: { | ||
onCharacterClassEnter(ccNode) { | ||
const charSet = regexp_ast_analysis_1.toCharSet(ccNode, flags); | ||
const charSet = (0, regexp_ast_analysis_1.toCharSet)(ccNode, flags); | ||
let predefined = undefined; | ||
@@ -62,3 +62,3 @@ if (charSet.equals(regexp_ast_analysis_1.Chars.digit(flags))) { | ||
type: "character class", | ||
expr: mention_1.mention(ccNode), | ||
expr: (0, mention_1.mention)(ccNode), | ||
instead: predefined, | ||
@@ -84,3 +84,3 @@ }, | ||
: "character class range", | ||
expr: mention_1.mention(e), | ||
expr: (0, mention_1.mention)(e), | ||
instead: expected, | ||
@@ -95,3 +95,3 @@ }, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -98,0 +98,0 @@ }); |
@@ -6,3 +6,3 @@ "use strict"; | ||
const type_tracker_1 = require("../utils/type-tracker"); | ||
exports.default = utils_1.createRule("prefer-escape-replacement-dollar-char", { | ||
exports.default = (0, utils_1.createRule)("prefer-escape-replacement-dollar-char", { | ||
meta: { | ||
@@ -21,6 +21,6 @@ docs: { | ||
create(context) { | ||
const typeTracer = type_tracker_1.createTypeTracker(context); | ||
const typeTracer = (0, type_tracker_1.createTypeTracker)(context); | ||
const sourceCode = context.getSourceCode(); | ||
function verify(replacement) { | ||
for (const element of ast_utils_1.parseReplacements(context, replacement)) { | ||
for (const element of (0, ast_utils_1.parseReplacements)(context, replacement)) { | ||
if (element.type === "CharacterElement" && | ||
@@ -41,3 +41,3 @@ element.value === "$") { | ||
CallExpression(node) { | ||
if (!ast_utils_1.isKnownMethodCall(node, { replace: 2, replaceAll: 2 })) { | ||
if (!(0, ast_utils_1.isKnownMethodCall)(node, { replace: 2, replaceAll: 2 })) { | ||
return; | ||
@@ -44,0 +44,0 @@ } |
@@ -37,3 +37,3 @@ "use strict"; | ||
if (start) { | ||
const { char } = regexp_ast_1.getPossiblyConsumedChar(start, flags); | ||
const { char } = (0, regexp_ast_1.getPossiblyConsumedChar)(start, flags); | ||
if (!hasDisjoint(char, elements.slice(1))) { | ||
@@ -44,3 +44,3 @@ result.add(0); | ||
const last = elements[elements.length - 1]; | ||
const lastChar = regexp_ast_analysis_1.FirstConsumedChars.toLook(regexp_ast_1.getFirstConsumedCharPlusAfter(last, "rtl", flags)); | ||
const lastChar = regexp_ast_analysis_1.FirstConsumedChars.toLook((0, regexp_ast_1.getFirstConsumedCharPlusAfter)(last, "rtl", flags)); | ||
if (!lastChar.char.isDisjointWith(char)) { | ||
@@ -54,4 +54,4 @@ result.add(0); | ||
if (first) { | ||
const { char } = regexp_ast_1.getPossiblyConsumedChar(end, flags); | ||
const firstChar = regexp_ast_analysis_1.FirstConsumedChars.toLook(regexp_ast_1.getFirstConsumedCharPlusAfter(first, "ltr", flags)); | ||
const { char } = (0, regexp_ast_1.getPossiblyConsumedChar)(end, flags); | ||
const firstChar = regexp_ast_analysis_1.FirstConsumedChars.toLook((0, regexp_ast_1.getFirstConsumedCharPlusAfter)(first, "ltr", flags)); | ||
if (!firstChar.char.isDisjointWith(char)) { | ||
@@ -66,3 +66,3 @@ result.add(1); | ||
if (isConstantLength(element)) { | ||
const elementChars = regexp_ast_1.getPossiblyConsumedChar(element, flags); | ||
const elementChars = (0, regexp_ast_1.getPossiblyConsumedChar)(element, flags); | ||
if (elementChars.char.isEmpty) { | ||
@@ -76,3 +76,3 @@ continue; | ||
else { | ||
const elementLook = regexp_ast_analysis_1.FirstConsumedChars.toLook(regexp_ast_1.getFirstConsumedCharPlusAfter(element, "ltr", flags)); | ||
const elementLook = regexp_ast_analysis_1.FirstConsumedChars.toLook((0, regexp_ast_1.getFirstConsumedCharPlusAfter)(element, "ltr", flags)); | ||
return elementLook.char.isDisjointWith(target); | ||
@@ -84,3 +84,3 @@ } | ||
function isConstantLength(target) { | ||
const range = regexp_ast_analysis_1.getLengthRange(target); | ||
const range = (0, regexp_ast_analysis_1.getLengthRange)(target); | ||
return Boolean(range && range.min === range.max); | ||
@@ -100,3 +100,3 @@ } | ||
} | ||
exports.default = utils_1.createRule("prefer-lookaround", { | ||
exports.default = (0, utils_1.createRule)("prefer-lookaround", { | ||
meta: { | ||
@@ -126,3 +126,3 @@ docs: { | ||
const { strictTypes } = parseOption(context.options[0]); | ||
const typeTracer = type_tracker_1.createTypeTracker(context); | ||
const typeTracer = (0, type_tracker_1.createTypeTracker)(context); | ||
function createVisitor(regexpContext) { | ||
@@ -135,5 +135,5 @@ const { regexpNode, patternAst } = regexpContext; | ||
const replaceReferenceList = []; | ||
for (const ref of ast_utils_1.extractExpressionReferences(regexpNode, context)) { | ||
for (const ref of (0, ast_utils_1.extractExpressionReferences)(regexpNode, context)) { | ||
if (ref.type === "argument") { | ||
if (!ast_utils_1.isKnownMethodCall(ref.callExpression, { | ||
if (!(0, ast_utils_1.isKnownMethodCall)(ref.callExpression, { | ||
replace: 2, | ||
@@ -151,5 +151,5 @@ replaceAll: 2, | ||
else if (ref.type === "member") { | ||
const parent = ast_utils_1.getParent(ref.memberExpression); | ||
const parent = (0, ast_utils_1.getParent)(ref.memberExpression); | ||
if ((parent === null || parent === void 0 ? void 0 : parent.type) === "CallExpression" && | ||
ast_utils_1.isKnownMethodCall(parent, { | ||
(0, ast_utils_1.isKnownMethodCall)(parent, { | ||
test: 1, | ||
@@ -196,3 +196,3 @@ }) && | ||
} | ||
const replacements = ast_utils_1.parseReplacements(context, node); | ||
const replacements = (0, ast_utils_1.parseReplacements)(context, node); | ||
let startRef = null; | ||
@@ -218,7 +218,7 @@ let endRef = null; | ||
function getReplaceReferenceFromNonLiteralReplacementArgument(node) { | ||
const evaluated = ast_utils_1.getStaticValue(context, node); | ||
const evaluated = (0, ast_utils_1.getStaticValue)(context, node); | ||
if (!evaluated || typeof evaluated.value !== "string") { | ||
return null; | ||
} | ||
const refRegex = /\$([1-9]\d*|<([^>]+)>)/gu; | ||
const refRegex = /\$(?<ref>[1-9]\d*|<(?<named>[^>]+)>)/gu; | ||
const allRefs = []; | ||
@@ -229,3 +229,7 @@ let startRef = null; | ||
while ((re = refRegex.exec(evaluated.value))) { | ||
const ref = { ref: re[2] ? re[2] : Number(re[1]) }; | ||
const ref = { | ||
ref: re.groups.named | ||
? re.groups.named | ||
: Number(re.groups.ref), | ||
}; | ||
if (re.index === 0) { | ||
@@ -279,3 +283,3 @@ startRef = ref; | ||
startRefState.capturingGroups[0] === alt.elements[0] && | ||
!regexp_ast_analysis_1.isZeroLength(startRefState.capturingGroups[0])) { | ||
!(0, regexp_ast_analysis_1.isZeroLength)(startRefState.capturingGroups[0])) { | ||
const capturingGroup = startRefState.capturingGroups[0]; | ||
@@ -294,3 +298,3 @@ reportStart = { | ||
alt.elements[alt.elements.length - 1] && | ||
!regexp_ast_analysis_1.isZeroLength(endRefState.capturingGroups[0])) { | ||
!(0, regexp_ast_analysis_1.isZeroLength)(endRefState.capturingGroups[0])) { | ||
const capturingGroup = endRefState.capturingGroups[0]; | ||
@@ -328,4 +332,4 @@ reportEnd = { | ||
data: { | ||
expr1: mention_1.mention(reportStart.expr), | ||
expr2: mention_1.mention(reportEnd.expr), | ||
expr1: (0, mention_1.mention)(reportStart.expr), | ||
expr2: (0, mention_1.mention)(reportEnd.expr), | ||
}, | ||
@@ -349,3 +353,3 @@ fix, | ||
kind: "lookbehind assertion", | ||
expr: mention_1.mention(reportStart.expr), | ||
expr: (0, mention_1.mention)(reportStart.expr), | ||
}, | ||
@@ -374,3 +378,3 @@ fix, | ||
kind: "lookahead assertion", | ||
expr: mention_1.mention(reportEnd.expr), | ||
expr: (0, mention_1.mention)(reportEnd.expr), | ||
}, | ||
@@ -427,3 +431,3 @@ fix, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -430,0 +434,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("prefer-named-backreference", { | ||
exports.default = (0, utils_1.createRule)("prefer-named-backreference", { | ||
meta: { | ||
@@ -33,3 +33,3 @@ docs: { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -36,0 +36,0 @@ }); |
@@ -5,3 +5,3 @@ "use strict"; | ||
const mention_1 = require("../utils/mention"); | ||
exports.default = utils_1.createRule("prefer-named-capture-group", { | ||
exports.default = (0, utils_1.createRule)("prefer-named-capture-group", { | ||
meta: { | ||
@@ -30,3 +30,3 @@ docs: { | ||
data: { | ||
group: mention_1.mention(cgNode), | ||
group: (0, mention_1.mention)(cgNode), | ||
}, | ||
@@ -38,3 +38,3 @@ }); | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -41,0 +41,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("prefer-named-replacement", { | ||
exports.default = (0, utils_1.createRule)("prefer-named-replacement", { | ||
meta: { | ||
@@ -31,3 +31,3 @@ docs: { | ||
function createVisitor(regexpContext) { | ||
const { node, getAllCapturingGroups, getCapturingGroupReferences, } = regexpContext; | ||
const { node, getAllCapturingGroups, getCapturingGroupReferences } = regexpContext; | ||
const capturingGroups = getAllCapturingGroups(); | ||
@@ -59,3 +59,3 @@ if (!capturingGroups.length) { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -62,0 +62,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("prefer-plus-quantifier", { | ||
exports.default = (0, utils_1.createRule)("prefer-plus-quantifier", { | ||
meta: { | ||
@@ -23,3 +23,3 @@ docs: { | ||
if (qNode.min === 1 && qNode.max === Infinity) { | ||
const [startOffset, endOffset] = utils_1.getQuantifierOffsets(qNode); | ||
const [startOffset, endOffset] = (0, utils_1.getQuantifierOffsets)(qNode); | ||
const text = qNode.raw.slice(startOffset, endOffset); | ||
@@ -44,3 +44,3 @@ if (text !== "+") { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -47,0 +47,0 @@ }); |
@@ -18,3 +18,3 @@ "use strict"; | ||
} | ||
exports.default = utils_1.createRule("prefer-predefined-assertion", { | ||
exports.default = (0, utils_1.createRule)("prefer-predefined-assertion", { | ||
meta: { | ||
@@ -35,10 +35,10 @@ docs: { | ||
function createVisitor(regexpContext) { | ||
const { node, flags, getRegexpLocation, fixReplaceNode, } = regexpContext; | ||
const { node, flags, getRegexpLocation, fixReplaceNode } = regexpContext; | ||
const word = regexp_ast_analysis_1.Chars.word(flags); | ||
const nonWord = regexp_ast_analysis_1.Chars.word(flags).negate(); | ||
function replaceWordAssertion(aNode, wordNegated) { | ||
const direction = regexp_ast_analysis_1.getMatchingDirectionFromAssertionKind(aNode.kind); | ||
const direction = (0, regexp_ast_analysis_1.getMatchingDirectionFromAssertionKind)(aNode.kind); | ||
let lookaroundNegated = aNode.negate; | ||
if (wordNegated) { | ||
const after = regexp_ast_analysis_1.getFirstCharAfter(aNode, direction, flags); | ||
const after = (0, regexp_ast_analysis_1.getFirstCharAfter)(aNode, direction, flags); | ||
const hasNextCharacter = !after.edge; | ||
@@ -52,3 +52,3 @@ if (hasNextCharacter) { | ||
} | ||
const before = regexp_ast_analysis_1.getFirstCharAfter(aNode, regexp_ast_analysis_1.invertMatchingDirection(direction), flags); | ||
const before = (0, regexp_ast_analysis_1.getFirstCharAfter)(aNode, (0, regexp_ast_analysis_1.invertMatchingDirection)(direction), flags); | ||
if (before.edge) { | ||
@@ -122,3 +122,3 @@ return; | ||
} | ||
const charSet = regexp_ast_analysis_1.toCharSet(chars, flags); | ||
const charSet = (0, regexp_ast_analysis_1.toCharSet)(chars, flags); | ||
if (charSet.isAll) { | ||
@@ -136,3 +136,3 @@ replaceEdgeAssertion(aNode, false); | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -139,0 +139,0 @@ }); |
@@ -42,9 +42,9 @@ "use strict"; | ||
if (charKind == null) { | ||
if (utils_1.isDigit(element.value)) { | ||
if ((0, utils_1.isDigit)(element.value)) { | ||
charKind = "digit"; | ||
} | ||
else if (utils_1.isLetter(element.value)) { | ||
else if ((0, utils_1.isLetter)(element.value)) { | ||
charKind = "letter"; | ||
} | ||
else if (utils_1.isSymbol(element.value)) { | ||
else if ((0, utils_1.isSymbol)(element.value)) { | ||
charKind = "symbol"; | ||
@@ -69,6 +69,6 @@ } | ||
getQuantifier() { | ||
return utils_1.quantToString({ min: this.times, max: this.times }); | ||
return (0, utils_1.quantToString)({ min: this.times, max: this.times }); | ||
} | ||
} | ||
exports.default = utils_1.createRule("prefer-quantifier", { | ||
exports.default = (0, utils_1.createRule)("prefer-quantifier", { | ||
meta: { | ||
@@ -115,3 +115,4 @@ docs: { | ||
start: buffer.elements[0].start, | ||
end: buffer.elements[buffer.elements.length - 1].end, | ||
end: buffer.elements[buffer.elements.length - 1] | ||
.end, | ||
}; | ||
@@ -142,3 +143,3 @@ context.report({ | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -145,0 +146,0 @@ }); |
@@ -5,3 +5,3 @@ "use strict"; | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("prefer-question-quantifier", { | ||
exports.default = (0, utils_1.createRule)("prefer-question-quantifier", { | ||
meta: { | ||
@@ -26,3 +26,3 @@ docs: { | ||
if (qNode.min === 0 && qNode.max === 1) { | ||
const [startOffset, endOffset] = utils_1.getQuantifierOffsets(qNode); | ||
const [startOffset, endOffset] = (0, utils_1.getQuantifierOffsets)(qNode); | ||
const text = qNode.raw.slice(startOffset, endOffset); | ||
@@ -79,3 +79,3 @@ if (text !== "?") { | ||
data: { | ||
expr: mention_1.mention(reportNode), | ||
expr: (0, mention_1.mention)(reportNode), | ||
instead, | ||
@@ -89,3 +89,3 @@ }, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -92,0 +92,0 @@ }); |
@@ -6,3 +6,3 @@ "use strict"; | ||
const mention_1 = require("../utils/mention"); | ||
exports.default = utils_1.createRule("prefer-range", { | ||
exports.default = (0, utils_1.createRule)("prefer-range", { | ||
meta: { | ||
@@ -19,3 +19,3 @@ docs: { | ||
properties: { | ||
target: char_ranges_1.getAllowedCharValueSchema(), | ||
target: (0, char_ranges_1.getAllowedCharValueSchema)(), | ||
}, | ||
@@ -32,3 +32,3 @@ additionalProperties: false, | ||
var _a; | ||
const allowedRanges = char_ranges_1.getAllowedCharRanges((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.target, context); | ||
const allowedRanges = (0, char_ranges_1.getAllowedCharRanges)((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.target, context); | ||
const sourceCode = context.getSourceCode(); | ||
@@ -62,3 +62,3 @@ function createVisitor(regexpContext) { | ||
if (element.type === "Character") { | ||
if (char_ranges_1.inRange(allowedRanges, element.value)) { | ||
if ((0, char_ranges_1.inRange)(allowedRanges, element.value)) { | ||
data = { min: element, max: element }; | ||
@@ -71,3 +71,3 @@ } | ||
else if (element.type === "CharacterClassRange") { | ||
if (char_ranges_1.inRange(allowedRanges, element.min.value, element.max.value)) { | ||
if ((0, char_ranges_1.inRange)(allowedRanges, element.min.value, element.max.value)) { | ||
data = { min: element.min, max: element.max }; | ||
@@ -90,3 +90,3 @@ } | ||
const max = Math.max(gp.max.value, data.max.value); | ||
return char_ranges_1.inRange(allowedRanges, min, max); | ||
return (0, char_ranges_1.inRange)(allowedRanges, min, max); | ||
}); | ||
@@ -116,3 +116,3 @@ if (group) { | ||
messageId: "unexpected", | ||
data: { range: mention_1.mention(newText) }, | ||
data: { range: (0, mention_1.mention)(newText) }, | ||
}); | ||
@@ -126,3 +126,3 @@ continue; | ||
messageId: "unexpected", | ||
data: { range: mention_1.mention(newText) }, | ||
data: { range: (0, mention_1.mention)(newText) }, | ||
fix: (fixer) => { | ||
@@ -143,3 +143,3 @@ return ranges.map((r, index) => { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -146,0 +146,0 @@ }); |
@@ -6,3 +6,3 @@ "use strict"; | ||
const ast_utils_1 = require("../utils/ast-utils"); | ||
exports.default = utils_1.createRule("prefer-regexp-exec", { | ||
exports.default = (0, utils_1.createRule)("prefer-regexp-exec", { | ||
meta: { | ||
@@ -21,10 +21,10 @@ docs: { | ||
create(context) { | ||
const typeTracer = type_tracker_1.createTypeTracker(context); | ||
const typeTracer = (0, type_tracker_1.createTypeTracker)(context); | ||
return { | ||
CallExpression(node) { | ||
if (!ast_utils_1.isKnownMethodCall(node, { match: 1 })) { | ||
if (!(0, ast_utils_1.isKnownMethodCall)(node, { match: 1 })) { | ||
return; | ||
} | ||
const arg = node.arguments[0]; | ||
const evaluated = ast_utils_1.getStaticValue(context, arg); | ||
const evaluated = (0, ast_utils_1.getStaticValue)(context, arg); | ||
if (evaluated && | ||
@@ -31,0 +31,0 @@ evaluated.value instanceof RegExp && |
@@ -7,3 +7,3 @@ "use strict"; | ||
const ast_utils_1 = require("../utils/ast-utils"); | ||
exports.default = utils_1.createRule("prefer-regexp-test", { | ||
exports.default = (0, utils_1.createRule)("prefer-regexp-test", { | ||
meta: { | ||
@@ -24,6 +24,6 @@ docs: { | ||
const sourceCode = context.getSourceCode(); | ||
const typeTracer = type_tracker_1.createTypeTracker(context); | ||
const typeTracer = (0, type_tracker_1.createTypeTracker)(context); | ||
return { | ||
CallExpression(node) { | ||
if (!ast_utils_1.isKnownMethodCall(node, { match: 1, exec: 1 })) { | ||
if (!(0, ast_utils_1.isKnownMethodCall)(node, { match: 1, exec: 1 })) { | ||
return; | ||
@@ -39,3 +39,3 @@ } | ||
const arg = node.arguments[0]; | ||
const evaluated = ast_utils_1.getStaticValue(context, arg); | ||
const evaluated = (0, ast_utils_1.getStaticValue)(context, arg); | ||
let argIsRegExp = true; | ||
@@ -60,4 +60,4 @@ if (evaluated && evaluated.value instanceof RegExp) { | ||
if (node.arguments.length !== 1 || | ||
eslint_utils_1.hasSideEffect(memberExpr, sourceCode) || | ||
eslint_utils_1.hasSideEffect(node.arguments[0], sourceCode)) { | ||
(0, eslint_utils_1.hasSideEffect)(memberExpr, sourceCode) || | ||
(0, eslint_utils_1.hasSideEffect)(node.arguments[0], sourceCode)) { | ||
return null; | ||
@@ -99,3 +99,3 @@ } | ||
function isUseBoolean(node) { | ||
const parent = ast_utils_1.getParent(node); | ||
const parent = (0, ast_utils_1.getParent)(node); | ||
if (!parent) { | ||
@@ -102,0 +102,0 @@ return false; |
@@ -6,3 +6,3 @@ "use strict"; | ||
const ts_utils_1 = require("../utils/ts-utils"); | ||
exports.default = utils_1.createRule("prefer-result-array-groups", { | ||
exports.default = (0, utils_1.createRule)("prefer-result-array-groups", { | ||
meta: { | ||
@@ -34,3 +34,3 @@ docs: { | ||
function createVisitor(regexpContext) { | ||
const { getAllCapturingGroups, getCapturingGroupReferences, } = regexpContext; | ||
const { getAllCapturingGroups, getCapturingGroupReferences } = regexpContext; | ||
const capturingGroups = getAllCapturingGroups(); | ||
@@ -58,3 +58,3 @@ if (!capturingGroups.length) { | ||
while (openingBracket && | ||
!eslint_utils_1.isOpeningBracketToken(openingBracket)) { | ||
!(0, eslint_utils_1.isOpeningBracketToken)(openingBracket)) { | ||
openingBracket = tokens.pop(); | ||
@@ -82,7 +82,7 @@ } | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
}); | ||
function getRegExpArrayTypeKind(node) { | ||
const { tsNodeMap, checker, usedTS, hasFullTypeInformation, } = ts_utils_1.getTypeScriptTools(context); | ||
const { tsNodeMap, checker, usedTS, hasFullTypeInformation } = (0, ts_utils_1.getTypeScriptTools)(context); | ||
if (!usedTS) { | ||
@@ -99,3 +99,3 @@ return null; | ||
} | ||
if (ts_utils_1.isClassOrInterface(tsType)) { | ||
if ((0, ts_utils_1.isClassOrInterface)(tsType)) { | ||
const name = tsType.symbol.escapedName; | ||
@@ -106,3 +106,3 @@ return name === "RegExpMatchArray" || name === "RegExpExecArray" | ||
} | ||
if (ts_utils_1.isAny(tsType)) { | ||
if ((0, ts_utils_1.isAny)(tsType)) { | ||
return "any"; | ||
@@ -109,0 +109,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("prefer-star-quantifier", { | ||
exports.default = (0, utils_1.createRule)("prefer-star-quantifier", { | ||
meta: { | ||
@@ -23,3 +23,3 @@ docs: { | ||
if (qNode.min === 0 && qNode.max === Infinity) { | ||
const [startOffset, endOffset] = utils_1.getQuantifierOffsets(qNode); | ||
const [startOffset, endOffset] = (0, utils_1.getQuantifierOffsets)(qNode); | ||
const text = qNode.raw.slice(startOffset, endOffset); | ||
@@ -44,3 +44,3 @@ if (text !== "*") { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -47,0 +47,0 @@ }); |
@@ -5,3 +5,3 @@ "use strict"; | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("prefer-t", { | ||
exports.default = (0, utils_1.createRule)("prefer-t", { | ||
meta: { | ||
@@ -35,3 +35,3 @@ docs: { | ||
data: { | ||
expr: mention_1.mention(cNode), | ||
expr: (0, mention_1.mention)(cNode), | ||
}, | ||
@@ -44,3 +44,3 @@ fix: fixReplaceNode(cNode, "\\t"), | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createLiteralVisitor(regexpContext) { | ||
@@ -47,0 +47,0 @@ return createVisitor(regexpContext, []); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("prefer-unicode-codepoint-escapes", { | ||
exports.default = (0, utils_1.createRule)("prefer-unicode-codepoint-escapes", { | ||
meta: { | ||
@@ -20,3 +20,3 @@ docs: { | ||
function createVisitor(regexpContext) { | ||
const { node, flags, getRegexpLocation, fixReplaceNode, } = regexpContext; | ||
const { node, flags, getRegexpLocation, fixReplaceNode } = regexpContext; | ||
if (!flags.unicode) { | ||
@@ -28,3 +28,3 @@ return {}; | ||
if (cNode.value >= 0x10000) { | ||
if (/^(?:\\u[\dA-Fa-f]{4}){2}$/.test(cNode.raw)) { | ||
if (/^(?:\\u[\dA-Fa-f]{4}){2}$/u.test(cNode.raw)) { | ||
context.report({ | ||
@@ -38,3 +38,3 @@ node, | ||
.toString(16); | ||
if (/[A-F]/.test(cNode.raw)) { | ||
if (/[A-F]/u.test(cNode.raw)) { | ||
text = text.toUpperCase(); | ||
@@ -50,3 +50,3 @@ } | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -53,0 +53,0 @@ }); |
@@ -25,3 +25,3 @@ "use strict"; | ||
} | ||
exports.default = utils_1.createRule("prefer-w", { | ||
exports.default = (0, utils_1.createRule)("prefer-w", { | ||
meta: { | ||
@@ -44,3 +44,3 @@ docs: { | ||
onCharacterClassEnter(ccNode) { | ||
const charSet = regexp_ast_analysis_1.toCharSet(ccNode, flags); | ||
const charSet = (0, regexp_ast_analysis_1.toCharSet)(ccNode, flags); | ||
let predefined = undefined; | ||
@@ -60,3 +60,3 @@ if (charSet.equals(regexp_ast_analysis_1.Chars.word(flags))) { | ||
type: "character class", | ||
expr: mention_1.mention(ccNode), | ||
expr: (0, mention_1.mention)(ccNode), | ||
instead: predefined, | ||
@@ -136,3 +136,3 @@ }, | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -139,0 +139,0 @@ }); |
@@ -17,5 +17,5 @@ "use strict"; | ||
try { | ||
regexpp_1.visitRegExpAST(pattern, { | ||
(0, regexpp_1.visitRegExpAST)(pattern, { | ||
onCharacterEnter(node) { | ||
if (/^\\(?![bfnrtv])[A-Za-z]$/.test(node.raw)) { | ||
if (/^\\(?![bfnrtv])[A-Za-z]$/u.test(node.raw)) { | ||
throw INCOMPATIBLE; | ||
@@ -25,3 +25,3 @@ } | ||
}); | ||
regexpp_1.visitRegExpAST(uPattern, { | ||
(0, regexpp_1.visitRegExpAST)(uPattern, { | ||
onCharacterEnter(node) { | ||
@@ -66,3 +66,3 @@ if (node.value > UTF16_MAX && | ||
const surrogatePositions = new Set(); | ||
regexpp_1.visitRegExpAST(uPattern, { | ||
(0, regexpp_1.visitRegExpAST)(uPattern, { | ||
onCharacterEnter(node) { | ||
@@ -78,4 +78,4 @@ if (node.value > UTF16_MAX) { | ||
const flags = regexpContext.flags; | ||
const uFlags = regexp_ast_analysis_1.toCache(Object.assign(Object.assign({}, flags), { unicode: true })); | ||
return !regexp_ast_analysis_1.hasSomeDescendant(pattern, (n) => { | ||
const uFlags = (0, regexp_ast_analysis_1.toCache)(Object.assign(Object.assign({}, flags), { unicode: true })); | ||
return !(0, regexp_ast_analysis_1.hasSomeDescendant)(pattern, (n) => { | ||
if (n.type === "Character" && surrogatePositions.has(n.start)) { | ||
@@ -92,7 +92,7 @@ return false; | ||
n.type === "CharacterSet") { | ||
const cs = regexp_ast_analysis_1.toCharSet(n, flags); | ||
const cs = (0, regexp_ast_analysis_1.toCharSet)(n, flags); | ||
if (!cs.isDisjointWith(SURROGATES)) { | ||
return true; | ||
} | ||
return !rangeEqual(cs.ranges, regexp_ast_analysis_1.toCharSet(n, uFlags).ranges); | ||
return !rangeEqual(cs.ranges, (0, regexp_ast_analysis_1.toCharSet)(n, uFlags).ranges); | ||
} | ||
@@ -111,3 +111,3 @@ return false; | ||
} | ||
exports.default = utils_1.createRule("require-unicode-regexp", { | ||
exports.default = (0, utils_1.createRule)("require-unicode-regexp", { | ||
meta: { | ||
@@ -147,3 +147,3 @@ docs: { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -150,0 +150,0 @@ }); |
@@ -32,3 +32,3 @@ "use strict"; | ||
function containsOnlyLiterals(element) { | ||
return !regexp_ast_analysis_1.hasSomeDescendant(element, (d) => { | ||
return !(0, regexp_ast_analysis_1.hasSomeDescendant)(element, (d) => { | ||
return (d.type === "Backreference" || | ||
@@ -79,3 +79,3 @@ d.type === "CharacterSet" || | ||
for (const a of alternatives) { | ||
const chars = regexp_ast_analysis_1.getFirstConsumedChar(a, "ltr", flags); | ||
const chars = (0, regexp_ast_analysis_1.getFirstConsumedChar)(a, "ltr", flags); | ||
const char = chars.empty || chars.char.isEmpty | ||
@@ -87,3 +87,3 @@ ? Infinity | ||
alternatives.sort((a, b) => { | ||
const prefixDiff = compareCharSetStrings(alternative_prefix_1.getLongestPrefix(a, "ltr", flags), alternative_prefix_1.getLongestPrefix(b, "ltr", flags)); | ||
const prefixDiff = compareCharSetStrings((0, alternative_prefix_1.getLongestPrefix)(a, "ltr", flags), (0, alternative_prefix_1.getLongestPrefix)(b, "ltr", flags)); | ||
if (prefixDiff !== 0) { | ||
@@ -100,3 +100,3 @@ return prefixDiff; | ||
function isIntegerString(str) { | ||
return /^(?:0|[1-9]\d*)$/.test(str); | ||
return /^(?:0|[1-9]\d*)$/u.test(str); | ||
} | ||
@@ -150,3 +150,3 @@ function trySortNumberAlternatives(alternatives) { | ||
} | ||
exports.default = utils_1.createRule("sort-alternatives", { | ||
exports.default = (0, utils_1.createRule)("sort-alternatives", { | ||
meta: { | ||
@@ -168,3 +168,3 @@ docs: { | ||
function createVisitor(regexpContext) { | ||
const { node, getRegexpLocation, fixReplaceNode, flags, } = regexpContext; | ||
const { node, getRegexpLocation, fixReplaceNode, flags } = regexpContext; | ||
const allowedChars = getAllowedChars(flags); | ||
@@ -175,3 +175,3 @@ const possibleCharsCache = new Map(); | ||
if (chars === undefined) { | ||
chars = regexp_ast_1.getPossiblyConsumedChar(a, flags).char; | ||
chars = (0, regexp_ast_1.getPossiblyConsumedChar)(a, flags).char; | ||
possibleCharsCache.set(a, chars); | ||
@@ -183,3 +183,3 @@ } | ||
const alternatives = run.elements; | ||
if (reorder_alternatives_1.canReorder(alternatives, flags)) { | ||
if ((0, reorder_alternatives_1.canReorder)(alternatives, flags)) { | ||
sortAlternatives(alternatives, flags); | ||
@@ -194,3 +194,3 @@ trySortNumberAlternatives(alternatives); | ||
if (elements.length > 1 && | ||
reorder_alternatives_1.canReorder(elements, flags)) { | ||
(0, reorder_alternatives_1.canReorder)(elements, flags)) { | ||
trySortNumberAlternatives(elements); | ||
@@ -266,3 +266,3 @@ alternatives.splice(index, elements.length, ...elements); | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -269,0 +269,0 @@ }); |
@@ -24,3 +24,3 @@ "use strict"; | ||
} | ||
exports.default = utils_1.createRule("sort-character-class-elements", { | ||
exports.default = (0, utils_1.createRule)("sort-character-class-elements", { | ||
meta: { | ||
@@ -78,4 +78,4 @@ docs: { | ||
data: { | ||
next: mention_1.mention(next), | ||
prev: mention_1.mention(moveTarget), | ||
next: (0, mention_1.mention)(next), | ||
prev: (0, mention_1.mention)(moveTarget), | ||
}, | ||
@@ -175,3 +175,3 @@ *fix(fixer) { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -178,0 +178,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("sort-flags", { | ||
exports.default = (0, utils_1.createRule)("sort-flags", { | ||
meta: { | ||
@@ -38,3 +38,3 @@ docs: { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor(regexpContext) { | ||
@@ -41,0 +41,0 @@ visit(regexpContext); |
@@ -13,3 +13,3 @@ "use strict"; | ||
catch (err) { | ||
return err.message; | ||
return err instanceof Error ? err.message : null; | ||
} | ||
@@ -19,3 +19,3 @@ } | ||
const SYNTAX_CHARACTERS = new Set("\\/()[]{}^$.|+*?".split("")); | ||
exports.default = utils_1.createRule("strict", { | ||
exports.default = (0, utils_1.createRule)("strict", { | ||
meta: { | ||
@@ -47,3 +47,3 @@ docs: { | ||
function createVisitor(regexpContext) { | ||
const { node, flags, pattern, getRegexpLocation, fixReplaceNode, } = regexpContext; | ||
const { node, flags, pattern, getRegexpLocation, fixReplaceNode } = regexpContext; | ||
if (flags.unicode) { | ||
@@ -62,3 +62,3 @@ return {}; | ||
data: { | ||
expr: mention_1.mention(element), | ||
expr: (0, mention_1.mention)(element), | ||
}, | ||
@@ -79,3 +79,3 @@ suggest: [ | ||
data: { | ||
expr: mention_1.mention(element), | ||
expr: (0, mention_1.mention)(element), | ||
}, | ||
@@ -100,3 +100,3 @@ fix: fix ? fixReplaceNode(element, fix) : null, | ||
} | ||
if (cNode.value !== 0 && utils_1.isOctalEscape(cNode.raw)) { | ||
if (cNode.value !== 0 && (0, utils_1.isOctalEscape)(cNode.raw)) { | ||
report("octalEscape", cNode, { | ||
@@ -124,3 +124,3 @@ fix: `\\x${cNode.value | ||
} | ||
if (utils_1.isEscapeSequence(cNode.raw)) { | ||
if ((0, utils_1.isEscapeSequence)(cNode.raw)) { | ||
return; | ||
@@ -190,3 +190,3 @@ } | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -193,0 +193,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("../utils"); | ||
exports.default = utils_1.createRule("unicode-escape", { | ||
exports.default = (0, utils_1.createRule)("unicode-escape", { | ||
meta: { | ||
@@ -72,3 +72,3 @@ docs: { | ||
} | ||
const kind = utils_1.getEscapeSequenceKind(cNode.raw); | ||
const kind = (0, utils_1.getEscapeSequenceKind)(cNode.raw); | ||
if (!kind) { | ||
@@ -81,3 +81,3 @@ return; | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -84,0 +84,0 @@ }); |
@@ -66,3 +66,3 @@ "use strict"; | ||
} | ||
exports.default = utils_1.createRule("use-ignore-case", { | ||
exports.default = (0, utils_1.createRule)("use-ignore-case", { | ||
meta: { | ||
@@ -93,3 +93,3 @@ docs: { | ||
} | ||
if (case_variation_1.isCaseVariant(patternAst, flags)) { | ||
if ((0, case_variation_1.isCaseVariant)(patternAst, flags)) { | ||
return {}; | ||
@@ -101,12 +101,12 @@ } | ||
onCharacterClassEnter(ccNode) { | ||
const invariantElement = ccNode.elements.filter((e) => !case_variation_1.isCaseVariant(e, flags)); | ||
const invariantElement = ccNode.elements.filter((e) => !(0, case_variation_1.isCaseVariant)(e, flags)); | ||
if (invariantElement.length === ccNode.elements.length) { | ||
return; | ||
} | ||
const invariant = regexp_ast_analysis_1.Chars.empty(flags).union(...invariantElement.map((e) => regexp_ast_analysis_1.toCharSet(e, flags))); | ||
const invariant = regexp_ast_analysis_1.Chars.empty(flags).union(...invariantElement.map((e) => (0, regexp_ast_analysis_1.toCharSet)(e, flags))); | ||
let variantElements = without(ccNode.elements, new Set(invariantElement)); | ||
const alwaysUseless = findUseless(variantElements, (e) => regexp_ast_analysis_1.toCharSet(e, flags), invariant); | ||
const alwaysUseless = findUseless(variantElements, (e) => (0, regexp_ast_analysis_1.toCharSet)(e, flags), invariant); | ||
variantElements = without(variantElements, alwaysUseless); | ||
const iFlags = case_variation_1.getIgnoreCaseFlags(flags); | ||
const useless = findUseless(variantElements, (e) => regexp_ast_analysis_1.toCharSet(e, iFlags), invariant); | ||
const iFlags = (0, case_variation_1.getIgnoreCaseFlags)(flags); | ||
const useless = findUseless(variantElements, (e) => (0, regexp_ast_analysis_1.toCharSet)(e, iFlags), invariant); | ||
uselessElements.push(...useless); | ||
@@ -124,3 +124,3 @@ ccs.push(ccNode); | ||
data: { | ||
classes: ccs.map((cc) => mention_1.mention(cc)).join(", "), | ||
classes: ccs.map((cc) => (0, mention_1.mention)(cc)).join(", "), | ||
}, | ||
@@ -149,3 +149,3 @@ fix(fixer) { | ||
} | ||
return utils_1.defineRegexpVisitor(context, { | ||
return (0, utils_1.defineRegexpVisitor)(context, { | ||
createVisitor, | ||
@@ -152,0 +152,0 @@ }); |
@@ -21,6 +21,6 @@ "use strict"; | ||
let node = expression; | ||
let parent = utils_1.getParent(node); | ||
let parent = (0, utils_1.getParent)(node); | ||
while ((parent === null || parent === void 0 ? void 0 : parent.type) === "ChainExpression") { | ||
node = parent; | ||
parent = utils_1.getParent(node); | ||
parent = (0, utils_1.getParent)(node); | ||
} | ||
@@ -49,3 +49,3 @@ if (!parent || parent.type === "ExpressionStatement") { | ||
if (parent.init === node) { | ||
const pp = utils_1.getParent(utils_1.getParent(parent)); | ||
const pp = (0, utils_1.getParent)((0, utils_1.getParent)(parent)); | ||
if ((pp === null || pp === void 0 ? void 0 : pp.type) === "ExportNamedDeclaration") { | ||
@@ -64,3 +64,3 @@ yield { node, type: "exported" }; | ||
if (parent.callee.type === "Identifier") { | ||
const fn = utils_1.findFunction(context, parent.callee); | ||
const fn = (0, utils_1.findFunction)(context, parent.callee); | ||
if (fn) { | ||
@@ -110,3 +110,3 @@ yield* iterateReferencesForFunctionArgument(node, fn, argIndex, context, alreadyChecked); | ||
function* iterateReferencesForVariable(identifier, context, alreadyChecked) { | ||
const variable = utils_1.findVariable(context, identifier); | ||
const variable = (0, utils_1.findVariable)(context, identifier); | ||
if (!variable) { | ||
@@ -113,0 +113,0 @@ yield { node: identifier, type: "unknown" }; |
@@ -11,3 +11,3 @@ "use strict"; | ||
} | ||
for (const ref of extract_expression_references_1.extractExpressionReferences(node, context)) { | ||
for (const ref of (0, extract_expression_references_1.extractExpressionReferences)(node, context)) { | ||
if (ref.type === "member") { | ||
@@ -37,5 +37,5 @@ yield* iteratePropertyReferencesForMemberExpression(ref.memberExpression, context); | ||
function isShallowCopy(node) { | ||
const parent = utils_1.getParent(node); | ||
const parent = (0, utils_1.getParent)(node); | ||
if ((parent === null || parent === void 0 ? void 0 : parent.type) === "SpreadElement") { | ||
const spreadParent = utils_1.getParent(parent); | ||
const spreadParent = (0, utils_1.getParent)(parent); | ||
if ((spreadParent === null || spreadParent === void 0 ? void 0 : spreadParent.type) === "ObjectExpression" || | ||
@@ -152,3 +152,3 @@ (spreadParent === null || spreadParent === void 0 ? void 0 : spreadParent.type) === "ArrayExpression") { | ||
if (target.type === "Identifier") { | ||
for (const exprRef of extract_expression_references_1.extractExpressionReferencesForVariable(target, context)) { | ||
for (const exprRef of (0, extract_expression_references_1.extractExpressionReferencesForVariable)(target, context)) { | ||
yield* extractPropertyReferences(exprRef.node, context); | ||
@@ -206,3 +206,3 @@ } | ||
} | ||
return utils_1.getStringIfConstant(context, node.property); | ||
return (0, utils_1.getStringIfConstant)(context, node.property); | ||
} | ||
@@ -220,3 +220,3 @@ else if (node.property.type === "Identifier") { | ||
if (node.computed) { | ||
return utils_1.getStringIfConstant(context, node.key); | ||
return (0, utils_1.getStringIfConstant)(context, node.key); | ||
} | ||
@@ -223,0 +223,0 @@ else if (node.key.type === "Identifier") { |
@@ -20,8 +20,8 @@ "use strict"; | ||
const end = range.end - nodeRange.start; | ||
if (utils_1.isRegexpLiteral(node)) { | ||
if ((0, utils_1.isRegexpLiteral)(node)) { | ||
const nodeStart = node.range[0] + "/".length; | ||
return new PatternReplaceRange([nodeStart + start, nodeStart + end], "RegExp"); | ||
} | ||
if (utils_1.isStringLiteral(node)) { | ||
const astRange = utils_1.getStringValueRange(sourceCode, node, start, end); | ||
if ((0, utils_1.isStringLiteral)(node)) { | ||
const astRange = (0, utils_1.getStringValueRange)(sourceCode, node, start, end); | ||
if (astRange) { | ||
@@ -35,3 +35,3 @@ const quote = sourceCode.text[node.range[0]]; | ||
getAstLocation(sourceCode) { | ||
return utils_1.astRangeToLocation(sourceCode, this.range); | ||
return (0, utils_1.astRangeToLocation)(sourceCode, this.range); | ||
} | ||
@@ -42,12 +42,12 @@ escape(text) { | ||
const base = text | ||
.replace(/\\/g, "\\\\") | ||
.replace(/\n/g, "\\n") | ||
.replace(/\r/g, "\\r") | ||
.replace(/\t/g, "\\t"); | ||
.replace(/\\/gu, "\\\\") | ||
.replace(/\n/gu, "\\n") | ||
.replace(/\r/gu, "\\r") | ||
.replace(/\t/gu, "\\t"); | ||
if (this.type === "DoubleQuotedString") { | ||
return base.replace(/"/g, '\\"'); | ||
return base.replace(/"/gu, '\\"'); | ||
} | ||
return base.replace(/'/g, "\\'"); | ||
return base.replace(/'/gu, "\\'"); | ||
} | ||
return text.replace(/\n/g, "\\n").replace(/\r/g, "\\r"); | ||
return text.replace(/\n/gu, "\\n").replace(/\r/gu, "\\r"); | ||
} | ||
@@ -80,3 +80,3 @@ replace(fixer, text) { | ||
getOwnedRegExpLiteral() { | ||
if (utils_1.isRegexpLiteral(this.node)) { | ||
if ((0, utils_1.isRegexpLiteral)(this.node)) { | ||
return this.node; | ||
@@ -86,4 +86,4 @@ } | ||
this.node.object.type !== "Super" && | ||
utils_1.isRegexpLiteral(this.node.object) && | ||
utils_1.getPropertyName(this.node) === "source") { | ||
(0, utils_1.isRegexpLiteral)(this.node.object) && | ||
(0, utils_1.getPropertyName)(this.node) === "source") { | ||
return this.node.object; | ||
@@ -126,4 +126,4 @@ } | ||
static fromExpression(context, expression) { | ||
expression = utils_1.dereferenceOwnedVariable(context, expression); | ||
if (utils_1.isRegexpLiteral(expression)) { | ||
expression = (0, utils_1.dereferenceOwnedVariable)(context, expression); | ||
if ((0, utils_1.isRegexpLiteral)(expression)) { | ||
return PatternSource.fromRegExpLiteral(context, expression); | ||
@@ -136,3 +136,3 @@ } | ||
for (const e of flat) { | ||
const staticValue = _1.getStaticValue(context, e); | ||
const staticValue = (0, _1.getStaticValue)(context, e); | ||
if (!staticValue) { | ||
@@ -204,3 +204,3 @@ return null; | ||
getAstLocation(range) { | ||
return utils_1.astRangeToLocation(this.sourceCode, this.getAstRange(range)); | ||
return (0, utils_1.astRangeToLocation)(this.sourceCode, this.getAstRange(range)); | ||
} | ||
@@ -226,3 +226,3 @@ getOwnedRegExpLiterals() { | ||
} | ||
const deRef = utils_1.dereferenceOwnedVariable(context, e); | ||
const deRef = (0, utils_1.dereferenceOwnedVariable)(context, e); | ||
if (deRef !== e) { | ||
@@ -229,0 +229,0 @@ return flattenPlus(context, deRef); |
@@ -181,3 +181,3 @@ "use strict"; | ||
function parseReplacements(context, node) { | ||
const stringLiteral = string_literal_parser_1.parseStringLiteral(context.getSourceCode().text, { | ||
const stringLiteral = (0, string_literal_parser_1.parseStringLiteral)(context.getSourceCode().text, { | ||
start: node.range[0], | ||
@@ -187,3 +187,3 @@ end: node.range[1], | ||
const tokens = stringLiteral.tokens.filter((t) => t.value); | ||
return replacements_utils_1.baseParseReplacements(tokens, (start, end) => { | ||
return (0, replacements_utils_1.baseParseReplacements)(tokens, (start, end) => { | ||
return { | ||
@@ -206,3 +206,3 @@ range: [start.range[0], end.range[1]], | ||
let start = null; | ||
for (const t of string_literal_parser_1.parseStringTokens(raw)) { | ||
for (const t of (0, string_literal_parser_1.parseStringTokens)(raw)) { | ||
const endIndex = valueIndex + t.value.length; | ||
@@ -209,0 +209,0 @@ if (start == null && |
@@ -61,3 +61,3 @@ "use strict"; | ||
type: "string", | ||
pattern: /^([\ud800-\udbff][\udc00-\udfff]|[^\ud800-\udfff])-([\ud800-\udbff][\udc00-\udfff]|[^\ud800-\udfff])$/ | ||
pattern: /^(?:[\ud800-\udbff][\udc00-\udfff]|[^\ud800-\udfff])-(?:[\ud800-\udbff][\udc00-\udfff]|[^\ud800-\udfff])$/ | ||
.source, | ||
@@ -64,0 +64,0 @@ }, |
@@ -16,3 +16,3 @@ "use strict"; | ||
}; | ||
for (const ref of ast_utils_1.extractExpressionReferences(node, context)) { | ||
for (const ref of (0, ast_utils_1.extractExpressionReferences)(node, context)) { | ||
if (ref.type === "argument") { | ||
@@ -34,3 +34,3 @@ yield* iterateForArgument(ref.callExpression, ref.node, ctx); | ||
function* iterateForArgument(callExpression, argument, ctx) { | ||
if (!ast_utils_1.isKnownMethodCall(callExpression, { | ||
if (!(0, ast_utils_1.isKnownMethodCall)(callExpression, { | ||
match: 1, | ||
@@ -80,7 +80,7 @@ search: 1, | ||
function* iterateForMember(memberExpression, object, ctx) { | ||
const parent = ast_utils_1.getParent(memberExpression); | ||
const parent = (0, ast_utils_1.getParent)(memberExpression); | ||
if (!parent || | ||
parent.type !== "CallExpression" || | ||
parent.callee !== memberExpression || | ||
!ast_utils_1.isKnownMethodCall(parent, { | ||
!(0, ast_utils_1.isKnownMethodCall)(parent, { | ||
test: 1, | ||
@@ -145,3 +145,3 @@ exec: 1, | ||
else { | ||
const evaluated = ast_utils_1.getStaticValue(ctx.context, replacement); | ||
const evaluated = (0, ast_utils_1.getStaticValue)(ctx.context, replacement); | ||
if (!evaluated || typeof evaluated.value !== "string") { | ||
@@ -161,3 +161,3 @@ yield { | ||
let useRet = false; | ||
for (const iterationRef of ast_utils_1.extractPropertyReferences(node, ctx.context)) { | ||
for (const iterationRef of (0, ast_utils_1.extractPropertyReferences)(node, ctx.context)) { | ||
if (!iterationRef.extractPropertyReferences) { | ||
@@ -229,3 +229,3 @@ useRet = true; | ||
function* iterateForExecResult(node, ctx) { | ||
for (const ref of ast_utils_1.extractPropertyReferences(node, ctx.context)) { | ||
for (const ref of (0, ast_utils_1.extractPropertyReferences)(node, ctx.context)) { | ||
if (hasNameRef(ref)) { | ||
@@ -258,3 +258,3 @@ if (ref.name === "groups") { | ||
let useReplacement = false; | ||
for (const replacement of ast_utils_1.parseReplacements(ctx.context, substr)) { | ||
for (const replacement of (0, ast_utils_1.parseReplacements)(ctx.context, substr)) { | ||
if (replacement.type === "ReferenceElement") { | ||
@@ -290,3 +290,3 @@ useReplacement = true; | ||
let useReplacement = false; | ||
for (const replacement of replacements_utils_1.parseReplacementsForString(substr)) { | ||
for (const replacement of (0, replacements_utils_1.parseReplacementsForString)(substr)) { | ||
if (replacement.type === "ReferenceElement") { | ||
@@ -319,3 +319,4 @@ useReplacement = true; | ||
function* iterateForReplacerFunction(replacementNode, argument, on, ctx) { | ||
if (replacementNode.params.length < 2) { | ||
if (replacementNode.params.length < 2 && | ||
!replacementNode.params.some((arg) => arg.type === "RestElement")) { | ||
yield { | ||
@@ -351,3 +352,3 @@ type: "WithoutRef", | ||
if (arg.type === "Identifier" || arg.type === "ObjectPattern") { | ||
for (const ref of extract_property_references_1.extractPropertyReferencesForPattern(arg, ctx.context)) { | ||
for (const ref of (0, extract_property_references_1.extractPropertyReferencesForPattern)(arg, ctx.context)) { | ||
if (hasNameRef(ref)) { | ||
@@ -354,0 +355,0 @@ yield { |
@@ -31,3 +31,3 @@ "use strict"; | ||
function* iterateUsageOfPattern(node, context) { | ||
for (const ref of ast_utils_1.extractExpressionReferences(node, context)) { | ||
for (const ref of (0, ast_utils_1.extractExpressionReferences)(node, context)) { | ||
if (ref.type === "member") { | ||
@@ -48,3 +48,3 @@ yield* iterateUsageOfPatternForMemberExpression(ref.memberExpression, context); | ||
? member.property.name | ||
: ast_utils_1.getStringIfConstant(context, member.property); | ||
: (0, ast_utils_1.getStringIfConstant)(context, member.property); | ||
if (propName === "match" || | ||
@@ -74,3 +74,3 @@ propName === "matchAll" || | ||
? node.property.name | ||
: ast_utils_1.getStringIfConstant(context, node.property); | ||
: (0, ast_utils_1.getStringIfConstant)(context, node.property); | ||
yield* iterateUsageOfPatternForPropName(propName); | ||
@@ -109,3 +109,3 @@ } | ||
else { | ||
propName = ast_utils_1.getStringIfConstant(context, prop.key); | ||
propName = (0, ast_utils_1.getStringIfConstant)(context, prop.key); | ||
} | ||
@@ -112,0 +112,0 @@ yield* iterateUsageOfPatternForPropName(propName); |
@@ -134,3 +134,3 @@ "use strict"; | ||
}); | ||
regexpp_1.visitRegExpAST(parsedPattern, createVisitor(helpers)); | ||
(0, regexpp_1.visitRegExpAST)(parsedPattern, createVisitor(helpers)); | ||
} | ||
@@ -141,3 +141,3 @@ const ownedRegExpLiterals = new Set(); | ||
Literal(node) { | ||
if (!utils_1.isRegexpLiteral(node) || ownedRegExpLiterals.has(node)) { | ||
if (!(0, utils_1.isRegexpLiteral)(node) || ownedRegExpLiterals.has(node)) { | ||
return; | ||
@@ -171,5 +171,5 @@ } | ||
if (flagsArg.type !== "SpreadElement") { | ||
flagsNode = utils_1.dereferenceOwnedVariable(context, flagsArg); | ||
flagsString = ast_utils_1.getStringIfConstant(context, flagsNode); | ||
ownsFlags = utils_1.isStringLiteral(flagsNode); | ||
flagsNode = (0, utils_1.dereferenceOwnedVariable)(context, flagsArg); | ||
flagsString = (0, ast_utils_1.getStringIfConstant)(context, flagsNode); | ||
ownsFlags = (0, utils_1.isStringLiteral)(flagsNode); | ||
} | ||
@@ -299,3 +299,3 @@ } | ||
}, | ||
getUsageOfPattern: () => (cacheUsageOfPattern !== null && cacheUsageOfPattern !== void 0 ? cacheUsageOfPattern : (cacheUsageOfPattern = get_usage_of_pattern_1.getUsageOfPattern(regexpNode, context))), | ||
getUsageOfPattern: () => (cacheUsageOfPattern !== null && cacheUsageOfPattern !== void 0 ? cacheUsageOfPattern : (cacheUsageOfPattern = (0, get_usage_of_pattern_1.getUsageOfPattern)(regexpNode, context))), | ||
getCapturingGroupReferences: (options) => { | ||
@@ -308,6 +308,5 @@ var _a; | ||
} | ||
const countOfCapturingGroup = getAllCapturingGroupsWithCache() | ||
.length; | ||
const countOfCapturingGroup = getAllCapturingGroupsWithCache().length; | ||
const capturingGroupReferences = [ | ||
...extract_capturing_group_references_1.extractCapturingGroupReferences(regexpNode, flags, type_tracker_1.createTypeTracker(context), countOfCapturingGroup, context, { strictTypes }), | ||
...(0, extract_capturing_group_references_1.extractCapturingGroupReferences)(regexpNode, flags, (0, type_tracker_1.createTypeTracker)(context), countOfCapturingGroup, context, { strictTypes }), | ||
]; | ||
@@ -321,3 +320,3 @@ cacheCapturingGroupReferenceMap.set(strictTypes, capturingGroupReferences); | ||
patternSource, | ||
flags: regexp_ast_analysis_1.toCache(flags), | ||
flags: (0, regexp_ast_analysis_1.toCache)(flags), | ||
}; | ||
@@ -330,3 +329,3 @@ function getAllCapturingGroupsWithCache() { | ||
const sourceCode = context.getSourceCode(); | ||
const flags = regexp_ast_analysis_1.toCache(originalFlags); | ||
const flags = (0, regexp_ast_analysis_1.toCache)(originalFlags); | ||
return { | ||
@@ -349,3 +348,3 @@ regexpNode, | ||
} | ||
if (utils_1.isRegexpLiteral(flagsNode)) { | ||
if ((0, utils_1.isRegexpLiteral)(flagsNode)) { | ||
return [ | ||
@@ -356,3 +355,3 @@ flagsNode.range[1] - flagsNode.regex.flags.length, | ||
} | ||
if (utils_1.isStringLiteral(flagsNode)) { | ||
if ((0, utils_1.isStringLiteral)(flagsNode)) { | ||
return [flagsNode.range[0] + 1, flagsNode.range[1] - 1]; | ||
@@ -382,3 +381,3 @@ } | ||
} | ||
if (utils_1.isRegexpLiteral(flagsNode)) { | ||
if ((0, utils_1.isRegexpLiteral)(flagsNode)) { | ||
const index = flagsNode.regex.flags.indexOf(flag); | ||
@@ -391,3 +390,3 @@ if (index === -1) { | ||
} | ||
if (utils_1.isStringLiteral(flagsNode)) { | ||
if ((0, utils_1.isStringLiteral)(flagsNode)) { | ||
const index = flagsNode.value.indexOf(flag); | ||
@@ -397,3 +396,3 @@ if (index === -1) { | ||
} | ||
return utils_1.getStringValueRange(sourceCode, flagsNode, index, index + 1); | ||
return (0, utils_1.getStringValueRange)(sourceCode, flagsNode, index, index + 1); | ||
} | ||
@@ -474,10 +473,10 @@ return null; | ||
} | ||
if (!/^[a-z]*$/i.test(newFlags)) { | ||
if (!/^[a-z]*$/iu.test(newFlags)) { | ||
return null; | ||
} | ||
if (includePattern && utils_1.isRegexpLiteral(regexpNode)) { | ||
if (includePattern && (0, utils_1.isRegexpLiteral)(regexpNode)) { | ||
return fixer.replaceText(regexpNode, `/${regexpNode.regex.pattern}/${newFlags}`); | ||
} | ||
let flagsFix; | ||
if (utils_1.isRegexpLiteral(regexpNode)) { | ||
if ((0, utils_1.isRegexpLiteral)(regexpNode)) { | ||
flagsFix = fixer.replaceTextRange(getFlagsRange(regexpNode), newFlags); | ||
@@ -569,36 +568,37 @@ } | ||
function mightCreateNewElement(before, after) { | ||
if (before.endsWith("\\c") && /^[a-z]/i.test(after)) { | ||
if (before.endsWith("\\c") && /^[a-z]/iu.test(after)) { | ||
return true; | ||
} | ||
if (/(?:^|[^\\])(?:\\{2})*\\(?:x[\dA-Fa-f]?|u[\dA-Fa-f]{0,3})$/.test(before) && | ||
/^[\da-f]/i.test(after)) { | ||
if (/(?:^|[^\\])(?:\\{2})*\\(?:x[\dA-Fa-f]?|u[\dA-Fa-f]{0,3})$/u.test(before) && | ||
/^[\da-f]/iu.test(after)) { | ||
return true; | ||
} | ||
if ((/(?:^|[^\\])(?:\\{2})*\\u$/.test(before) && | ||
/^\{[\da-f]*(?:\}[\s\S]*)?$/i.test(after)) || | ||
(/(?:^|[^\\])(?:\\{2})*\\u\{[\da-f]*$/.test(before) && | ||
/^(?:[\da-f]+\}?|\})/i.test(after))) { | ||
if ((/(?:^|[^\\])(?:\\{2})*\\u$/u.test(before) && | ||
/^\{[\da-f]*(?:\}[\s\S]*)?$/iu.test(after)) || | ||
(/(?:^|[^\\])(?:\\{2})*\\u\{[\da-f]*$/u.test(before) && | ||
/^(?:[\da-f]+\}?|\})/iu.test(after))) { | ||
return true; | ||
} | ||
if ((/(?:^|[^\\])(?:\\{2})*\\0[0-7]?$/.test(before) && | ||
/^[0-7]/.test(after)) || | ||
(/(?:^|[^\\])(?:\\{2})*\\[1-7]$/.test(before) && /^[0-7]/.test(after))) { | ||
if ((/(?:^|[^\\])(?:\\{2})*\\0[0-7]?$/u.test(before) && | ||
/^[0-7]/u.test(after)) || | ||
(/(?:^|[^\\])(?:\\{2})*\\[1-7]$/u.test(before) && /^[0-7]/u.test(after))) { | ||
return true; | ||
} | ||
if ((/(?:^|[^\\])(?:\\{2})*\\[1-9]\d*$/.test(before) && | ||
/^\d/.test(after)) || | ||
(/(?:^|[^\\])(?:\\{2})*\\k$/.test(before) && after.startsWith("<")) || | ||
/(?:^|[^\\])(?:\\{2})*\\k<[^<>]*$/.test(before)) { | ||
if ((/(?:^|[^\\])(?:\\{2})*\\[1-9]\d*$/u.test(before) && | ||
/^\d/u.test(after)) || | ||
(/(?:^|[^\\])(?:\\{2})*\\k$/u.test(before) && after.startsWith("<")) || | ||
/(?:^|[^\\])(?:\\{2})*\\k<[^<>]*$/u.test(before)) { | ||
return true; | ||
} | ||
if ((/(?:^|[^\\])(?:\\{2})*\\p$/i.test(before) && | ||
/^\{[\w=]*(?:\}[\s\S]*)?$/.test(after)) || | ||
(/(?:^|[^\\])(?:\\{2})*\\p\{[\w=]*$/i.test(before) && | ||
/^[\w=]+(?:\}[\s\S]*)?$|^\}/.test(after))) { | ||
if ((/(?:^|[^\\])(?:\\{2})*\\p$/iu.test(before) && | ||
/^\{[\w=]*(?:\}[\s\S]*)?$/u.test(after)) || | ||
(/(?:^|[^\\])(?:\\{2})*\\p\{[\w=]*$/iu.test(before) && | ||
/^[\w=]+(?:\}[\s\S]*)?$|^\}/u.test(after))) { | ||
return true; | ||
} | ||
if ((/(?:^|[^\\])(?:\\{2})*\{\d*$/.test(before) && /^[\d,}]/.test(after)) || | ||
(/(?:^|[^\\])(?:\\{2})*\{\d+,$/.test(before) && | ||
/^(?:\d+(?:\}|$)|\})/.test(after)) || | ||
(/(?:^|[^\\])(?:\\{2})*\{\d+,\d*$/.test(before) && | ||
if ((/(?:^|[^\\])(?:\\{2})*\{\d*$/u.test(before) && | ||
/^[\d,}]/u.test(after)) || | ||
(/(?:^|[^\\])(?:\\{2})*\{\d+,$/u.test(before) && | ||
/^(?:\d+(?:\}|$)|\})/u.test(after)) || | ||
(/(?:^|[^\\])(?:\\{2})*\{\d+,\d*$/u.test(before) && | ||
after.startsWith("}"))) { | ||
@@ -630,19 +630,19 @@ return true; | ||
function isOctalEscape(raw) { | ||
return /^\\[0-7]{1,3}$/.test(raw); | ||
return /^\\[0-7]{1,3}$/u.test(raw); | ||
} | ||
exports.isOctalEscape = isOctalEscape; | ||
function isControlEscape(raw) { | ||
return /^\\c[A-Za-z]$/.test(raw); | ||
return /^\\c[A-Za-z]$/u.test(raw); | ||
} | ||
exports.isControlEscape = isControlEscape; | ||
function isHexadecimalEscape(raw) { | ||
return /^\\x[\dA-Fa-f]{2}$/.test(raw); | ||
return /^\\x[\dA-Fa-f]{2}$/u.test(raw); | ||
} | ||
exports.isHexadecimalEscape = isHexadecimalEscape; | ||
function isUnicodeEscape(raw) { | ||
return /^\\u[\dA-Fa-f]{4}$/.test(raw); | ||
return /^\\u[\dA-Fa-f]{4}$/u.test(raw); | ||
} | ||
exports.isUnicodeEscape = isUnicodeEscape; | ||
function isUnicodeCodePointEscape(raw) { | ||
return /^\\u\{[\dA-Fa-f]{1,8}\}$/.test(raw); | ||
return /^\\u\{[\dA-Fa-f]{1,8}\}$/u.test(raw); | ||
} | ||
@@ -693,3 +693,3 @@ exports.isUnicodeCodePointEscape = isUnicodeCodePointEscape; | ||
const groups = []; | ||
regexpp_1.visitRegExpAST(pattern, { | ||
(0, regexpp_1.visitRegExpAST)(pattern, { | ||
onCapturingGroupEnter(group) { | ||
@@ -696,0 +696,0 @@ groups.push(group); |
@@ -26,3 +26,3 @@ "use strict"; | ||
return (value | ||
.replace(/\\([\s\S])/g, (m, char) => { | ||
.replace(/\\(?<char>[\s\S])/gu, (m, char) => { | ||
if (char.charCodeAt(0) < 0x20) { | ||
@@ -33,3 +33,3 @@ return escapeControl(char); | ||
}) | ||
.replace(/[\0-\x1f]/g, escapeControl)); | ||
.replace(/[\0-\x1f]/gu, escapeControl)); | ||
} | ||
@@ -36,0 +36,0 @@ function escapeControl(control) { |
@@ -22,3 +22,3 @@ "use strict"; | ||
if (prefix.complete) { | ||
chars.push(regexp_ast_analysis_1.getFirstCharAfter(alternative, direction, flags).char); | ||
chars.push((0, regexp_ast_analysis_1.getFirstCharAfter)(alternative, direction, flags).char); | ||
} | ||
@@ -55,3 +55,3 @@ for (let i = 0; i < chars.length; i++) { | ||
return { | ||
chars: [regexp_ast_analysis_1.toCharSet(element, flags)], | ||
chars: [(0, regexp_ast_analysis_1.toCharSet)(element, flags)], | ||
complete: true, | ||
@@ -65,3 +65,3 @@ }; | ||
case "Backreference": { | ||
if (regexp_ast_analysis_1.isStrictBackreference(element)) { | ||
if ((0, regexp_ast_analysis_1.isStrictBackreference)(element)) { | ||
const inner = getElementPrefix(element.resolved, direction, flags); | ||
@@ -72,3 +72,3 @@ if (inner.complete) { | ||
} | ||
const look = regexp_ast_analysis_1.FirstConsumedChars.toLook(common_1.getFirstConsumedCharPlusAfter(element, direction, flags)); | ||
const look = regexp_ast_analysis_1.FirstConsumedChars.toLook((0, common_1.getFirstConsumedCharPlusAfter)(element, direction, flags)); | ||
return { chars: [look.char], complete: false }; | ||
@@ -106,3 +106,3 @@ } | ||
complete = false; | ||
cs.push(regexp_ast_analysis_1.getFirstCharAfter(element, direction, flags).char); | ||
cs.push((0, regexp_ast_analysis_1.getFirstCharAfter)(element, direction, flags).char); | ||
} | ||
@@ -115,7 +115,7 @@ const total = cs[0].union(...cs.slice(1)); | ||
function getQuantifierPrefix(element, direction, flags) { | ||
if (regexp_ast_analysis_1.isZeroLength(element)) { | ||
if ((0, regexp_ast_analysis_1.isZeroLength)(element)) { | ||
return { chars: [], complete: true }; | ||
} | ||
if (regexp_ast_analysis_1.isPotentiallyZeroLength(element)) { | ||
const look = regexp_ast_analysis_1.FirstConsumedChars.toLook(common_1.getFirstConsumedCharPlusAfter(element, direction, flags)); | ||
if ((0, regexp_ast_analysis_1.isPotentiallyZeroLength)(element)) { | ||
const look = regexp_ast_analysis_1.FirstConsumedChars.toLook((0, common_1.getFirstConsumedCharPlusAfter)(element, direction, flags)); | ||
return { chars: [look.char], complete: false }; | ||
@@ -137,5 +137,5 @@ } | ||
} | ||
const look = regexp_ast_analysis_1.FirstConsumedChars.toLook(regexp_ast_analysis_1.getFirstConsumedCharAfter(element.element, direction, flags)); | ||
const look = regexp_ast_analysis_1.FirstConsumedChars.toLook((0, regexp_ast_analysis_1.getFirstConsumedCharAfter)(element.element, direction, flags)); | ||
chars.push(look.char); | ||
return { chars, complete: false }; | ||
} |
@@ -13,3 +13,3 @@ "use strict"; | ||
if (cached === undefined) { | ||
cached = regexp_ast_analysis_1.toCache(Object.assign(Object.assign({}, flags), { ignoreCase: true })); | ||
cached = (0, regexp_ast_analysis_1.toCache)(Object.assign(Object.assign({}, flags), { ignoreCase: true })); | ||
ignoreCaseFlagsCache.set(flags, cached); | ||
@@ -26,3 +26,3 @@ } | ||
if (cached === undefined) { | ||
cached = regexp_ast_analysis_1.toCache(Object.assign(Object.assign({}, flags), { ignoreCase: false })); | ||
cached = (0, regexp_ast_analysis_1.toCache)(Object.assign(Object.assign({}, flags), { ignoreCase: false })); | ||
caseSensitiveFlagsCache.set(flags, cached); | ||
@@ -40,5 +40,5 @@ } | ||
case "Character": | ||
return regexp_ast_analysis_1.toCharSet(e, iSet).size !== 1; | ||
return (0, regexp_ast_analysis_1.toCharSet)(e, iSet).size !== 1; | ||
case "CharacterClassRange": | ||
return !regexp_ast_analysis_1.toCharSet(e, iSet).equals(regexp_ast_analysis_1.toCharSet(e, iUnset)); | ||
return !(0, regexp_ast_analysis_1.toCharSet)(e, iSet).equals((0, regexp_ast_analysis_1.toCharSet)(e, iUnset)); | ||
case "CharacterSet": | ||
@@ -49,3 +49,3 @@ switch (e.kind) { | ||
case "property": | ||
return !regexp_ast_analysis_1.toCharSet(e, iSet).equals(regexp_ast_analysis_1.toCharSet(e, iUnset)); | ||
return !(0, regexp_ast_analysis_1.toCharSet)(e, iSet).equals((0, regexp_ast_analysis_1.toCharSet)(e, iUnset)); | ||
default: | ||
@@ -58,3 +58,3 @@ return false; | ||
} | ||
return regexp_ast_analysis_1.hasSomeDescendant(element, (d) => { | ||
return (0, regexp_ast_analysis_1.hasSomeDescendant)(element, (d) => { | ||
switch (d.type) { | ||
@@ -64,6 +64,6 @@ case "Assertion": | ||
case "Backreference": | ||
if (regexp_ast_analysis_1.hasSomeDescendant(element, d.resolved)) { | ||
if ((0, regexp_ast_analysis_1.hasSomeDescendant)(element, d.resolved)) { | ||
return false; | ||
} | ||
return (!regexp_ast_analysis_1.isEmptyBackreference(d) && | ||
return (!(0, regexp_ast_analysis_1.isEmptyBackreference)(d) && | ||
isCaseVariant(d.resolved, flags)); | ||
@@ -78,3 +78,3 @@ case "Character": | ||
} | ||
return !regexp_ast_analysis_1.toCharSet(d, iSet).equals(regexp_ast_analysis_1.toCharSet(d, iUnset)); | ||
return !(0, regexp_ast_analysis_1.toCharSet)(d, iSet).equals((0, regexp_ast_analysis_1.toCharSet)(d, iUnset)); | ||
default: | ||
@@ -81,0 +81,0 @@ return false; |
@@ -6,8 +6,8 @@ "use strict"; | ||
function getFirstConsumedCharPlusAfter(element, direction, flags) { | ||
const consumed = regexp_ast_analysis_1.getFirstConsumedChar(element, direction, flags); | ||
const consumed = (0, regexp_ast_analysis_1.getFirstConsumedChar)(element, direction, flags); | ||
if (!consumed.empty) { | ||
return consumed; | ||
} | ||
return regexp_ast_analysis_1.FirstConsumedChars.concat([consumed, regexp_ast_analysis_1.getFirstConsumedCharAfter(element, direction, flags)], flags); | ||
return regexp_ast_analysis_1.FirstConsumedChars.concat([consumed, (0, regexp_ast_analysis_1.getFirstConsumedCharAfter)(element, direction, flags)], flags); | ||
} | ||
exports.getFirstConsumedCharPlusAfter = getFirstConsumedCharPlusAfter; |
@@ -34,3 +34,3 @@ "use strict"; | ||
} | ||
const evaluated = ast_utils_1.getStaticValue(context, node); | ||
const evaluated = (0, ast_utils_1.getStaticValue)(context, node); | ||
if (!evaluated || !(evaluated.value instanceof RegExp)) { | ||
@@ -40,3 +40,3 @@ return null; | ||
try { | ||
return regexpp_1.parseRegExpLiteral(evaluated.value); | ||
return (0, regexpp_1.parseRegExpLiteral)(evaluated.value); | ||
} | ||
@@ -51,3 +51,3 @@ catch (_b) { | ||
const names = new Set(); | ||
regexpp_1.visitRegExpAST(patternNode, { | ||
(0, regexpp_1.visitRegExpAST)(patternNode, { | ||
onCapturingGroupEnter(cgNode) { | ||
@@ -66,11 +66,11 @@ count++; | ||
let exact = true; | ||
regexp_ast_analysis_1.hasSomeDescendant(element, (d) => { | ||
(0, regexp_ast_analysis_1.hasSomeDescendant)(element, (d) => { | ||
if (d.type === "Character" || | ||
d.type === "CharacterClass" || | ||
d.type === "CharacterSet") { | ||
const c = regexp_ast_analysis_1.toCharSet(d, flags); | ||
const c = (0, regexp_ast_analysis_1.toCharSet)(d, flags); | ||
ranges.push(...c.ranges); | ||
exact = exact && !c.isEmpty; | ||
} | ||
else if (d.type === "Backreference" && !regexp_ast_analysis_1.isEmptyBackreference(d)) { | ||
else if (d.type === "Backreference" && !(0, regexp_ast_analysis_1.isEmptyBackreference)(d)) { | ||
const c = getPossiblyConsumedChar(d.resolved, flags); | ||
@@ -77,0 +77,0 @@ ranges.push(...c.char.ranges); |
@@ -21,3 +21,3 @@ "use strict"; | ||
static fromElement(element, options) { | ||
return new NormalizedCharacter(regexp_ast_analysis_1.toCharSet(element, options.flags)); | ||
return new NormalizedCharacter((0, regexp_ast_analysis_1.toCharSet)(element, options.flags)); | ||
} | ||
@@ -220,3 +220,3 @@ } | ||
right.type === "NormalizedOther") { | ||
return is_equals_1.isEqualNodes(left.node, right.node, options.flags); | ||
return (0, is_equals_1.isEqualNodes)(left.node, right.node, options.flags); | ||
} | ||
@@ -232,3 +232,3 @@ return false; | ||
} | ||
return is_equals_1.isEqualNodes(left.node, right.node, options.flags); | ||
return (0, is_equals_1.isEqualNodes)(left.node, right.node, options.flags); | ||
} | ||
@@ -235,0 +235,0 @@ return false; |
@@ -32,3 +32,3 @@ "use strict"; | ||
} | ||
return regexp_ast_analysis_1.toCharSet(a, flags).equals(regexp_ast_analysis_1.toCharSet(b, flags)); | ||
return (0, regexp_ast_analysis_1.toCharSet)(a, flags).equals((0, regexp_ast_analysis_1.toCharSet)(b, flags)); | ||
} | ||
@@ -117,3 +117,3 @@ const EQUALS_CHECKER = { | ||
} | ||
if (/[(*+?[\\{|]/.test(a.raw) || /[(*+?[\\{|]/.test(b.raw)) { | ||
if (/[(*+?[\\{|]/u.test(a.raw) || /[(*+?[\\{|]/u.test(b.raw)) { | ||
return EQUALS_CHECKER[a.type](a, b, flags, shortCircuit); | ||
@@ -120,0 +120,0 @@ } |
@@ -14,3 +14,3 @@ "use strict"; | ||
const slice = getAlternativesSlice(target); | ||
const dir = matchingDirection !== null && matchingDirection !== void 0 ? matchingDirection : regexp_ast_analysis_1.getMatchingDirection(slice[0]); | ||
const dir = matchingDirection !== null && matchingDirection !== void 0 ? matchingDirection : (0, regexp_ast_analysis_1.getMatchingDirection)(slice[0]); | ||
const eqClasses = dir === "unknown" | ||
@@ -88,3 +88,3 @@ ? getDirectionIndependedDeterminismEqClasses(slice, flags) | ||
const getPrefixCharSets = cachedFn((a) => { | ||
let prefix = alternative_prefix_1.getLongestPrefix(a, dir, flags); | ||
let prefix = (0, alternative_prefix_1.getLongestPrefix)(a, dir, flags); | ||
let all = 0; | ||
@@ -203,3 +203,3 @@ for (let i = prefix.length - 1; i >= 0; i--) { | ||
function canReorderBasedOnLength(slice) { | ||
const lengthRange = regexp_ast_analysis_1.getLengthRange(slice); | ||
const lengthRange = (0, regexp_ast_analysis_1.getLengthRange)(slice); | ||
return Boolean(lengthRange && lengthRange.min === lengthRange.max); | ||
@@ -216,4 +216,4 @@ } | ||
const consumedChars = regexp_ast_analysis_1.Chars.empty(flags).union(...slice.map((a) => getConsumedChars(a, flags))); | ||
return (regexp_ast_analysis_1.getFirstCharAfter(parent, "rtl", flags).char.isDisjointWith(consumedChars) && | ||
regexp_ast_analysis_1.getFirstCharAfter(parent, "ltr", flags).char.isDisjointWith(consumedChars)); | ||
return ((0, regexp_ast_analysis_1.getFirstCharAfter)(parent, "rtl", flags).char.isDisjointWith(consumedChars) && | ||
(0, regexp_ast_analysis_1.getFirstCharAfter)(parent, "ltr", flags).char.isDisjointWith(consumedChars)); | ||
} | ||
@@ -252,9 +252,9 @@ function getAlternativesSlice(set) { | ||
const sets = []; | ||
regexp_ast_analysis_1.hasSomeDescendant(element, (d) => { | ||
(0, regexp_ast_analysis_1.hasSomeDescendant)(element, (d) => { | ||
if (d.type === "Character" || | ||
d.type === "CharacterClass" || | ||
d.type === "CharacterSet") { | ||
sets.push(regexp_ast_analysis_1.toCharSet(d, flags)); | ||
sets.push((0, regexp_ast_analysis_1.toCharSet)(d, flags)); | ||
} | ||
else if (d.type === "Backreference" && !regexp_ast_analysis_1.isEmptyBackreference(d)) { | ||
else if (d.type === "Backreference" && !(0, regexp_ast_analysis_1.isEmptyBackreference)(d)) { | ||
sets.push(getConsumedChars(d.resolved, flags)); | ||
@@ -267,3 +267,3 @@ } | ||
function containsCapturingGroup(node) { | ||
return regexp_ast_analysis_1.hasSomeDescendant(node, (d) => d.type === "CapturingGroup"); | ||
return (0, regexp_ast_analysis_1.hasSomeDescendant)(node, (d) => d.type === "CapturingGroup"); | ||
} | ||
@@ -270,0 +270,0 @@ function cachedFn(fn) { |
@@ -10,3 +10,3 @@ "use strict"; | ||
const ts_utils_1 = require("../ts-utils"); | ||
const ts = ts_utils_1.getTypeScript(); | ||
const ts = (0, ts_utils_1.getTypeScript)(); | ||
const cacheTypeTracker = new WeakMap(); | ||
@@ -19,3 +19,3 @@ function createTypeTracker(context) { | ||
} | ||
const { tsNodeMap, checker, usedTS } = ts_utils_1.getTypeScriptTools(context); | ||
const { tsNodeMap, checker, usedTS } = (0, ts_utils_1.getTypeScriptTools)(context); | ||
const cacheTypeInfo = new WeakMap(); | ||
@@ -31,3 +31,3 @@ const tracker = { | ||
function isString(node) { | ||
return type_data_1.hasType(getType(node), "String"); | ||
return (0, type_data_1.hasType)(getType(node), "String"); | ||
} | ||
@@ -44,3 +44,3 @@ function maybeString(node) { | ||
function isRegExp(node) { | ||
return type_data_1.hasType(getType(node), "RegExp"); | ||
return (0, type_data_1.hasType)(getType(node), "RegExp"); | ||
} | ||
@@ -100,5 +100,5 @@ function getTypes(node) { | ||
} | ||
const jsdoc = jsdoc_1.getJSDoc(node, context); | ||
const jsdoc = (0, jsdoc_1.getJSDoc)(node, context); | ||
if (jsdoc) { | ||
if (utils_1.isParenthesized(context, node)) { | ||
if ((0, utils_1.isParenthesized)(context, node)) { | ||
const type = typeTextToTypeInfo((_a = jsdoc.getTag("type")) === null || _a === void 0 ? void 0 : _a.type); | ||
@@ -140,3 +140,3 @@ if (type) { | ||
const argType = getType(element.argument); | ||
if (type_data_1.isTypeClass(argType)) { | ||
if ((0, type_data_1.isTypeClass)(argType)) { | ||
yield argType.iterateType(); | ||
@@ -161,3 +161,3 @@ } | ||
continue; | ||
const name = utils_1.getPropertyName(context, property); | ||
const name = (0, utils_1.getPropertyName)(context, property); | ||
if (name != null) { | ||
@@ -170,3 +170,3 @@ const value = property.value; | ||
const spreadType = getType(property.argument); | ||
if (type_data_1.isTypeClass(spreadType) && | ||
if ((0, type_data_1.isTypeClass)(spreadType) && | ||
spreadType.type === "Object") { | ||
@@ -204,3 +204,3 @@ yield* spreadType.allProperties(); | ||
else if (node.type === "Identifier") { | ||
const variable = utils_1.findVariable(context, node); | ||
const variable = (0, utils_1.findVariable)(context, node); | ||
if (variable) { | ||
@@ -210,3 +210,3 @@ if (variable.defs.length === 1) { | ||
if (def.type === "Variable") { | ||
const idJsdoc = jsdoc_1.getJSDoc(def.node, context); | ||
const idJsdoc = (0, jsdoc_1.getJSDoc)(def.node, context); | ||
if (idJsdoc) { | ||
@@ -230,7 +230,7 @@ const type = typeTextToTypeInfo((_c = idJsdoc.getTag("type")) === null || _c === void 0 ? void 0 : _c.type); | ||
else { | ||
const parent = ast_utils_1.getParent(def.parent); | ||
const parent = (0, ast_utils_1.getParent)(def.parent); | ||
if (parent) { | ||
if ((parent === null || parent === void 0 ? void 0 : parent.type) === "ForOfStatement") { | ||
const rightType = getType(parent.right); | ||
if (type_data_1.isTypeClass(rightType)) { | ||
if ((0, type_data_1.isTypeClass)(rightType)) { | ||
const type = rightType.iterateType(); | ||
@@ -250,3 +250,3 @@ if (type) { | ||
else if (def.type === "Parameter") { | ||
const fnJsdoc = jsdoc_1.getJSDoc(def.node, context); | ||
const fnJsdoc = (0, jsdoc_1.getJSDoc)(def.node, context); | ||
if (fnJsdoc) { | ||
@@ -261,6 +261,6 @@ const jsdocParams = fnJsdoc.parseParams(); | ||
} | ||
const parent = ast_utils_1.getParent(def.name); | ||
const parent = (0, ast_utils_1.getParent)(def.name); | ||
if (parent) { | ||
if (parent.type === "RestElement") { | ||
const pp = ast_utils_1.getParent(parent); | ||
const pp = (0, ast_utils_1.getParent)(parent); | ||
if (pp) { | ||
@@ -286,3 +286,3 @@ if (pp.type === "ArrayPattern") { | ||
else if (def.type === "FunctionName") { | ||
const fnJsdoc = jsdoc_1.getJSDoc(def.node, context); | ||
const fnJsdoc = (0, jsdoc_1.getJSDoc)(def.node, context); | ||
if (fnJsdoc) { | ||
@@ -308,3 +308,3 @@ const type = typeTextToTypeInfo((_f = fnJsdoc.getTag("returns")) === null || _f === void 0 ? void 0 : _f.type); | ||
const type = getType(node.callee); | ||
if (type_data_1.isTypeClass(type)) { | ||
if ((0, type_data_1.isTypeClass)(type)) { | ||
const argTypes = []; | ||
@@ -348,3 +348,3 @@ for (const arg of node.arguments) { | ||
const propertyType = getType(mem.property); | ||
if (type_data_1.hasType(propertyType, "Number")) { | ||
if ((0, type_data_1.hasType)(propertyType, "Number")) { | ||
propertyName = "0"; | ||
@@ -359,5 +359,5 @@ } | ||
const objectType = getType(mem.object); | ||
if (type_data_1.isTypeClass(objectType)) { | ||
if ((0, type_data_1.isTypeClass)(objectType)) { | ||
const type = objectType.propertyType(propertyName); | ||
if (type_data_1.isTypeClass(type)) { | ||
if ((0, type_data_1.isTypeClass)(type)) { | ||
return type.returnType(() => objectType, argTypes); | ||
@@ -371,3 +371,3 @@ } | ||
const type = getType(callee); | ||
if (type_data_1.isTypeClass(type)) { | ||
if ((0, type_data_1.isTypeClass)(type)) { | ||
return type.returnType(null, argTypes); | ||
@@ -387,3 +387,3 @@ } | ||
const propertyType = getType(node.property); | ||
if (type_data_1.hasType(propertyType, "Number")) { | ||
if ((0, type_data_1.hasType)(propertyType, "Number")) { | ||
propertyName = "0"; | ||
@@ -394,3 +394,3 @@ } | ||
const objectType = getType(node.object); | ||
if (type_data_1.isTypeClass(objectType)) { | ||
if ((0, type_data_1.isTypeClass)(objectType)) { | ||
const type = objectType.propertyType(propertyName); | ||
@@ -413,24 +413,24 @@ if (type) { | ||
var _a, _b; | ||
if (ts_utils_1.isStringLine(tsType)) { | ||
if ((0, ts_utils_1.isStringLine)(tsType)) { | ||
return type_data_1.STRING; | ||
} | ||
if (ts_utils_1.isNumberLike(tsType)) { | ||
if ((0, ts_utils_1.isNumberLike)(tsType)) { | ||
return type_data_1.NUMBER; | ||
} | ||
if (ts_utils_1.isBooleanLike(tsType)) { | ||
if ((0, ts_utils_1.isBooleanLike)(tsType)) { | ||
return type_data_1.BOOLEAN; | ||
} | ||
if (ts_utils_1.isBigIntLike(tsType)) { | ||
if ((0, ts_utils_1.isBigIntLike)(tsType)) { | ||
return type_data_1.BIGINT; | ||
} | ||
if (ts_utils_1.isAny(tsType) || ts_utils_1.isUnknown(tsType)) { | ||
if ((0, ts_utils_1.isAny)(tsType) || (0, ts_utils_1.isUnknown)(tsType)) { | ||
return null; | ||
} | ||
if (ts_utils_1.isArrayLikeObject(tsType)) { | ||
if ((0, ts_utils_1.isArrayLikeObject)(tsType)) { | ||
return type_data_1.UNKNOWN_ARRAY; | ||
} | ||
if (ts_utils_1.isReferenceObject(tsType) && tsType.target !== tsType) { | ||
if ((0, ts_utils_1.isReferenceObject)(tsType) && tsType.target !== tsType) { | ||
return getTypeFromTsType(tsType.target); | ||
} | ||
if (ts_utils_1.isTypeParameter(tsType)) { | ||
if ((0, ts_utils_1.isTypeParameter)(tsType)) { | ||
const constraintType = getConstraintType(tsType); | ||
@@ -442,3 +442,3 @@ if (constraintType) { | ||
} | ||
if (ts_utils_1.isUnionOrIntersection(tsType)) { | ||
if ((0, ts_utils_1.isUnionOrIntersection)(tsType)) { | ||
return type_data_1.TypeUnionOrIntersection.buildType(function* () { | ||
@@ -453,8 +453,8 @@ for (const t of tsType.types) { | ||
} | ||
if (ts_utils_1.isClassOrInterface(tsType)) { | ||
if ((0, ts_utils_1.isClassOrInterface)(tsType)) { | ||
const name = tsType.symbol.escapedName; | ||
const typeName = (_b = (_a = /^Readonly(.*)/.exec(name)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : name; | ||
const typeName = (_b = (_a = /^Readonly(?<typeName>.*)/u.exec(name)) === null || _a === void 0 ? void 0 : _a.groups.typeName) !== null && _b !== void 0 ? _b : name; | ||
return typeName === "Array" ? type_data_1.UNKNOWN_ARRAY : typeName; | ||
} | ||
if (ts_utils_1.isObject(tsType)) { | ||
if ((0, ts_utils_1.isObject)(tsType)) { | ||
return type_data_1.UNKNOWN_OBJECT; | ||
@@ -468,3 +468,4 @@ } | ||
const declaration = declarations && declarations[0]; | ||
if (ts.isTypeParameterDeclaration(declaration) && | ||
if (declaration && | ||
ts.isTypeParameterDeclaration(declaration) && | ||
declaration.constraint != null) { | ||
@@ -481,3 +482,3 @@ return checker.getTypeFromTypeNode(declaration.constraint); | ||
} | ||
return jsDocTypeNodeToTypeInfo(jsdoc_1.parseTypeText(typeText)); | ||
return jsDocTypeNodeToTypeInfo((0, jsdoc_1.parseTypeText)(typeText)); | ||
} | ||
@@ -527,3 +528,3 @@ function jsDocTypeNodeToTypeInfo(node) { | ||
const subject = jsDocTypeNodeToTypeInfo(node.subject); | ||
if (type_data_1.hasType(subject, "Array")) { | ||
if ((0, type_data_1.hasType)(subject, "Array")) { | ||
return new type_data_1.TypeArray(function* () { | ||
@@ -533,6 +534,6 @@ yield jsDocTypeNodeToTypeInfo(node.objects[0]); | ||
} | ||
if (type_data_1.hasType(subject, "Map")) { | ||
if ((0, type_data_1.hasType)(subject, "Map")) { | ||
return new type_data_1.TypeMap(() => jsDocTypeNodeToTypeInfo(node.objects[0]), () => jsDocTypeNodeToTypeInfo(node.objects[1])); | ||
} | ||
if (type_data_1.hasType(subject, "Set")) { | ||
if ((0, type_data_1.hasType)(subject, "Set")) { | ||
return new type_data_1.TypeSet(() => jsDocTypeNodeToTypeInfo(node.objects[0])); | ||
@@ -607,3 +608,3 @@ } | ||
function getParamPath(name, node, context) { | ||
const parent = ast_utils_1.getParent(node); | ||
const parent = (0, ast_utils_1.getParent)(node); | ||
if (!parent) { | ||
@@ -628,5 +629,5 @@ return [{ name, index: null }]; | ||
if (parent.type === "Property") { | ||
const object = ast_utils_1.getParent(parent); | ||
const object = (0, ast_utils_1.getParent)(parent); | ||
const path = { | ||
name: utils_1.getPropertyName(context, parent), | ||
name: (0, utils_1.getPropertyName)(context, parent), | ||
index: object.properties.indexOf(parent), | ||
@@ -633,0 +634,0 @@ }; |
@@ -148,3 +148,3 @@ "use strict"; | ||
} | ||
if (eslint_utils_1.isCommentToken(tokenBefore)) { | ||
if ((0, eslint_utils_1.isCommentToken)(tokenBefore)) { | ||
if (tokenBefore.type === "Line") { | ||
@@ -151,0 +151,0 @@ target = tokenBefore; |
@@ -52,3 +52,3 @@ "use strict"; | ||
typeNames() { | ||
const param0 = common_1.getTypeName(this.iterateType()); | ||
const param0 = (0, common_1.getTypeName)(this.iterateType()); | ||
return [`Array${param0 ? `<${param0}>` : ""}`]; | ||
@@ -60,3 +60,3 @@ } | ||
} | ||
return common_1.isEquals(this.iterateType(), o.iterateType()); | ||
return (0, common_1.isEquals)(this.iterateType(), o.iterateType()); | ||
} | ||
@@ -68,3 +68,3 @@ } | ||
function buildArrayConstructor() { | ||
const ARRAY_TYPES = common_1.createObject({ | ||
const ARRAY_TYPES = (0, common_1.createObject)({ | ||
isArray: function_1.RETURN_BOOLEAN, | ||
@@ -74,2 +74,3 @@ from: function_1.RETURN_UNKNOWN_ARRAY, | ||
prototype: null, | ||
[Symbol.species]: null, | ||
}); | ||
@@ -79,6 +80,6 @@ return new function_1.TypeGlobalFunction(() => exports.UNKNOWN_ARRAY, ARRAY_TYPES); | ||
exports.buildArrayConstructor = buildArrayConstructor; | ||
const getPrototypes = common_1.cache(() => { | ||
const getPrototypes = (0, common_1.cache)(() => { | ||
const RETURN_ARRAY_ELEMENT = new function_1.TypeFunction(function returnArrayElement(selfType) { | ||
const type = selfType === null || selfType === void 0 ? void 0 : selfType(); | ||
if (!common_1.isTypeClass(type)) { | ||
if (!(0, common_1.isTypeClass)(type)) { | ||
return null; | ||
@@ -96,3 +97,3 @@ } | ||
const s = getType === null || getType === void 0 ? void 0 : getType(); | ||
if (common_1.isTypeClass(s)) { | ||
if ((0, common_1.isTypeClass)(s)) { | ||
yield s.iterateType(); | ||
@@ -111,3 +112,3 @@ } | ||
const type = selfType === null || selfType === void 0 ? void 0 : selfType(); | ||
if (common_1.isTypeClass(type)) { | ||
if ((0, common_1.isTypeClass)(type)) { | ||
yield type.iterateType(); | ||
@@ -126,3 +127,3 @@ } | ||
const type = selfType === null || selfType === void 0 ? void 0 : selfType(); | ||
if (common_1.isTypeClass(type)) { | ||
if ((0, common_1.isTypeClass)(type)) { | ||
return type.iterateType(); | ||
@@ -136,7 +137,7 @@ } | ||
const type = argType === null || argType === void 0 ? void 0 : argType(); | ||
if (common_1.isTypeClass(type)) { | ||
if ((0, common_1.isTypeClass)(type)) { | ||
yield type.returnType(selfType, [ | ||
() => { | ||
const s = selfType === null || selfType === void 0 ? void 0 : selfType(); | ||
return common_1.isTypeClass(s) ? s.iterateType() : null; | ||
return (0, common_1.isTypeClass)(s) ? s.iterateType() : null; | ||
}, | ||
@@ -148,3 +149,3 @@ () => number_1.NUMBER, | ||
}); | ||
return common_1.createObject(Object.assign(Object.assign({}, object_1.getObjectPrototypes()), { toString: function_1.RETURN_STRING, toLocaleString: function_1.RETURN_STRING, pop: RETURN_ARRAY_ELEMENT, push: function_1.RETURN_NUMBER, concat: RETURN_CONCAT, join: function_1.RETURN_STRING, reverse: RETURN_SELF, shift: RETURN_ARRAY_ELEMENT, slice: RETURN_SELF, sort: RETURN_SELF, splice: RETURN_SELF, unshift: function_1.RETURN_NUMBER, indexOf: function_1.RETURN_NUMBER, lastIndexOf: function_1.RETURN_NUMBER, every: function_1.RETURN_BOOLEAN, some: function_1.RETURN_BOOLEAN, forEach: function_1.RETURN_VOID, map: RETURN_MAP, filter: RETURN_SELF, reduce: null, reduceRight: null, find: RETURN_ARRAY_ELEMENT, findIndex: function_1.RETURN_NUMBER, fill: function_1.RETURN_UNKNOWN_ARRAY, copyWithin: RETURN_SELF, entries: RETURN_ENTRIES, keys: RETURN_KEYS, values: RETURN_VALUES, includes: function_1.RETURN_BOOLEAN, flatMap: function_1.RETURN_UNKNOWN_ARRAY, flat: function_1.RETURN_UNKNOWN_ARRAY, length: number_1.NUMBER, 0: null })); | ||
return (0, common_1.createObject)(Object.assign(Object.assign({}, (0, object_1.getObjectPrototypes)()), { toString: function_1.RETURN_STRING, toLocaleString: function_1.RETURN_STRING, pop: RETURN_ARRAY_ELEMENT, push: function_1.RETURN_NUMBER, concat: RETURN_CONCAT, join: function_1.RETURN_STRING, reverse: RETURN_SELF, shift: RETURN_ARRAY_ELEMENT, slice: RETURN_SELF, sort: RETURN_SELF, splice: RETURN_SELF, unshift: function_1.RETURN_NUMBER, indexOf: function_1.RETURN_NUMBER, lastIndexOf: function_1.RETURN_NUMBER, every: function_1.RETURN_BOOLEAN, some: function_1.RETURN_BOOLEAN, forEach: function_1.RETURN_VOID, map: RETURN_MAP, filter: RETURN_SELF, reduce: null, reduceRight: null, find: RETURN_ARRAY_ELEMENT, findIndex: function_1.RETURN_NUMBER, fill: function_1.RETURN_UNKNOWN_ARRAY, copyWithin: RETURN_SELF, entries: RETURN_ENTRIES, keys: RETURN_KEYS, values: RETURN_VALUES, includes: function_1.RETURN_BOOLEAN, flatMap: function_1.RETURN_UNKNOWN_ARRAY, flat: function_1.RETURN_UNKNOWN_ARRAY, at: RETURN_ARRAY_ELEMENT, length: number_1.NUMBER, 0: null, [Symbol.iterator]: null, [Symbol.unscopables]: null })); | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.buildBigIntConstructor = exports.BIGINT = exports.TypeBigInt = void 0; | ||
const string_1 = require("./string"); | ||
const common_1 = require("./common"); | ||
@@ -36,3 +37,3 @@ const function_1 = require("./function"); | ||
function buildBigIntConstructor() { | ||
const BIGINT_TYPES = common_1.createObject({ | ||
const BIGINT_TYPES = (0, common_1.createObject)({ | ||
asIntN: function_1.RETURN_BIGINT, | ||
@@ -45,2 +46,2 @@ asUintN: function_1.RETURN_BIGINT, | ||
exports.buildBigIntConstructor = buildBigIntConstructor; | ||
const getPrototypes = common_1.cache(() => common_1.createObject(Object.assign(Object.assign({}, object_1.getObjectPrototypes()), { toString: function_1.RETURN_STRING, toLocaleString: function_1.RETURN_STRING, valueOf: function_1.RETURN_BIGINT }))); | ||
const getPrototypes = (0, common_1.cache)(() => (0, common_1.createObject)(Object.assign(Object.assign({}, (0, object_1.getObjectPrototypes)()), { toString: function_1.RETURN_STRING, toLocaleString: function_1.RETURN_STRING, valueOf: function_1.RETURN_BIGINT, [Symbol.toStringTag]: string_1.STRING }))); |
@@ -36,3 +36,3 @@ "use strict"; | ||
function buildBooleanConstructor() { | ||
const BOOLEAN_TYPES = common_1.createObject({ | ||
const BOOLEAN_TYPES = (0, common_1.createObject)({ | ||
prototype: null, | ||
@@ -43,2 +43,2 @@ }); | ||
exports.buildBooleanConstructor = buildBooleanConstructor; | ||
const getPrototypes = common_1.cache(() => common_1.createObject(Object.assign(Object.assign({}, object_1.getObjectPrototypes()), { valueOf: function_1.RETURN_BOOLEAN }))); | ||
const getPrototypes = (0, common_1.cache)(() => (0, common_1.createObject)(Object.assign(Object.assign({}, (0, object_1.getObjectPrototypes)()), { valueOf: function_1.RETURN_BOOLEAN }))); |
@@ -54,3 +54,3 @@ "use strict"; | ||
function buildFunctionConstructor() { | ||
const FUNCTION_TYPES = common_1.createObject({ | ||
const FUNCTION_TYPES = (0, common_1.createObject)({ | ||
prototype: null, | ||
@@ -94,2 +94,2 @@ }); | ||
}); | ||
const getPrototypes = common_1.cache(() => common_1.createObject(Object.assign(Object.assign({}, object_1.getObjectPrototypes()), { toString: exports.RETURN_STRING, bind: RETURN_SELF, length: number_1.NUMBER, name: string_1.STRING, apply: exports.UNKNOWN_FUNCTION, call: exports.UNKNOWN_FUNCTION, arguments: null, caller: exports.UNKNOWN_FUNCTION, prototype: null }))); | ||
const getPrototypes = (0, common_1.cache)(() => (0, common_1.createObject)(Object.assign(Object.assign({}, (0, object_1.getObjectPrototypes)()), { toString: exports.RETURN_STRING, bind: RETURN_SELF, length: number_1.NUMBER, name: string_1.STRING, apply: exports.UNKNOWN_FUNCTION, call: exports.UNKNOWN_FUNCTION, arguments: null, caller: exports.UNKNOWN_FUNCTION, prototype: null, [Symbol.hasInstance]: null }))); |
@@ -43,13 +43,13 @@ "use strict"; | ||
exports.GLOBAL = new TypeGlobal(); | ||
const getProperties = common_1.cache(() => common_1.createObject({ | ||
String: string_1.buildStringConstructor(), | ||
Number: number_1.buildNumberConstructor(), | ||
Boolean: boolean_1.buildBooleanConstructor(), | ||
RegExp: regexp_1.buildRegExpConstructor(), | ||
BigInt: bigint_1.buildBigIntConstructor(), | ||
Array: array_1.buildArrayConstructor(), | ||
Object: object_1.buildObjectConstructor(), | ||
Function: function_1.buildFunctionConstructor(), | ||
Map: map_1.buildMapConstructor(), | ||
Set: set_1.buildSetConstructor(), | ||
const getProperties = (0, common_1.cache)(() => (0, common_1.createObject)({ | ||
String: (0, string_1.buildStringConstructor)(), | ||
Number: (0, number_1.buildNumberConstructor)(), | ||
Boolean: (0, boolean_1.buildBooleanConstructor)(), | ||
RegExp: (0, regexp_1.buildRegExpConstructor)(), | ||
BigInt: (0, bigint_1.buildBigIntConstructor)(), | ||
Array: (0, array_1.buildArrayConstructor)(), | ||
Object: (0, object_1.buildObjectConstructor)(), | ||
Function: (0, function_1.buildFunctionConstructor)(), | ||
Map: (0, map_1.buildMapConstructor)(), | ||
Set: (0, set_1.buildSetConstructor)(), | ||
isFinite: function_1.RETURN_BOOLEAN, | ||
@@ -56,0 +56,0 @@ isNaN: function_1.RETURN_BOOLEAN, |
@@ -44,7 +44,7 @@ "use strict"; | ||
let unknown = true; | ||
if (common_1.hasType(t1, "Number") || common_1.hasType(t2, "Number")) { | ||
if ((0, common_1.hasType)(t1, "Number") || (0, common_1.hasType)(t2, "Number")) { | ||
unknown = false; | ||
yield number_1.NUMBER; | ||
} | ||
if (common_1.hasType(t1, "BigInt") && common_1.hasType(t2, "BigInt")) { | ||
if ((0, common_1.hasType)(t1, "BigInt") && (0, common_1.hasType)(t2, "BigInt")) { | ||
unknown = false; | ||
@@ -65,3 +65,3 @@ yield bigint_1.BIGINT; | ||
} | ||
exports.BI_OPERATOR_TYPES = common_1.createObject({ | ||
exports.BI_OPERATOR_TYPES = (0, common_1.createObject)({ | ||
"==": resultBool, | ||
@@ -92,11 +92,11 @@ "!=": resultBool, | ||
let unknown = true; | ||
if (common_1.hasType(t1, "String") || common_1.hasType(t2, "String")) { | ||
if ((0, common_1.hasType)(t1, "String") || (0, common_1.hasType)(t2, "String")) { | ||
unknown = false; | ||
yield string_1.STRING; | ||
} | ||
if (common_1.hasType(t1, "Number") && common_1.hasType(t2, "Number")) { | ||
if ((0, common_1.hasType)(t1, "Number") && (0, common_1.hasType)(t2, "Number")) { | ||
unknown = false; | ||
yield number_1.NUMBER; | ||
} | ||
if (common_1.hasType(t1, "BigInt") && common_1.hasType(t2, "BigInt")) { | ||
if ((0, common_1.hasType)(t1, "BigInt") && (0, common_1.hasType)(t2, "BigInt")) { | ||
unknown = false; | ||
@@ -117,7 +117,7 @@ yield bigint_1.BIGINT; | ||
let unknown = true; | ||
if (common_1.hasType(t, "Number")) { | ||
if ((0, common_1.hasType)(t, "Number")) { | ||
unknown = false; | ||
yield number_1.NUMBER; | ||
} | ||
if (common_1.hasType(t, "BigInt")) { | ||
if ((0, common_1.hasType)(t, "BigInt")) { | ||
unknown = false; | ||
@@ -132,3 +132,3 @@ yield bigint_1.BIGINT; | ||
} | ||
exports.UN_OPERATOR_TYPES = common_1.createObject({ | ||
exports.UN_OPERATOR_TYPES = (0, common_1.createObject)({ | ||
"!": resultBool, | ||
@@ -135,0 +135,0 @@ delete: resultBool, |
@@ -6,4 +6,4 @@ "use strict"; | ||
const object_1 = require("./object"); | ||
const getPrototypes = common_1.cache(() => { | ||
return common_1.createObject(Object.assign({}, object_1.getObjectPrototypes())); | ||
const getPrototypes = (0, common_1.cache)(() => { | ||
return (0, common_1.createObject)(Object.assign(Object.assign({}, (0, object_1.getObjectPrototypes)()), { [Symbol.iterator]: null })); | ||
}); | ||
@@ -34,3 +34,3 @@ class TypeIterable { | ||
typeNames() { | ||
const param0 = common_1.getTypeName(this.iterateType()); | ||
const param0 = (0, common_1.getTypeName)(this.iterateType()); | ||
return [`Iterable${param0 != null ? `<${param0}>` : ""}`]; | ||
@@ -42,3 +42,3 @@ } | ||
} | ||
return common_1.isEquals(this.iterateType(), o.iterateType()); | ||
return (0, common_1.isEquals)(this.iterateType(), o.iterateType()); | ||
} | ||
@@ -45,0 +45,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.buildMapConstructor = exports.UNKNOWN_MAP = exports.TypeMap = void 0; | ||
const string_1 = require("./string"); | ||
const array_1 = require("./array"); | ||
@@ -10,6 +11,6 @@ const common_1 = require("./common"); | ||
const object_1 = require("./object"); | ||
const getPrototypes = common_1.cache(() => { | ||
const getPrototypes = (0, common_1.cache)(() => { | ||
const RETURN_MAP_VALUE = new function_1.TypeFunction(function returnMapValue(selfType) { | ||
const type = selfType === null || selfType === void 0 ? void 0 : selfType(); | ||
if (!common_1.isTypeClass(type)) { | ||
if (!(0, common_1.isTypeClass)(type)) { | ||
return null; | ||
@@ -27,3 +28,3 @@ } | ||
const type = selfType === null || selfType === void 0 ? void 0 : selfType(); | ||
if (common_1.isTypeClass(type)) { | ||
if ((0, common_1.isTypeClass)(type)) { | ||
yield type.paramType(0); | ||
@@ -42,3 +43,3 @@ yield type.paramType(1); | ||
const type = selfType === null || selfType === void 0 ? void 0 : selfType(); | ||
if (common_1.isTypeClass(type)) { | ||
if ((0, common_1.isTypeClass)(type)) { | ||
return type.paramType(0); | ||
@@ -52,3 +53,3 @@ } | ||
const type = selfType === null || selfType === void 0 ? void 0 : selfType(); | ||
if (common_1.isTypeClass(type)) { | ||
if ((0, common_1.isTypeClass)(type)) { | ||
return type.paramType(1); | ||
@@ -59,3 +60,3 @@ } | ||
}); | ||
return common_1.createObject(Object.assign(Object.assign({}, object_1.getObjectPrototypes()), { clear: function_1.RETURN_VOID, delete: function_1.RETURN_BOOLEAN, forEach: function_1.RETURN_VOID, get: RETURN_MAP_VALUE, has: function_1.RETURN_BOOLEAN, set: RETURN_SELF, size: number_1.NUMBER, entries: RETURN_ENTRIES, keys: RETURN_KEYS, values: RETURN_VALUES })); | ||
return (0, common_1.createObject)(Object.assign(Object.assign({}, (0, object_1.getObjectPrototypes)()), { clear: function_1.RETURN_VOID, delete: function_1.RETURN_BOOLEAN, forEach: function_1.RETURN_VOID, get: RETURN_MAP_VALUE, has: function_1.RETURN_BOOLEAN, set: RETURN_SELF, size: number_1.NUMBER, entries: RETURN_ENTRIES, keys: RETURN_KEYS, values: RETURN_VALUES, [Symbol.iterator]: null, [Symbol.toStringTag]: string_1.STRING })); | ||
}); | ||
@@ -94,4 +95,4 @@ class TypeMap { | ||
typeNames() { | ||
const param0 = common_1.getTypeName(this.paramType(0)); | ||
const param1 = common_1.getTypeName(this.paramType(1)); | ||
const param0 = (0, common_1.getTypeName)(this.paramType(0)); | ||
const param1 = (0, common_1.getTypeName)(this.paramType(1)); | ||
return [ | ||
@@ -105,4 +106,4 @@ `Map${param0 != null && param1 != null ? `<${param0},${param1}>` : ""}`, | ||
} | ||
return (common_1.isEquals(this.paramType(0), o.paramType(0)) && | ||
common_1.isEquals(this.paramType(1), o.paramType(1))); | ||
return ((0, common_1.isEquals)(this.paramType(0), o.paramType(0)) && | ||
(0, common_1.isEquals)(this.paramType(1), o.paramType(1))); | ||
} | ||
@@ -113,4 +114,5 @@ } | ||
function buildMapConstructor() { | ||
const MAP_TYPES = common_1.createObject({ | ||
const MAP_TYPES = (0, common_1.createObject)({ | ||
prototype: null, | ||
[Symbol.species]: null, | ||
}); | ||
@@ -126,5 +128,5 @@ return new function_1.TypeGlobalFunction(mapConstructor, MAP_TYPES); | ||
const arg = (_a = argTypes[0]) === null || _a === void 0 ? void 0 : _a.call(argTypes); | ||
if (common_1.isTypeClass(arg) && arg.type === "Array") { | ||
if ((0, common_1.isTypeClass)(arg) && arg.type === "Array") { | ||
const iterateType = arg.iterateType(); | ||
if (common_1.isTypeClass(iterateType) && iterateType.type === "Array") { | ||
if ((0, common_1.isTypeClass)(iterateType) && iterateType.type === "Array") { | ||
return new TypeMap(() => iterateType.at(0), () => iterateType.at(1)); | ||
@@ -131,0 +133,0 @@ } |
@@ -36,3 +36,3 @@ "use strict"; | ||
function buildNumberConstructor() { | ||
const NUMBER_TYPES = common_1.createObject({ | ||
const NUMBER_TYPES = (0, common_1.createObject)({ | ||
MAX_VALUE: exports.NUMBER, | ||
@@ -57,2 +57,2 @@ MIN_VALUE: exports.NUMBER, | ||
exports.buildNumberConstructor = buildNumberConstructor; | ||
const getPrototypes = common_1.cache(() => common_1.createObject(Object.assign(Object.assign({}, object_1.getObjectPrototypes()), { toString: function_1.RETURN_STRING, toFixed: function_1.RETURN_STRING, toExponential: function_1.RETURN_STRING, toPrecision: function_1.RETURN_STRING, valueOf: function_1.RETURN_NUMBER, toLocaleString: function_1.RETURN_STRING }))); | ||
const getPrototypes = (0, common_1.cache)(() => (0, common_1.createObject)(Object.assign(Object.assign({}, (0, object_1.getObjectPrototypes)()), { toString: function_1.RETURN_STRING, toFixed: function_1.RETURN_STRING, toExponential: function_1.RETURN_STRING, toPrecision: function_1.RETURN_STRING, valueOf: function_1.RETURN_NUMBER, toLocaleString: function_1.RETURN_STRING }))); |
@@ -6,3 +6,3 @@ "use strict"; | ||
const function_1 = require("./function"); | ||
exports.getObjectPrototypes = common_1.cache(() => common_1.createObject({ | ||
exports.getObjectPrototypes = (0, common_1.cache)(() => (0, common_1.createObject)({ | ||
constructor: function_1.UNKNOWN_FUNCTION, | ||
@@ -46,3 +46,3 @@ toString: function_1.RETURN_STRING, | ||
} | ||
return exports.getObjectPrototypes()[name] || null; | ||
return (0, exports.getObjectPrototypes)()[name] || null; | ||
} | ||
@@ -67,3 +67,3 @@ iterateType() { | ||
if (get2) { | ||
if (!common_1.isEquals(get1(), get2())) { | ||
if (!(0, common_1.isEquals)(get1(), get2())) { | ||
return false; | ||
@@ -78,3 +78,3 @@ } | ||
if (key1 === key2) { | ||
if (!common_1.isEquals(get1(), get())) { | ||
if (!(0, common_1.isEquals)(get1(), get())) { | ||
return false; | ||
@@ -109,3 +109,3 @@ } | ||
const s = getType === null || getType === void 0 ? void 0 : getType(); | ||
if (common_1.isTypeClass(s) && s.type === "Object") { | ||
if ((0, common_1.isTypeClass)(s) && s.type === "Object") { | ||
yield* s.allProperties(); | ||
@@ -116,3 +116,3 @@ } | ||
}); | ||
const OBJECT_TYPES = common_1.createObject({ | ||
const OBJECT_TYPES = (0, common_1.createObject)({ | ||
getPrototypeOf: null, | ||
@@ -119,0 +119,0 @@ getOwnPropertyDescriptor: null, |
@@ -39,3 +39,3 @@ "use strict"; | ||
function buildRegExpConstructor() { | ||
const REGEXP_TYPES = common_1.createObject({ | ||
const REGEXP_TYPES = (0, common_1.createObject)({ | ||
$1: string_1.STRING, | ||
@@ -52,2 +52,3 @@ $2: string_1.STRING, | ||
prototype: null, | ||
[Symbol.species]: null, | ||
}); | ||
@@ -57,2 +58,2 @@ return new function_1.TypeGlobalFunction(() => exports.REGEXP, REGEXP_TYPES); | ||
exports.buildRegExpConstructor = buildRegExpConstructor; | ||
const getPrototypes = common_1.cache(() => common_1.createObject(Object.assign(Object.assign({}, object_1.getObjectPrototypes()), { exec: function_1.RETURN_STRING_ARRAY, test: function_1.RETURN_BOOLEAN, source: string_1.STRING, global: boolean_1.BOOLEAN, ignoreCase: boolean_1.BOOLEAN, multiline: boolean_1.BOOLEAN, lastIndex: number_1.NUMBER, compile: function_1.RETURN_REGEXP, flags: string_1.STRING, sticky: boolean_1.BOOLEAN, unicode: boolean_1.BOOLEAN, dotAll: boolean_1.BOOLEAN }))); | ||
const getPrototypes = (0, common_1.cache)(() => (0, common_1.createObject)(Object.assign(Object.assign({}, (0, object_1.getObjectPrototypes)()), { exec: function_1.RETURN_STRING_ARRAY, test: function_1.RETURN_BOOLEAN, source: string_1.STRING, global: boolean_1.BOOLEAN, ignoreCase: boolean_1.BOOLEAN, multiline: boolean_1.BOOLEAN, lastIndex: number_1.NUMBER, compile: function_1.RETURN_REGEXP, flags: string_1.STRING, sticky: boolean_1.BOOLEAN, unicode: boolean_1.BOOLEAN, dotAll: boolean_1.BOOLEAN, [Symbol.match]: null, [Symbol.replace]: null, [Symbol.search]: null, [Symbol.split]: null, [Symbol.matchAll]: null }))); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.buildSetConstructor = exports.UNKNOWN_SET = exports.TypeSet = void 0; | ||
const string_1 = require("./string"); | ||
const _1 = require("."); | ||
@@ -11,3 +12,3 @@ const array_1 = require("./array"); | ||
const object_1 = require("./object"); | ||
const getPrototypes = common_1.cache(() => { | ||
const getPrototypes = (0, common_1.cache)(() => { | ||
const RETURN_SELF = new function_1.TypeFunction(function returnSelf(selfType) { | ||
@@ -21,3 +22,3 @@ var _a; | ||
const type = selfType === null || selfType === void 0 ? void 0 : selfType(); | ||
if (_1.isTypeClass(type)) { | ||
if ((0, _1.isTypeClass)(type)) { | ||
yield type.iterateType(); | ||
@@ -36,3 +37,3 @@ yield type.iterateType(); | ||
const type = selfType === null || selfType === void 0 ? void 0 : selfType(); | ||
if (_1.isTypeClass(type)) { | ||
if ((0, _1.isTypeClass)(type)) { | ||
return type.iterateType(); | ||
@@ -46,3 +47,3 @@ } | ||
const type = selfType === null || selfType === void 0 ? void 0 : selfType(); | ||
if (_1.isTypeClass(type)) { | ||
if ((0, _1.isTypeClass)(type)) { | ||
return type.iterateType(); | ||
@@ -53,3 +54,3 @@ } | ||
}); | ||
return common_1.createObject(Object.assign(Object.assign({}, object_1.getObjectPrototypes()), { clear: function_1.RETURN_VOID, delete: function_1.RETURN_BOOLEAN, forEach: function_1.RETURN_VOID, has: function_1.RETURN_BOOLEAN, add: RETURN_SELF, size: number_1.NUMBER, entries: RETURN_ENTRIES, keys: RETURN_KEYS, values: RETURN_VALUES })); | ||
return (0, common_1.createObject)(Object.assign(Object.assign({}, (0, object_1.getObjectPrototypes)()), { clear: function_1.RETURN_VOID, delete: function_1.RETURN_BOOLEAN, forEach: function_1.RETURN_VOID, has: function_1.RETURN_BOOLEAN, add: RETURN_SELF, size: number_1.NUMBER, entries: RETURN_ENTRIES, keys: RETURN_KEYS, values: RETURN_VALUES, [Symbol.iterator]: null, [Symbol.toStringTag]: string_1.STRING })); | ||
}); | ||
@@ -80,3 +81,3 @@ class TypeSet { | ||
typeNames() { | ||
const param0 = common_1.getTypeName(this.iterateType()); | ||
const param0 = (0, common_1.getTypeName)(this.iterateType()); | ||
return [`Set${param0 != null ? `<${param0}>` : ""}`]; | ||
@@ -88,3 +89,3 @@ } | ||
} | ||
return common_1.isEquals(this.iterateType(), o.iterateType()); | ||
return (0, common_1.isEquals)(this.iterateType(), o.iterateType()); | ||
} | ||
@@ -95,4 +96,5 @@ } | ||
function buildSetConstructor() { | ||
const SET_TYPES = common_1.createObject({ | ||
const SET_TYPES = (0, common_1.createObject)({ | ||
prototype: null, | ||
[Symbol.species]: null, | ||
}); | ||
@@ -108,3 +110,3 @@ return new function_1.TypeGlobalFunction(setConstructor, SET_TYPES); | ||
const arg = (_a = argTypes[0]) === null || _a === void 0 ? void 0 : _a.call(argTypes); | ||
if (_1.isTypeClass(arg)) { | ||
if ((0, _1.isTypeClass)(arg)) { | ||
return new TypeSet(() => arg.iterateType()); | ||
@@ -111,0 +113,0 @@ } |
@@ -40,3 +40,3 @@ "use strict"; | ||
function buildStringConstructor() { | ||
const STRING_TYPES = common_1.createObject({ | ||
const STRING_TYPES = (0, common_1.createObject)({ | ||
fromCharCode: function_1.RETURN_STRING, | ||
@@ -50,2 +50,2 @@ fromCodePoint: function_1.RETURN_STRING, | ||
exports.buildStringConstructor = buildStringConstructor; | ||
const getPrototypes = common_1.cache(() => common_1.createObject(Object.assign(Object.assign({}, object_1.getObjectPrototypes()), { toString: function_1.RETURN_STRING, charAt: function_1.RETURN_STRING, charCodeAt: function_1.RETURN_NUMBER, concat: function_1.RETURN_STRING, indexOf: function_1.RETURN_NUMBER, lastIndexOf: function_1.RETURN_NUMBER, localeCompare: function_1.RETURN_NUMBER, match: function_1.RETURN_STRING_ARRAY, replace: function_1.RETURN_STRING, search: function_1.RETURN_NUMBER, slice: function_1.RETURN_STRING, split: function_1.RETURN_STRING_ARRAY, substring: function_1.RETURN_STRING, toLowerCase: function_1.RETURN_STRING, toLocaleLowerCase: function_1.RETURN_STRING, toUpperCase: function_1.RETURN_STRING, toLocaleUpperCase: function_1.RETURN_STRING, trim: function_1.RETURN_STRING, substr: function_1.RETURN_STRING, valueOf: function_1.RETURN_STRING, codePointAt: function_1.RETURN_NUMBER, includes: function_1.RETURN_BOOLEAN, endsWith: function_1.RETURN_BOOLEAN, normalize: function_1.RETURN_STRING, repeat: function_1.RETURN_STRING, startsWith: function_1.RETURN_BOOLEAN, anchor: function_1.RETURN_STRING, big: function_1.RETURN_STRING, blink: function_1.RETURN_STRING, bold: function_1.RETURN_STRING, fixed: function_1.RETURN_STRING, fontcolor: function_1.RETURN_STRING, fontsize: function_1.RETURN_STRING, italics: function_1.RETURN_STRING, link: function_1.RETURN_STRING, small: function_1.RETURN_STRING, strike: function_1.RETURN_STRING, sub: function_1.RETURN_STRING, sup: function_1.RETURN_STRING, padStart: function_1.RETURN_STRING, padEnd: function_1.RETURN_STRING, trimLeft: function_1.RETURN_STRING, trimRight: function_1.RETURN_STRING, trimStart: function_1.RETURN_STRING, trimEnd: function_1.RETURN_STRING, matchAll: null, length: number_1.NUMBER, 0: exports.STRING }))); | ||
const getPrototypes = (0, common_1.cache)(() => (0, common_1.createObject)(Object.assign(Object.assign({}, (0, object_1.getObjectPrototypes)()), { toString: function_1.RETURN_STRING, charAt: function_1.RETURN_STRING, charCodeAt: function_1.RETURN_NUMBER, concat: function_1.RETURN_STRING, indexOf: function_1.RETURN_NUMBER, lastIndexOf: function_1.RETURN_NUMBER, localeCompare: function_1.RETURN_NUMBER, match: function_1.RETURN_STRING_ARRAY, replace: function_1.RETURN_STRING, search: function_1.RETURN_NUMBER, slice: function_1.RETURN_STRING, split: function_1.RETURN_STRING_ARRAY, substring: function_1.RETURN_STRING, toLowerCase: function_1.RETURN_STRING, toLocaleLowerCase: function_1.RETURN_STRING, toUpperCase: function_1.RETURN_STRING, toLocaleUpperCase: function_1.RETURN_STRING, trim: function_1.RETURN_STRING, substr: function_1.RETURN_STRING, valueOf: function_1.RETURN_STRING, codePointAt: function_1.RETURN_NUMBER, includes: function_1.RETURN_BOOLEAN, endsWith: function_1.RETURN_BOOLEAN, normalize: function_1.RETURN_STRING, repeat: function_1.RETURN_STRING, startsWith: function_1.RETURN_BOOLEAN, anchor: function_1.RETURN_STRING, big: function_1.RETURN_STRING, blink: function_1.RETURN_STRING, bold: function_1.RETURN_STRING, fixed: function_1.RETURN_STRING, fontcolor: function_1.RETURN_STRING, fontsize: function_1.RETURN_STRING, italics: function_1.RETURN_STRING, link: function_1.RETURN_STRING, small: function_1.RETURN_STRING, strike: function_1.RETURN_STRING, sub: function_1.RETURN_STRING, sup: function_1.RETURN_STRING, padStart: function_1.RETURN_STRING, padEnd: function_1.RETURN_STRING, trimLeft: function_1.RETURN_STRING, trimRight: function_1.RETURN_STRING, trimStart: function_1.RETURN_STRING, trimEnd: function_1.RETURN_STRING, matchAll: null, at: function_1.RETURN_STRING, length: number_1.NUMBER, 0: exports.STRING, [Symbol.iterator]: null }))); |
@@ -31,3 +31,3 @@ "use strict"; | ||
for (const type of baseCollection.all()) { | ||
const propType = _1.isTypeClass(type) | ||
const propType = (0, _1.isTypeClass)(type) | ||
? type.propertyType(name) | ||
@@ -45,3 +45,3 @@ : null; | ||
for (const type of baseCollection.all()) { | ||
if (_1.isTypeClass(type)) { | ||
if ((0, _1.isTypeClass)(type)) { | ||
const itrType = type.iterateType(); | ||
@@ -59,3 +59,3 @@ if (itrType) { | ||
for (const type of baseCollection.all()) { | ||
if (_1.isTypeClass(type)) { | ||
if ((0, _1.isTypeClass)(type)) { | ||
const itrType = type.returnType(thisType, argTypes); | ||
@@ -81,3 +81,3 @@ if (itrType) { | ||
while (!e1.done && !e2.done) { | ||
if (!common_1.isEquals(e1.value, e2.value)) { | ||
if (!(0, common_1.isEquals)(e1.value, e2.value)) { | ||
return false; | ||
@@ -84,0 +84,0 @@ } |
{ | ||
"name": "eslint-plugin-regexp", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "ESLint plugin for finding RegExp mistakes and RegExp style guide violations.", | ||
@@ -56,38 +56,37 @@ "engines": { | ||
"@ota-meshi/eslint-plugin": "^0.8.0", | ||
"@types/chai": "^4.2.18", | ||
"@types/eslint": "^7.2.0", | ||
"@types/eslint-scope": "^3.7.0", | ||
"@types/chai": "^4.2.22", | ||
"@types/eslint": "^7.28.0", | ||
"@types/eslint-scope": "^3.7.1", | ||
"@types/estree": "^0.0.50", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^14.14.39", | ||
"@typescript-eslint/eslint-plugin": "^4.14.0", | ||
"@typescript-eslint/parser": "^4.14.0", | ||
"babel-eslint": "^10.1.0", | ||
"@types/node": "^16.10.1", | ||
"@typescript-eslint/eslint-plugin": "^4.31.2", | ||
"@typescript-eslint/parser": "^4.31.2", | ||
"chai": "^4.3.4", | ||
"env-cmd": "^10.1.0", | ||
"eslint": "^7.32.0", | ||
"eslint-config-prettier": "^8.0.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"eslint-plugin-eslint-plugin": "^3.0.0", | ||
"eslint-plugin-json-schema-validator": "^1.0.9", | ||
"eslint-plugin-jsonc": "^1.0.0", | ||
"eslint-plugin-eslint-plugin": "^3.6.1", | ||
"eslint-plugin-json-schema-validator": "^1.2.24", | ||
"eslint-plugin-jsonc": "^1.7.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-regexp": "^1.0.0", | ||
"eslint-plugin-vue": "^7.5.0", | ||
"eslint-plugin-yml": "^0.10.0", | ||
"eslint4b": "^7.3.1", | ||
"mocha": "^9.0.0", | ||
"mocha-chai-jest-snapshot": "^1.1.2", | ||
"eslint-plugin-regexp": "~1.4.0", | ||
"eslint-plugin-vue": "^7.18.0", | ||
"eslint-plugin-yml": "^0.10.1", | ||
"eslint4b": "^7.32.0", | ||
"mocha": "^9.1.2", | ||
"mocha-chai-jest-snapshot": "^1.1.3", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.0.5", | ||
"raw-loader": "^4.0.1", | ||
"prettier": "~2.4.1", | ||
"raw-loader": "^4.0.2", | ||
"stylelint": "^13.13.1", | ||
"stylelint-config-standard": "^22.0.0", | ||
"stylelint-plugin-stylus": "^0.11.0", | ||
"ts-node": "^10.0.0", | ||
"typescript": "^4.0.0", | ||
"ts-node": "^10.2.1", | ||
"typescript": "~4.4.3", | ||
"vue-eslint-editor": "^1.1.0", | ||
"vue-eslint-parser": "^7.4.1", | ||
"vuepress": "^1.5.2" | ||
"vue-eslint-parser": "^7.11.0", | ||
"vuepress": "^1.8.2" | ||
}, | ||
@@ -94,0 +93,0 @@ "dependencies": { |
612949
0.75%36
-2.7%15202
0.11%