eslint-plugin-sonarjs [](https://badge.fury.io/js/eslint-plugin-sonarjs)

September 22, 2026 Β· View on GitHub

eslint-plugin-sonarjs is an ESLint plugin maintained by Sonar, designed to help developers write Clean Code. This plugin exposes to ESLint users all original JS/TS rules from SonarJS, an analyzer for JavaScript and TypeScript within the Sonar ecosystem. This plugin offers general-purpose rules for detecting code smells and bugs, as well as rules for other aspects of code quality, including testing, accessibility, and more. Additionally, it enhances code security by providing rules to report potential security vulnerabilities.

This ESLint plugin does not contain all the rules from the SonarQube JS/TS analyzer. Aside of the rules available here, SonarQube uses rules from other ESLint plugins (some used as they are, some others have been modified). We recommend installing those ESLint plugins and enabling those rules if you are looking for similar results to SonarQube using ESLint.

If you are a SonarQube Server or a SonarQube Cloud user, to lint your code locally, we suggest using the SonarQube for IDE extension (available for VSCode, JetBrains IDEs and Eclipse). You can connect SonarQube for IDE to your Server or Cloud project to synchronize rules configuration, issue statuses, etc.

Table of Contents

Changelog

Prerequisites

The prerequisites for using this plugin depend on the ESLint version you are using:

  • For ESLint 8, you need Node.js version >= 18.
  • For ESLint 9, you need Node.js version that complies with (^18.18.0 || ^20.9.0 || >=21).

Installation

First, ensure that your project is configured with ESLint. If it is not, please follow the ESLint instructions to set it up.

To install eslint-plugin-sonarjs, use the following npm command (or yarn equivalent):

npm install eslint-plugin-sonarjs --save-dev # locally
npm install eslint-plugin-sonarjs -g         # globally

Usage

The usage of eslint-plugin-sonarjs depends on the ESLint version used by your project.

For ESLint 9

This plugin provides a single configuration named recommended. This configuration enables most of the rules except for a few exceptions, and the rules are enabled with the error severity. You can enable the recommended configuration in your eslint.config.js file:

import sonarjs from 'eslint-plugin-sonarjs';

export default [sonarjs.configs.recommended];

If you don't use the recommended configuration, you need to declare the plugin manually in the plugins field. Enable or disable rules using the rules field:

import sonarjs from 'eslint-plugin-sonarjs';
export default [
  {
    plugins: { sonarjs },
    rules: {
      'sonarjs/no-implicit-dependencies': 'error',
    },
  },
];

For ESLint 8

We include a recommended-legacy configuration to be backward compatible with ESLint v8, equivalent to the recommended configuration for ESLint 9.

Add sonarjs to your .eslintrc file:

{
  "plugins": ["sonarjs"],
  "extends": ["plugin:sonarjs/recommended-legacy"]
}

You can enable some rules manually:

{
  "rules": {
    "sonarjs/cognitive-complexity": "error",
    "sonarjs/no-identical-expressions": "error"
  }
}

TypeScript ESLint parser

Several rules are designed for linting both JavaScript and TypeScript code, and some even rely on type checking through TypeScript. Therefore, you will need to install the @typescript-eslint/parser dependency and instruct ESLint to use this parser through the parserOptions property.

SonarQube for IDE

As an alternative to using this ESLint plugin, you can use SonarQube for IDE. SonarQube for IDE is an IDE extension that helps you detect and fix quality issues as you write code. It provides a broader set of rules compared to the ESLint plugin, improved versions of ESLint rules, and additional features that enhance your linting experience.

Feedback

If you have any questions, encounter any bugs, or have feature requests, please reach out to us through the Sonar Community Forum. Your messages will reach the maintainers of this GitHub repository.

Rules

πŸ’Ό Configurations enabled in.
βœ… Set in the recommended configuration.
πŸ”§ Automatically fixable by the --fix CLI option.
πŸ’‘ Manually fixable by editor suggestions.
πŸ’­ Requires type information.
❌ Deprecated.

NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β DescriptionπŸ’ΌπŸ”§πŸ’‘πŸ’­βŒ
anchor-precedenceAlternatives in regular expressions should be grouped when used with anchorsβœ…πŸ’­
argument-typeArguments to built-in functions should match documented typesβœ…πŸ’­
arguments-orderParameters should be passed in the correct orderβœ…πŸ’­
arguments-usage"arguments" should not be accessed directly
array-callback-without-returnCallbacks of array methods should have return statementsβœ…πŸ’­
array-constructorArray constructors should not be usedπŸ’‘
arrow-function-conventionBraces and parentheses should be used consistently with arrow functions
assertions-in-test-casesAssertions should be placed inside test cases or hooksβœ…
assertions-in-testsTests should include assertionsβœ…πŸ’­
async-test-assertionsAsync test assertions should be awaited or returnedβœ…
avoid-mutating-nested-properties-of-shallow-clonesNested properties of Lodash and Underscore.js clone results should not be mutatedβœ…πŸ’‘
aws-apigateway-public-apiAWS API Gateway should require authenticationβœ…
aws-ec2-rds-dms-publicPublic network access to cloud resources should be disabledβœ…
aws-ec2-unencrypted-ebs-volumeEBS volumes should be encryptedβœ…
aws-efs-unencryptedAmazon EFS file systems should be encryptedβœ…
aws-iam-all-privilegesPolicies should not grant all privilegesβœ…
aws-iam-all-resources-accessibleIAM policies should not grant access to all account resources
aws-iam-privilege-escalationAWS IAM policies should limit the scope of permissions givenβœ…
aws-iam-public-accessAWS resource-based policies should not grant public accessβœ…
aws-opensearchservice-domainOpenSearch domains should have encryption at rest enabledβœ…
aws-rds-unencrypted-databasesAmazon RDS resources should be encrypted at restβœ…
aws-restricted-ip-admin-accessAdministration services access should be restricted to specific IP addressesβœ…
aws-s3-bucket-granted-accessS3 buckets should not grant access to all users or authenticated usersβœ…
aws-s3-bucket-insecure-httpS3 buckets should enforce HTTPS-only accessβœ…
aws-s3-bucket-public-accessAmazon S3 bucket public access should be fully blockedβœ…
aws-s3-bucket-versioningAmazon S3 buckets should have versioning enabledβœ…
aws-sagemaker-unencrypted-notebookSageMaker notebook instances should be encrypted at restβœ…
aws-sns-unencrypted-topicsAmazon SNS topics should be encrypted at restβœ…
aws-sqs-unencrypted-queueSQS queues should be encryptedβœ…
bitwise-operatorsBitwise operators should not be used in boolean contextsβœ…πŸ’­
block-scoped-varVariables should be used in the blocks where they are declaredβœ…
bool-param-defaultOptional boolean parameters should have default value
call-argument-lineFunction call arguments should not start on new linesβœ…
chai-determinate-assertionChai assertions should have only one reason to succeedβœ…
class-nameClass names should comply with a naming conventionβœ…
class-prototypeClass methods should be used instead of "prototype" assignmentsπŸ’­
code-evalDynamic code execution should not use user-controlled dataβœ…
cognitive-complexityCognitive Complexity of functions should not be too highβœ…
comma-or-logical-or-caseComma and logical OR operators should not be used in switch casesβœ…
comment-regexTrack comments matching a regular expression
composite-assertionsComposite assertions should be split
concise-regexRegular expression quantifiers and character classes should be used conciselyβœ…πŸ’­
conditional-indentationA conditionally executed single line should be denoted by indentation❌
confidential-information-loggingConfidential information should not be logged❌
constructor-for-side-effectsObjects should not be created to be dropped immediately without being usedβœ…
content-lengthHTTP request content length should be limitedβœ…
content-security-policyContent security policy fetch directives should not be disabledβœ…
cookie-no-httponlyCookies should have the "HttpOnly" flagβœ…
corsCross-Origin Resource Sharing (CORS) policy should be restricted to trusted originsβœ…
csrfCSRF protections should not be disabledβœ…
cyclomatic-complexityCyclomatic Complexity of functions should not be too high
declarations-in-global-scopeVariables and functions should not be declared in the global scope
deprecationDeprecated APIs should not be usedβœ…πŸ’­
destructuring-assignment-syntaxDestructuring syntax should be used for assignments
different-types-comparisonStrict equality operators should not be used with dissimilar typesβœ…πŸ’‘πŸ’­
disabled-auto-escapingAuto-escaping in HTML template engines should not be disabledβœ…πŸ’­
disabled-resource-integrityRemote artifacts should not be used without integrity checksβœ…πŸ’­
disabled-timeoutDisabling Mocha timeouts should be explicitβœ…
dompurify-unsafe-configDOMPurify configuration should not be bypassableβœ…πŸ’­
duplicates-in-character-classCharacter classes in regular expressions should not contain the same character twiceβœ…πŸ’­
dynamically-constructed-templatesTemplates should not be constructed dynamicallyβœ…
elseif-without-else"if ... else if" constructs should end with "else" clauses
empty-string-repetitionRepeated patterns in regular expressions should not match the empty stringβœ…πŸ’­
encryption-secure-modeEncryption algorithms should be used with secure mode and padding schemeβœ…
existing-groupsReplacement strings should reference existing regular expression groupsβœ…πŸ’­
explicit-test-skipTests should be skipped explicitlyβœ…πŸ’‘
expression-complexityExpressions should not be too complex
file-headerTrack lack of copyright and license headers
file-name-differ-from-classDefault export names and file names should match
file-permissionsFile permissions should not be set to world-accessible valuesβœ…
file-uploadsFile uploads should be restrictedβœ…
fixme-tagTrack uses of "FIXME" tagsβœ…
for-in"for...in" loops should filter properties before acting on them
for-loop-increment-signA "for" loop update clause should move the counter in the right directionβœ…
frame-ancestorsContent Security Policy frame-ancestors directive should not be disabled❌
function-inside-loopFunctions should not be defined inside loopsβœ…
function-nameFunction and method names should comply with a naming convention
function-return-typeFunctions should always return the same typeβœ…πŸ’­
future-reserved-wordsFuture reserved words should not be used as identifiersβœ…
generator-without-yieldGenerators should explicitly "yield" a valueβœ…
hardcoded-secret-signaturesCredentials should not be hard-codedβœ…
hashingWeak hashing algorithms should not be usedβœ…
hidden-filesHidden files should not be served statically❌
hooks-before-test-casesLifecycle hooks should not be interleaved with test cases or nested suitesβœ…
in-operator-type-error"in" should not be used with primitive typesβœ…πŸ’­
inconsistent-function-callFunctions should be called consistently with or without "new"βœ…
index-of-compare-to-positive-number"indexOf" checks should not be for positive numbersβœ…πŸ’­
insecure-cookieCookies should have the "secure" flagβœ…
insecure-jwt-tokenJWT should be signed and verified with strong cipher algorithmsβœ…
inverted-assertion-argumentsAssertion arguments should be passed in the correct orderβœ…πŸ’‘
jsx-no-leaked-renderReact components should not render non-boolean condition valuesβœ…πŸ’‘πŸ’­
label-positionOnly "while", "do", "for" and "switch" statements should be labelledβœ…
link-with-target-blankOpened windows should not have access to the originating pageβœ…
max-linesFiles should not have too many lines of code
max-lines-per-functionFunctions should not have too many lines of code
max-switch-cases"switch" statements should not have too many "case" clausesβœ…
max-union-sizeUnion types should not have too many elements
memoize-cache-keyLodash and Underscore.js memoize calls on functions with multiple parameters should use an explicit cache key functionβœ…
misplaced-loop-counter"for" loop increment clauses should modify the loops' countersβœ…
nested-control-flowControl flow statements "if", "for", "while", "switch" and "try" should not be nested too deeply
new-operator-misuse"new" should only be used with functions and classesβœ…πŸ’­
no-all-duplicated-branchesAll branches in a conditional structure should not have exactly the same implementationβœ…
no-alphabetical-sort"Array.prototype.sort()" and "Array.prototype.toSorted()" should use a compare functionβœ…πŸ’‘πŸ’­
no-angular-bypass-sanitizationAngular built-in sanitization should not be disabledβœ…
no-array-delete"delete" should not be used on arraysβœ…πŸ’­
no-associative-arraysArray indexes should be numericβœ…πŸ’­
no-async-constructorConstructors should not contain asynchronous operationsβœ…πŸ’­
no-built-in-overrideBuilt-in objects should not be overridden
no-case-label-in-switch"switch" statements should not contain non-case labelsβœ…
no-clear-text-protocolsClear-text protocols should not be usedβœ…
no-code-after-doneTests should not execute any code after "done()" is calledβœ…
no-collapsible-ifMergeable "if" statements should be combined
no-collection-size-mischeckCollection size and array length comparisons should make senseβœ…πŸ’‘πŸ’­
no-commented-codeSections of code should not be commented outπŸ’‘
no-control-regexRegular expressions should not contain control charactersβœ…πŸ’­
no-dead-storeUnused assignments should be removedβœ…
no-debounce-throttle-in-renderLodash and Underscore.js debounced or throttled functions should not be recreated on every React renderβœ…
no-debug-commands-in-ui-testsUI test debug commands should not be committed to version controlβœ…πŸ”§
no-default-utility-importsDefault imports from modular utility libraries should not be usedβœ…
no-delete-var"delete" should be used only with object propertiesβœ…
no-duplicate-in-compositeUnion and intersection types should not include duplicated constituentsβœ…πŸ’‘
no-duplicate-parameterized-test-caseParameterized tests should not contain duplicate test casesβœ…πŸ”§
no-duplicate-stringString literals should not be duplicated
no-duplicate-test-titleTest titles should be unique within the same suiteβœ…
no-duplicated-branchesTwo branches in a conditional structure should not have exactly the same implementationβœ…
no-element-overwriteCollection elements should not be replaced unconditionallyβœ…
no-empty-after-reluctantReluctant quantifiers in regular expressions should be followed by an expression that can't match the empty stringβœ…πŸ’­
no-empty-alternativesAlternation in regular expressions should not contain empty alternativesβœ…πŸ’­
no-empty-character-classEmpty character classes should not be usedβœ…πŸ’­
no-empty-collectionEmpty collections should not be accessed or iteratedβœ…
no-empty-groupRegular expressions should not contain empty groupsβœ…πŸ’­
no-empty-parameterized-test-datasetParameterized tests should not have empty datasetsβœ…
no-empty-test-fileTest files should contain at least one test caseβœ…
no-empty-test-titleTest and suite titles should not be empty or whitespace-onlyβœ…
no-equals-in-for-terminationEquality operators should not be used in "for" loop termination conditionsβœ…
no-exclusive-testsExclusive tests should not be committed to version controlβœ…πŸ’‘
no-extra-argumentsFunction calls should not pass extra argumentsβœ…
no-fallthroughSwitch cases should end with an unconditional "break" statementβœ…
no-fixed-wait-in-testsFixed waits should not be used in testsβœ…
no-floating-point-equalityFloating point numbers should not be tested for equalityβœ…
no-for-in-iterable"for in" should not be used with iterablesπŸ’­
no-forced-browser-interactionForced browser interactions should not bypass actionability checksβœ…
no-function-declaration-in-blockFunction declarations should not be made within blocks
no-global-thisThe global "this" object should not be usedβœ…πŸ’‘
no-globals-shadowingSpecial identifiers should not be bound or assignedβœ…
no-gratuitous-expressionsBoolean expressions should not be gratuitousβœ…
no-hardcoded-ipIP addresses should not be hardcodedβœ…
no-hardcoded-passwordsCredentials should not be hard-codedβœ…
no-hardcoded-secretsSecrets should not be hard-codedβœ…
no-hook-setter-in-bodyReact's useState hook should not be used directly in the render function or body of a componentβœ…
no-identical-conditions"if/else if" chains and "switch" cases should not have the same conditionβœ…
no-identical-expressionsIdentical expressions should not be used on both sides of a binary operatorβœ…
no-identical-functionsFunctions should not have identical implementationsβœ…
no-ignored-exceptionsExceptions should not be ignoredβœ…
no-ignored-returnReturn values from functions without side effects should not be ignoredβœ…πŸ’­
no-implicit-dependenciesDependencies should be explicit
no-implicit-globalVariables should be declared explicitlyβœ…
no-in-misuse"in" should not be used on arraysβœ…πŸ’‘πŸ’­
no-incompatible-assertion-typesAssertions comparing incompatible types should not be madeβœ…πŸ’­
no-incomplete-assertionsAssertions should be completeβœ…
no-inconsistent-returnsFunctions should use "return" consistentlyπŸ’­
no-incorrect-string-concatStrings and non-strings should not be addedπŸ’­
no-internal-api-useUsers should not use internal APIsβœ…
no-interpolation-in-inline-snapshotsInline snapshots should not contain interpolationsβœ…
no-intrusive-permissionsSensitive permissions should not be requested unnecessarily❌
no-invalid-regexpRegular expressions should be syntactically validβœ…πŸ’­
no-invariant-returnsFunction returns should not be invariantβœ…
no-inverted-boolean-checkBoolean checks should not be invertedβœ…πŸ’‘
no-ip-forwardClient IP address should not be forwarded to proxies❌
no-labelsLabels should not be usedβœ…
no-literal-callLiterals should not be used as functionsβœ…
no-mime-sniffBrowsers should not be allowed to perform MIME type sniffingβœ…
no-misleading-array-reverseArray-mutating methods should not be used misleadinglyβœ…πŸ’‘πŸ’­
no-misleading-character-classUnicode Grapheme Clusters should be avoided inside regex character classesβœ…πŸ’‘πŸ’­
no-mixed-completion-styleTest and hook callbacks should use a single completion style
no-mixed-contentContent Security Policy should block mixed-content❌
no-mutate-reactive-state-in-updated-hookReactive state should not be unconditionally mutated inside Vue's "updated" lifecycle hookβœ…
no-nested-assignmentAssignments should not be made from within sub-expressionsβœ…
no-nested-conditionalTernary operators should not be nestedβœ…
no-nested-functionsFunctions should not be nested too deeplyβœ…
no-nested-incdecIncrement (++) and decrement (--) operators should not be used in a method call or mixed with other operators in an expression
no-nested-switch"switch" statements should not be nested
no-nested-template-literalsTemplate literals should not be nestedβœ…
no-networkidle-waitPlaywright "networkidle" waits should not be used
no-os-command-from-pathOS commands should not rely on PATH resolutionβœ…
no-parameter-reassignmentInitial values of parameters, caught exceptions, and loop variables should not be ignoredβœ…
no-primitive-wrappersWrapper objects should not be used for primitive typesβœ…πŸ’‘
no-redundant-assignmentsAssignments should not be redundantβœ…
no-redundant-booleanBoolean literals should not be used in comparisonsβœ…πŸ’‘
no-redundant-jumpJump statements should not be redundantβœ…πŸ’‘
no-redundant-optionalOptional property declarations should not use both '?' and 'undefined' syntaxβœ…πŸ’‘πŸ’­
no-redundant-parenthesesRedundant pairs of parentheses should be removedπŸ’‘βŒ
no-reference-errorVariables should be defined before being used
no-referrer-policyHTTP Referrer-Policy should not be set to an unsafe valueβœ…
no-regex-spacesRegular expressions should not contain multiple spacesβœ…πŸ’‘πŸ’­
no-require-or-define"import" should be used to include external codeπŸ’­
no-return-type-anyPrimitive return types should be usedπŸ’­
no-same-argument-assertAssertions should not be given twice the same argumentβœ…
no-same-line-conditionalConditionals should start on new linesβœ…πŸ’‘
no-selector-parameterMethods should not contain selector parametersβœ…πŸ’­
no-session-cookies-on-static-assetsStatic Assets should not serve session cookiesβœ…
no-skipped-testsTests should not be skipped without providing a reasonβœ…
no-small-switch"if" statements should be preferred over "switch" when simplerβœ…πŸ’­
no-sonar-commentsTrack uses of "NOSONAR" comments
no-tabTabulation characters should not be used❌
no-table-as-layoutHTML "<table>" should not be used for layout purposesβœ…
no-trivial-assertionsAssertions should not be trivially trueβœ…πŸ’‘
no-try-promisePromise rejections should not be caught by "try" blocksβœ…πŸ’­
no-undefined-argument"undefined" should not be passed as the value of optional parametersβœ…πŸ’‘πŸ’­
no-undefined-assignment"undefined" should not be assigned
no-unenclosed-multiline-blockMultiline blocks should be enclosed in curly bracesβœ…
no-uniq-keyJSX list components keys should match up between rendersβœ…
no-unsafe-unzipExpanding archive files should not be done without controlling resource consumption❌
no-unthrown-errorErrors should not be created without being thrownβœ…πŸ’‘
no-unused-collectionCollection contents should be usedβœ…
no-unused-function-argumentUnused function parameters should be removedπŸ’‘
no-unused-varsUnused local variables and functions should be removedβœ…
no-use-of-empty-return-valueThe return value of void functions should not be usedβœ…
no-useless-catch"catch" clauses should do more than rethrowβœ…
no-useless-incrementValues should not be uselessly incrementedβœ…
no-useless-intersectionType intersections should use meaningful typesβœ…πŸ’­
no-useless-react-setstateReact state setter function should not be called with its matching state variableβœ…
no-variable-usage-before-declarationVariables declared with "var" should be declared before they are used
no-vue-class-componentVue components should not use the deprecated "vue-class-component" or "vue-property-decorator" librariesβœ…
no-vue-mixinsVue components should not use mixinsβœ…
no-weak-cipherCipher algorithms should be robustβœ…
no-weak-keysCryptographic keys should be robustβœ…
no-wildcard-importWildcard imports should not be used
non-existent-operatorNon-existent operators '=+', '=-' and '=!' should not be usedβœ…πŸ’‘
non-number-in-arithmetic-expressionArithmetic operators should only have numbers as operandsπŸ’­
null-dereferenceProperties of variables with "null" or "undefined" values should not be accessedβœ…πŸ’­
object-alt-content"" tags should provide an alternative contentβœ…
operation-returning-nanArithmetic operations should not result in "NaN"πŸ’­
os-commandOS commands should not be executed using a shell interpreter❌
parameterized-testsSimilar tests should be grouped in a single Parameterized testβœ…
post-messageOrigins should be verified during cross-origin communicationsβœ…πŸ’­
prefer-cypress-shouldCypress assertions should be retryableβœ…πŸ’‘
prefer-default-last"default" clauses should be lastβœ…
prefer-immediate-returnLocal variables should not be declared and then immediately returned or thrownπŸ”§πŸ’­
prefer-native-axios-alternativeNative APIs should be preferred over Axios utility methodsβœ…πŸ’‘
prefer-native-jquery-alternativeNative APIs should be preferred over jQuery utility methodsβœ…
prefer-native-lodash-alternativeNative APIs should be preferred over Lodash and Underscore.js methodsβœ…
prefer-object-literalObject literal syntax should be used
prefer-promise-shorthandShorthand promises should be usedβœ…πŸ’‘
prefer-read-only-propsReact props should be read-onlyβœ…πŸ’‘πŸ’­
prefer-regexp-exec"RegExp.exec()" should be preferred over "String.match()"βœ…πŸ’‘πŸ’­
prefer-single-boolean-returnReturn of boolean expressions should not be wrapped into an "if-then-else" statementβœ…πŸ’‘
prefer-specific-assertionsThe most specific assertion should be usedβœ…πŸ’‘
prefer-type-guardType predicates should be usedβœ…πŸ’‘
prefer-whileA "while" loop should be used instead of a "for" loopβœ…πŸ”§
production-debugDebugging features should not be enabled in productionβœ…
pseudo-randomPseudorandom number generators (PRNGs) should not be used in security contextsβœ…
public-static-readonlyPublic "static" fields should be read-onlyβœ…πŸ’‘
publicly-writable-directoriesTemporary files should not be created in publicly writable directoriesβœ…
reduce-initial-value"Array.reduce()" calls should include an initial valueβœ…πŸ’­
redundant-type-aliasesRedundant type aliases should not be usedβœ…
regex-complexityRegular expressions should not be too complicatedβœ…πŸ’­
review-blockchain-mnemonicWallet phrases should not be hard-codedβœ…
session-regenerationA new session should be created during user authenticationβœ…
shorthand-property-groupingShorthand object properties should be grouped at the beginning or end of an object declaration
single-char-in-character-classesCharacter classes in regular expressions should not contain only one characterβœ…πŸ’­
single-character-alternationSingle-character alternations in regular expressions should be replaced with character classesβœ…πŸ’­
slow-regexRegular expressions should not cause catastrophic backtrackingβœ…πŸ’­
sql-queriesSQL queries should not be dynamically formattedβœ…πŸ’­
stable-testsTests should be stableβœ…
stateful-regexRegular expressions with the global flag should be used with cautionβœ…
strict-transport-securityHTTP Strict-Transport-Security policy should not be disabledβœ…
strings-comparisonComparison operators should not be used with stringsπŸ’­
super-linear-regexRegular expressions should not cause non-linear backtrackingβœ…
synchronous-exception-assertionsSynchronous exception assertions should receive synchronous callbacksβœ…πŸ’‘πŸ’­
synchronous-suite-callbackTests should not be registered asynchronously in suite callbacksβœ…πŸ’‘
table-headerTables should have headersβœ…
table-header-referenceTable cells should reference their headersβœ…
test-check-exceptionTests should check which exception is thrownβœ…
testing-library-prefer-query-by-disappearanceTesting Library disappearance waits should use non-throwing queriesβœ…πŸ”§
testing-library-query-assertionTesting Library queries should match presence assertionsβœ…πŸ”§
todo-tagTrack uses of "TODO" tagsβœ…
too-many-break-or-continue-in-loopLoops should not contain more than a single "break" or "continue" statement
unicode-aware-regexRegular expressions using Unicode character classes or property escapes should enable the unicode flagπŸ’­
unused-importUnnecessary imports should be removedβœ…πŸ’‘πŸ’­
unused-named-groupsNames of regular expressions named groups should be usedβœ…πŸ’­
unverified-certificateServer certificates should be verified during SSL/TLS connectionsβœ…
unverified-hostnameServer hostnames should be verified during SSL/TLS connectionsβœ…
updated-const-var"const" variables should not be reassignedβœ…
updated-loop-counterLoop counters should not be assigned within the loop bodyβœ…
use-type-aliasType aliases should be usedβœ…
useless-string-operationResults of operations on strings should not be ignoredπŸ’­βŒ
values-not-convertible-to-numbersValues not convertible to numbers should not be used in numeric comparisonsπŸ’­
variable-nameVariable, property and parameter names should comply with a naming convention
vitest-mock-at-module-scopevi.mock should be declared at module scopeβœ…
void-use"void" should not be usedβœ…πŸ’­
weak-sslWeak SSL/TLS protocols should not be usedβœ…
web-sql-databaseWeb SQL databases should not be usedπŸ’­βŒ
x-powered-byWeb application technologies should not disclose version informationβœ…
xml-parser-xxeXML parsers should not be vulnerable to XXE attacksβœ…

ESLint rules

SonarJS uses some rules are not shipped in this ESLint plugin to avoid duplication with already existing rules from ESLint core and third-party ESLint plugins. The following rules are used directly, without modifying the original behavior:

SonarJS rule IDRule implemented by
S103@stylistic/eslint-plugin/max-len
S106eslint/no-console
S108eslint/no-empty
S113@stylistic/eslint-plugin/eol-last
S121eslint/curly
S122@stylistic/eslint-plugin/max-statements-per-line
S139eslint/line-comment-position
S878eslint/no-sequences
S909eslint/no-continue
S1090jsx-a11y/iframe-has-title
S1117typescript-eslint/no-shadow
S1131@stylistic/eslint-plugin/no-trailing-spaces
S1199eslint/no-lone-blocks
S1314eslint/no-octal
S1321eslint/no-with
S1440eslint/eqeqeq
S1441@stylistic/eslint-plugin/quotes
S1442eslint/no-alert
S1516eslint/no-multi-str
S1525eslint/no-debugger
S1536eslint/no-dupe-args
S1537@stylistic/eslint-plugin/comma-dangle
S1539eslint/strict
S1656eslint/no-self-assign
S1751eslint/no-unreachable-loop
S1774eslint/no-ternary
S2427eslint/radix
S2432eslint/no-setter-return
S2685eslint/no-caller
S2966typescript-eslint/no-non-null-assertion
S3257typescript-eslint/no-inferrable-types
S3353eslint/prefer-const
S3523eslint/no-new-func
S3786eslint/no-template-curly-in-string
S3812eslint/no-unsafe-negation
S3834eslint/no-new-native-nonconstructor
S3863import/no-duplicates
S4124typescript-eslint/no-misused-new
S4125eslint/valid-typeof
S4136typescript-eslint/adjacent-overload-signatures
S4137typescript-eslint/consistent-type-assertions
S4140eslint/no-sparse-arrays
S4157typescript-eslint/no-unnecessary-type-arguments
S4204typescript-eslint/no-explicit-any
S4326eslint/no-return-await
S6325eslint/prefer-regex-literals
S6435react/require-render-return
S6438react/jsx-no-comment-textnodes
S6480react/jsx-no-bind
S6509eslint/no-extra-boolean-cast
S6522eslint/no-import-assign
S6523eslint/no-unsafe-optional-chaining
S6534eslint/no-loss-of-precision
S6550typescript-eslint/prefer-literal-enum-member
S6565typescript-eslint/prefer-return-this-type
S6568typescript-eslint/no-confusing-non-null-assertion
S6569typescript-eslint/no-unnecessary-type-constraint
S6578typescript-eslint/no-duplicate-enum-values
S6583typescript-eslint/no-mixed-enums
S6590typescript-eslint/prefer-as-const
S6635eslint/no-constructor-return
S6637eslint/no-extra-bind
S6638eslint/no-constant-binary-expression
S6644eslint/no-unneeded-ternary
S6645eslint/no-undef-init
S6650eslint/no-useless-rename
S6653eslint/prefer-object-has-own
S6654eslint/no-proto
S6657eslint/no-octal-escape
S6671typescript-eslint/prefer-promise-reject-errors
S6746react/no-direct-mutation-state
S6748react/no-children-prop
S6750react/no-render-return-value
S6756react/no-access-state-in-setstate
S6761react/no-danger-with-children
S6763react/no-redundant-should-component-update
S6766react/no-unescaped-entities
S6770react/jsx-pascal-case
S6772react/jsx-child-element-spacing
S6775react/default-props-match-prop-types
S6789react/no-is-mounted
S6790react/no-string-refs
S6793jsx-a11y/aria-proptypes
S6807jsx-a11y/role-has-required-aria-props
S6811jsx-a11y/role-supports-aria-props
S6821jsx-a11y/aria-role
S6822jsx-a11y/no-redundant-roles
S6823jsx-a11y/aria-activedescendant-has-tabindex
S6824jsx-a11y/aria-unsupported-elements
S6825jsx-a11y/no-aria-hidden-on-focusable
S6836eslint/no-case-declarations
S6840jsx-a11y/autocomplete-valid
S6841jsx-a11y/tabindex-no-positive
S6842jsx-a11y/no-noninteractive-element-to-interactive-role
S6843jsx-a11y/no-interactive-element-to-noninteractive-role
S6845jsx-a11y/no-noninteractive-tabindex
S6846jsx-a11y/no-access-key
S6847jsx-a11y/no-noninteractive-element-interactions
S6848jsx-a11y/no-static-element-interactions
S6850jsx-a11y/heading-has-content
S6851jsx-a11y/img-redundant-alt
S6852jsx-a11y/interactive-supports-focus
S6861import/no-mutable-exports
S7641@angular-eslint/contextual-lifecycle
S7647@angular-eslint/no-empty-lifecycle-method
S7648@angular-eslint/prefer-standalone
S7650@angular-eslint/no-inputs-metadata-property
S7651@angular-eslint/no-output-native
S7652@angular-eslint/no-output-on-prefix
S7653@angular-eslint/no-output-rename
S7654@angular-eslint/no-outputs-metadata-property
S7655@angular-eslint/use-lifecycle-interface
S7656@angular-eslint/use-pipe-transform-interface
S7718unicorn/catch-error-name
S7719unicorn/consistent-date-clone
S7720unicorn/consistent-empty-array-spread
S7721unicorn/consistent-function-scoping
S7724unicorn/no-abusive-eslint-disable
S7725unicorn/no-accessor-recursion
S7726unicorn/no-anonymous-default-export
S7730unicorn/no-await-expression-member
S7731unicorn/no-for-loop
S7732unicorn/no-instanceof-builtins
S7733unicorn/no-invalid-fetch-options
S7734unicorn/no-named-default
S7735unicorn/no-negated-condition
S7736unicorn/no-negation-in-equality-check
S7737unicorn/no-object-as-default-parameter
S7738unicorn/no-single-promise-in-promise-methods
S7740unicorn/no-this-assignment
S7741unicorn/no-typeof-undefined
S7742unicorn/no-unnecessary-polyfills
S7743unicorn/no-unreadable-iife
S7744unicorn/no-useless-fallback-in-spread
S7745unicorn/no-useless-length-check
S7746unicorn/no-useless-promise-resolve-reject
S7747unicorn/no-useless-spread
S7748unicorn/no-zero-fractions
S7749unicorn/numeric-separators-style
S7750unicorn/prefer-array-find
S7751unicorn/prefer-array-flat
S7752unicorn/prefer-array-flat-map
S7753unicorn/prefer-array-index-of
S7754unicorn/prefer-array-some
S7756unicorn/prefer-blob-reading-methods
S7757unicorn/prefer-class-fields
S7758unicorn/prefer-code-point
S7760unicorn/prefer-default-parameters
S7761unicorn/dom-node-dataset
S7762unicorn/prefer-dom-node-remove
S7764unicorn/prefer-global-this
S7765unicorn/prefer-includes
S7767unicorn/prefer-math-trunc
S7768unicorn/prefer-modern-dom-apis
S7769unicorn/prefer-modern-math-apis
S7771unicorn/prefer-negative-index
S7772unicorn/prefer-node-protocol
S7773unicorn/prefer-number-properties
S7774unicorn/prefer-prototype-methods
S7775unicorn/prefer-regexp-test
S7776unicorn/prefer-set-has
S7777unicorn/prefer-set-size
S7783unicorn/prefer-string-trim-start-end
S7786unicorn/prefer-type-error
S7787unicorn/require-module-specifiers
S8957vue/require-prop-types
S8962vue/require-typed-ref
S8981testing-library/no-global-regexp-flag-in-query

Improved ESLint rules

The following rules are used in SonarJS but not available in this ESLint plugin. These rules have been modified, so your experience using them in your ESLint configuration may differ from the results you may get using SonarQube.

SonarJS rule IDRules used in the SonarJS implementation
S107eslint/max-params
S109typescript-eslint/no-magic-numbers
S131typescript-eslint/switch-exhaustiveness-check
S905typescript-eslint/no-unused-expressions
S1068eslint/no-unused-private-class-members
S1077jsx-a11y/alt-text
S1082jsx-a11y/mouse-events-have-key-events
jsx-a11y/click-events-have-key-events
S1105@stylistic/eslint-plugin/brace-style
S1116@stylistic/eslint-plugin/no-extra-semi
S1143eslint/no-unsafe-finally
S1186typescript-eslint/no-empty-function
S1438@stylistic/eslint-plugin/semi
S1534eslint/no-dupe-keys
typescript-eslint/no-dupe-class-members
react/jsx-no-duplicate-props
vue/no-duplicate-attributes
S1763eslint/no-unreachable
S1788typescript-eslint/default-param-last
S2094typescript-eslint/no-extraneous-class
S2189eslint/no-unmodified-loop-condition
S2376eslint/accessor-pairs
S2430eslint/new-cap
S2688eslint/use-isnan
S2814typescript-eslint/no-redeclare
S2933typescript-eslint/prefer-readonly
S3498eslint/object-shorthand
S3504eslint/no-var
S3512eslint/prefer-template
S3696eslint/no-throw-literal
S3723@stylistic/eslint-plugin/comma-dangle
S3799eslint/no-empty-pattern
S3854eslint/constructor-super
eslint/no-this-before-super
S4023typescript-eslint/no-empty-interface
S4084jsx-a11y/media-has-caption
S4123typescript-eslint/await-thenable
S4138typescript-eslint/prefer-for-of
S4156typescript-eslint/prefer-namespace-keyword
S4275eslint/getter-return
S4325typescript-eslint/no-unnecessary-type-assertion
S4327typescript-eslint/no-this-alias
S5254jsx-a11y/lang
jsx-a11y/html-has-lang
S6440react-hooks/rules-of-hooks
S6441react/no-unused-class-component-methods
S6477react/jsx-key
S6478react/no-unstable-nested-components
S6479react/no-array-index-key
S6481react/jsx-no-constructed-context-values
S6535eslint/no-useless-escape
eslint/no-nonoctal-decimal-escape
S6544typescript-eslint/no-misused-promises
eslint/no-async-promise-executor
S6551typescript-eslint/no-base-to-string
S6557typescript-eslint/prefer-string-starts-ends-with
S6571typescript-eslint/no-redundant-type-constituents
S6572typescript-eslint/prefer-enum-initializers
S6582typescript-eslint/prefer-optional-chain
S6598typescript-eslint/prefer-function-type
S6606typescript-eslint/prefer-nullish-coalescing
S6643eslint/no-extend-native
S6647eslint/no-useless-constructor
S6660eslint/no-lonely-if
S6661eslint/prefer-object-spread
S6666eslint/prefer-spread
S6676eslint/no-useless-call
S6679eslint/no-self-compare
S6747react/no-unknown-property
jsx-a11y/aria-props
S6749react/jsx-no-useless-fragment
S6754react/hook-use-state
S6757react/no-this-in-sfc
S6767react/no-unused-prop-types
S6774react/prop-types
S6788react/no-find-dom-node
S6791react/no-unsafe
S6819jsx-a11y/prefer-tag-over-role
S6827jsx-a11y/anchor-has-content
S6844jsx-a11y/anchor-is-valid
S6853jsx-a11y/label-has-associated-control
S6859import/no-absolute-path
S6957react/no-deprecated
S7060import/no-self-import
S7503typescript-eslint/require-await
S7649@angular-eslint/no-input-rename
S7722unicorn/error-message
S7723unicorn/new-for-builtins
S7727unicorn/no-array-callback-reference
S7728unicorn/no-array-for-each
S7729unicorn/no-array-method-this-argument
S7739unicorn/no-thenable
S7755unicorn/prefer-at
S7759unicorn/prefer-date-now
S7763unicorn/prefer-export-from
S7766unicorn/prefer-math-min-max
S7770unicorn/prefer-native-coercion-functions
S7778unicorn/prefer-single-call
S7780unicorn/prefer-string-raw
S7781unicorn/prefer-string-replace-all
S7784unicorn/prefer-structured-clone
S7785unicorn/prefer-top-level-await
S8950vue/no-required-prop-with-default
S8951vue/no-mutating-props
S8961vue/require-explicit-emits
S8980testing-library/no-unnecessary-act
S8982vue/require-v-for-key
S8984vue/valid-v-for
S8985testing-library/no-wait-for-side-effects
S8987vue/no-use-v-if-with-v-for
S8988vue/no-side-effects-in-computed-properties
S8990testing-library/no-promise-in-fire-event
S9011react/button-has-type
vue/html-button-has-type
S9012testing-library/no-wait-for-snapshot
S9019vue/no-ref-as-operand
S9020testing-library/prefer-find-by
S9025vue/no-async-in-computed-properties
S9026testing-library/await-async-queries
S9107vue/require-prop-type-constructor
S9115testing-library/await-async-events
S9128vue/no-dupe-keys
S9333testing-library/no-await-sync-queries
S9379jsx-a11y/no-autofocus
S9380jsx-a11y/scope
S9381promise/no-nesting
S9382eslint/no-await-in-loop
S9383typescript-eslint/no-floating-promises