Skip to content

Commit

Permalink
[[DOCS]] Improve warning message for W040 (#3052)
Browse files Browse the repository at this point in the history
Expand the message to describe the rationale for the warning.
  • Loading branch information
jugglinmike authored and rwaldron committed Oct 19, 2016
1 parent 8e9d406 commit 3add263
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/messages.js
Expand Up @@ -119,7 +119,8 @@ var warnings = {
W037: "'{a}' is a statement label.",
W038: "'{a}' used out of scope.",
W039: "'{a}' is not allowed.",
W040: "Possible strict violation.",
W040: "If a strict mode function is executed using function invocation, " +
"its 'this' value will be undefined.",
W041: "Use '{a}' to compare with '{b}'.",
W042: "Avoid EOL escaping.",
W043: "Bad escaping of EOL. Use option multistr if needed.",
Expand Down
12 changes: 6 additions & 6 deletions tests/regression/thirdparty.js
Expand Up @@ -152,7 +152,7 @@ exports.lodash_0_6_1 = function (test) {
};

TestRun(test)
.addError(168, "Possible strict violation.")
.addError(168, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.addError(170, "Missing '()' invoking a constructor.")
.addError(632, "Missing semicolon.")
.addError(920, "Reassignment of 'isArguments', which is is a function. Use 'var' or 'let' to declare bindings that may change.")
Expand All @@ -164,15 +164,15 @@ exports.lodash_0_6_1 = function (test) {
.addError(1159, "'isArr' used out of scope.")
.addError(1490, "Use '===' to compare with '0'.")
.addError(1670, "Missing semicolon.")
.addError(3374, "Possible strict violation.")
.addError(3374, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.addError(3377, "Missing '()' invoking a constructor.")
.addError(3384, "Missing semicolon.")
.addError(3677, "Missing '()' invoking a constructor.")
.addError(3683, "Missing '()' invoking a constructor.")
.addError(3825, "Possible strict violation.")
.addError(4225, "Possible strict violation.")
.addError(4226, "Possible strict violation.")
.addError(4242, "Possible strict violation.")
.addError(3825, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.addError(4225, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.addError(4226, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.addError(4242, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.test(src, options, globals);

test.done();
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/options.js
Expand Up @@ -1705,7 +1705,7 @@ exports.strict = function (test) {

// Test for strict mode violations
run = TestRun(test)
.addError(4, 'Possible strict violation.')
.addError(4, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.addError(7, 'Strict violation.')
.addError(8, 'Strict violation.');
run.test(src, { es3: true, strict: true });
Expand Down Expand Up @@ -1992,9 +1992,9 @@ exports.validthis = function (test) {
var src = fs.readFileSync(__dirname + '/fixtures/strict_this.js', 'utf8');

TestRun(test)
.addError(8, "Possible strict violation.")
.addError(9, "Possible strict violation.")
.addError(11, "Possible strict violation.")
.addError(8, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.addError(9, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.addError(11, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.test(src, {es3: true});

src = fs.readFileSync(__dirname + '/fixtures/strict_this2.js', 'utf8');
Expand Down Expand Up @@ -3596,12 +3596,12 @@ exports.module.behavior = function(test) {
TestRun(test)
.addError(0, "The 'module' option is only available when linting ECMAScript 6 code.")
.addError(1, "Expected an identifier and instead saw 'package' (a reserved word).")
.addError(2, "Possible strict violation.")
.addError(2, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.test(code, { module: true });

TestRun(test)
.addError(1, "Expected an identifier and instead saw 'package' (a reserved word).")
.addError(2, "Possible strict violation.")
.addError(2, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.test(code, { module: true, esnext: true });

code = [
Expand All @@ -3613,14 +3613,14 @@ exports.module.behavior = function(test) {
TestRun(test)
.addError(1, "The 'module' option is only available when linting ECMAScript 6 code.")
.addError(2, "Expected an identifier and instead saw 'package' (a reserved word).")
.addError(3, "Possible strict violation.")
.addError(3, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.test(code);

code[0] = "/* jshint module: true, esnext: true */";

TestRun(test)
.addError(2, "Expected an identifier and instead saw 'package' (a reserved word).")
.addError(3, "Possible strict violation.")
.addError(3, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.test(code);

test.done();
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/parser.js
Expand Up @@ -6126,7 +6126,7 @@ exports["class method this"] = function (test) {
];

TestRun(test)
.addError(10, "Possible strict violation.")
.addError(10, "If a strict mode function is executed using function invocation, its 'this' value will be undefined.")
.test(code, {esnext: true});

test.done();
Expand Down

0 comments on commit 3add263

Please sign in to comment.