avajs / eslint-plugin-ava

ESLint rules for AVA
https://avajs.dev
MIT License
230 stars 49 forks source link

Allow concatenation when ensuring assertion message is a string #332

Open Yash-Singh1 opened 3 years ago

Yash-Singh1 commented 3 years ago

Currently, doing:

t.notThrowsAsync(asyncNotThrowingFn, 'abc' + someString)

Would fail, saying that the assertion message is not a string. This is happening over here:

https://github.com/avajs/eslint-plugin-ava/blob/dee1802d39e22aec0915d5067062356f5abfbd84/rules/assertion-arguments.js#L206

The function should also support concatenation. Looking at the AST Explorer, I think that the function should run recursively and recheck its left and its right to ensure that they are either a Binary Expression or a String Literal, or an Identifier.

sindresorhus commented 3 years ago

I think we can make it better by using getStaticValue there.