generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
This file contains 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
dependabot
bot
added
dependencies
Pull requests that update a dependency file
javascript
Pull requests that update Javascript code
labels
Dec 3, 2022
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as resolved.
This comment was marked as resolved.
dependabot
bot
force-pushed
the
dependabot/npm_and_yarn/eslint-8.29.0
branch
from
December 3, 2022 06:19
89b35d2
to
4bd01d4
Compare
This comment was marked as resolved.
This comment was marked as resolved.
dependabot
bot
force-pushed
the
dependabot/npm_and_yarn/eslint-8.29.0
branch
from
December 3, 2022 06:26
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] <support@github.com>
dependabot
bot
force-pushed
the
dependabot/npm_and_yarn/eslint-8.29.0
branch
from
December 3, 2022 06:32
1ce6210
to
91f04c2
Compare
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 <nicholas+npm@nczconsulting.com>",
"description": "An AST-based pattern checker for JavaScript.",
Command detailsnpm diff --diff=eslint@8.28.0 --diff=eslint@8.29.0 --diff-unified=2 See also the Posted by ybiquitous/npm-diff-action@v1.3.5 (Node.js 18.12.1 and npm 9.1.3) |
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
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
d3e4b59
8.29.06a5f667
Build: changelog update for 8.29.00311d81
docs: Configuring Plugins page intro, page tweaks, and rename (#16534)57089b1
docs: add a property assignment example for camelcase rule (#16605)b6ab030
docs: add docs codeowners (#16601)7628403
chore: add discord channel link (#16590)49a07c5
feat: addallowParensAfterCommentPattern
option to no-extra-parens (#16561)6380c87
docs: fix sitemap and feed (#16592)e6a865d
feat:prefer-named-capture-group
add suggestions (#16544)ade621d
docs: 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 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)