facebook pixelCodiga Analysis TypeScript Rules
BACK TO LIST

TypeScript rules

The Codiga Static Analysis engine checks TypeScript code and supports many popular libraries. If you are using React, NextJS, Vue or Angular: the engine will flag any issue in your codebase. Automate your code reviews with Codiga and merge with confidence.

@angular-eslint/component-class-suffix

Code style
High

Detect if component doesn't have a descriptive suffix depending on its use, such as Component, Directive, Module, Pipe, or Service

Learn more

@angular-eslint/component-selector

Unknown
High

Detect if component selector isn't a hyphenated, lowercase value or doesn't have a descriptive prefix to represent the feature area or the application itself.

@angular-eslint/directive-selector

Best practice
High

Detect if directive selector isn't a hyphenated, lowercase value or doesn't have a descriptive prefix to represent the feature area or the application itself.

@angular-eslint/no-empty-lifecycle-method

Design
High

Detect empty lifecycle methods

@angular-eslint/no-output-on-prefix

Best practice
High

Prevent any Output values with prefix 'on' as this prefix should be used only for event handler methods to follow web conventions

@angular-eslint/prefer-on-push-component-change-detection

Design
High

Prefer ChangeDetectionStrategy.OnPush as the changeDetection strategy for your @Component

@angular-eslint/use-component-view-encapsulation

Design
High

Detect any component encapsulation that is ViewEncapsulation.None. It should be either ViewEncapsulation.ShadowDom or ViewEncapsulation.Emulated

@angular-eslint/use-lifecycle-interface

Design
High

Detect if there are missing any implements keyword for every lifecycle hook you use (e.g if using the lifecycle method ngAfterViewInit, the AfterViewInit interface should be implemented)

@next/next/link-passhref

Best practice
High

Detect any <Link> without an <a> child, they should have passHref=true parameter

@next/next/no-img-element

Best practice
High

Detect any native <img> element, it should be replaced by the <Image /> component

@no-var-requires

Best practice
High

Detect the assignation of a require import to a var such as 'var module = require("module")'.

@typescript-eslint/adjacent-overload-signatures

Best practice
High

Require that member overloads be consecutive.

@typescript-eslint/ban-ts-comment

Best practice
Critical

Detect any @ts-<directive> comment as it can reduce the effectiveness of TypeScript overall.

@typescript-eslint/ban-types

Best practice
High

Detect any types that are banned (such as String).

@typescript-eslint/camelcase

Code style
Medium

Detect all values and method definitions that do not use camelCase, they should.

@typescript-eslint/class-name-casing

Code style
Medium

Detect all classes and interfaces that do not follow the PascalCased name convention

@typescript-eslint/explicit-module-boundary-types

Code style
Medium

Detect if not all function types for arguments and return values are specified in the function signature

@typescript-eslint/interface-name-prefix

Code style
Minor

Detect interfaces that are not prefixed with "I" to differenciate them from regular classes. (e.g ISomeInterface as oposed to SomeInterface)

@typescript-eslint/no-empty-function

Best practice
High

Detect any empty methods, as in methods that do not have any logic

@typescript-eslint/no-explicit-any

Best practice
Medium

Detect any explicit "any" type, it should be replaced by another specific valid type (e.g string, number, boolean)

@typescript-eslint/no-extra-non-null-assertion

Best practice
High

Detect extra null assertions, there should be just a single null assertion in a expression

@typescript-eslint/no-inferrable-types

Best practice
High

Detect any explicit types that can easily be inferred by the compiler

@typescript-eslint/no-misused-new

Best practice
High

Detect any interfaces that are being initialized with "new", as only classes should be initialized with "new"

@typescript-eslint/no-namespace

Best practice
High

Disallow the use of custom TypeScript modules and namespaces

@typescript-eslint/no-non-null-asserted-optional-chain

Error prone
High

Disallows using a non-null assertion after an optional chain expression

@typescript-eslint/no-non-null-assertion

Best practice
Medium

Detect all non-null assertions as they cancel the benefits of strict null-checking mode

@typescript-eslint/no-this-alias

Best practice
High

Disallow aliasing this

@typescript-eslint/no-unused-vars

Safety
Medium

Detect all defined variables (e.g "var foo = true") that are not being used somewhere else

@typescript-eslint/no-var-requires

Best practice
Medium

Disallows the use of require statements except in import statements.

@typescript-eslint/prefer-as-const

Best practice
Critical

This rule recommends usage of const assertion when type primitive value is equal to type.

@typescript-eslint/prefer-namespace-keyword

Best practice
Medium

