Skip to content

Missing converter(s): SonarTS #1083

Closed
@Res42

Description

@Res42

Hi!

Just migrated from TSLint to ESLint and I saw that there is no support for tslint-sonarts to eslint-plugin-sonarjs migration.

I want to share a document for the conversions since I already have it and I didn't find any migration documents in the Sonar repos.

Empty row means I didn't find an equivalent new rule.

💥 Missing Converter

  • tslint-to-eslint-config version: 2.4.2
  • typescript-eslint version: 4.24.0

Package Source

NPM: tslint-sonarts
GitHub: tslint-sonarts (Watch out, the default branch is empty, you need to view the latest tag!)

New ESLint Sonar plugin:
NPM: eslint-plugin-sonarjs
GitHub: eslint-plugin-sonarjs

Rules

TSLint rule TSLint config ESLint rule ESLint config Comment
arguments-order boolean
bool-param-default boolean
cognitive-complexity [boolean, number]
Default is 15.
sonarjs/cognitive-complexity [string, number]
Default is 15.
consecutive-overloads boolean @typescript-eslint/adjacent-overload-signatures string
max-switch-cases [boolean, number]
Default is 30.
sonarjs/max-switch-cases [string, number]
Default is 30.
max-union-size [boolean, number]
Default is 3.
mccabe-complexity [boolean, number]
Default is 10.
no-accessor-field-mismatch boolean
no-all-duplicated-branches boolean sonarjs/no-all-duplicated-branches string
no-alphabetical-sort boolean
no-array-delete boolean
no-big-function [boolean, number]
Default is 200.
max-lines-per-function [string, { max: number }] or [string, number]
Default is 50.
no-case-with-or boolean
no-collapsible-if boolean sonarjs/no-collapsible-if string
no-collection-size-mischeck boolean sonarjs/no-collection-size-mischeck string
no-commented-code boolean
no-dead-store boolean
no-duplicate-in-composite boolean
no-duplicate-string [boolean, number]
Default is 3.
sonarjs/no-duplicate-string [string, number]
Default is 3.
no-duplicated-branches boolean sonarjs/no-duplicated-branches string
no-element-overwrite boolean sonarjs/no-element-overwrite string
no-empty-array boolean
no-empty-destructuring boolean no-empty-pattern string
no-empty-nested-blocks boolean no-empty [string, { allowEmptyCatch: boolean }] Sonar logic is { allowEmptyCatch: true }.
no-extra-semicolon boolean no-extra-semi
---
@typescript-eslint/no-extra-semi
"off"
---
string
no-gratuitous-expressions boolean
no-hardcoded-credentials [boolean, ...string[]] Default list is "password","pwd","passwd".
no-identical-conditions boolean sonarjs/no-identical-conditions string
no-identical-expressions boolean sonarjs/no-identical-expressions string
no-identical-functions boolean sonarjs/no-identical-functions string
no-ignored-initial-value boolean
no-ignored-return boolean
no-in-misuse boolean @typescript-eslint/no-for-in-array string
no-inconsistent-return boolean
no-invalid-await boolean @typescript-eslint/await-thenable string
no-invariant-return boolean
no-inverted-boolean-check boolean sonarjs/no-inverted-boolean-check string
no-misleading-array-reverse boolean
no-misspelled-operator boolean
no-multiline-string-literals boolean no-multi-str string
no-nested-incdec boolean
no-nested-switch boolean
no-nested-template-literals boolean
no-redundant-boolean boolean sonarjs/no-redundant-boolean string
no-redundant-jump boolean sonarjs/no-redundant-jump string
no-redundant-parentheses boolean no-extra-parens string
no-return-type-any boolean ⚠️ @typescript-eslint/no-unsafe-return ⚠️ string Not exactly the same rule! But very similar. See #1085 (comment)
no-same-line-conditional boolean sonarjs/no-same-line-conditional string
no-self-assignment boolean no-self-assign string
no-small-switch boolean sonarjs/no-small-switch string
no-statements-same-line boolean
no-try-promise boolean
no-unconditional-jump boolean sonarjs/no-one-iteration-loop string
no-undefined-argument boolean
no-unenclosed-multiline-block boolean
no-unthrown-error boolean
no-unused-array boolean sonarjs/no-unused-collection string
no-use-of-empty-return-value boolean sonarjs/no-use-of-empty-return-value string
no-useless-cast boolean @typescript-eslint/no-unnecessary-type-assertion [string, { typesToIgnore: string[] }] Don't need to use the second, optional parameter.
no-useless-catch boolean sonarjs/no-useless-catch string
no-useless-increment boolean
no-useless-intersection boolean
no-variable-usage-before-declaration boolean no-use-before-define
---
@typescript-eslint/no-use-before-define
[string, { functions?: boolean, classes?: boolean, variables?: boolean }]
---
[string, { functions?: boolean, classes?: boolean, variables?: boolean, enums?: boolean, typedefs?: boolean, ignoreTypeReferences?: boolean }]
The original rule (no-use-before-define) should be "off".

Second argument should be at least { "variables": true }.
parameters-max-number [boolean, number]
Default is 7.
max-params [string, { max: number }] or [string, number]
Default is 3.
prefer-default-last boolean default-case-last string
prefer-immediate-return boolean sonarjs/prefer-immediate-return string
prefer-optional boolean
prefer-promise-shorthand boolean
prefer-type-guard boolean
use-primitive-type boolean no-new-wrappers
---
@typescript-eslint/ban-types
string
---
[string, Options]
Need to use both rules.
---
Complex config but the default options is good.
Or at least the options for String, Boolean, and Number
use-type-alias boolean

New rules; don't care about them in this issue, but for the sake of completeness:

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomers; welcome aboard!status: accepting prsPlease, send in a PR to resolve this! ✨

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions