Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps-dev): bump eslint from 8.28.0 to 8.29.0 #202

Merged
merged 1 commit into from
Dec 3, 2022

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Dec 3, 2022

Bumps eslint from 8.28.0 to 8.29.0.

Release notes

Sourced from eslint's releases.

v8.29.0

Features

  • 49a07c5 feat: add allowParensAfterCommentPattern option to no-extra-parens (#16561) (Nitin Kumar)
  • e6a865d feat: prefer-named-capture-group add suggestions (#16544) (Josh Goldberg)
  • a91332b feat: In no-invalid-regexp validate flags also for non-literal patterns (#16583) (trosos)

Documentation

  • 0311d81 docs: Configuring Plugins page intro, page tweaks, and rename (#16534) (Ben Perlmutter)
  • 57089b1 docs: add a property assignment example for camelcase rule (#16605) (Milos Djermanovic)
  • b6ab030 docs: add docs codeowners (#16601) (Strek)
  • 6380c87 docs: fix sitemap and feed (#16592) (Milos Djermanovic)
  • ade621d docs: perf debounce the search query (#16586) (Shanmughapriyan S)
  • fbcf3ab docs: fix searchbar clear button (#16585) (Shanmughapriyan S)
  • f894035 docs: HTTPS link to yeoman.io (#16582) (Christian Oliff)
  • de12b26 docs: Update configuration file pages (#16509) (Ben Perlmutter)
  • 1ae9f20 docs: update correct code examples for no-extra-parens rule (#16560) (Nitin Kumar)

Chores

  • 7628403 chore: add discord channel link (#16590) (Amaresh S M)
  • f5808cb chore: fix rule doc headers check (#16564) (Milos Djermanovic)
Changelog

Sourced from eslint's changelog.

v8.29.0 - December 2, 2022

  • 0311d81 docs: Configuring Plugins page intro, page tweaks, and rename (#16534) (Ben Perlmutter)
  • 57089b1 docs: add a property assignment example for camelcase rule (#16605) (Milos Djermanovic)
  • b6ab030 docs: add docs codeowners (#16601) (Strek)
  • 7628403 chore: add discord channel link (#16590) (Amaresh S M)
  • 49a07c5 feat: add allowParensAfterCommentPattern option to no-extra-parens (#16561) (Nitin Kumar)
  • 6380c87 docs: fix sitemap and feed (#16592) (Milos Djermanovic)
  • e6a865d feat: prefer-named-capture-group add suggestions (#16544) (Josh Goldberg)
  • ade621d docs: perf debounce the search query (#16586) (Shanmughapriyan S)
  • a91332b feat: In no-invalid-regexp validate flags also for non-literal patterns (#16583) (trosos)
  • fbcf3ab docs: fix searchbar clear button (#16585) (Shanmughapriyan S)
  • f894035 docs: HTTPS link to yeoman.io (#16582) (Christian Oliff)
  • de12b26 docs: Update configuration file pages (#16509) (Ben Perlmutter)
  • f5808cb chore: fix rule doc headers check (#16564) (Milos Djermanovic)
  • 1ae9f20 docs: update correct code examples for no-extra-parens rule (#16560) (Nitin Kumar)
Commits

Dependabot compatibility score

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 rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will 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 version will 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 dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot bot added dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code labels Dec 3, 2022
@github-actions

This comment was marked as duplicate.

@ybiquitous

This comment was marked as resolved.

@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/eslint-8.29.0 branch from 89b35d2 to 4bd01d4 Compare December 3, 2022 06:19
@ybiquitous

This comment was marked as resolved.

@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/eslint-8.29.0 branch from 4bd01d4 to 1ce6210 Compare December 3, 2022 06:26
@ybiquitous

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] <support@github.com>
@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/eslint-8.29.0 branch from 1ce6210 to 91f04c2 Compare December 3, 2022 06:32
@ybiquitous ybiquitous self-assigned this Dec 3, 2022
@github-actions
Copy link

github-actions bot commented Dec 3, 2022

Diff between eslint 8.28.0 and 8.29.0
diff --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 <nicholas+npm@nczconsulting.com>",
   "description": "An AST-based pattern checker for JavaScript.",
Size Files
2.7 MB → 2.7 MB (+3.6 KB 🟡) 400 → 400 (±0 🟢)
Command details
npm diff --diff=eslint@8.28.0 --diff=eslint@8.29.0 --diff-unified=2

See also the npm diff document.

Posted by ybiquitous/npm-diff-action@v1.3.5 (Node.js 18.12.1 and npm 9.1.3)

@ybiquitous ybiquitous merged commit 1797be3 into main Dec 3, 2022
@ybiquitous ybiquitous deleted the dependabot/npm_and_yarn/eslint-8.29.0 branch December 3, 2022 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant