Skip to content

Commit f4a6784

Browse files
authoredMay 28, 2021
Add SonarTS converters. (#1085)
* Add SonarTS converters. * Fix plugin name. * Add no-empty merger. * Add no-use-before-define merger. * Fix no-extra-semicolon converter. * Add no-return-type-any converter. * Add no-alphabetical-sort converter. * Remove no-return-type-any converter.
1 parent 559f31c commit f4a6784

File tree

80 files changed

+1482
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1482
-1
lines changed
 

‎src/converters/lintConfigs/rules/ruleConverters.ts

+77-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import { convertNoDuplicateImports } from "./ruleConverters/no-duplicate-imports
5555
import { convertNoDuplicateSuper } from "./ruleConverters/no-duplicate-super";
5656
import { convertNoDuplicateSwitchCase } from "./ruleConverters/no-duplicate-switch-case";
5757
import { convertNoDuplicateVariable } from "./ruleConverters/no-duplicate-variable";
58-
import { convertNoDynamicDelete } from './ruleConverters/no-dynamic-delete';
58+
import { convertNoDynamicDelete } from "./ruleConverters/no-dynamic-delete";
5959
import { convertNoEmpty } from "./ruleConverters/no-empty";
6060
import { convertNoEmptyInterface } from "./ruleConverters/no-empty-interface";
6161
import { convertNoEmptyLineAfterOpeningBrace } from "./ruleConverters/no-empty-line-after-opening-brace";
@@ -232,6 +232,45 @@ import { convertNoUnboundMethods } from "./ruleConverters/eslint-plugin-rxjs/no-
232232
import { convertNoUnsafeSubjectNext } from "./ruleConverters/eslint-plugin-rxjs/no-unsafe-subject-next";
233233
import { convertNoUnsafeTakeUntil } from "./ruleConverters/eslint-plugin-rxjs/no-unsafe-takeuntil";
234234

235+
// eslint-plugin-sonarjs converters
236+
import { convertCognitiveComplexity } from "./ruleConverters/eslint-plugin-sonarjs/cognitive-complexity";
237+
import { convertConsecutiveOverloads } from "./ruleConverters/eslint-plugin-sonarjs/consecutive-overloads";
238+
import { convertMaxSwitchCases } from "./ruleConverters/eslint-plugin-sonarjs/max-switch-cases";
239+
import { convertNoAllDuplicatedBranches } from "./ruleConverters/eslint-plugin-sonarjs/no-all-duplicated-branches";
240+
import { convertNoAlphabeticalSort } from "./ruleConverters/eslint-plugin-sonarjs/no-alphabetical-sort";
241+
import { convertNoBigFunction } from "./ruleConverters/eslint-plugin-sonarjs/no-big-function";
242+
import { convertNoCollapsibleIf } from "./ruleConverters/eslint-plugin-sonarjs/no-collapsible-if";
243+
import { convertNoCollectionSizeMischeck } from "./ruleConverters/eslint-plugin-sonarjs/no-collection-size-mischeck";
244+
import { convertNoDuplicateString } from "./ruleConverters/eslint-plugin-sonarjs/no-duplicate-string";
245+
import { convertNoDuplicatedBranches } from "./ruleConverters/eslint-plugin-sonarjs/no-duplicated-branches";
246+
import { convertNoElementOverwrite } from "./ruleConverters/eslint-plugin-sonarjs/no-element-overwrite";
247+
import { convertNoEmptyDestructuring } from "./ruleConverters/eslint-plugin-sonarjs/no-empty-destructuring";
248+
import { convertNoEmptyNestedBlocks } from "./ruleConverters/eslint-plugin-sonarjs/no-empty-nested-blocks";
249+
import { convertNoExtraSemicolon } from "./ruleConverters/eslint-plugin-sonarjs/no-extra-semicolon";
250+
import { convertNoIdenticalConditions } from "./ruleConverters/eslint-plugin-sonarjs/no-identical-conditions";
251+
import { convertNoIdenticalExpressions } from "./ruleConverters/eslint-plugin-sonarjs/no-identical-expressions";
252+
import { convertNoIdenticalFunctions } from "./ruleConverters/eslint-plugin-sonarjs/no-identical-functions";
253+
import { convertNoInMisuse } from "./ruleConverters/eslint-plugin-sonarjs/no-in-misuse";
254+
import { convertNoInvalidAwait } from "./ruleConverters/eslint-plugin-sonarjs/no-invalid-await";
255+
import { convertNoInvertedBooleanCheck } from "./ruleConverters/eslint-plugin-sonarjs/no-inverted-boolean-check";
256+
import { convertNoMultilineStringLiterals } from "./ruleConverters/eslint-plugin-sonarjs/no-multiline-string-literals";
257+
import { convertNoRedundantBoolean } from "./ruleConverters/eslint-plugin-sonarjs/no-redundant-boolean";
258+
import { convertNoRedundantJump } from "./ruleConverters/eslint-plugin-sonarjs/no-redundant-jump";
259+
import { convertNoRedundantParentheses } from "./ruleConverters/eslint-plugin-sonarjs/no-redundant-parentheses";
260+
import { convertNoSameLineConditional } from "./ruleConverters/eslint-plugin-sonarjs/no-same-line-conditional";
261+
import { convertNoSelfAssignment } from "./ruleConverters/eslint-plugin-sonarjs/no-self-assignment";
262+
import { convertNoSmallSwitch } from "./ruleConverters/eslint-plugin-sonarjs/no-small-switch";
263+
import { convertNoUnconditionalJump } from "./ruleConverters/eslint-plugin-sonarjs/no-unconditional-jump";
264+
import { convertNoUnusedArray } from "./ruleConverters/eslint-plugin-sonarjs/no-unused-array";
265+
import { convertNoUseOfEmptyReturnValue } from "./ruleConverters/eslint-plugin-sonarjs/no-use-of-empty-return-value";
266+
import { convertNoUselessCast } from "./ruleConverters/eslint-plugin-sonarjs/no-useless-cast";
267+
import { convertNoUselessCatch } from "./ruleConverters/eslint-plugin-sonarjs/no-useless-catch";
268+
import { convertNoVariableUsageBeforeDeclaration } from "./ruleConverters/eslint-plugin-sonarjs/no-variable-usage-before-declaration";
269+
import { convertParametersMaxNumber } from "./ruleConverters/eslint-plugin-sonarjs/parameters-max-number";
270+
import { convertPreferDefaultLast } from "./ruleConverters/eslint-plugin-sonarjs/prefer-default-last";
271+
import { convertPreferImmediateReturn } from "./ruleConverters/eslint-plugin-sonarjs/prefer-immediate-return";
272+
import { convertUsePrimitiveType } from "./ruleConverters/eslint-plugin-sonarjs/use-primitive-type";
273+
235274
/**
236275
* Keys TSLint rule names to their ESLint rule converters.
237276
*/
@@ -248,10 +287,12 @@ export const ruleConverters = new Map([
248287
["binary-expression-operand-order", convertBinaryExpressionOperandOrder],
249288
["callable-types", convertCallableTypes],
250289
["class-name", convertClassName],
290+
["cognitive-complexity", convertCognitiveComplexity],
251291
["comment-format", convertCommentFormat],
252292
["component-class-suffix", convertComponentClassSuffix],
253293
["component-max-inline-declarations", convertComponentMaxInlineDeclarations],
254294
["component-selector", convertComponentSelector],
295+
["consecutive-overloads", convertConsecutiveOverloads],
255296
["contextual-lifecycle", convertContextualLifecycle],
256297
["contextual-decorator", convertContextualDecorator],
257298
["curly", convertCurly],
@@ -285,20 +326,26 @@ export const ruleConverters = new Map([
285326
["max-func-body-length", convertMaxFuncBodyLength],
286327
["max-file-line-count", convertMaxFileLineCount],
287328
["max-line-length", convertMaxLineLength],
329+
["max-switch-cases", convertMaxSwitchCases],
288330
["member-access", convertMemberAccess],
289331
["member-ordering", convertMemberOrdering],
290332
["mocha-avoid-only", convertMochaAvoidOnly],
291333
["new-parens", convertNewParens],
292334
["newline-before-return", convertNewlineBeforeReturn],
293335
["newline-per-chained-call", convertNewlinePerChainedCall],
336+
["no-all-duplicated-branches", convertNoAllDuplicatedBranches],
337+
["no-alphabetical-sort", convertNoAlphabeticalSort],
294338
["no-angle-bracket-type-assertion", convertNoAngleBracketTypeAssertion],
295339
["no-any", convertNoExplicitAny],
296340
["no-arg", convertNoArg],
297341
["no-async-without-await", convertNoAsyncWithoutAwait],
298342
["no-attribute-decorator", convertNoAttributeDecorator],
299343
["no-banned-terms", convertNoBannedTerms],
344+
["no-big-function", convertNoBigFunction],
300345
["no-bitwise", convertNoBitwise],
301346
["no-boolean-literal-compare", convertNoBooleanLiteralCompare],
347+
["no-collapsible-if", convertNoCollapsibleIf],
348+
["no-collection-size-mischeck", convertNoCollectionSizeMischeck],
302349
["no-conditional-assignment", convertNoConditionalAssignment],
303350
["no-conflicting-lifecycle", convertNoConflictingLifecycle],
304351
["no-consecutive-blank-lines", convertNoConsecutiveBlankLines],
@@ -310,34 +357,47 @@ export const ruleConverters = new Map([
310357
["no-default-export", convertNoDefaultExport],
311358
["no-delete-expression", convertNoDeleteExpression],
312359
["no-duplicate-imports", convertNoDuplicateImports],
360+
["no-duplicate-string", convertNoDuplicateString],
313361
["no-duplicate-super", convertNoDuplicateSuper],
314362
["no-duplicate-switch-case", convertNoDuplicateSwitchCase],
315363
["no-duplicate-variable", convertNoDuplicateVariable],
364+
["no-duplicated-branches", convertNoDuplicatedBranches],
316365
["no-dynamic-delete", convertNoDynamicDelete],
366+
["no-element-overwrite", convertNoElementOverwrite],
367+
["no-empty-destructuring", convertNoEmptyDestructuring],
317368
["no-empty-interface", convertNoEmptyInterface],
318369
["no-empty-line-after-opening-brace", convertNoEmptyLineAfterOpeningBrace], // padded-blocks
370+
["no-empty-nested-blocks", convertNoEmptyNestedBlocks],
319371
["no-empty", convertNoEmpty],
320372
["no-eval", convertNoEval],
373+
["no-extra-semicolon", convertNoExtraSemicolon],
321374
["no-floating-promises", convertNoFloatingPromises],
322375
["no-for-in-array", convertNoForInArray],
323376
["no-for-in", convertNoForIn],
324377
["no-forward-ref", convertNoForwardRef],
325378
["no-host-metadata-property", convertNoHostMetadataProperty],
379+
["no-identical-conditions", convertNoIdenticalConditions],
380+
["no-identical-expressions", convertNoIdenticalExpressions],
381+
["no-identical-functions", convertNoIdenticalFunctions],
326382
["no-implicit-dependencies", convertNoImplicitDependencies],
327383
["no-import-side-effect", convertNoImportSideEffect],
384+
["no-in-misuse", convertNoInMisuse],
328385
["no-inferrable-types", convertNoInferrableTypes],
329386
["no-input-prefix", convertNoInputPrefix],
330387
["no-input-rename", convertNoInputRename],
331388
["no-inputs-metadata-property", convertNoInputsMetadataProperty],
332389
["no-internal-module", convertNoInternalModule],
390+
["no-invalid-await", convertNoInvalidAwait],
333391
["no-invalid-regexp", convertNoInvalidRegexp],
334392
["no-invalid-template-strings", convertNoInvalidTemplateStrings],
335393
["no-invalid-this", convertNoInvalidThis],
394+
["no-inverted-boolean-check", convertNoInvertedBooleanCheck],
336395
["no-irregular-whitespace", convertNoIrregularWhitespace],
337396
["no-lifecycle-call", convertNoLifecycleCall],
338397
["no-magic-numbers", convertNoMagicNumbers],
339398
["no-misused-new", convertNoMisusedNew],
340399
["no-multiline-string", convertNoMultilineString],
400+
["no-multiline-string-literals", convertNoMultilineStringLiterals],
341401
["no-namespace", convertNoNamespace],
342402
["no-non-null-assertion", convertNoNonNullAssertion],
343403
["no-null-keyword", convertNoNullKeyword],
@@ -352,13 +412,19 @@ export const ruleConverters = new Map([
352412
["no-parameter-reassignment", convertNoParameterReassignment],
353413
["no-pipe-impure", convertNoPipeImpure],
354414
["no-queries-metadata-property", convertNoQueriesMetadataProperty],
415+
["no-redundant-boolean", convertNoRedundantBoolean],
416+
["no-redundant-jump", convertNoRedundantJump],
355417
["no-redundant-jsdoc", convertNoRedundantJsdoc],
418+
["no-redundant-parentheses", convertNoRedundantParentheses],
356419
["no-reference-import", convertNoReferenceImport],
357420
["no-reference", convertNoReference],
358421
["no-regex-spaces", convertNoRegexSpaces],
359422
["no-require-imports", convertNoRequireImports],
360423
["no-return-await", convertNoReturnAwait],
424+
["no-same-line-conditional", convertNoSameLineConditional],
425+
["no-self-assignment", convertNoSelfAssignment],
361426
["no-shadowed-variable", convertNoShadowedVariable],
427+
["no-small-switch", convertNoSmallSwitch],
362428
["no-sparse-arrays", convertNoSparseArrays],
363429
["no-string-literal", convertNoStringLiteral],
364430
["no-string-throw", convertNoStringThrow],
@@ -368,17 +434,23 @@ export const ruleConverters = new Map([
368434
["no-this-assignment", convertNoThisAssignment],
369435
["no-trailing-whitespace", convertNoTrailingWhitespace],
370436
["no-unbound-method", convertNoUnboundMethod],
437+
["no-unconditional-jump", convertNoUnconditionalJump],
371438
["no-unnecessary-class", convertNoUnnecessaryClass],
372439
["no-unnecessary-initializer", convertNoUnnecessaryInitializer],
373440
["no-unnecessary-qualifier", convertNoUnnecessaryQualifier],
374441
["no-unnecessary-semicolons", convertNoUnnecessarySemicolons],
375442
["no-unnecessary-type-assertion", convertNoUnnecessaryTypeAssertion],
443+
["no-unused-array", convertNoUnusedArray],
376444
["no-unsafe-finally", convertNoUnsafeFinally],
377445
["no-unused-expression", convertNoUnusedExpression],
378446
["no-unused-variable", convertNoUnusedVariable],
379447
["no-use-before-declare", convertNoUseBeforeDeclare],
448+
["no-use-of-empty-return-value", convertNoUseOfEmptyReturnValue],
449+
["no-useless-cast", convertNoUselessCast],
450+
["no-useless-catch", convertNoUselessCatch],
380451
["no-var-keyword", convertNoVarKeyword],
381452
["no-var-requires", convertNoVarRequires],
453+
["no-variable-usage-before-declaration", convertNoVariableUsageBeforeDeclaration],
382454
["no-void-expression", convertNoVoidExpression],
383455
["no-with-statement", convertNoWithStatement],
384456
["object-literal-key-quotes", convertObjectLiteralKeyQuotes],
@@ -387,12 +459,15 @@ export const ruleConverters = new Map([
387459
["one-variable-per-declaration", convertOneVariablePerDeclaration],
388460
["only-arrow-functions", convertOnlyArrowFunctions],
389461
["ordered-imports", convertOrderedImports],
462+
["parameters-max-number", convertParametersMaxNumber],
390463
["pipe-prefix", convertPipePrefix],
391464
["prefer-array-literal", convertPreferArrayLiteral],
392465
["prefer-conditional-expression", convertPreferConditionalExpression],
393466
["prefer-const", convertPreferConst],
467+
["prefer-default-last", convertPreferDefaultLast],
394468
["prefer-for-of", convertPreferForOf],
395469
["prefer-function-over-method", convertPreferFunctionOverMethod],
470+
["prefer-immediate-return", convertPreferImmediateReturn],
396471
["prefer-object-spread", convertPreferObjectSpread],
397472
["prefer-on-push-component-change-detection", convertPreferOnPushComponentChangeDetection],
398473
["prefer-output-readonly", convertPreferOutputReadonly],
@@ -444,6 +519,7 @@ export const ruleConverters = new Map([
444519
["use-lifecycle-interface", convertUseLifecycleInterface],
445520
["use-pipe-decorator", convertUsePipeDecorator],
446521
["use-pipe-transform-interface", convertUsePipeTransformInterface],
522+
["use-primitive-type", convertUsePrimitiveType],
447523
["variable-name", convertVariableName],
448524
["rxjs-no-async-subscribe", convertNoAsyncSubscribe],
449525
["rxjs-no-implicit-any-catch", convertNoImplicitAnyCatch],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { RuleConverter } from "../../ruleConverter";
2+
3+
export const convertCognitiveComplexity: RuleConverter = (tslintRule) => {
4+
return {
5+
rules: [
6+
{
7+
...(tslintRule.ruleArguments.length !== 0 && {
8+
ruleArguments: tslintRule.ruleArguments,
9+
}),
10+
ruleName: "sonarjs/cognitive-complexity",
11+
},
12+
],
13+
plugins: ["sonarjs"],
14+
};
15+
};

0 commit comments

Comments
 (0)
Please sign in to comment.