0

I'm setting up ESLint for a new Next.js TypeScript project in VS Code and find that I cannot configure the @typescript-eslint/quotes rule to enforce double-quotes rather than single-quotes.

For non-Typescript ESLint I'd just use:

"quotes": ["error", "double", { "allowTemplateLiterals": true }],

Checking the @typescript-eslint/quotes page doesn't really describe how to config any options, and applying the same formatting as the non-TypeScript:

"@typescript-eslint/quotes": [
  "error",
  "double",
  {
    "allowTemplateLiterals": true
  }
],

shows the error Array has too many items. Expected 2 or fewer..

Removing the third arg:

"@typescript-eslint/quotes": [
  "error",
  "double"
],

gives me the error Incorrect type. Expected "object" on the "double" arg. It seems to just want error/off/warn for the first arg and an object for the second, but I can't find any docs on how to do that to mark single quotes with an error.

For now I've disabled the TypeScript rule and enabled the normal ESLint version, but is the @typescript-eslint/quotes rule not configurable for double-quotes?

1
  • Suggestion: Use a formatter and disable formatting linter rules. For example prettier.io plus github.com/prettier/eslint-config-prettier . You can enforce that the formatter was run (--check flag for Prettier), but this way people don't have to manually correct linter errors around styles (eslint --fix can fix some but not all).
    – TrueWill
    Commented Jul 2 at 22:56

0

Browse other questions tagged or ask your own question.