forked from eslint/eslint
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Make rule-tester strictly check messageId. (ref eslint#9890)
This change makes rule-tester check messageId directly by value provided instead of the current behavior, which is to check the messageId's message value against the message returned from the rule at runtime.
- Loading branch information
1 parent
084351b
commit 59437bf
Showing
6 changed files
with
150 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"use strict"; | ||
module.exports.withMetaWithData = { | ||
meta: { | ||
messages: { | ||
avoidFoo: "Avoid using variables named '{{ name }}'.", | ||
unused: "An unused key" | ||
} | ||
}, | ||
create(context) { | ||
return { | ||
Identifier(node) { | ||
if (node.name === "foo") { | ||
context.report({ | ||
node, | ||
messageId: "avoidFoo", | ||
data: { | ||
name: "foo" | ||
} | ||
}); | ||
} | ||
} | ||
}; | ||
} | ||
}; | ||
|
||
module.exports.withMessageOnly = { | ||
create(context) { | ||
return { | ||
Identifier(node) { | ||
if (node.name === "foo") { | ||
context.report({ node, message: "Avoid using variables named 'foo'."}); | ||
} | ||
} | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters