Skip to content

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.

RuleSettingFilesWhat it checksWhy
no-multi-strinfoJS + TSDisallow multiline strings—
no-nonoctal-decimal-escapeerrorJS + TSDisallow \8 and \9 escape sequences in string literals—
no-octal-escapeerrorJS + TSDisallow octal escape sequences in string literals—
no-useless-escapeinfoJS + TSDisallow unnecessary escape characters—
prefer-templateerrorJS + TSRequire template literals instead of string concatenation—
unicode-bomoffJS + TSRequire or disallow Unicode byte order mark (BOM)Off: formatting is Prettier's job.
sonarjs/no-duplicate-stringoffJS + TSString literals should not be duplicatedOff: not in the Sonar way profile of SonarQube.
sonarjs/useless-string-operationoffJS + TSResults of operations on strings should not be ignoredOff: not in the Sonar way profile of SonarQube.
sonarjs/dynamically-constructed-templateserrorJS + TSTemplates should not be constructed dynamically—
sonarjs/empty-string-repetitionerrorJS + TSRepeated patterns in regular expressions should not match the empty string—
sonarjs/no-nested-template-literalswarnJS + TSTemplate literals should not be nested—
sonarjs/single-character-alternationwarnJS + TSSingle-character alternations in regular expressions should be replaced with character classes—
no-octal-escapeoffTSDisallow octal escape sequences in string literals—
@typescript-eslint/no-base-to-stringerrorTSRequire .toString() and .toLocaleString() to only be called on objects which provide useful information when stringified—
@typescript-eslint/no-unnecessary-template-expressionerrorTSDisallow unnecessary template expressions—
@typescript-eslint/prefer-string-starts-ends-witherrorTSEnforce using String#startsWith and String#endsWith over other equivalent methods of checking substrings—
@typescript-eslint/restrict-template-expressionserrorTSEnforce template literal expressions to be of string type—

Generated from the JSDoc of the sources.