You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing ESLint rule tests using RuleTester, it can be beneficial to enforce consistent usage of the errors property in this RuleTester docs screenshot:
For example, I usually always want to enforce errors to be an object, and I want to require that object to include the message, line, and column properties.
Thoughts on adding a rule like this? Still thinking through what the name could be and what the default options would be for this rule.
The text was updated successfully, but these errors were encountered:
macklinu
changed the title
Rule: consistent RuleTester.error properties
Rule: consistent RuleTester.errors property
May 28, 2018
Sure, this seems reasonable to me. I don't have any strong opinions about what the options would be like -- maybe a list of required keys in options objects? I'm open to other design suggestions too.
The hard part about this rule is how to configure it and what the default options are. With the addition of the messageId property, it doesn't necessarily make sense to default to requiring the user of this rule to use message vs. messageId. I figure at least one of them should be required, though, by default.
maybe a list of required keys in options objects
That's what I'm thinking for sure. I suppose there is nothing wrong with an opinionated default list of required keys, and if someone is using this rule, they can override the defaults? Not sure it'd be the best experience, but I don't see another way forward for this rule.
When writing ESLint rule tests using RuleTester, it can be beneficial to enforce consistent usage of the
errors
property in this RuleTester docs screenshot:For example, I usually always want to enforce
errors
to be an object, and I want to require that object to include themessage
,line
, andcolumn
properties.Thoughts on adding a rule like this? Still thinking through what the name could be and what the default options would be for this rule.
The text was updated successfully, but these errors were encountered: