JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
Third-Party External

TypeScript Warning Classes Corresponding to typescript-eslint Rules

This page describes the CodeSonar warning classes that are assigned to TypeScript warnings imported from a SARIF file produced by ESLint with typescript-eslint.

For JavaScript warnings, see JavaScript Warning Classes Corresponding to ESLint Rules.

See also the table of CodeSonar warning classes that are supported for all languages. If these classes are enabled, the corresponding CodeSonar checks will include all TypeScript source files that were imported into the project with codesonar es_scan.py, codesonar import_sarif.py, or codesonar add_source_files.py.



Introduction

This page describes the CodeSonar warning classes that are assigned to warnings imported from a SARIF file produced by ESLint.

For information on setting up your CodeSonar project to incorporate TypeScript source code and the corresponding ESLint results, see Including JavaScript and TypeScript Components in a CodeSonar Project.

TypeScript Warning Classes from typescript-eslint rules

When CodeSonar imports a SARIF file, it determines a corresponding CodeSonar warning class for each rule object in the SARIF rules. If a given warning class does not already exist, the SARIF importer creates it.

There is special handling for SARIF files produced by ESLint, including special handling for any typescript-eslint rules in those files.

CodeSonar Warning Property Value
Name Generated from the id property of the rule object.

The general form of the id is @typescript-eslint/rule_identifier. The CodeSonar warning class name is generated from this id as follows.

  • The lower-case, hyphenated rule_identifier components is transformed to space-separated title case.
    This includes capitalizing most words, except for minor words such as "or" and "and".
  • " (TS-ESLint)" is appended to the resulting string.
    This greatly reduces the chance of collision with warning class names from other sources, which is important because warning class Name is a unique identifier. It also provides a ready mechanism for visually and programmatically identifying CodeSonar warnings that originate from typescript-eslint results in ESLint-generated SARIF.
Categories When a warning class is based on a typescript-eslint rule, its categories depend on whether the warning class is built in to CodeSonar or created by the SARIF importer.
  • In both cases, the class has a category of the form typescript-esint:<id>
    <id> is the typescript-eslint rule ID, which matches the id property of the SARIF rule object.
  • For built-in classes only, there is also a warning class mnemonic: TS.<metatype>.<abbr>
    <metatype> is based on the meta.type property of the corresponding typescript-eslint rule, and <abbr> is an abbreviation of the class Name.
otherwise Other warning class properties are not set by the SARIF importer.

Example

Suppose the imported SARIF file includes rule objects like the following.

# ...
    "rules":[
        # ...
        {
          "id": "no-empty",
          # ...
        },
        {
          "id": "@typescript-eslint/no-unused-vars",
          # ...
        },
      # ...
    ],
# ...

CodeSonar identifies the first of these rules ("id": "no-empty") as originating from a built-in ESLint rule, and handles it as described for JavaScript Warning Classes Corresponding to ESLint Rules.

The id for the second rule ("id": "@typescript-eslint/no-unused-vars") starts with @typescript-eslint/, so CodeSonar identifies it as originating from a typescript-eslint rule.
(It corresponds to the typescript-eslint no-unused-vars rule.)

  1. CodeSonar computes the corresponding warning class name: "No Unused Vars (TS-ESLint)".
  2. If there is not already a warning class with this name, CodeSonar creates the warning class. The class categories will be
  3. CodeSonar creates a "No Unused Vars (TS-ESLint)" warning instance for each result entry in the SARIF that has "ruleId": "@typescript-eslint/no-unused-vars".

SARIF files produced by ESLint

CodeSonar will consider a SARIF file to be produced by ESLint in the following cases.

Within a SARIF file produced by ESLint, CodeSonar will determine an individual result to be produced by typescript-eslint if its id begins with @typescript-eslint/.
(For other warnings in ESLint SARIF, see JavaScript Warning Classes Corresponding to ESLint Rules.)

Built-in TypeScript Warning Classes

