Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const regexp_ast_analysis_1 = require("regexp-ast-analysis");
const utils_1 = require("../utils");
const regexp_ast_1 = require("../utils/regexp-ast");
exports.default = (0, utils_1.createRule)("confusing-quantifier", {
meta: {
docs: {
description: "disallow confusing quantifiers",
category: "Best Practices",
recommended: true,
default: "warn",
},
schema: [],
messages: {
confusing: "This quantifier is confusing because its minimum is {{min}} but it can match the empty string. Maybe replace it with `{{proposal}}` to reflect that it can match the empty string?",
},
type: "problem",
},
create(context) {
function createVisitor({ node, flags, getRegexpLocation, }) {
return {
onQuantifierEnter(qNode) {
if (qNode.min > 0 &&
(0, regexp_ast_analysis_1.isPotentiallyEmpty)(qNode.element, flags)) {
const proposal = (0, regexp_ast_1.quantToString)({ ...qNode, min: 0 });
context.report({
node,
loc: getRegexpLocation(qNode, (0, regexp_ast_1.getQuantifierOffsets)(qNode)),
messageId: "confusing",
data: {
min: String(qNode.min),
proposal,
},
});
}
},
};
}
return (0, utils_1.defineRegexpVisitor)(context, {
createVisitor,
});
},
});