Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enhancement: [restrict-plus-operands] Bring in options from restrict-template-expressions #6110

Closed
Labels
enhancement: plugin rule optionNew rule option for an existing eslint-plugin rulepackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugintriageWaiting for team members to take a look
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Before You File a Proposal Please Confirm You Have Done The Following...

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Link to the rule's documentation

https://typescript-eslint.io/rules/restrict-plus-operands

Description

restrict-plus-operands andrestrict-template-expressions don't tackle the exact same JavaScript behaviors (+ operands and template expressions don't concatenate/toString()/toValue() quite the same). But they both generally tackle the specific common case of code trying to join a string with a non-string:

''+0;''+{};// _roughly_ equivalent to:`${0}`;`${{}}`;

As a user, I've been inconvenienced byrestrict-plus-operands complaining on concatenating two primitive values: e.g.number andstring. Sometimes I want to be able to join primitives together in my logs!

Proposal: can we add the following options that already exist inrestrict-template-expressions?

Fail

''+{}

Pass

''+0

Additional Info

I think we've seen a bigger demand for them inrestrict-template-expressions because ofhttps://eslint.org/docs/latest/rules/prefer-template. Linted projects don't concatenate strings with+ as much as they used to.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement: plugin rule optionNew rule option for an existing eslint-plugin rulepackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugintriageWaiting for team members to take a look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp