Skip to content

Docs: restrict-plus-operands example is wrong for the default configuration #7297

@lgenzelis

Description

@lgenzelis

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

restrict-plus-operands docs starts by giving these incorrect examples:

let foo = '5.5' + 5;

I remember that was once the case, and I don't know when it changed, but now that's not an error anymore. The default configuration is:

const defaultOptions: Options = [
  {
    allowAny: true,
    allowBoolean: true,
    allowNullish: true,
    allowNumberAndString: true,
    allowRegExp: true,
    skipCompoundAssignments: false,
  },
];

Since we have allowNumberAndString: true, it's ok to do '5.5' + 5. It can be verified in the playground.

Affected URL(s)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuedocumentationDocumentation ("docs") that needs adding/updatinggood first issueGood for newcomerslocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions