Files
NapCatQQ/.pnpm-store/v3/files/68/c2727d7c68398a4cbe74b88d58257c6ec91a47d0846b496b1fba839d03537b339b89ffe1a02b1c137107705427bd9957da36673dd2496226d99bc6d4d93606
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

61 lines
2.2 KiB
Plaintext

/**
* @author Yosuke Ota
* See LICENSE file in root directory for full license.
*/
"use strict"
const utils = require("@eslint-community/eslint-utils")
const { getSourceCode } = require("eslint-compat-utils")
module.exports = {
meta: {
docs: {
description: "disallow logical assignment operators.",
category: "ES2021",
recommended: false,
url: "http://eslint-community.github.io/eslint-plugin-es-x/rules/no-logical-assignment-operators.html",
},
fixable: "code",
messages: {
forbidden: "ES2021 logical assignment operators are forbidden.",
},
schema: [],
type: "problem",
},
create(context) {
const sourceCode = getSourceCode(context)
return {
"AssignmentExpression[operator=/(?:\\|\\||&&|\\?\\?)=/]"(node) {
const operatorToken = sourceCode.getTokenAfter(node.left)
context.report({
node: operatorToken,
messageId: "forbidden",
fix(fixer) {
if (node.left.type !== "Identifier") {
return null
}
const newOperator = node.operator.slice(-1)
const biOperator = node.operator.slice(0, -1)
const varText = sourceCode.getText(node.left)
const results = [
fixer.replaceText(operatorToken, newOperator),
fixer.insertTextAfter(
operatorToken,
` ${varText} ${biOperator}`,
),
]
if (!utils.isParenthesized(node.right, sourceCode)) {
results.push(
fixer.insertTextBefore(node.right, "("),
fixer.insertTextAfter(node.right, ")"),
)
}
return results
},
})
},
}
},
}