Bump packages to fix linter

This commit is contained in:
Henry Mercer 2023-01-18 20:50:03 +00:00
parent ed9506bbaf
commit 0a11e3fdd9
6063 changed files with 378752 additions and 306784 deletions

View file

@ -17,23 +17,23 @@ const astUtils = require("./utils/ast-utils");
/**
* Checks whether an operator is commutative and has an operator assignment
* shorthand form.
* @param {string} operator Operator to check.
* @returns {boolean} True if the operator is commutative and has a
* @param {string} operator Operator to check.
* @returns {boolean} True if the operator is commutative and has a
* shorthand form.
*/
function isCommutativeOperatorWithShorthand(operator) {
return ["*", "&", "^", "|"].indexOf(operator) >= 0;
return ["*", "&", "^", "|"].includes(operator);
}
/**
* Checks whether an operator is not commutative and has an operator assignment
* shorthand form.
* @param {string} operator Operator to check.
* @returns {boolean} True if the operator is not commutative and has
* @param {string} operator Operator to check.
* @returns {boolean} True if the operator is not commutative and has
* a shorthand form.
*/
function isNonCommutativeOperatorWithShorthand(operator) {
return ["+", "-", "/", "%", "<<", ">>", ">>>", "**"].indexOf(operator) >= 0;
return ["+", "-", "/", "%", "<<", ">>", ">>>", "**"].includes(operator);
}
//------------------------------------------------------------------------------
@ -57,13 +57,13 @@ function canBeFixed(node) {
);
}
/** @type {import('../shared/types').Rule} */
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "require or disallow assignment operator shorthand where possible",
category: "Stylistic Issues",
description: "Require or disallow assignment operator shorthand where possible",
recommended: false,
url: "https://eslint.org/docs/rules/operator-assignment"
},
@ -76,8 +76,8 @@ module.exports = {
fixable: "code",
messages: {
replaced: "Assignment (=) can be replaced with operator assignment ({{operator}}=).",
unexpected: "Unexpected operator assignment ({{operator}}=) shorthand."
replaced: "Assignment (=) can be replaced with operator assignment ({{operator}}).",
unexpected: "Unexpected operator assignment ({{operator}}) shorthand."
}
},
@ -96,7 +96,7 @@ module.exports = {
/**
* Ensures that an assignment uses the shorthand form where possible.
* @param {ASTNode} node An AssignmentExpression node.
* @param {ASTNode} node An AssignmentExpression node.
* @returns {void}
*/
function verify(node) {
@ -109,11 +109,13 @@ module.exports = {
const operator = expr.operator;
if (isCommutativeOperatorWithShorthand(operator) || isNonCommutativeOperatorWithShorthand(operator)) {
const replacementOperator = `${operator}=`;
if (astUtils.isSameReference(left, expr.left, true)) {
context.report({
node,
messageId: "replaced",
data: { operator },
data: { operator: replacementOperator },
fix(fixer) {
if (canBeFixed(left) && canBeFixed(expr.left)) {
const equalsToken = getOperatorToken(node);
@ -126,7 +128,7 @@ module.exports = {
return null;
}
return fixer.replaceText(node, `${leftText}${expr.operator}=${rightText}`);
return fixer.replaceText(node, `${leftText}${replacementOperator}${rightText}`);
}
return null;
}
@ -141,7 +143,7 @@ module.exports = {
context.report({
node,
messageId: "replaced",
data: { operator }
data: { operator: replacementOperator }
});
}
}
@ -149,7 +151,7 @@ module.exports = {
/**
* Warns if an assignment expression uses operator assignment shorthand.
* @param {ASTNode} node An AssignmentExpression node.
* @param {ASTNode} node An AssignmentExpression node.
* @returns {void}
*/
function prohibit(node) {