style: disallow format calls without interpolation placeholders#13404
Draft
Planeshifter wants to merge 1 commit into
Draft
style: disallow format calls without interpolation placeholders#13404Planeshifter wants to merge 1 commit into
format calls without interpolation placeholders#13404Planeshifter wants to merge 1 commit into
Conversation
kgryte
reviewed
Jul 10, 2026
|
|
||
| // format without interpolation | ||
| { | ||
| 'selector': 'CallExpression[callee.name="format"][arguments.length=1][arguments.0.value=/^[^%]*$/]', |
Member
There was a problem hiding this comment.
This is a little tricky, as this supposes we never use format as an alias for something else which is not string interpolation. E.g., we could have a "format" function which does some other kind of formatting and does not operate on a formatting string, and devs will get spurious lint errors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request:
no-restricted-syntaxESLint entry which disallows callingformat(fromstring/format) with a single string literal containing no interpolation placeholders (e.g.,format( 'invalid argument. Third argument must not be an empty string.' )), as such calls are unnecessary overhead and the string can be used directlyformatcall and removingformatrequires which became unusedNote that single-argument calls whose string contains
%(e.g.,%%escapes) remain allowed, as those do perform work.This should help with AI agents or humans adding
formatfor strings where it is not needed.Related Issues
No.
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code, with the lint rule selector and all call-site fixes verified locally against the repository ESLint configuration.
@stdlib-js/reviewers