These warning classes correspond to rules from typescript-eslint version v7.0.2.

Class Name Mnemonic
Adjacent Overload Signatures (TS-ESLint) TS.SUGGESTION.AOS
Array Type (TS-ESLint) TS.SUGGESTION.AT
Await Thenable (TS-ESLint) TS.PROBLEM.AT
Ban Ts Comment (TS-ESLint) TS.PROBLEM.BTC
Ban Tslint Comment (TS-ESLint) TS.SUGGESTION.BTC
Ban Types (TS-ESLint) TS.SUGGESTION.BT
Block Spacing (TS-ESLint) TS.LAYOUT.BLKSP
Brace Style (TS-ESLint) TS.LAYOUT.BRSTYLE
Class Literal Property Style (TS-ESLint) TS.PROBLEM.CLPS
Class Methods Use This (TS-ESLint) TS.SUGGESTION.CMUT
Comma Dangle (TS-ESLint) TS.LAYOUT.CD
Comma Spacing (TS-ESLint) TS.LAYOUT.CS
Consistent Generic Constructors (TS-ESLint) TS.SUGGESTION.CGC
Consistent Indexed Object Style (TS-ESLint) TS.SUGGESTION.CIOS
Consistent Type Assertions (TS-ESLint) TS.SUGGESTION.CTA
Consistent Type Definitions (TS-ESLint) TS.SUGGESTION.CTD
Consistent Type Exports (TS-ESLint) TS.SUGGESTION.CTE
Consistent Type Imports (TS-ESLint) TS.SUGGESTION.CTI
Default Param Last (TS-ESLint) TS.SUGGESTION.DPL
Dot Notation (TS-ESLint) TS.SUGGESTION.DN
Explicit Function Return Type (TS-ESLint) TS.PROBLEM.EFRT
Explicit Member Accessibility (TS-ESLint) TS.PROBLEM.EMA
Explicit Module Boundary Types (TS-ESLint) TS.PROBLEM.EMBT
Func Call Spacing (TS-ESLint) TS.LAYOUT.FCS
Indent (TS-ESLint) TS.LAYOUT.INDENT
Init Declarations (TS-ESLint) TS.SUGGESTION.ID
Key Spacing (TS-ESLint) TS.LAYOUT.KEYSP
Keyword Spacing (TS-ESLint) TS.LAYOUT.KWDSP
Lines Around Comment (TS-ESLint) TS.LAYOUT.LAC
Lines Between Class Members (TS-ESLint) TS.LAYOUT.LBCM
Max Params (TS-ESLint) TS.SUGGESTION.MP
Member Delimiter Style (TS-ESLint) TS.LAYOUT.MDS
Member Ordering (TS-ESLint) TS.SUGGESTION.MO
Method Signature Style (TS-ESLint) TS.SUGGESTION.MSS
Naming Convention (TS-ESLint) TS.SUGGESTION.NC
No Array Constructor (TS-ESLint) TS.SUGGESTION.NAC
No Array Delete (TS-ESLint) TS.PROBLEM.NAD
No Base to String (TS-ESLint) TS.SUGGESTION.NBTS
No Confusing Non Null Assertion (TS-ESLint) TS.PROBLEM.NCNNA
No Confusing Void Expression (TS-ESLint) TS.PROBLEM.NCVE
No Dupe Class Members (TS-ESLint) TS.PROBLEM.NDCM
No Duplicate Enum Values (TS-ESLint) TS.PROBLEM.NDEV
No Duplicate Type Constituents (TS-ESLint) TS.SUGGESTION.NDTC
No Dynamic Delete (TS-ESLint) TS.SUGGESTION.NDD
No Empty Function (TS-ESLint) TS.SUGGESTION.NEF
No Empty Interface (TS-ESLint) TS.SUGGESTION.NEI
No Explicit Any (TS-ESLint) TS.SUGGESTION.NEA
No Extra Non Null Assertion (TS-ESLint) TS.PROBLEM.NENNA
No Extra Parens (TS-ESLint) TS.LAYOUT.NEP
No Extra Semi (TS-ESLint) TS.SUGGESTION.NES
No Extraneous Class (TS-ESLint) TS.SUGGESTION.NEC
No Floating Promises (TS-ESLint) TS.PROBLEM.NFP
No Implied Eval (TS-ESLint) TS.SUGGESTION.NIE
No Import Type Side Effects (TS-ESLint) TS.PROBLEM.NITSE
No Inferrable Types (TS-ESLint) TS.SUGGESTION.NINFT
No Invalid This (TS-ESLint) TS.SUGGESTION.NINVTH
No Invalid Void Type (TS-ESLint) TS.PROBLEM.NIVT
No Loop Func (TS-ESLint) TS.SUGGESTION.NLF
No Loss of Precision (TS-ESLint) TS.PROBLEM.NLOP
No Magic Numbers (TS-ESLint) TS.SUGGESTION.NMN
No Meaningless Void Operator (TS-ESLint) TS.SUGGESTION.NMVO
No Misused New (TS-ESLint) TS.PROBLEM.NMN
No Misused Promises (TS-ESLint) TS.PROBLEM.NMP
No Mixed Enums (TS-ESLint) TS.PROBLEM.NME
No Namespace (TS-ESLint) TS.SUGGESTION.NN
No Non Null Asserted Nullish Coalescing (TS-ESLint) TS.PROBLEM.NNNANC
No Non Null Asserted Optional Chain (TS-ESLint) TS.PROBLEM.NNNAOC
No Non Null Assertion (TS-ESLint) TS.PROBLEM.NNNA
No Redeclare (TS-ESLint) TS.SUGGESTION.NR
No Redundant Type Constituents (TS-ESLint) TS.SUGGESTION.NRTC
No Require Imports (TS-ESLint) TS.PROBLEM.NRI
No Restricted Imports (TS-ESLint) TS.SUGGESTION.NRI
No Shadow (TS-ESLint) TS.SUGGESTION.NS
No This Alias (TS-ESLint) TS.SUGGESTION.NTHA
No Throw Literal (TS-ESLint) TS.PROBLEM.NTL
No Type Alias (TS-ESLint) TS.SUGGESTION.NTYPEA
No Unnecessary Boolean Literal Compare (TS-ESLint) TS.SUGGESTION.NUBLC
No Unnecessary Condition (TS-ESLint) TS.SUGGESTION.NUC
No Unnecessary Qualifier (TS-ESLint) TS.SUGGESTION.NUQ
No Unnecessary Type Arguments (TS-ESLint) TS.SUGGESTION.NUTARG
No Unnecessary Type Assertion (TS-ESLint) TS.SUGGESTION.NUTASRT
No Unnecessary Type Constraint (TS-ESLint) TS.SUGGESTION.NUTC
No Unsafe Argument (TS-ESLint) TS.PROBLEM.NUARG
No Unsafe Assignment (TS-ESLint) TS.PROBLEM.NUASGN
No Unsafe Call (TS-ESLint) TS.PROBLEM.NUCALL
No Unsafe Declaration Merging (TS-ESLint) TS.PROBLEM.NUDM
No Unsafe Enum Comparison (TS-ESLint) TS.SUGGESTION.NUEC
No Unsafe Member Access (TS-ESLint) TS.PROBLEM.NUMA
No Unsafe Return (TS-ESLint) TS.PROBLEM.NUR
No Unsafe Unary Minus (TS-ESLint) TS.PROBLEM.NUUM
No Unused Expressions (TS-ESLint) TS.SUGGESTION.NUE
No Unused Vars (TS-ESLint) TS.PROBLEM.NUV
No Use Before Define (TS-ESLint) TS.PROBLEM.NUBD
No Useless Constructor (TS-ESLint) TS.PROBLEM.NUCONS
No Useless Empty Export (TS-ESLint) TS.SUGGESTION.NUEE
No Useless Template Literals (TS-ESLint) TS.SUGGESTION.NUTL
No Var Requires (TS-ESLint) TS.PROBLEM.NVR
No for in Array (TS-ESLint) TS.PROBLEM.NFIA
Non Nullable Type Assertion Style (TS-ESLint) TS.SUGGESTION.NNTAS
Object Curly Spacing (TS-ESLint) TS.LAYOUT.OCS
Padding Line Between Statements (TS-ESLint) TS.LAYOUT.PLBS
Parameter Properties (TS-ESLint) TS.PROBLEM.PP
Prefer As Const (TS-ESLint) TS.SUGGESTION.PAC
Prefer Destructuring (TS-ESLint) TS.SUGGESTION.PD
Prefer Enum Initializers (TS-ESLint) TS.SUGGESTION.PEI
Prefer Find (TS-ESLint) TS.SUGGESTION.PF
Prefer Function Type (TS-ESLint) TS.SUGGESTION.PFT
Prefer Includes (TS-ESLint) TS.SUGGESTION.PI
Prefer Literal Enum Member (TS-ESLint) TS.SUGGESTION.PLEM
Prefer Namespace Keyword (TS-ESLint) TS.SUGGESTION.PNK
Prefer Nullish Coalescing (TS-ESLint) TS.SUGGESTION.PNC
Prefer Optional Chain (TS-ESLint) TS.SUGGESTION.POC
Prefer Promise Reject Errors (TS-ESLint) TS.SUGGESTION.PPRE
Prefer Readonly (TS-ESLint) TS.SUGGESTION.PR
Prefer Readonly Parameter Types (TS-ESLint) TS.SUGGESTION.PRPT
Prefer Reduce Type Parameter (TS-ESLint) TS.PROBLEM.PRTP
Prefer Regexp Exec (TS-ESLint) TS.SUGGESTION.PRE
Prefer Return This Type (TS-ESLint) TS.SUGGESTION.PRTT
Prefer String Starts Ends With (TS-ESLint) TS.SUGGESTION.PSSEW
Prefer Ts Expect Error (TS-ESLint) TS.PROBLEM.PTEE
Prefer for of (TS-ESLint) TS.SUGGESTION.PFO
Promise Function Async (TS-ESLint) TS.SUGGESTION.PFA
Quotes (TS-ESLint) TS.LAYOUT.QUOTES
Require Array Sort Compare (TS-ESLint) TS.PROBLEM.RASC
Require Await (TS-ESLint) TS.SUGGESTION.RA
Restrict Plus Operands (TS-ESLint) TS.PROBLEM.RPO
Restrict Template Expressions (TS-ESLint) TS.PROBLEM.RTE
Return Await (TS-ESLint) TS.PROBLEM.RA
Semi (TS-ESLint) TS.LAYOUT.SEMI
Sort Type Constituents (TS-ESLint) TS.SUGGESTION.STC
Space Before Blocks (TS-ESLint) TS.LAYOUT.SBB
Space Before Function Paren (TS-ESLint) TS.LAYOUT.SBFP
Space Infix Ops (TS-ESLint) TS.LAYOUT.SIO
Strict Boolean Expressions (TS-ESLint) TS.SUGGESTION.SBE
Switch Exhaustiveness Check (TS-ESLint) TS.SUGGESTION.SEC
Triple Slash Reference (TS-ESLint) TS.SUGGESTION.TSR
Type Annotation Spacing (TS-ESLint) TS.LAYOUT.TAS
Typedef (TS-ESLint) TS.SUGGESTION.TYPEDEF
Unbound Method (TS-ESLint) TS.PROBLEM.UM
Unified Signatures (TS-ESLint) TS.SUGGESTION.US

Enabling and Disabling

You have multiple degrees of control over reporting for the warnings issued by ESLint, including when it is used with typescript-eslint.

 

To report problems with this documentation, please visit https://support.codesecure.com/.