Skip to content

Commit

Permalink
Fix: Fixes tests checking the entire problem object or using unrelate…
Browse files Browse the repository at this point in the history
…d structures for formatting.
  • Loading branch information
betaorbust committed Jan 28, 2018
1 parent d2267d1 commit c783b09
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/rules/no-undef.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports = {
context.report({
node: identifier,
message: "'{{name}}' is not defined.",
data: identifier
data: { name: identifier.name }
});
});
}
Expand Down
4 changes: 3 additions & 1 deletion lib/rules/no-unused-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,9 @@ module.exports = {
message: unusedVar.references.some(ref => ref.isWrite())
? getAssignedMessage()
: getDefinedMessage(unusedVar),
data: unusedVar
data: {
name: unusedVar.name
}
});
}
}
Expand Down
6 changes: 6 additions & 0 deletions tests/lib/cli-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ describe("CLIEngine", () => {
ruleId: "no-undef",
severity: 2,
message: "'foo' is not defined.",
data: { name: "foo" },
line: 1,
column: 11,
endLine: 1,
Expand Down Expand Up @@ -1395,6 +1396,10 @@ describe("CLIEngine", () => {
column: 9,
line: 2,
message: "Expected '===' and instead saw '=='.",
data: {
actualOperator: "==",
expectedOperator: "==="
},
nodeType: "BinaryExpression",
ruleId: "eqeqeq",
severity: 2,
Expand All @@ -1416,6 +1421,7 @@ describe("CLIEngine", () => {
endColumn: 21,
endLine: 1,
message: "'foo' is not defined.",
data: { name: "foo" },
nodeType: "Identifier",
ruleId: "no-undef",
severity: 2,
Expand Down
8 changes: 6 additions & 2 deletions tests/lib/report-translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("createReportTranslator", () => {
describe("old-style call with location", () => {
it("should extract the location correctly", () => {
assert.deepStrictEqual(
translateReport(node, location, message, {}),
translateReport(node, location, message),
{
ruleId: "foo-rule",
severity: 2,
Expand All @@ -71,7 +71,7 @@ describe("createReportTranslator", () => {
describe("old-style call without location", () => {
it("should use the start location and end location of the node", () => {
assert.deepStrictEqual(
translateReport(node, message, {}),
translateReport(node, message),
{
ruleId: "foo-rule",
severity: 2,
Expand Down Expand Up @@ -336,6 +336,7 @@ describe("createReportTranslator", () => {
ruleId: "foo-rule",
severity: 2,
message: "my message testing!",
data: ["!", "testing"],
line: 42,
column: 24,
nodeType: "ExpressionStatement",
Expand All @@ -358,6 +359,7 @@ describe("createReportTranslator", () => {
severity: 2,
ruleId: "foo-rule",
message: "hello ExpressionStatement",
data: { dynamic: "ExpressionStatement" },
nodeType: "ExpressionStatement",
line: 1,
column: 4,
Expand All @@ -373,6 +375,7 @@ describe("createReportTranslator", () => {
severity: 2,
ruleId: "foo-rule",
message: "hello ExpressionStatement",
data: { dynamic: "ExpressionStatement" },
nodeType: "ExpressionStatement",
line: 1,
column: 4,
Expand Down Expand Up @@ -558,6 +561,7 @@ describe("createReportTranslator", () => {
severity: 2,
ruleId: "foo-rule",
message: "my message testing!",
data: ["!", "testing"],
nodeType: "ExpressionStatement",
line: 1,
column: 1,
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/rules/no-fallthrough.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ ruleTester.run("no-fallthrough", rule, {
}],
errors: [
{
message: errorsDefault.message,
type: errorsDefault.type,
message: errorsDefault[0].message,
type: errorsDefault[0].type,
line: 4,
column: 1
}
Expand Down

0 comments on commit c783b09

Please sign in to comment.