progre/tslint-config-airbnb

[tslint] " should be ' (quotemark) for string that contains '

dbkaplun opened this issue · 1 comments

Here's a test case:

"This sentence's apostrophe causes a linting error."

There are a few things wrong with regard to quotemarks. Currently the rule does not follow:

6.1 Use single quotes '' for strings. eslint: quotes

// bad
const name = "Capt. Janeway";

 // bad - template literals should contain interpolation or newlines
 const name = `Capt. Janeway`;

 // good
 const name = 'Capt. Janeway';

6.3 When programmatically building up strings, use template strings instead of concatenation. eslint: prefer-template template-curly-spacing

6.5 Do not unnecessarily escape characters in strings. eslint: no-useless-escape

From React style guide:

Always use double quotes (") for JSX attributes, but single quotes (') for all other JS. eslint: jsx-quotes


Proposed changes to make this match:

  1. Change quotemark rule to use arguments [true, "single", "avoid-escape", "avoid-template", "jsx-double"]

  2. Add prefer-template rule.

I'll send a PR for this.