Skip to content

Commit

Permalink
[[FIX]] Removed warning message W041 (#3115)
Browse files Browse the repository at this point in the history
* [[FIX]] Removed warning message W041

This commit removes the warning message W041 altogether from the jshint
project.

Fixes #3109

* [[FIX]] Removed warning message W041

This commit removes the warning message W041 and the corresponding
assertions from junits.

Fixes #3109
  • Loading branch information
sunilkumarc authored and rwaldron committed Apr 13, 2017
1 parent 42dc572 commit 376fa62
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 46 deletions.
20 changes: 0 additions & 20 deletions src/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -1215,16 +1215,6 @@ var JSHINT = (function() {
return x;
}

function isPoorRelation(node) {
return node &&
((node.type === "(number)" && +node.value === 0) ||
(node.type === "(string)" && node.value === "") ||
(node.type === "null" && !state.option.eqnull) ||
node.type === "true" ||
node.type === "false" ||
node.type === "undefined");
}

var typeofValues = {};
typeofValues.legacy = [
// E4X extended the `typeof` operator to return "xml" for the XML and
Expand Down Expand Up @@ -2068,12 +2058,6 @@ var JSHINT = (function() {
this.from = this.character;
warning("W116", this, "===", "==");
break;
case isPoorRelation(left):
warning("W041", this, "===", left.value);
break;
case isPoorRelation(right):
warning("W041", this, "===", right.value);
break;
case isTypoTypeof(right, left, state):
warning("W122", this, right.value);
break;
Expand All @@ -2099,10 +2083,6 @@ var JSHINT = (function() {
if (!eqnull && state.option.eqeqeq) {
this.from = this.character;
warning("W116", this, "!==", "!=");
} else if (isPoorRelation(left)) {
warning("W041", this, "!==", left.value);
} else if (isPoorRelation(right)) {
warning("W041", this, "!==", right.value);
} else if (isTypoTypeof(right, left, state)) {
warning("W122", this, right.value);
} else if (isTypoTypeof(left, right, state)) {
Expand Down
2 changes: 1 addition & 1 deletion src/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ var warnings = {
W039: "'{a}' is not allowed.",
W040: "If a strict mode function is executed using function invocation, " +
"its 'this' value will be undefined.",
W041: "Use '{a}' to compare with '{b}'.",
W041: null,
W042: "Avoid EOL escaping.",
W043: "Bad escaping of EOL. Use option multistr if needed.",
W044: "Bad or unnecessary escaping.", /* TODO(caitp): remove W044 */
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/testhelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@ exports.setup.testRun = function (test, name) {
};

return helperObj;
};
};
15 changes: 0 additions & 15 deletions tests/regression/thirdparty.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ exports["Backbone.js 0.5.3"] = function (test) {
.addError(784, "Unnecessary grouping operator.")
.addError(864, "Unnecessary grouping operator.")
.addError(685, "Missing '()' invoking a constructor.")
.addError(764, "Use '===' to compare with '0'.")
.addError(859, "Use '!==' to compare with '0'.")
.test(src, { expr: true, eqnull: true, boss: true, regexdash: true, singleGroups: true });

test.done();
Expand Down Expand Up @@ -73,10 +71,6 @@ exports.prototype_1_7 = function (test) {
.addError(409, "Missing semicolon.")
.addError(430, "Missing semicolon.")
.addError(451, "Missing semicolon.")
.addError(633, "Use '!==' to compare with 'undefined'.")
.addError(737, "Use '===' to compare with ''.")
.addError(807, "Use '===' to compare with ''.")
.addError(1137, "Use '===' to compare with '0'.")
.addError(1215, "Missing semicolon.")
.addError(1224, "Unnecessary semicolon.")
.addError(1916, "Missing semicolon.")
Expand All @@ -102,18 +96,12 @@ exports.prototype_1_7 = function (test) {
.addError(4322, "'nodeCheck' used out of scope.")
.addError(4520, "'i' is already defined.")
.addError(4538, "Expected a 'break' statement before 'case'.")
.addError(4547, "Use '===' to compare with '0'.")
.addError(4565, "Use '===' to compare with '0'.")
.addError(4566, "Use '===' to compare with '0'.")
.addError(4568, "Use '===' to compare with '0'.")
.addError(4656, "'i' is already defined.")
.addError(4722, "Missing '()' invoking a constructor.")
.addError(4988, "Missing semicolon.")
.addError(4988, "Missing semicolon.")
.addError(5021, "Missing semicolon.")
.addError(5397, "Missing semicolon.")
.addError(5112, "Use '!==' to compare with 'undefined'.")
.addError(5140, "Use '!==' to compare with ''.")
.addError(5224, "'values' is already defined.")
.addError(5495, "Function declarations should not be placed in blocks. Use a function " +
"expression or move the statement to the top of the outer function.")
Expand Down Expand Up @@ -159,10 +147,8 @@ exports.lodash_0_6_1 = function (test) {
.addError(963, "Reassignment of 'isFunction', which is is a function. Use 'var' or 'let' to declare bindings that may change.")
.addError(1122, "'isArr' used out of scope.")
.addError(1127, "'className' used out of scope.")
.addError(1129, "Use '===' to compare with 'true'.")
.addError(1153, "'isArr' used out of scope.")
.addError(1159, "'isArr' used out of scope.")
.addError(1490, "Use '===' to compare with '0'.")
.addError(1670, "Missing semicolon.")
.addError(3374, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.addError(3377, "Missing '()' invoking a constructor.")
Expand Down Expand Up @@ -206,7 +192,6 @@ exports.codemirror3 = function (test) {
"-W008": true, // Ignore warnings about leading dots in numbers.
"-W038": true, // Ignore scope warnings.
"-W040": true, // Ignore possible strict violations.
"-W041": true, // Ignore poor relations warnings.

};

Expand Down
15 changes: 10 additions & 5 deletions tests/unit/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -1414,11 +1414,12 @@ exports.eqnull = function (test) {
];

// By default, warn about `== null` comparison
/**
* This test previously asserted the issuance of warning W041.
* W041 has since been removed, but the test is maintained in
* order to discourage regressions.
*/
TestRun(test)
.addError(1, "Use '===' to compare with 'null'.")
.addError(2, "Use '===' to compare with 'null'.")
.addError(3, "Use '!==' to compare with 'null'.")
.addError(4, "Use '!==' to compare with 'null'.")
.test(code, {es3: true});

// But when `eqnull` is true, no questions asked
Expand Down Expand Up @@ -1533,8 +1534,12 @@ exports.debug = function (test) {
exports.eqeqeq = function (test) {
var src = fs.readFileSync(__dirname + '/fixtures/eqeqeq.js', 'utf8');

/**
* This test previously asserted the issuance of warning W041.
* W041 has since been removed, but the test is maintained in
* order to discourage regressions.
*/
TestRun(test)
.addError(8, "Use '===' to compare with 'null'.")
.test(src, {es3: true});

TestRun(test)
Expand Down
9 changes: 5 additions & 4 deletions tests/unit/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1039,15 +1039,13 @@ exports["gh-2587"] = function (test) {
TestRun(test)
.addError(1, "Expected an identifier and instead saw 'if'.")
.addError(1, "Unrecoverable syntax error. (100% scanned).")
.addError(1, "Use '===' to compare with 'true'.")
.test([
"true == if"
], {});

TestRun(test)
.addError(1, "Expected an identifier and instead saw 'if'.")
.addError(1, "Unrecoverable syntax error. (100% scanned).")
.addError(1, "Use '!==' to compare with 'true'.")
.test([
"true != if"
], {});
Expand Down Expand Up @@ -6920,8 +6918,12 @@ exports.ignoreDirective["should be a good option and only accept start, end or l
exports.ignoreDirective["should allow the linter to skip blocked-out lines to continue finding errors in the rest of the code"] = function (test) {
var code = fs.readFileSync(__dirname + "/fixtures/gh826.js", "utf8");

/**
* This test previously asserted the issuance of warning W041.
* W041 has since been removed, but the test is maintained in
* order to discourage regressions.
*/
TestRun(test)
.addError(34, "Use '===' to compare with '0'.")
.test(code);

test.done();
Expand Down Expand Up @@ -7027,7 +7029,6 @@ exports["should be able to ignore a single line with a trailing comment: // jshi
exports["regression test for GH-1431"] = function (test) {
// The code is invalid but it should not crash JSHint.
TestRun(test)
.addError(1, "Use '!==' to compare with 'null'.")
.addError(1, "Expected ';' and instead saw ')'.")
.addError(1, "Expected ')' and instead saw ';'.")
.addError(1, "Expected an identifier and instead saw ';'.")
Expand Down

0 comments on commit 376fa62

Please sign in to comment.