eslint/rules/strings
Strings: String methods, templates, quotes and character handling. Rules of ESLint, typescript-eslint and SonarJS (the Sonar way profile of SonarQube) on this subject, every rule listed; the TypeScript rules apply to TypeScript files only.
17 rules, 13 on. Source: lint/eslint/rules/strings.mjs.
| Rule | Setting | Files | What it checks | Why |
|---|---|---|---|---|
no-multi-str | info | JS + TS | Disallow multiline strings | — |
no-nonoctal-decimal-escape | error | JS + TS | Disallow \8 and \9 escape sequences in string literals | — |
no-octal-escape | error | JS + TS | Disallow octal escape sequences in string literals | — |
no-useless-escape | info | JS + TS | Disallow unnecessary escape characters | — |
prefer-template | error | JS + TS | Require template literals instead of string concatenation | — |
unicode-bom | off | JS + TS | Require or disallow Unicode byte order mark (BOM) | Off: formatting is Prettier's job. |
sonarjs/no-duplicate-string | off | JS + TS | String literals should not be duplicated | Off: not in the Sonar way profile of SonarQube. |
sonarjs/useless-string-operation | off | JS + TS | Results of operations on strings should not be ignored | Off: not in the Sonar way profile of SonarQube. |
sonarjs/dynamically-constructed-templates | error | JS + TS | Templates should not be constructed dynamically | — |
sonarjs/empty-string-repetition | error | JS + TS | Repeated patterns in regular expressions should not match the empty string | — |
sonarjs/no-nested-template-literals | warn | JS + TS | Template literals should not be nested | — |
sonarjs/single-character-alternation | warn | JS + TS | Single-character alternations in regular expressions should be replaced with character classes | — |
no-octal-escape | off | TS | Disallow octal escape sequences in string literals | — |
@typescript-eslint/no-base-to-string | error | TS | Require .toString() and .toLocaleString() to only be called on objects which provide useful information when stringified | — |
@typescript-eslint/no-unnecessary-template-expression | error | TS | Disallow unnecessary template expressions | — |
@typescript-eslint/prefer-string-starts-ends-with | error | TS | Enforce using String#startsWith and String#endsWith over other equivalent methods of checking substrings | — |
@typescript-eslint/restrict-template-expressions | error | TS | Enforce template literal expressions to be of string type | — |