mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-25 13:31:24 +01:00
merge completed... now to fix all the bugs...
This commit is contained in:
commit
87c4d80fbc
3472 changed files with 466748 additions and 6517 deletions
69
node_modules/eslint/lib/rules/require-unicode-regexp.js
generated
vendored
Normal file
69
node_modules/eslint/lib/rules/require-unicode-regexp.js
generated
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* @fileoverview Rule to enforce the use of `u` flag on RegExp.
|
||||
* @author Toru Nagashima
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const {
|
||||
CALL,
|
||||
CONSTRUCT,
|
||||
ReferenceTracker,
|
||||
getStringIfConstant
|
||||
} = require("eslint-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../shared/types').Rule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description: "enforce the use of `u` flag on RegExp",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/require-unicode-regexp"
|
||||
},
|
||||
|
||||
messages: {
|
||||
requireUFlag: "Use the 'u' flag."
|
||||
},
|
||||
|
||||
schema: []
|
||||
},
|
||||
|
||||
create(context) {
|
||||
return {
|
||||
"Literal[regex]"(node) {
|
||||
const flags = node.regex.flags || "";
|
||||
|
||||
if (!flags.includes("u")) {
|
||||
context.report({ node, messageId: "requireUFlag" });
|
||||
}
|
||||
},
|
||||
|
||||
Program() {
|
||||
const scope = context.getScope();
|
||||
const tracker = new ReferenceTracker(scope);
|
||||
const trackMap = {
|
||||
RegExp: { [CALL]: true, [CONSTRUCT]: true }
|
||||
};
|
||||
|
||||
for (const { node } of tracker.iterateGlobalReferences(trackMap)) {
|
||||
const flagsNode = node.arguments[1];
|
||||
const flags = getStringIfConstant(flagsNode, scope);
|
||||
|
||||
if (!flagsNode || (typeof flags === "string" && !flags.includes("u"))) {
|
||||
context.report({ node, messageId: "requireUFlag" });
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue