eslint-plugin-ava icon indicating copy to clipboard operation
eslint-plugin-ava copied to clipboard

Allow concatenation when ensuring assertion message is a string

Open Yash-Singh1 opened this issue 4 years ago • 1 comments

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.

Yash-Singh1 avatar Sep 06 '21 20:09 Yash-Singh1

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

sindresorhus avatar Sep 07 '21 02:09 sindresorhus