Use 'namespace' instead of 'module' to declare custom TypeScript modules.

@typescript-eslint/triple-slash-reference

Code style
Medium

Detect any triple slash reference definitions in the top of the file, they should be replaced by the import style (e.g replace "/// <reference path="foo" />" by "import * as foo from 'foo';")

fp/no-let

Best practice
Minor

Forbid the use of let

fp/no-mutating-assign

Best practice
High

Forbid the use of Object.assign() with a variable as first argument

fp/no-mutating-methods

Best practice
Medium

Forbid the use of mutating methods

fp/no-mutation

Best practice
High

Forbid the use of mutating operators

fp/no-rest-parameters

Best practice
High

Forbid the use of rest parameters

fp/no-throw

Best practice
High

Forbid the use of throw

import/dynamic-import-chunkname

Best practice
High

Detect missing webpackChunkName in any dynamic imports

import/export

Best practice
High

Detect any error with your imports and exports, like more than one default export or redundant imports.

import/first

Best practice
High

Detect non-import statements before an import statement

import/max-dependencies

Design
High

Detect if there are too many dependencies in one module according to settings

import/no-cycle

Error prone
High

Detect dependency cycles from your project as in two modules depending on each other

import/no-default-export

Best practice
Medium

Prohibit default exports.

import/no-duplicates

Best practice
Medium

Detect any duplicate imports

import/no-extraneous-dependencies

Best practice
Medium

Forbid the import of external modules that are not declared in the package.json's dependencies, devDependencies, optionalDependencies, peerDependencies, or bundledDependencies.

import/no-named-as-default

Best practice
High

Reports use of an exported name as the locally imported name of a default export.

import/no-named-default

Best practice
High

Reports use of a default export as a locally named import.

import/no-namespace

Code style
High

Enforce a convention of not using namespace (a.k.a. "wildcard" *) imports.

import/no-unassigned-import

Error prone
Medium

Aims to remove modules with side-effects by reporting when a module is imported but not assigned.

import/prefer-default-export

Code style
Medium

When there is only a single export from a module, prefer using default export over named export.

insecure-random

Security
Critical

Detects insecure generation of random data (e.g Math.random())

jest/no-disabled-tests

Best practice
High

Disallow disabled tests

jest/no-done-callback

Best practice
High

Avoid using a callback in asynchronous tests and hooks (no-done-callback)

jest/no-restricted-matchers

Best practice
High

Disallow specific matchers & modifiers.

jest/prefer-called-with

Best practice
High

Suggest using toBeCalledWith() or toHaveBeenCalledWith()

jest/prefer-spy-on

Best practice
Medium

Suggest using jest.spyOn()

jest/require-top-level-describe

Best practice
High

Require test cases and hooks to be inside a describe block

jsx-a11y/aria-proptypes

Best practice
High

ARIA state and property values must be valid.

jsx-a11y/no-autofocus

Best practice
High

Enforce that autoFocus prop is not used on elements. Autofocusing elements can cause usability issues for sighted and non-sighted users, alike.

jsx-a11y/role-supports-aria-props

Best practice
High

Enforce that elements with explicit or implicit roles defined contain only aria-* properties supported by that role.

no-async-promise-executor

Error prone
High

Promise executor functions should not be async.

no-case-declarations

Best practice
High

Disallows lexical declarations (let, const, function and class) in case/default clauses.

no-compare-neg-zero

Error prone
High

Detect the use of operator (e.g <=, <, ===, etc) to compare against -0.

no-constant-condition

Error prone
High

Disallows constant expressions in the test condition of: if, for, while, do...while, or ternary operations (?:)

no-control-regex

Error prone
High

Disallow control characters in regular expressions.

no-debugger

Error prone
High

Detects any debugger statement

no-empty

Error prone
High

Disallow empty block statements.

no-empty-pattern

Best practice
High

Disallow empty destructuring patterns

no-extra-boolean-cast

Error prone
High

Disallows unnecessary boolean casts.

no-mixed-spaces-and-tabs

Code style
High

Detects when there are mixed spaces and tabs in a module definition

no-prototype-builtins

Error prone
High

Disallows calling some Object.prototype methods directly on object instances.

no-self-assign

Best practice
High

Detects self assignments as they have no effect, so probably those are an error due to incomplete refactoring.

no-sparse-arrays

Error prone
High

Disallows sparse array literals which have "holes" where commas are not preceded by elements.

no-useless-catch

Best practice
High

Reports catch clauses that only throw the caught error.

no-useless-escape

Best practice
High

Disallow unnecessary escape usage

no-var

Code style
High

Disallows var definition

prefer-const

