build(deps-dev): bump eslint from 8.28.0 to 8.29.0#202
Merged
ybiquitous merged 1 commit intomainfrom Dec 3, 2022
Merged
Conversation
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as resolved.
This comment was marked as resolved.
89b35d2 to
4bd01d4
Compare
This comment was marked as resolved.
This comment was marked as resolved.
4bd01d4 to
1ce6210
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Bumps [eslint](https://github.com/eslint/eslint) from 8.28.0 to 8.29.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](eslint/eslint@v8.28.0...v8.29.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]>
1ce6210 to
91f04c2
Compare
Contributor
Diff between eslint 8.28.0 and 8.29.0diff --git a/lib/rules/no-extra-parens.js b/lib/rules/no-extra-parens.js
index v8.28.0..v8.29.0 100644
--- a/lib/rules/no-extra-parens.js
+++ b/lib/rules/no-extra-parens.js
@@ -53,5 +53,6 @@
enforceForSequenceExpressions: { type: "boolean" },
enforceForNewInMemberExpressions: { type: "boolean" },
- enforceForFunctionPrototypeMethods: { type: "boolean" }
+ enforceForFunctionPrototypeMethods: { type: "boolean" },
+ allowParensAfterCommentPattern: { type: "string" }
},
additionalProperties: false
@@ -87,4 +88,5 @@
const IGNORE_FUNCTION_PROTOTYPE_METHODS = ALL_NODES && context.options[1] &&
context.options[1].enforceForFunctionPrototypeMethods === false;
+ const ALLOW_PARENS_AFTER_COMMENT_PATTERN = ALL_NODES && context.options[1] && context.options[1].allowParensAfterCommentPattern;
const PRECEDENCE_OF_ASSIGNMENT_EXPR = precedence({ type: "AssignmentExpression" });
@@ -403,4 +405,17 @@
return;
}
+
+ if (ALLOW_PARENS_AFTER_COMMENT_PATTERN) {
+ const commentsBeforeLeftParenToken = sourceCode.getCommentsBefore(leftParenToken);
+ const totalCommentsBeforeLeftParenTokenCount = commentsBeforeLeftParenToken.length;
+ const ignorePattern = new RegExp(ALLOW_PARENS_AFTER_COMMENT_PATTERN, "u");
+
+ if (
+ totalCommentsBeforeLeftParenTokenCount > 0 &&
+ ignorePattern.test(commentsBeforeLeftParenToken[totalCommentsBeforeLeftParenTokenCount - 1].value)
+ ) {
+ return;
+ }
+ }
}
diff --git a/lib/rules/no-invalid-regexp.js b/lib/rules/no-invalid-regexp.js
index v8.28.0..v8.29.0 100644
--- a/lib/rules/no-invalid-regexp.js
+++ b/lib/rules/no-invalid-regexp.js
@@ -61,4 +61,18 @@
/**
+ * Reports error with the provided message.
+ * @param {ASTNode} node The node holding the invalid RegExp
+ * @param {string} message The message to report.
+ * @returns {void}
+ */
+ function report(node, message) {
+ context.report({
+ node,
+ messageId: "regexMessage",
+ data: { message }
+ });
+ }
+
+ /**
* Check if node is a string
* @param {ASTNode} node node to evaluate
@@ -109,8 +123,11 @@
/**
* Check syntax error in a given flags.
- * @param {string} flags The RegExp flags to validate.
+ * @param {string|null} flags The RegExp flags to validate.
* @returns {string|null} The syntax error.
*/
function validateRegExpFlags(flags) {
+ if (!flags) {
+ return null;
+ }
try {
validator.validateFlags(flags);
@@ -123,8 +140,8 @@
return {
"CallExpression, NewExpression"(node) {
- if (node.callee.type !== "Identifier" || node.callee.name !== "RegExp" || !isString(node.arguments[0])) {
+ if (node.callee.type !== "Identifier" || node.callee.name !== "RegExp") {
return;
}
- const pattern = node.arguments[0].value;
+
let flags = getFlags(node);
@@ -133,22 +150,27 @@
}
- const message =
- (
- flags && validateRegExpFlags(flags)
- ) ||
- (
+ let message = validateRegExpFlags(flags);
- // If flags are unknown, report the regex only if its pattern is invalid both with and without the "u" flag
- flags === null
- ? validateRegExpPattern(pattern, true) && validateRegExpPattern(pattern, false)
- : validateRegExpPattern(pattern, flags.includes("u"))
- );
+ if (message) {
+ report(node, message);
+ return;
+ }
+ if (!isString(node.arguments[0])) {
+ return;
+ }
+
+ const pattern = node.arguments[0].value;
+
+ message = (
+
+ // If flags are unknown, report the regex only if its pattern is invalid both with and without the "u" flag
+ flags === null
+ ? validateRegExpPattern(pattern, true) && validateRegExpPattern(pattern, false)
+ : validateRegExpPattern(pattern, flags.includes("u"))
+ );
+
if (message) {
- context.report({
- node,
- messageId: "regexMessage",
- data: { message }
- });
+ report(node, message);
}
}
diff --git a/lib/rules/prefer-named-capture-group.js b/lib/rules/prefer-named-capture-group.js
index v8.28.0..v8.29.0 100644
--- a/lib/rules/prefer-named-capture-group.js
+++ b/lib/rules/prefer-named-capture-group.js
@@ -24,4 +24,59 @@
const parser = new regexpp.RegExpParser();
+/**
+ * Creates fixer suggestions for the regex, if statically determinable.
+ * @param {number} groupStart Starting index of the regex group.
+ * @param {string} pattern The regular expression pattern to be checked.
+ * @param {string} rawText Source text of the regexNode.
+ * @param {ASTNode} regexNode AST node which contains the regular expression.
+ * @returns {Array<SuggestionResult>} Fixer suggestions for the regex, if statically determinable.
+ */
+function suggestIfPossible(groupStart, pattern, rawText, regexNode) {
+ switch (regexNode.type) {
+ case "Literal":
+ if (typeof regexNode.value === "string" && rawText.includes("\\")) {
+ return null;
+ }
+ break;
+ case "TemplateLiteral":
+ if (regexNode.expressions.length || rawText.slice(1, -1) !== pattern) {
+ return null;
+ }
+ break;
+ default:
+ return null;
+ }
+
+ const start = regexNode.range[0] + groupStart + 2;
+
+ return [
+ {
+ fix(fixer) {
+ const existingTemps = pattern.match(/temp\d+/gu) || [];
+ const highestTempCount = existingTemps.reduce(
+ (previous, next) =>
+ Math.max(previous, Number(next.slice("temp".length))),
+ 0
+ );
+
+ return fixer.insertTextBeforeRange(
+ [start, start],
+ `?<temp${highestTempCount + 1}>`
+ );
+ },
+ messageId: "addGroupName"
+ },
+ {
+ fix(fixer) {
+ return fixer.insertTextBeforeRange(
+ [start, start],
+ "?:"
+ );
+ },
+ messageId: "addNonCapture"
+ }
+ ];
+}
+
//------------------------------------------------------------------------------
// Rule Definition
@@ -39,7 +94,11 @@
},
+ hasSuggestions: true,
+
schema: [],
messages: {
+ addGroupName: "Add name to capture group.",
+ addNonCapture: "Convert group to non-capturing.",
required: "Capture group '{{group}}' should be converted to a named or non-capturing group."
}
@@ -47,13 +106,15 @@
create(context) {
+ const sourceCode = context.getSourceCode();
/**
* Function to check regular expression.
- * @param {string} pattern The regular expression pattern to be check.
- * @param {ASTNode} node AST node which contains regular expression.
+ * @param {string} pattern The regular expression pattern to be checked.
+ * @param {ASTNode} node AST node which contains the regular expression or a call/new expression.
+ * @param {ASTNode} regexNode AST node which contains the regular expression.
* @param {boolean} uFlag Flag indicates whether unicode mode is enabled or not.
* @returns {void}
*/
- function checkRegex(pattern, node, uFlag) {
+ function checkRegex(pattern, node, regexNode, uFlag) {
let ast;
@@ -69,4 +130,7 @@
onCapturingGroupEnter(group) {
if (!group.name) {
+ const rawText = sourceCode.getText(regexNode);
+ const suggest = suggestIfPossible(group.start, pattern, rawText, regexNode);
+
context.report({
node,
@@ -74,5 +138,6 @@
data: {
group: group.raw
- }
+ },
+ suggest
});
}
@@ -84,5 +149,5 @@
Literal(node) {
if (node.regex) {
- checkRegex(node.regex.pattern, node, node.regex.flags.includes("u"));
+ checkRegex(node.regex.pattern, node, node, node.regex.flags.includes("u"));
}
},
@@ -102,5 +167,5 @@
if (regex) {
- checkRegex(regex, node, flags && flags.includes("u"));
+ checkRegex(regex, node, node.arguments[0], flags && flags.includes("u"));
}
}
diff --git a/package.json b/package.json
index v8.28.0..v8.29.0 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
{
"name": "eslint",
- "version": "8.28.0",
+ "version": "8.29.0",
"author": "Nicholas C. Zakas <[email protected]>",
"description": "An AST-based pattern checker for JavaScript.",
Command detailsnpm diff [email protected] [email protected] --diff-unified=2See also the Posted by ybiquitous/[email protected] (Node.js 18.12.1 and npm 9.1.3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bumps eslint from 8.28.0 to 8.29.0.
Release notes
Sourced from eslint's releases.
Changelog
Sourced from eslint's changelog.
Commits
d3e4b598.29.06a5f667Build: changelog update for 8.29.00311d81docs: Configuring Plugins page intro, page tweaks, and rename (#16534)57089b1docs: add a property assignment example for camelcase rule (#16605)b6ab030docs: add docs codeowners (#16601)7628403chore: add discord channel link (#16590)49a07c5feat: addallowParensAfterCommentPatternoption to no-extra-parens (#16561)6380c87docs: fix sitemap and feed (#16592)e6a865dfeat:prefer-named-capture-groupadd suggestions (#16544)ade621ddocs: perf debounce the search query (#16586)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebasewill rebase this PR@dependabot recreatewill recreate this PR, overwriting any edits that have been made to it@dependabot mergewill merge this PR after your CI passes on it@dependabot squash and mergewill squash and merge this PR after your CI passes on it@dependabot cancel mergewill cancel a previously requested merge and block automerging@dependabot reopenwill reopen this PR if it is closed@dependabot closewill close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot ignore this major versionwill close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor versionwill close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependencywill close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)