Rule proposal: `no-useless-interpolation`
See original GitHub issueHi there! 👋 First of all, thanks again for this plugin, super helpful, the things available in this plugin.
I wanted to propose a new rule to address a pattern that I have seen from a lot of our students at @upleveled - writing overly complex patterns with unnecessary interpolations in template strings (eg. a single string variable, or a string literal, or multiple string literals).
Fail
const withString = `${str}`;
const withStringLiteral = `${'abc'}`;
const withMultipleStringLiterals = `${'abc'}${'def'}`;
Pass
const withString = str;
const withStringLiteral = 'abc';
const withMultipleStringLiterals = 'abcdef';
Implementation ideas
Looking into the ASTExplorer, I guess the simple version of the first failure case below would be:
- only 1 element in
TemplateLiteral.expressions
(anIdentifier
) - only 2 elements in
TemplateLiteral.quasis
, all empty strings
For the literals, I guess no limit to the quasis
, but every element in expressions
should be a Literal
.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:12
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Proposed rule: Order Competition Rule - SEC.gov
proposed rule would prohibit a restricted competition trading center from internally executing certain orders of individual investors at a ...
Read more >Spatially adaptive color filter array interpolation for ... - CiteSeerX
ABSTRACT: Conventional single-chip digital cameras use color filter arrays (CFA) to sample different spectral components. Demosaicing algorithms interpolate ...
Read more >Spatially adaptive color filter array ... - ResearchGate
In this work, we propose to perform the edge-preserving signal correlation based (EP-SCB) interpolation [1] as a second pass to those images ...
Read more >Kernel Interpolation of High Dimensional Scattered Data - arXiv
The main goal of the current paper is to propose and study a new stochastic framework for kernel interpolation of high dimensional data....
Read more >Denoising and interpolation of noisy Bayer data ... - NASA/ADS
The aim is to obtain a full-resolution RGB noiseless image. The proposed technique is specifically targeted to filter signal-dependant, e.g. Poissonian, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The rule could be two parts
Update:
String concatenation should fobid too
`before${ "head" + expression + "tail" }after`
One note, taged templates should not reported.