Skip to content

Disable backtick quotes if it is not a template #838

@ghost

Description

Now you could write either

let a = 'hello'

or

let a = `hello`

And it would pass standard linter for both cases, even if in the second case the template doesn't have any interpolated variables and in fact is just a different form of a string. So you could mix both forms, something conceptually similar to mixing " and ' quotes.

ESLint allows us to prevent this behavior by adding a rule

"quotes": [2, "single"]

This rule makes ESLint to throw an error for this

let a = `hello`

but don't throw any errors for this

let subject = 'world'
let a = `hello, ${world}`

Also see this issue in ESLint.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions