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
Fix: improve detection of static arguments of context.report() in several rules (#129)
Several of our rules check the arguments of `context.report()`. This PR makes some improvements:
1. When inferring the arguments passed to `context.report()` in `utils.getReportInfo()`, take into account the static value of the second argument when available.
2. Update the rules using `utils.getReportInfo()` to also consider the static value or variable declaration of the message argument when necessary.
I noticed these issues because in a number of my plugins, we have stored rule error messages in variables like `const MESSAGE = 'do A instead of B';`, and this prevented many of our rules from operating correctly.
Example of how this improvement enables the `no-deprecated-report-api` rule to correctly autofix this code:
```js
const MESSAGE = 'do A instead of B';
module.exports = {
create(context) {
// Before autofix
context.report(theNode, MESSAGE);
// After autofix
context.report({node: theNode, message: MESSAGE});
}
};
```
0 commit comments