webidl2js icon indicating copy to clipboard operation
webidl2js copied to clipboard

Better abstract string concatenation

Open TimothyGu opened this issue 5 years ago • 3 comments

Due to the way we construct type conversions, oftentimes we see unidiomatic code like https://github.com/jsdom/webidl2js/blob/7d45dfc6e6d1ba737b77eaabbab712dcf2d19435/test/snapshots/test.js.snap#L167 Ideally we want to merge string literals together and even use template literals.

Related to this is #204, but this seems mostly orthogonal and more tractable.

TimothyGu avatar Apr 30 '20 17:04 TimothyGu

I wonder if this could be done as a post-processing step using eslint --fix or some more aggressive prettier configuration.

domenic avatar Apr 30 '20 17:04 domenic

Prettier has a stance of not changing ASTs, so I guess that'd be off. ESLint has no-useless-concat, but sadly no fixer for it. This is easy to do even without a postprocessor though, so maybe we should just write the code.

TimothyGu avatar Apr 30 '20 17:04 TimothyGu

I already have code for this in https://github.com/ExE-Boss/webidl2js/tree/refactor/precompute-concatenated-strings from a month ago, but I wasn’t sure whether it was something that was needed, and now it needs rebasing.

ExE-Boss avatar May 03 '20 08:05 ExE-Boss