From 694223a83e124034b48def97f709b3b708eaa0ec Mon Sep 17 00:00:00 2001 From: Shinigami Date: Mon, 2 Jan 2023 13:43:11 +0100 Subject: [PATCH] feat: add `eslint-plugin-sonarjs` (#161) Co-authored-by: Julien --- package.json | 1 + pnpm-lock.yaml | 11 +++ .../generate-rule-files/src/plugins-map.ts | 6 ++ src/config/extends/eslint-plugin-sonarjs.d.ts | 6 ++ src/config/extends/index.d.ts | 2 + src/config/plugin.d.ts | 1 + src/rules/index.d.ts | 2 + src/rules/sonarjs/cognitive-complexity.d.ts | 41 +++++++++++ src/rules/sonarjs/elseif-without-else.d.ts | 22 ++++++ src/rules/sonarjs/index.d.ts | 68 +++++++++++++++++++ src/rules/sonarjs/max-switch-cases.d.ts | 32 +++++++++ .../sonarjs/no-all-duplicated-branches.d.ts | 22 ++++++ src/rules/sonarjs/no-collapsible-if.d.ts | 32 +++++++++ .../sonarjs/no-collection-size-mischeck.d.ts | 22 ++++++ src/rules/sonarjs/no-duplicate-string.d.ts | 40 +++++++++++ src/rules/sonarjs/no-duplicated-branches.d.ts | 33 +++++++++ src/rules/sonarjs/no-element-overwrite.d.ts | 33 +++++++++ src/rules/sonarjs/no-empty-collection.d.ts | 22 ++++++ src/rules/sonarjs/no-extra-arguments.d.ts | 32 +++++++++ .../sonarjs/no-gratuitous-expressions.d.ts | 33 +++++++++ .../sonarjs/no-identical-conditions.d.ts | 33 +++++++++ .../sonarjs/no-identical-expressions.d.ts | 33 +++++++++ src/rules/sonarjs/no-identical-functions.d.ts | 41 +++++++++++ src/rules/sonarjs/no-ignored-return.d.ts | 22 ++++++ .../sonarjs/no-inverted-boolean-check.d.ts | 22 ++++++ src/rules/sonarjs/no-nested-switch.d.ts | 22 ++++++ .../sonarjs/no-nested-template-literals.d.ts | 22 ++++++ src/rules/sonarjs/no-one-iteration-loop.d.ts | 22 ++++++ src/rules/sonarjs/no-redundant-boolean.d.ts | 22 ++++++ src/rules/sonarjs/no-redundant-jump.d.ts | 22 ++++++ .../sonarjs/no-same-line-conditional.d.ts | 33 +++++++++ src/rules/sonarjs/no-small-switch.d.ts | 22 ++++++ src/rules/sonarjs/no-unused-collection.d.ts | 22 ++++++ .../sonarjs/no-use-of-empty-return-value.d.ts | 22 ++++++ src/rules/sonarjs/no-useless-catch.d.ts | 22 ++++++ src/rules/sonarjs/non-existent-operator.d.ts | 22 ++++++ .../sonarjs/prefer-immediate-return.d.ts | 22 ++++++ src/rules/sonarjs/prefer-object-literal.d.ts | 22 ++++++ .../sonarjs/prefer-single-boolean-return.d.ts | 22 ++++++ src/rules/sonarjs/prefer-while.d.ts | 22 ++++++ 40 files changed, 953 insertions(+) create mode 100644 src/config/extends/eslint-plugin-sonarjs.d.ts create mode 100644 src/rules/sonarjs/cognitive-complexity.d.ts create mode 100644 src/rules/sonarjs/elseif-without-else.d.ts create mode 100644 src/rules/sonarjs/index.d.ts create mode 100644 src/rules/sonarjs/max-switch-cases.d.ts create mode 100644 src/rules/sonarjs/no-all-duplicated-branches.d.ts create mode 100644 src/rules/sonarjs/no-collapsible-if.d.ts create mode 100644 src/rules/sonarjs/no-collection-size-mischeck.d.ts create mode 100644 src/rules/sonarjs/no-duplicate-string.d.ts create mode 100644 src/rules/sonarjs/no-duplicated-branches.d.ts create mode 100644 src/rules/sonarjs/no-element-overwrite.d.ts create mode 100644 src/rules/sonarjs/no-empty-collection.d.ts create mode 100644 src/rules/sonarjs/no-extra-arguments.d.ts create mode 100644 src/rules/sonarjs/no-gratuitous-expressions.d.ts create mode 100644 src/rules/sonarjs/no-identical-conditions.d.ts create mode 100644 src/rules/sonarjs/no-identical-expressions.d.ts create mode 100644 src/rules/sonarjs/no-identical-functions.d.ts create mode 100644 src/rules/sonarjs/no-ignored-return.d.ts create mode 100644 src/rules/sonarjs/no-inverted-boolean-check.d.ts create mode 100644 src/rules/sonarjs/no-nested-switch.d.ts create mode 100644 src/rules/sonarjs/no-nested-template-literals.d.ts create mode 100644 src/rules/sonarjs/no-one-iteration-loop.d.ts create mode 100644 src/rules/sonarjs/no-redundant-boolean.d.ts create mode 100644 src/rules/sonarjs/no-redundant-jump.d.ts create mode 100644 src/rules/sonarjs/no-same-line-conditional.d.ts create mode 100644 src/rules/sonarjs/no-small-switch.d.ts create mode 100644 src/rules/sonarjs/no-unused-collection.d.ts create mode 100644 src/rules/sonarjs/no-use-of-empty-return-value.d.ts create mode 100644 src/rules/sonarjs/no-useless-catch.d.ts create mode 100644 src/rules/sonarjs/non-existent-operator.d.ts create mode 100644 src/rules/sonarjs/prefer-immediate-return.d.ts create mode 100644 src/rules/sonarjs/prefer-object-literal.d.ts create mode 100644 src/rules/sonarjs/prefer-single-boolean-return.d.ts create mode 100644 src/rules/sonarjs/prefer-while.d.ts diff --git a/package.json b/package.json index 80c37d8d..3f029039 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "eslint-plugin-n": "~15.6.0", "eslint-plugin-node": "~11.1.0", "eslint-plugin-prettier": "~4.2.1", + "eslint-plugin-sonarjs": "~0.17.0", "eslint-plugin-spellcheck": "~0.0.20", "eslint-plugin-unicorn": "~45.0.2", "eslint-plugin-vue": "~9.8.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5dd05b3d..312a69f8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,6 +22,7 @@ specifiers: eslint-plugin-n: ~15.6.0 eslint-plugin-node: ~11.1.0 eslint-plugin-prettier: ~4.2.1 + eslint-plugin-sonarjs: ~0.17.0 eslint-plugin-spellcheck: ~0.0.20 eslint-plugin-unicorn: ~45.0.2 eslint-plugin-vue: ~9.8.0 @@ -60,6 +61,7 @@ devDependencies: eslint-plugin-n: 15.6.0_eslint@8.31.0 eslint-plugin-node: 11.1.0_eslint@8.31.0 eslint-plugin-prettier: 4.2.1_xtjuwoibeoaqavcvkna3ocxxbu + eslint-plugin-sonarjs: 0.17.0_eslint@8.31.0 eslint-plugin-spellcheck: 0.0.20_eslint@8.31.0 eslint-plugin-unicorn: 45.0.2_eslint@8.31.0 eslint-plugin-vue: 9.8.0_eslint@8.31.0 @@ -1896,6 +1898,15 @@ packages: prettier-linter-helpers: 1.0.0 dev: true + /eslint-plugin-sonarjs/0.17.0_eslint@8.31.0: + resolution: {integrity: sha512-jtGtxI49UbJJeJj7CVRLI3+LLH+y+hkR3GOOwM7vBbci9DEFIRGCWvEd2BJScrzltZ6D6iubukTAfc9cyG7sdw==} + engines: {node: '>=14'} + peerDependencies: + eslint: ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 + dependencies: + eslint: 8.31.0 + dev: true + /eslint-plugin-spellcheck/0.0.20_eslint@8.31.0: resolution: {integrity: sha512-GJa6vgzWAYqe0elKADAsiBRrhvqBnKyt7tpFSqlCZJsK2W9+K80oMyHhKolA7vJ13H5RCGs5/KCN+mKUyKoAiA==} peerDependencies: diff --git a/scripts/generate-rule-files/src/plugins-map.ts b/scripts/generate-rule-files/src/plugins-map.ts index ff788854..1db34408 100644 --- a/scripts/generate-rule-files/src/plugins-map.ts +++ b/scripts/generate-rule-files/src/plugins-map.ts @@ -10,6 +10,7 @@ import * as eslintPluginMdx from 'eslint-plugin-mdx'; import eslintPluginNode from 'eslint-plugin-node'; // @ts-expect-error import eslintPluginN from 'eslint-plugin-n'; +import * as eslintPluginSonarJS from 'eslint-plugin-sonarjs'; // @ts-expect-error import eslintPluginSpellcheck from 'eslint-plugin-spellcheck'; // @ts-expect-error @@ -71,6 +72,11 @@ export const PLUGIN_REGISTRY: Readonly> = { name: 'Node', rules: (eslintPluginNode as Plugin).rules, }, + sonarjs: { + name: 'SonarJS', + prefix: 'sonarjs', + rules: eslintPluginSonarJS.rules, + }, spellcheck: { name: 'Spellcheck', rules: (eslintPluginSpellcheck as Plugin).rules, diff --git a/src/config/extends/eslint-plugin-sonarjs.d.ts b/src/config/extends/eslint-plugin-sonarjs.d.ts new file mode 100644 index 00000000..6456feac --- /dev/null +++ b/src/config/extends/eslint-plugin-sonarjs.d.ts @@ -0,0 +1,6 @@ +/** + * Eslint Sonarjs extensions. + * + * @see [Eslint Sonarjs extensions](https://github.com/SonarSource/eslint-plugin-sonarjs#available-configurations) + */ +export type SonarjsExtensions = 'plugin:sonarjs/recommended'; diff --git a/src/config/extends/index.d.ts b/src/config/extends/index.d.ts index d6ab38c8..9daf4c5f 100644 --- a/src/config/extends/index.d.ts +++ b/src/config/extends/index.d.ts @@ -7,6 +7,7 @@ import type { MdxExtensions } from './eslint-plugin-mdx'; import type { NExtensions } from './eslint-plugin-n'; import type { NodeExtensions } from './eslint-plugin-node'; import type { PrettierExtensions } from './eslint-plugin-prettier'; +import type { SonarjsExtensions } from './eslint-plugin-sonarjs'; import type { UnicornExtensions } from './eslint-plugin-unicorn'; import type { VueExtensions } from './eslint-plugin-vue'; import type { VuePugExtensions } from './eslint-plugin-vue-pug'; @@ -26,6 +27,7 @@ export type KnownExtensions = LiteralUnion< | NExtensions | NodeExtensions | PrettierExtensions + | SonarjsExtensions | TypescriptEslintExtensions | UnicornExtensions | VueExtensions diff --git a/src/config/plugin.d.ts b/src/config/plugin.d.ts index e4920c20..c76631f3 100644 --- a/src/config/plugin.d.ts +++ b/src/config/plugin.d.ts @@ -9,6 +9,7 @@ export type Plugin = LiteralUnion< | 'jsdoc' | 'mdx' | 'prettier' + | 'sonarjs' | 'spellcheck' | 'unicorn' | 'vue' diff --git a/src/rules/index.d.ts b/src/rules/index.d.ts index 2edc7e56..99e8769d 100644 --- a/src/rules/index.d.ts +++ b/src/rules/index.d.ts @@ -6,6 +6,7 @@ import type { JsoncRules } from './jsonc'; import type { NRules } from './n'; import type { NodeRules } from './node'; import type { RuleConfig } from './rule-config'; +import type { SonarJSRules } from './sonarjs'; import type { SpellcheckRules } from './spellcheck'; import type { TypeScriptRules } from './typescript-eslint'; import type { UnicornRules } from './unicorn'; @@ -26,6 +27,7 @@ export type Rules = Partial< JsoncRules & NodeRules & NRules & + SonarJSRules & SpellcheckRules & TypeScriptRules & UnicornRules & diff --git a/src/rules/sonarjs/cognitive-complexity.d.ts b/src/rules/sonarjs/cognitive-complexity.d.ts new file mode 100644 index 00000000..8e762320 --- /dev/null +++ b/src/rules/sonarjs/cognitive-complexity.d.ts @@ -0,0 +1,41 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Config. + */ +export type CognitiveComplexityConfig = 'sonar-runtime' | 'metric'; + +/** + * Option. + */ +export type CognitiveComplexityOption = number; + +/** + * Options. + */ +export type CognitiveComplexityOptions = [ + CognitiveComplexityOption?, + CognitiveComplexityConfig?, +]; + +/** + * Cognitive Complexity of functions should not be too high. + * + * @see [cognitive-complexity](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/cognitive-complexity.md) + */ +export type CognitiveComplexityRuleConfig = + RuleConfig; + +/** + * Cognitive Complexity of functions should not be too high. + * + * @see [cognitive-complexity](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/cognitive-complexity.md) + */ +export interface CognitiveComplexityRule { + /** + * Cognitive Complexity of functions should not be too high. + * + * @see [cognitive-complexity](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/cognitive-complexity.md) + */ + 'sonarjs/cognitive-complexity': CognitiveComplexityRuleConfig; +} diff --git a/src/rules/sonarjs/elseif-without-else.d.ts b/src/rules/sonarjs/elseif-without-else.d.ts new file mode 100644 index 00000000..1a61b4a5 --- /dev/null +++ b/src/rules/sonarjs/elseif-without-else.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * "if ... else if" constructs should end with "else" clauses. + * + * @see [elseif-without-else](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/elseif-without-else.md) + */ +export type ElseifWithoutElseRuleConfig = RuleConfig<[]>; + +/** + * "if ... else if" constructs should end with "else" clauses. + * + * @see [elseif-without-else](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/elseif-without-else.md) + */ +export interface ElseifWithoutElseRule { + /** + * "if ... else if" constructs should end with "else" clauses. + * + * @see [elseif-without-else](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/elseif-without-else.md) + */ + 'sonarjs/elseif-without-else': ElseifWithoutElseRuleConfig; +} diff --git a/src/rules/sonarjs/index.d.ts b/src/rules/sonarjs/index.d.ts new file mode 100644 index 00000000..402bbfe3 --- /dev/null +++ b/src/rules/sonarjs/index.d.ts @@ -0,0 +1,68 @@ +import type { CognitiveComplexityRule } from './cognitive-complexity'; +import type { ElseifWithoutElseRule } from './elseif-without-else'; +import type { MaxSwitchCasesRule } from './max-switch-cases'; +import type { NoAllDuplicatedBranchesRule } from './no-all-duplicated-branches'; +import type { NoCollapsibleIfRule } from './no-collapsible-if'; +import type { NoCollectionSizeMischeckRule } from './no-collection-size-mischeck'; +import type { NoDuplicateStringRule } from './no-duplicate-string'; +import type { NoDuplicatedBranchesRule } from './no-duplicated-branches'; +import type { NoElementOverwriteRule } from './no-element-overwrite'; +import type { NoEmptyCollectionRule } from './no-empty-collection'; +import type { NoExtraArgumentsRule } from './no-extra-arguments'; +import type { NoGratuitousExpressionsRule } from './no-gratuitous-expressions'; +import type { NoIdenticalConditionsRule } from './no-identical-conditions'; +import type { NoIdenticalExpressionsRule } from './no-identical-expressions'; +import type { NoIdenticalFunctionsRule } from './no-identical-functions'; +import type { NoIgnoredReturnRule } from './no-ignored-return'; +import type { NoInvertedBooleanCheckRule } from './no-inverted-boolean-check'; +import type { NoNestedSwitchRule } from './no-nested-switch'; +import type { NoNestedTemplateLiteralsRule } from './no-nested-template-literals'; +import type { NoOneIterationLoopRule } from './no-one-iteration-loop'; +import type { NoRedundantBooleanRule } from './no-redundant-boolean'; +import type { NoRedundantJumpRule } from './no-redundant-jump'; +import type { NoSameLineConditionalRule } from './no-same-line-conditional'; +import type { NoSmallSwitchRule } from './no-small-switch'; +import type { NoUnusedCollectionRule } from './no-unused-collection'; +import type { NoUseOfEmptyReturnValueRule } from './no-use-of-empty-return-value'; +import type { NoUselessCatchRule } from './no-useless-catch'; +import type { NonExistentOperatorRule } from './non-existent-operator'; +import type { PreferImmediateReturnRule } from './prefer-immediate-return'; +import type { PreferObjectLiteralRule } from './prefer-object-literal'; +import type { PreferSingleBooleanReturnRule } from './prefer-single-boolean-return'; +import type { PreferWhileRule } from './prefer-while'; + +/** + * All SonarJS rules. + */ +export type SonarJSRules = CognitiveComplexityRule & + ElseifWithoutElseRule & + MaxSwitchCasesRule & + NoAllDuplicatedBranchesRule & + NoCollapsibleIfRule & + NoCollectionSizeMischeckRule & + NoDuplicateStringRule & + NoDuplicatedBranchesRule & + NoElementOverwriteRule & + NoEmptyCollectionRule & + NoExtraArgumentsRule & + NoGratuitousExpressionsRule & + NoIdenticalConditionsRule & + NoIdenticalExpressionsRule & + NoIdenticalFunctionsRule & + NoIgnoredReturnRule & + NoInvertedBooleanCheckRule & + NoNestedSwitchRule & + NoNestedTemplateLiteralsRule & + NoOneIterationLoopRule & + NoRedundantBooleanRule & + NoRedundantJumpRule & + NoSameLineConditionalRule & + NoSmallSwitchRule & + NoUnusedCollectionRule & + NoUseOfEmptyReturnValueRule & + NoUselessCatchRule & + NonExistentOperatorRule & + PreferImmediateReturnRule & + PreferObjectLiteralRule & + PreferSingleBooleanReturnRule & + PreferWhileRule; diff --git a/src/rules/sonarjs/max-switch-cases.d.ts b/src/rules/sonarjs/max-switch-cases.d.ts new file mode 100644 index 00000000..c52fc58b --- /dev/null +++ b/src/rules/sonarjs/max-switch-cases.d.ts @@ -0,0 +1,32 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type MaxSwitchCasesOption = number; + +/** + * Options. + */ +export type MaxSwitchCasesOptions = [MaxSwitchCasesOption?]; + +/** + * "switch" statements should not have too many "case" clauses. + * + * @see [max-switch-cases](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/max-switch-cases.md) + */ +export type MaxSwitchCasesRuleConfig = RuleConfig; + +/** + * "switch" statements should not have too many "case" clauses. + * + * @see [max-switch-cases](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/max-switch-cases.md) + */ +export interface MaxSwitchCasesRule { + /** + * "switch" statements should not have too many "case" clauses. + * + * @see [max-switch-cases](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/max-switch-cases.md) + */ + 'sonarjs/max-switch-cases': MaxSwitchCasesRuleConfig; +} diff --git a/src/rules/sonarjs/no-all-duplicated-branches.d.ts b/src/rules/sonarjs/no-all-duplicated-branches.d.ts new file mode 100644 index 00000000..b64252d7 --- /dev/null +++ b/src/rules/sonarjs/no-all-duplicated-branches.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * All branches in a conditional structure should not have exactly the same implementation. + * + * @see [no-all-duplicated-branches](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-all-duplicated-branches.md) + */ +export type NoAllDuplicatedBranchesRuleConfig = RuleConfig<[]>; + +/** + * All branches in a conditional structure should not have exactly the same implementation. + * + * @see [no-all-duplicated-branches](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-all-duplicated-branches.md) + */ +export interface NoAllDuplicatedBranchesRule { + /** + * All branches in a conditional structure should not have exactly the same implementation. + * + * @see [no-all-duplicated-branches](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-all-duplicated-branches.md) + */ + 'sonarjs/no-all-duplicated-branches': NoAllDuplicatedBranchesRuleConfig; +} diff --git a/src/rules/sonarjs/no-collapsible-if.d.ts b/src/rules/sonarjs/no-collapsible-if.d.ts new file mode 100644 index 00000000..2ad4252a --- /dev/null +++ b/src/rules/sonarjs/no-collapsible-if.d.ts @@ -0,0 +1,32 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type NoCollapsibleIfOption = 'sonar-runtime'; + +/** + * Options. + */ +export type NoCollapsibleIfOptions = [NoCollapsibleIfOption?]; + +/** + * Collapsible "if" statements should be merged. + * + * @see [no-collapsible-if](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-collapsible-if.md) + */ +export type NoCollapsibleIfRuleConfig = RuleConfig; + +/** + * Collapsible "if" statements should be merged. + * + * @see [no-collapsible-if](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-collapsible-if.md) + */ +export interface NoCollapsibleIfRule { + /** + * Collapsible "if" statements should be merged. + * + * @see [no-collapsible-if](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-collapsible-if.md) + */ + 'sonarjs/no-collapsible-if': NoCollapsibleIfRuleConfig; +} diff --git a/src/rules/sonarjs/no-collection-size-mischeck.d.ts b/src/rules/sonarjs/no-collection-size-mischeck.d.ts new file mode 100644 index 00000000..2fc98bca --- /dev/null +++ b/src/rules/sonarjs/no-collection-size-mischeck.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Collection sizes and array length comparisons should make sense. + * + * @see [no-collection-size-mischeck](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-collection-size-mischeck.md) + */ +export type NoCollectionSizeMischeckRuleConfig = RuleConfig<[]>; + +/** + * Collection sizes and array length comparisons should make sense. + * + * @see [no-collection-size-mischeck](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-collection-size-mischeck.md) + */ +export interface NoCollectionSizeMischeckRule { + /** + * Collection sizes and array length comparisons should make sense. + * + * @see [no-collection-size-mischeck](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-collection-size-mischeck.md) + */ + 'sonarjs/no-collection-size-mischeck': NoCollectionSizeMischeckRuleConfig; +} diff --git a/src/rules/sonarjs/no-duplicate-string.d.ts b/src/rules/sonarjs/no-duplicate-string.d.ts new file mode 100644 index 00000000..cad61034 --- /dev/null +++ b/src/rules/sonarjs/no-duplicate-string.d.ts @@ -0,0 +1,40 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Config. + */ +export type NoDuplicateStringConfig = 'sonar-runtime'; + +/** + * Option. + */ +export type NoDuplicateStringOption = number; + +/** + * Options. + */ +export type NoDuplicateStringOptions = [ + NoDuplicateStringOption?, + NoDuplicateStringConfig?, +]; + +/** + * String literals should not be duplicated. + * + * @see [no-duplicate-string](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-duplicate-string.md) + */ +export type NoDuplicateStringRuleConfig = RuleConfig; + +/** + * String literals should not be duplicated. + * + * @see [no-duplicate-string](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-duplicate-string.md) + */ +export interface NoDuplicateStringRule { + /** + * String literals should not be duplicated. + * + * @see [no-duplicate-string](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-duplicate-string.md) + */ + 'sonarjs/no-duplicate-string': NoDuplicateStringRuleConfig; +} diff --git a/src/rules/sonarjs/no-duplicated-branches.d.ts b/src/rules/sonarjs/no-duplicated-branches.d.ts new file mode 100644 index 00000000..7e38348e --- /dev/null +++ b/src/rules/sonarjs/no-duplicated-branches.d.ts @@ -0,0 +1,33 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type NoDuplicatedBranchesOption = 'sonar-runtime'; + +/** + * Options. + */ +export type NoDuplicatedBranchesOptions = [NoDuplicatedBranchesOption?]; + +/** + * Two branches in a conditional structure should not have exactly the same implementation. + * + * @see [no-duplicated-branches](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-duplicated-branches.md) + */ +export type NoDuplicatedBranchesRuleConfig = + RuleConfig; + +/** + * Two branches in a conditional structure should not have exactly the same implementation. + * + * @see [no-duplicated-branches](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-duplicated-branches.md) + */ +export interface NoDuplicatedBranchesRule { + /** + * Two branches in a conditional structure should not have exactly the same implementation. + * + * @see [no-duplicated-branches](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-duplicated-branches.md) + */ + 'sonarjs/no-duplicated-branches': NoDuplicatedBranchesRuleConfig; +} diff --git a/src/rules/sonarjs/no-element-overwrite.d.ts b/src/rules/sonarjs/no-element-overwrite.d.ts new file mode 100644 index 00000000..32ad10f6 --- /dev/null +++ b/src/rules/sonarjs/no-element-overwrite.d.ts @@ -0,0 +1,33 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type NoElementOverwriteOption = 'sonar-runtime'; + +/** + * Options. + */ +export type NoElementOverwriteOptions = [NoElementOverwriteOption?]; + +/** + * Collection elements should not be replaced unconditionally. + * + * @see [no-element-overwrite](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-element-overwrite.md) + */ +export type NoElementOverwriteRuleConfig = + RuleConfig; + +/** + * Collection elements should not be replaced unconditionally. + * + * @see [no-element-overwrite](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-element-overwrite.md) + */ +export interface NoElementOverwriteRule { + /** + * Collection elements should not be replaced unconditionally. + * + * @see [no-element-overwrite](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-element-overwrite.md) + */ + 'sonarjs/no-element-overwrite': NoElementOverwriteRuleConfig; +} diff --git a/src/rules/sonarjs/no-empty-collection.d.ts b/src/rules/sonarjs/no-empty-collection.d.ts new file mode 100644 index 00000000..87f3dd6f --- /dev/null +++ b/src/rules/sonarjs/no-empty-collection.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Empty collections should not be accessed or iterated. + * + * @see [no-empty-collection](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-empty-collection.md) + */ +export type NoEmptyCollectionRuleConfig = RuleConfig<[]>; + +/** + * Empty collections should not be accessed or iterated. + * + * @see [no-empty-collection](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-empty-collection.md) + */ +export interface NoEmptyCollectionRule { + /** + * Empty collections should not be accessed or iterated. + * + * @see [no-empty-collection](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-empty-collection.md) + */ + 'sonarjs/no-empty-collection': NoEmptyCollectionRuleConfig; +} diff --git a/src/rules/sonarjs/no-extra-arguments.d.ts b/src/rules/sonarjs/no-extra-arguments.d.ts new file mode 100644 index 00000000..575e5fa5 --- /dev/null +++ b/src/rules/sonarjs/no-extra-arguments.d.ts @@ -0,0 +1,32 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type NoExtraArgumentsOption = 'sonar-runtime'; + +/** + * Options. + */ +export type NoExtraArgumentsOptions = [NoExtraArgumentsOption?]; + +/** + * Function calls should not pass extra arguments. + * + * @see [no-extra-arguments](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-extra-arguments.md) + */ +export type NoExtraArgumentsRuleConfig = RuleConfig; + +/** + * Function calls should not pass extra arguments. + * + * @see [no-extra-arguments](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-extra-arguments.md) + */ +export interface NoExtraArgumentsRule { + /** + * Function calls should not pass extra arguments. + * + * @see [no-extra-arguments](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-extra-arguments.md) + */ + 'sonarjs/no-extra-arguments': NoExtraArgumentsRuleConfig; +} diff --git a/src/rules/sonarjs/no-gratuitous-expressions.d.ts b/src/rules/sonarjs/no-gratuitous-expressions.d.ts new file mode 100644 index 00000000..ea865ecc --- /dev/null +++ b/src/rules/sonarjs/no-gratuitous-expressions.d.ts @@ -0,0 +1,33 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type NoGratuitousExpressionsOption = 'sonar-runtime'; + +/** + * Options. + */ +export type NoGratuitousExpressionsOptions = [NoGratuitousExpressionsOption?]; + +/** + * Boolean expressions should not be gratuitous. + * + * @see [no-gratuitous-expressions](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-gratuitous-expressions.md) + */ +export type NoGratuitousExpressionsRuleConfig = + RuleConfig; + +/** + * Boolean expressions should not be gratuitous. + * + * @see [no-gratuitous-expressions](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-gratuitous-expressions.md) + */ +export interface NoGratuitousExpressionsRule { + /** + * Boolean expressions should not be gratuitous. + * + * @see [no-gratuitous-expressions](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-gratuitous-expressions.md) + */ + 'sonarjs/no-gratuitous-expressions': NoGratuitousExpressionsRuleConfig; +} diff --git a/src/rules/sonarjs/no-identical-conditions.d.ts b/src/rules/sonarjs/no-identical-conditions.d.ts new file mode 100644 index 00000000..7cc7eef4 --- /dev/null +++ b/src/rules/sonarjs/no-identical-conditions.d.ts @@ -0,0 +1,33 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type NoIdenticalConditionsOption = 'sonar-runtime'; + +/** + * Options. + */ +export type NoIdenticalConditionsOptions = [NoIdenticalConditionsOption?]; + +/** + * Related "if/else if" statements should not have the same condition. + * + * @see [no-identical-conditions](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-identical-conditions.md) + */ +export type NoIdenticalConditionsRuleConfig = + RuleConfig; + +/** + * Related "if/else if" statements should not have the same condition. + * + * @see [no-identical-conditions](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-identical-conditions.md) + */ +export interface NoIdenticalConditionsRule { + /** + * Related "if/else if" statements should not have the same condition. + * + * @see [no-identical-conditions](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-identical-conditions.md) + */ + 'sonarjs/no-identical-conditions': NoIdenticalConditionsRuleConfig; +} diff --git a/src/rules/sonarjs/no-identical-expressions.d.ts b/src/rules/sonarjs/no-identical-expressions.d.ts new file mode 100644 index 00000000..8a71289b --- /dev/null +++ b/src/rules/sonarjs/no-identical-expressions.d.ts @@ -0,0 +1,33 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type NoIdenticalExpressionsOption = 'sonar-runtime'; + +/** + * Options. + */ +export type NoIdenticalExpressionsOptions = [NoIdenticalExpressionsOption?]; + +/** + * Identical expressions should not be used on both sides of a binary operator. + * + * @see [no-identical-expressions](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-identical-expressions.md) + */ +export type NoIdenticalExpressionsRuleConfig = + RuleConfig; + +/** + * Identical expressions should not be used on both sides of a binary operator. + * + * @see [no-identical-expressions](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-identical-expressions.md) + */ +export interface NoIdenticalExpressionsRule { + /** + * Identical expressions should not be used on both sides of a binary operator. + * + * @see [no-identical-expressions](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-identical-expressions.md) + */ + 'sonarjs/no-identical-expressions': NoIdenticalExpressionsRuleConfig; +} diff --git a/src/rules/sonarjs/no-identical-functions.d.ts b/src/rules/sonarjs/no-identical-functions.d.ts new file mode 100644 index 00000000..ad87e9b6 --- /dev/null +++ b/src/rules/sonarjs/no-identical-functions.d.ts @@ -0,0 +1,41 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Config. + */ +export type NoIdenticalFunctionsConfig = 'sonar-runtime'; + +/** + * Option. + */ +export type NoIdenticalFunctionsOption = number; + +/** + * Options. + */ +export type NoIdenticalFunctionsOptions = [ + NoIdenticalFunctionsOption?, + NoIdenticalFunctionsConfig?, +]; + +/** + * Functions should not have identical implementations. + * + * @see [no-identical-functions](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-identical-functions.md) + */ +export type NoIdenticalFunctionsRuleConfig = + RuleConfig; + +/** + * Functions should not have identical implementations. + * + * @see [no-identical-functions](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-identical-functions.md) + */ +export interface NoIdenticalFunctionsRule { + /** + * Functions should not have identical implementations. + * + * @see [no-identical-functions](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-identical-functions.md) + */ + 'sonarjs/no-identical-functions': NoIdenticalFunctionsRuleConfig; +} diff --git a/src/rules/sonarjs/no-ignored-return.d.ts b/src/rules/sonarjs/no-ignored-return.d.ts new file mode 100644 index 00000000..bd8ea979 --- /dev/null +++ b/src/rules/sonarjs/no-ignored-return.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Return values from functions without side effects should not be ignored. + * + * @see [no-ignored-return](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-ignored-return.md) + */ +export type NoIgnoredReturnRuleConfig = RuleConfig<[]>; + +/** + * Return values from functions without side effects should not be ignored. + * + * @see [no-ignored-return](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-ignored-return.md) + */ +export interface NoIgnoredReturnRule { + /** + * Return values from functions without side effects should not be ignored. + * + * @see [no-ignored-return](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-ignored-return.md) + */ + 'sonarjs/no-ignored-return': NoIgnoredReturnRuleConfig; +} diff --git a/src/rules/sonarjs/no-inverted-boolean-check.d.ts b/src/rules/sonarjs/no-inverted-boolean-check.d.ts new file mode 100644 index 00000000..d6668b1c --- /dev/null +++ b/src/rules/sonarjs/no-inverted-boolean-check.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Boolean checks should not be inverted. + * + * @see [no-inverted-boolean-check](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-inverted-boolean-check.md) + */ +export type NoInvertedBooleanCheckRuleConfig = RuleConfig<[]>; + +/** + * Boolean checks should not be inverted. + * + * @see [no-inverted-boolean-check](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-inverted-boolean-check.md) + */ +export interface NoInvertedBooleanCheckRule { + /** + * Boolean checks should not be inverted. + * + * @see [no-inverted-boolean-check](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-inverted-boolean-check.md) + */ + 'sonarjs/no-inverted-boolean-check': NoInvertedBooleanCheckRuleConfig; +} diff --git a/src/rules/sonarjs/no-nested-switch.d.ts b/src/rules/sonarjs/no-nested-switch.d.ts new file mode 100644 index 00000000..4e065c1c --- /dev/null +++ b/src/rules/sonarjs/no-nested-switch.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * "switch" statements should not be nested. + * + * @see [no-nested-switch](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-nested-switch.md) + */ +export type NoNestedSwitchRuleConfig = RuleConfig<[]>; + +/** + * "switch" statements should not be nested. + * + * @see [no-nested-switch](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-nested-switch.md) + */ +export interface NoNestedSwitchRule { + /** + * "switch" statements should not be nested. + * + * @see [no-nested-switch](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-nested-switch.md) + */ + 'sonarjs/no-nested-switch': NoNestedSwitchRuleConfig; +} diff --git a/src/rules/sonarjs/no-nested-template-literals.d.ts b/src/rules/sonarjs/no-nested-template-literals.d.ts new file mode 100644 index 00000000..c30f047e --- /dev/null +++ b/src/rules/sonarjs/no-nested-template-literals.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Template literals should not be nested. + * + * @see [no-nested-template-literals](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-nested-template-literals.md) + */ +export type NoNestedTemplateLiteralsRuleConfig = RuleConfig<[]>; + +/** + * Template literals should not be nested. + * + * @see [no-nested-template-literals](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-nested-template-literals.md) + */ +export interface NoNestedTemplateLiteralsRule { + /** + * Template literals should not be nested. + * + * @see [no-nested-template-literals](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-nested-template-literals.md) + */ + 'sonarjs/no-nested-template-literals': NoNestedTemplateLiteralsRuleConfig; +} diff --git a/src/rules/sonarjs/no-one-iteration-loop.d.ts b/src/rules/sonarjs/no-one-iteration-loop.d.ts new file mode 100644 index 00000000..bbac575c --- /dev/null +++ b/src/rules/sonarjs/no-one-iteration-loop.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Loops with at most one iteration should be refactored. + * + * @see [no-one-iteration-loop](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-one-iteration-loop.md) + */ +export type NoOneIterationLoopRuleConfig = RuleConfig<[]>; + +/** + * Loops with at most one iteration should be refactored. + * + * @see [no-one-iteration-loop](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-one-iteration-loop.md) + */ +export interface NoOneIterationLoopRule { + /** + * Loops with at most one iteration should be refactored. + * + * @see [no-one-iteration-loop](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-one-iteration-loop.md) + */ + 'sonarjs/no-one-iteration-loop': NoOneIterationLoopRuleConfig; +} diff --git a/src/rules/sonarjs/no-redundant-boolean.d.ts b/src/rules/sonarjs/no-redundant-boolean.d.ts new file mode 100644 index 00000000..e1880425 --- /dev/null +++ b/src/rules/sonarjs/no-redundant-boolean.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Boolean literals should not be redundant. + * + * @see [no-redundant-boolean](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-redundant-boolean.md) + */ +export type NoRedundantBooleanRuleConfig = RuleConfig<[]>; + +/** + * Boolean literals should not be redundant. + * + * @see [no-redundant-boolean](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-redundant-boolean.md) + */ +export interface NoRedundantBooleanRule { + /** + * Boolean literals should not be redundant. + * + * @see [no-redundant-boolean](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-redundant-boolean.md) + */ + 'sonarjs/no-redundant-boolean': NoRedundantBooleanRuleConfig; +} diff --git a/src/rules/sonarjs/no-redundant-jump.d.ts b/src/rules/sonarjs/no-redundant-jump.d.ts new file mode 100644 index 00000000..5dd52760 --- /dev/null +++ b/src/rules/sonarjs/no-redundant-jump.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Jump statements should not be redundant. + * + * @see [no-redundant-jump](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-redundant-jump.md) + */ +export type NoRedundantJumpRuleConfig = RuleConfig<[]>; + +/** + * Jump statements should not be redundant. + * + * @see [no-redundant-jump](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-redundant-jump.md) + */ +export interface NoRedundantJumpRule { + /** + * Jump statements should not be redundant. + * + * @see [no-redundant-jump](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-redundant-jump.md) + */ + 'sonarjs/no-redundant-jump': NoRedundantJumpRuleConfig; +} diff --git a/src/rules/sonarjs/no-same-line-conditional.d.ts b/src/rules/sonarjs/no-same-line-conditional.d.ts new file mode 100644 index 00000000..e5cca876 --- /dev/null +++ b/src/rules/sonarjs/no-same-line-conditional.d.ts @@ -0,0 +1,33 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type NoSameLineConditionalOption = 'sonar-runtime'; + +/** + * Options. + */ +export type NoSameLineConditionalOptions = [NoSameLineConditionalOption?]; + +/** + * Conditionals should start on new lines. + * + * @see [no-same-line-conditional](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-same-line-conditional.md) + */ +export type NoSameLineConditionalRuleConfig = + RuleConfig; + +/** + * Conditionals should start on new lines. + * + * @see [no-same-line-conditional](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-same-line-conditional.md) + */ +export interface NoSameLineConditionalRule { + /** + * Conditionals should start on new lines. + * + * @see [no-same-line-conditional](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-same-line-conditional.md) + */ + 'sonarjs/no-same-line-conditional': NoSameLineConditionalRuleConfig; +} diff --git a/src/rules/sonarjs/no-small-switch.d.ts b/src/rules/sonarjs/no-small-switch.d.ts new file mode 100644 index 00000000..1d7ccb0c --- /dev/null +++ b/src/rules/sonarjs/no-small-switch.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * "switch" statements should have at least 3 "case" clauses. + * + * @see [no-small-switch](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-small-switch.md) + */ +export type NoSmallSwitchRuleConfig = RuleConfig<[]>; + +/** + * "switch" statements should have at least 3 "case" clauses. + * + * @see [no-small-switch](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-small-switch.md) + */ +export interface NoSmallSwitchRule { + /** + * "switch" statements should have at least 3 "case" clauses. + * + * @see [no-small-switch](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-small-switch.md) + */ + 'sonarjs/no-small-switch': NoSmallSwitchRuleConfig; +} diff --git a/src/rules/sonarjs/no-unused-collection.d.ts b/src/rules/sonarjs/no-unused-collection.d.ts new file mode 100644 index 00000000..fda50dbd --- /dev/null +++ b/src/rules/sonarjs/no-unused-collection.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Collection and array contents should be used. + * + * @see [no-unused-collection](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-unused-collection.md) + */ +export type NoUnusedCollectionRuleConfig = RuleConfig<[]>; + +/** + * Collection and array contents should be used. + * + * @see [no-unused-collection](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-unused-collection.md) + */ +export interface NoUnusedCollectionRule { + /** + * Collection and array contents should be used. + * + * @see [no-unused-collection](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-unused-collection.md) + */ + 'sonarjs/no-unused-collection': NoUnusedCollectionRuleConfig; +} diff --git a/src/rules/sonarjs/no-use-of-empty-return-value.d.ts b/src/rules/sonarjs/no-use-of-empty-return-value.d.ts new file mode 100644 index 00000000..0c4dda16 --- /dev/null +++ b/src/rules/sonarjs/no-use-of-empty-return-value.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * The output of functions that don't return anything should not be used. + * + * @see [no-use-of-empty-return-value](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-use-of-empty-return-value.md) + */ +export type NoUseOfEmptyReturnValueRuleConfig = RuleConfig<[]>; + +/** + * The output of functions that don't return anything should not be used. + * + * @see [no-use-of-empty-return-value](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-use-of-empty-return-value.md) + */ +export interface NoUseOfEmptyReturnValueRule { + /** + * The output of functions that don't return anything should not be used. + * + * @see [no-use-of-empty-return-value](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-use-of-empty-return-value.md) + */ + 'sonarjs/no-use-of-empty-return-value': NoUseOfEmptyReturnValueRuleConfig; +} diff --git a/src/rules/sonarjs/no-useless-catch.d.ts b/src/rules/sonarjs/no-useless-catch.d.ts new file mode 100644 index 00000000..d6dda396 --- /dev/null +++ b/src/rules/sonarjs/no-useless-catch.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * "catch" clauses should do more than rethrow. + * + * @see [no-useless-catch](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-useless-catch.md) + */ +export type NoUselessCatchRuleConfig = RuleConfig<[]>; + +/** + * "catch" clauses should do more than rethrow. + * + * @see [no-useless-catch](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-useless-catch.md) + */ +export interface NoUselessCatchRule { + /** + * "catch" clauses should do more than rethrow. + * + * @see [no-useless-catch](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/no-useless-catch.md) + */ + 'sonarjs/no-useless-catch': NoUselessCatchRuleConfig; +} diff --git a/src/rules/sonarjs/non-existent-operator.d.ts b/src/rules/sonarjs/non-existent-operator.d.ts new file mode 100644 index 00000000..995be33a --- /dev/null +++ b/src/rules/sonarjs/non-existent-operator.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Non-existent operators "=+", "=-" and "=!" should not be used. + * + * @see [non-existent-operator](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/non-existent-operator.md) + */ +export type NonExistentOperatorRuleConfig = RuleConfig<[]>; + +/** + * Non-existent operators "=+", "=-" and "=!" should not be used. + * + * @see [non-existent-operator](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/non-existent-operator.md) + */ +export interface NonExistentOperatorRule { + /** + * Non-existent operators "=+", "=-" and "=!" should not be used. + * + * @see [non-existent-operator](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/non-existent-operator.md) + */ + 'sonarjs/non-existent-operator': NonExistentOperatorRuleConfig; +} diff --git a/src/rules/sonarjs/prefer-immediate-return.d.ts b/src/rules/sonarjs/prefer-immediate-return.d.ts new file mode 100644 index 00000000..c5fa010f --- /dev/null +++ b/src/rules/sonarjs/prefer-immediate-return.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Local variables should not be declared and then immediately returned or thrown. + * + * @see [prefer-immediate-return](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/prefer-immediate-return.md) + */ +export type PreferImmediateReturnRuleConfig = RuleConfig<[]>; + +/** + * Local variables should not be declared and then immediately returned or thrown. + * + * @see [prefer-immediate-return](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/prefer-immediate-return.md) + */ +export interface PreferImmediateReturnRule { + /** + * Local variables should not be declared and then immediately returned or thrown. + * + * @see [prefer-immediate-return](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/prefer-immediate-return.md) + */ + 'sonarjs/prefer-immediate-return': PreferImmediateReturnRuleConfig; +} diff --git a/src/rules/sonarjs/prefer-object-literal.d.ts b/src/rules/sonarjs/prefer-object-literal.d.ts new file mode 100644 index 00000000..14c1dd97 --- /dev/null +++ b/src/rules/sonarjs/prefer-object-literal.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Object literal syntax should be used. + * + * @see [prefer-object-literal](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/prefer-object-literal.md) + */ +export type PreferObjectLiteralRuleConfig = RuleConfig<[]>; + +/** + * Object literal syntax should be used. + * + * @see [prefer-object-literal](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/prefer-object-literal.md) + */ +export interface PreferObjectLiteralRule { + /** + * Object literal syntax should be used. + * + * @see [prefer-object-literal](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/prefer-object-literal.md) + */ + 'sonarjs/prefer-object-literal': PreferObjectLiteralRuleConfig; +} diff --git a/src/rules/sonarjs/prefer-single-boolean-return.d.ts b/src/rules/sonarjs/prefer-single-boolean-return.d.ts new file mode 100644 index 00000000..aa040245 --- /dev/null +++ b/src/rules/sonarjs/prefer-single-boolean-return.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Return of boolean expressions should not be wrapped into an "if-then-else" statement. + * + * @see [prefer-single-boolean-return](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/prefer-single-boolean-return.md) + */ +export type PreferSingleBooleanReturnRuleConfig = RuleConfig<[]>; + +/** + * Return of boolean expressions should not be wrapped into an "if-then-else" statement. + * + * @see [prefer-single-boolean-return](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/prefer-single-boolean-return.md) + */ +export interface PreferSingleBooleanReturnRule { + /** + * Return of boolean expressions should not be wrapped into an "if-then-else" statement. + * + * @see [prefer-single-boolean-return](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/prefer-single-boolean-return.md) + */ + 'sonarjs/prefer-single-boolean-return': PreferSingleBooleanReturnRuleConfig; +} diff --git a/src/rules/sonarjs/prefer-while.d.ts b/src/rules/sonarjs/prefer-while.d.ts new file mode 100644 index 00000000..3df4e1fe --- /dev/null +++ b/src/rules/sonarjs/prefer-while.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * A "while" loop should be used instead of a "for" loop. + * + * @see [prefer-while](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/prefer-while.md) + */ +export type PreferWhileRuleConfig = RuleConfig<[]>; + +/** + * A "while" loop should be used instead of a "for" loop. + * + * @see [prefer-while](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/prefer-while.md) + */ +export interface PreferWhileRule { + /** + * A "while" loop should be used instead of a "for" loop. + * + * @see [prefer-while](https://github.com/SonarSource/eslint-plugin-sonarjs/blob/master/docs/rules/prefer-while.md) + */ + 'sonarjs/prefer-while': PreferWhileRuleConfig; +}