Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2023-07-13 09:09:17 +00:00
parent 4fad06f438
commit 40a500c743
4168 changed files with 298222 additions and 374905 deletions

View file

@ -3,17 +3,16 @@
*/
"use strict";
const { CALL, CONSTRUCT, ReferenceTracker, getStringIfConstant } = require("eslint-utils");
const { RegExpValidator, RegExpParser, visitRegExpAST } = require("regexpp");
const { CALL, CONSTRUCT, ReferenceTracker, getStringIfConstant } = require("@eslint-community/eslint-utils");
const { RegExpParser, visitRegExpAST } = require("@eslint-community/regexpp");
const { isCombiningCharacter, isEmojiModifier, isRegionalIndicatorSymbol, isSurrogatePair } = require("./utils/unicode");
const astUtils = require("./utils/ast-utils.js");
const { isValidWithUnicodeFlag } = require("./utils/regular-expressions");
//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
const REGEXPP_LATEST_ECMA_VERSION = 2022;
/**
* Iterate character sequences of a given nodes.
*
@ -109,7 +108,7 @@ module.exports = {
docs: {
description: "Disallow characters which are made with multiple code points in character class syntax",
recommended: true,
url: "https://eslint.org/docs/rules/no-misleading-character-class"
url: "https://eslint.org/docs/latest/rules/no-misleading-character-class"
},
hasSuggestions: true,
@ -126,7 +125,7 @@ module.exports = {
}
},
create(context) {
const sourceCode = context.getSourceCode();
const sourceCode = context.sourceCode;
const parser = new RegExpParser();
/**
@ -185,46 +184,18 @@ module.exports = {
}
}
/**
* Checks if the given regular expression pattern would be valid with the `u` flag.
* @param {string} pattern The regular expression pattern to verify.
* @returns {boolean} `true` if the pattern would be valid with the `u` flag.
* `false` if the pattern would be invalid with the `u` flag or the configured
* ecmaVersion doesn't support the `u` flag.
*/
function isValidWithUnicodeFlag(pattern) {
const { ecmaVersion } = context.languageOptions;
// ecmaVersion <= 5 doesn't support the 'u' flag
if (ecmaVersion <= 5) {
return false;
}
const validator = new RegExpValidator({
ecmaVersion: Math.min(ecmaVersion, REGEXPP_LATEST_ECMA_VERSION)
});
try {
validator.validatePattern(pattern, void 0, void 0, /* uFlag = */ true);
} catch {
return false;
}
return true;
}
return {
"Literal[regex]"(node) {
verify(node, node.regex.pattern, node.regex.flags, fixer => {
if (!isValidWithUnicodeFlag(node.regex.pattern)) {
if (!isValidWithUnicodeFlag(context.languageOptions.ecmaVersion, node.regex.pattern)) {
return null;
}
return fixer.insertTextAfter(node, "u");
});
},
"Program"() {
const scope = context.getScope();
"Program"(node) {
const scope = sourceCode.getScope(node);
const tracker = new ReferenceTracker(scope);
/*
@ -232,22 +203,22 @@ module.exports = {
* E.g., `new RegExp()`, `RegExp()`, `new window.RegExp()`,
* `const {RegExp: a} = window; new a()`, etc...
*/
for (const { node } of tracker.iterateGlobalReferences({
for (const { node: refNode } of tracker.iterateGlobalReferences({
RegExp: { [CALL]: true, [CONSTRUCT]: true }
})) {
const [patternNode, flagsNode] = node.arguments;
const [patternNode, flagsNode] = refNode.arguments;
const pattern = getStringIfConstant(patternNode, scope);
const flags = getStringIfConstant(flagsNode, scope);
if (typeof pattern === "string") {
verify(node, pattern, flags || "", fixer => {
verify(refNode, pattern, flags || "", fixer => {
if (!isValidWithUnicodeFlag(pattern)) {
if (!isValidWithUnicodeFlag(context.languageOptions.ecmaVersion, pattern)) {
return null;
}
if (node.arguments.length === 1) {
const penultimateToken = sourceCode.getLastToken(node, { skip: 1 }); // skip closing parenthesis
if (refNode.arguments.length === 1) {
const penultimateToken = sourceCode.getLastToken(refNode, { skip: 1 }); // skip closing parenthesis
return fixer.insertTextAfter(
penultimateToken,