Bug 1436575 - Remove autofix from rule since it is not reliable in all cases. r?standard8
MozReview-Commit-ID: AYrOuQ95fD6
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-compare-against-boolean-literals.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/rules/no-compare-against-boolean-literals.js
@@ -18,36 +18,13 @@ module.exports = function(context) {
// Public
// --------------------------------------------------------------------------
return {
"BinaryExpression": function(node) {
if (["==", "!="].includes(node.operator) &&
(["true", "false"].includes(node.left.raw) ||
["true", "false"].includes(node.right.raw))) {
- context.report({
- node,
- message: "Don't compare for inexact equality against boolean literals",
- fix(fixer) {
- let unaryOp = "!!";
- if ((node.operator == "==" &&
- (node.left.raw == "false" ||
- node.right.raw == "false")) ||
- (node.operator == "!=" &&
- (node.left.raw == "true" ||
- node.right.raw == "true"))) {
- unaryOp = "!";
- }
- let fixings = [];
- if (["true", "false"].includes(node.left)) {
- fixings.push(fixer.removeRange([node.left.range[0], node.right.range[0]]));
- fixings.push(fixer.insertTextBefore(node.right, unaryOp));
- } else {
- fixings.push(fixer.removeRange([node.left.range[1], node.right.range[1]]));
- fixings.push(fixer.insertTextBefore(node.left, unaryOp));
- }
- return fixings;
- }
- });
+ context.report(node, "Don't compare for inexact equality against boolean literals");
}
}
};
};