Skip to content

Commit

Permalink
Fix: Removing curly quotes in no-eq-null report message (#9852)
Browse files Browse the repository at this point in the history
  • Loading branch information
platinumazure committed Jan 20, 2018
1 parent b96fb31 commit 13bcf3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/rules/no-eq-null.js
Expand Up @@ -31,7 +31,7 @@ module.exports = {

if (node.right.type === "Literal" && node.right.raw === "null" && badOperator ||
node.left.type === "Literal" && node.left.raw === "null" && badOperator) {
context.report({ node, message: "Use === to compare with null." });
context.report({ node, message: "Use '===' to compare with null." });
}
}
};
Expand Down
8 changes: 5 additions & 3 deletions tests/lib/rules/no-eq-null.js
Expand Up @@ -18,14 +18,16 @@ const rule = require("../../../lib/rules/no-eq-null"),

const ruleTester = new RuleTester();

const MESSAGE = "Use '===' to compare with null.";

ruleTester.run("no-eq-null", rule, {
valid: [
"if (x === null) { }",
"if (null === f()) { }"
],
invalid: [
{ code: "if (x == null) { }", errors: [{ message: "Use ‘===’ to compare with ‘null’.", type: "BinaryExpression" }] },
{ code: "if (x != null) { }", errors: [{ message: "Use ‘===’ to compare with ‘null’.", type: "BinaryExpression" }] },
{ code: "do {} while (null == x)", errors: [{ message: "Use ‘===’ to compare with ‘null’.", type: "BinaryExpression" }] }
{ code: "if (x == null) { }", errors: [{ message: MESSAGE, type: "BinaryExpression" }] },
{ code: "if (x != null) { }", errors: [{ message: MESSAGE, type: "BinaryExpression" }] },
{ code: "do {} while (null == x)", errors: [{ message: MESSAGE, type: "BinaryExpression" }] }
]
});

0 comments on commit 13bcf3c

Please sign in to comment.