Code style
High

Suggest using const instead of var or let

prefer-rest-params

Code style
High

Suggest using the rest parameters instead of arguments

prefer-spread

Code style
High

Suggest using spread syntax instead of .apply()

react-hooks/exhaustive-deps

Best practice
High

Incorrect use of hooks

react-native/no-raw-text

Best practice
High

Detect raw text outside of Text component

react/display-name

Best practice
High

Component definition is missing display name

react/forbid-component-props

Best practice
High

By default this rule prevents passing of props that add lots of complexity (className, style) to Components.

react/jsx-boolean-value

Best practice
High

Enforce boolean attributes notation in JSX

react/jsx-key

Error prone
High

Detect missing key prop

react/jsx-no-bind

Performance
High

Disallows .bind() or Arrow Functions in JSX Props as it can be bad for performance

react/jsx-no-comment-textnodes

Error prone
High

Prevents comment strings (e.g. beginning with // or /*) from being accidentally injected as a text node in JSX statements.

react/jsx-no-literals

Best practice
High

Disallow the usage of string literals inside JSX components

react/jsx-no-undef

Error prone
High

Disallow undeclared variables in JSX

react/jsx-no-useless-fragment

Performance
High

Disallow unnecessary fragments

react/jsx-props-no-spreading

Best practice
High

Disallow JSX props spreading

react/no-children-prop

Best practice
High

Prevent passing of children as props

react/no-did-update-set-state

Performance
High

Prevent usage of setState in componentDidUpdate

react/no-multi-comp

Best practice
High

Prevent multiple component definition per file. Declaring only one component per file improves readability and reusability of components.

react/no-unescaped-entities

Error prone
High

Prevent invalid characters from appearing in markup

react/no-unknown-property

Safety
High

Prevent usage of unknown DOM property

react/no-unused-prop-types

Best practice
Medium

Prevent definitions of unused propTypes

react/prop-types

Best practice
High

Prevent missing props validation in a React component definition

react/react-in-jsx-scope

Error prone
High

Prevent missing React when using JSX

typescript/interface-name-prefix

Code style
Minor

Require that interface names be prefixed with "I".

unicorn/no-array-reduce

Performance
High

Disallow Array#reduce() and Array#reduceRight() as usually result in hard-to-read and less performant code.

unicorn/no-null

Best practice
High

Disallow the use of the null literal.

@typescript-eslint/no-extra-semi

Best practice
Minor

Unnecessary semicolon.

no-unsafe-optional-chaining

Best practice
Medium

Disallow use of optional chaining in contexts where the undefined value is not allowed

@typescript-eslint/no-empty-interface

Design
Medium

An interface declaring no members is equivalent to its supertype.

@typescript-eslint/no-unnecessary-type-constraint

Design
Medium

Disallows unnecessary constraints on generic types

no-fallthrough

Error prone
High

Incorrect handling of switch

@next/next/no-page-custom-font

Performance
Medium

The custom font you're adding was added to a separate component within Document - this disables automatic font optimization.

vue/no-deprecated-data-object-declaration

Best practice
High

Disallow using deprecated object declaration on data

@next/next/next-script-for-ga

Safety
Medium

Use the `next/script` component for loading third party scripts

@next/next/google-font-display

Best practice
Medium

Display parameter is missing

import/no-anonymous-default-export

Error prone
Medium

Assign object to a variable before exporting as module default

no-cond-assign

Best practice
Medium

Expected a conditional expression and instead saw an assignment

jsx-a11y/alt-text

Best practice
High

Image elements must have an alt prop, either with meaningful text, or an empty string for decorative images.

@typescript-eslint/no-array-constructor

Best practice
Minor

Disallows Array constructors.

@next/next/no-head-element

Best practice
Medium

Do not use <head>. Use Head from 'next/head' instead.

@typescript-eslint/no-loss-of-precision

Error prone
High

Disallows literal numbers that lose precision.

vue/multi-word-component-names

Code style
Medium

Component nam should always be multi-word

no-ex-assign

Best practice
Medium

Do not assign to the exception parameter.

@next/next/no-server-import-in-page

Best practice
Medium

Prevent usage of next/server outside of middleware.js.

@next/next/no-sync-scripts

Performance
High

Synchronous scripts should not be used

@next/next/no-before-interactive-script-outside-document

Best practice
Medium

`next/script`'s `beforeInteractive` strategy should not be used outside of `pages/_document.js`

vue/component-definition-name-casing

Code style
Medium

Enforce specific casing for component definition name

@next/next/inline-script-id

Best practice
High

`next/script` components with inline content must specify an `id` attribute.