Skip to content

Commit

Permalink
Fix: Normalizes messages so all end with a period (fixes #6762) (#6807)
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick McElhaney authored and nzakas committed Aug 1, 2016
1 parent c7488ac commit 4ca809e
Show file tree
Hide file tree
Showing 59 changed files with 498 additions and 499 deletions.
4 changes: 2 additions & 2 deletions lib/rules/accessor-pairs.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ module.exports = {
}

if (checkSetWithoutGet && isSetPresent && !isGetPresent) {
context.report(node, "Getter is not present");
context.report(node, "Getter is not present.");
} else if (checkGetWithoutSet && isGetPresent && !isSetPresent) {
context.report(node, "Setter is not present");
context.report(node, "Setter is not present.");
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/rules/array-bracket-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module.exports = {
context.report({
node: node,
loc: token.loc.start,
message: "There should be no space after '" + token.value + "'",
message: "There should be no space after '" + token.value + "'.",
fix: function(fixer) {
let nextToken = sourceCode.getTokenAfter(token);

Expand All @@ -94,7 +94,7 @@ module.exports = {
context.report({
node: node,
loc: token.loc.start,
message: "There should be no space before '" + token.value + "'",
message: "There should be no space before '" + token.value + "'.",
fix: function(fixer) {
let previousToken = sourceCode.getTokenBefore(token);

Expand All @@ -113,7 +113,7 @@ module.exports = {
context.report({
node: node,
loc: token.loc.start,
message: "A space is required after '" + token.value + "'",
message: "A space is required after '" + token.value + "'.",
fix: function(fixer) {
return fixer.insertTextAfter(token, " ");
}
Expand All @@ -130,7 +130,7 @@ module.exports = {
context.report({
node: node,
loc: token.loc.start,
message: "A space is required before '" + token.value + "'",
message: "A space is required before '" + token.value + "'.",
fix: function(fixer) {
return fixer.insertTextBefore(token, " ");
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/arrow-parens.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {

create: function(context) {
let message = "Expected parentheses around arrow function argument.";
let asNeededMessage = "Unexpected parentheses around single function argument";
let asNeededMessage = "Unexpected parentheses around single function argument.";
let asNeeded = context.options[0] === "as-needed";

let sourceCode = context.getSourceCode();
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/arrow-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports = {
if (countSpace.before === 0) {
context.report({
node: tokens.before,
message: "Missing space before =>",
message: "Missing space before =>.",
fix: function(fixer) {
return fixer.insertTextBefore(tokens.arrow, " ");
}
Expand All @@ -104,7 +104,7 @@ module.exports = {
if (countSpace.before > 0) {
context.report({
node: tokens.before,
message: "Unexpected space before =>",
message: "Unexpected space before =>.",
fix: function(fixer) {
return fixer.removeRange([tokens.before.range[1], tokens.arrow.range[0]]);
}
Expand All @@ -118,7 +118,7 @@ module.exports = {
if (countSpace.after === 0) {
context.report({
node: tokens.after,
message: "Missing space after =>",
message: "Missing space after =>.",
fix: function(fixer) {
return fixer.insertTextAfter(tokens.arrow, " ");
}
Expand All @@ -130,7 +130,7 @@ module.exports = {
if (countSpace.after > 0) {
context.report({
node: tokens.after,
message: "Unexpected space after =>",
message: "Unexpected space after =>.",
fix: function(fixer) {
return fixer.removeRange([tokens.arrow.range[1], tokens.after.range[0]]);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/computed-property-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = {
context.report({
node: node,
loc: token.loc.start,
message: "There should be no space after '" + token.value + "'",
message: "There should be no space after '" + token.value + "'.",
fix: function(fixer) {
return fixer.removeRange([token.range[1], tokenAfter.range[0]]);
}
Expand All @@ -64,7 +64,7 @@ module.exports = {
context.report({
node: node,
loc: token.loc.start,
message: "There should be no space before '" + token.value + "'",
message: "There should be no space before '" + token.value + "'.",
fix: function(fixer) {
return fixer.removeRange([tokenBefore.range[1], token.range[0]]);
}
Expand All @@ -81,7 +81,7 @@ module.exports = {
context.report({
node: node,
loc: token.loc.start,
message: "A space is required after '" + token.value + "'",
message: "A space is required after '" + token.value + "'.",
fix: function(fixer) {
return fixer.insertTextAfter(token, " ");
}
Expand All @@ -98,7 +98,7 @@ module.exports = {
context.report({
node: node,
loc: token.loc.start,
message: "A space is required before '" + token.value + "'",
message: "A space is required before '" + token.value + "'.",
fix: function(fixer) {
return fixer.insertTextBefore(token, " ");
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/id-blacklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = {
* @private
*/
function report(node) {
context.report(node, "Identifier '{{name}}' is blacklisted", {
context.report(node, "Identifier '{{name}}' is blacklisted.", {
name: node.name
});
}
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/id-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ module.exports = {
context.report(
node,
isShort ?
"Identifier name '{{name}}' is too short. (< {{min}})" :
"Identifier name '{{name}}' is too long. (> {{max}})",
"Identifier name '{{name}}' is too short (< {{min}})." :
"Identifier name '{{name}}' is too long (> {{max}}).",
{ name: name, min: minLength, max: maxLength }
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/max-lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ module.exports = {
if (lines.length > max) {
context.report({
loc: { line: 1, column: 0 },
message: "File must be at most " + max + " lines long"
message: "File must be at most " + max + " lines long."
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/new-parens.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
});

if (prenticesTokens.length < 2) {
context.report(node, "Missing '()' invoking a constructor");
context.report(node, "Missing '()' invoking a constructor.");
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-continue.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {

return {
ContinueStatement: function(node) {
context.report(node, "Unexpected use of continue statement");
context.report(node, "Unexpected use of continue statement.");
}
};

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-invalid-regexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ module.exports = {
try {
void new RegExp(node.arguments[0].value);
} catch (e) {
context.report(node, e.message);
context.report(node, e.message + ".");
}

if (flags) {

try {
espree.parse("/./" + flags, context.parserOptions);
} catch (ex) {
context.report(node, "Invalid flags supplied to RegExp constructor '" + flags + "'");
context.report(node, "Invalid flags supplied to RegExp constructor '" + flags + "'.");
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-irregular-whitespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ module.exports = {
column: match.index
};

errors.push([node, location, "Irregular whitespace not allowed"]);
errors.push([node, location, "Irregular whitespace not allowed."]);
}
});
}
Expand Down Expand Up @@ -181,7 +181,7 @@ module.exports = {
column: sourceLines[lineIndex].length
};

errors.push([node, location, "Irregular whitespace not allowed"]);
errors.push([node, location, "Irregular whitespace not allowed."]);
lastLineIndex = lineIndex;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-loop-func.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ module.exports = {
if (references.length > 0 &&
!references.every(isSafe.bind(null, node, loopNode))
) {
context.report(node, "Don't make functions within a loop");
context.report(node, "Don't make functions within a loop.");
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-magic-numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ module.exports = {
if (enforceConst && parent.parent.kind !== "const") {
context.report({
node: node,
message: "Number constants declarations must use 'const'"
message: "Number constants declarations must use 'const'."
});
}
} else if (okTypes.indexOf(parent.type) === -1 ||
(parent.type === "AssignmentExpression" && parent.operator !== "=")) {
context.report({
node: node,
message: "No magic number: " + raw
message: "No magic number: " + raw + "."
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-negated-in-lhs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {

BinaryExpression: function(node) {
if (node.operator === "in" && node.left.type === "UnaryExpression" && node.left.operator === "!") {
context.report(node, "The 'in' expression's left operand is negated");
context.report(node, "The 'in' expression's left operand is negated.");
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-nested-ternary.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
ConditionalExpression: function(node) {
if (node.alternate.type === "ConditionalExpression" ||
node.consequent.type === "ConditionalExpression") {
context.report(node, "Do not nest ternary expressions");
context.report(node, "Do not nest ternary expressions.");
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-redeclare.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = {
for (let i = (hasBuiltin ? 0 : 1), l = variable.identifiers.length; i < l; i++) {
context.report(
variable.identifiers[i],
"'{{a}}' is already defined",
"'{{a}}' is already defined.",
{a: variable.name});
}
}
Expand Down
3 changes: 1 addition & 2 deletions lib/rules/no-restricted-globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module.exports = {
* @private
*/
function reportReference(reference) {
context.report(reference.identifier, "Unexpected use of '{{name}}'", {
context.report(reference.identifier, "Unexpected use of '{{name}}'.", {
name: reference.identifier.name
});
}
Expand Down Expand Up @@ -77,4 +77,3 @@ module.exports = {
};
}
};

4 changes: 2 additions & 2 deletions lib/rules/no-unneeded-ternary.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ module.exports = {

ConditionalExpression: function(node) {
if (isBooleanLiteral(node.alternate) && isBooleanLiteral(node.consequent)) {
context.report(node, node.consequent.loc.start, "Unnecessary use of boolean literals in conditional expression");
context.report(node, node.consequent.loc.start, "Unnecessary use of boolean literals in conditional expression.");
} else if (!defaultAssignment && matchesDefaultAssignment(node)) {
context.report(node, node.consequent.loc.start, "Unnecessary use of conditional expression for default assignment");
context.report(node, node.consequent.loc.start, "Unnecessary use of conditional expression for default assignment.");
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-unsafe-finally.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module.exports = {
function check(node) {
if (isInFinallyBlock(node, node.label)) {
context.report({
message: "Unsafe usage of " + node.type,
message: "Unsafe usage of " + node.type + ".",
node: node,
line: node.loc.line,
column: node.loc.column
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-use-before-define.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ module.exports = {
// Reports.
context.report({
node: reference.identifier,
message: "'{{name}}' was used before it was defined",
message: "'{{name}}' was used before it was defined.",
data: reference.identifier
});
});
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-useless-escape.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ module.exports = {
line: node.loc.start.line,
column: node.loc.start.column + elm.index
},
message: "Unnecessary escape character: " + elm[0]
message: "Unnecessary escape character: " + elm[0] + "."
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/object-curly-spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = {
context.report({
node: node,
loc: token.loc.start,
message: "There should be no space after '" + token.value + "'",
message: "There should be no space after '" + token.value + "'.",
fix: function(fixer) {
let nextToken = context.getSourceCode().getTokenAfter(token);

Expand All @@ -93,7 +93,7 @@ module.exports = {
context.report({
node: node,
loc: token.loc.start,
message: "There should be no space before '" + token.value + "'",
message: "There should be no space before '" + token.value + "'.",
fix: function(fixer) {
let previousToken = context.getSourceCode().getTokenBefore(token);

Expand All @@ -112,7 +112,7 @@ module.exports = {
context.report({
node: node,
loc: token.loc.start,
message: "A space is required after '" + token.value + "'",
message: "A space is required after '" + token.value + "'.",
fix: function(fixer) {
return fixer.insertTextAfter(token, " ");
}
Expand All @@ -129,7 +129,7 @@ module.exports = {
context.report({
node: node,
loc: token.loc.start,
message: "A space is required before '" + token.value + "'",
message: "A space is required before '" + token.value + "'.",
fix: function(fixer) {
return fixer.insertTextBefore(token, " ");
}
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/object-property-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ module.exports = {
create: function(context) {
let allowSameLine = context.options[0] && Boolean(context.options[0].allowMultiplePropertiesPerLine);
let errorMessage = allowSameLine ?
"Object properties must go on a new line if they aren't all on the same line" :
"Object properties must go on a new line";
"Object properties must go on a new line if they aren't all on the same line." :
"Object properties must go on a new line.";

let sourceCode = context.getSourceCode();

Expand Down
2 changes: 1 addition & 1 deletion lib/rules/operator-linebreak.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ module.exports = {
context.report(node, {
line: operatorToken.loc.end.line,
column: operatorToken.loc.end.column
}, "There should be no line break before or after '" + operator + "'");
}, "There should be no line break before or after '" + operator + "'.");

}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-reflect.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module.exports = {
* @returns {void}
*/
function report(node, existing, substitute) {
context.report(node, "Avoid using {{existing}}, instead use {{substitute}}", {
context.report(node, "Avoid using {{existing}}, instead use {{substitute}}.", {
existing: existing,
substitute: substitute
});
Expand Down
Loading

0 comments on commit 4ca809e

Please sign in to comment.