facebook pixelCodiga Analysis TypeScript Rules, category best practice
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/directive-selector

Best practice
Error

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.

Learn more

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

Best practice
Error

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

@next/next/link-passhref

Best practice
Error

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

@next/next/no-img-element

Best practice
Error

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

@no-var-requires

Best practice
Error

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

@typescript-eslint/adjacent-overload-signatures

Best practice
Error

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
Error

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

@typescript-eslint/no-empty-function

Best practice
Error

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

@typescript-eslint/no-explicit-any

Best practice
Warning

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
Error

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

@typescript-eslint/no-inferrable-types

Best practice
Error

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

@typescript-eslint/no-misused-new

Best practice
Error

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

@typescript-eslint/no-namespace

Best practice
Error

Disallow the use of custom TypeScript modules and namespaces

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

Best practice
Warning

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

@typescript-eslint/no-this-alias

Best practice
Error

Disallow aliasing this

@typescript-eslint/no-var-requires

Best practice
Warning

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
Warning

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

fp/no-let

Best practice
Informational

Forbid the use of let

fp/no-mutating-assign

Best practice
Error

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

fp/no-mutating-methods

Best practice
Warning

Forbid the use of mutating methods

fp/no-mutation

Best practice
Error

Forbid the use of mutating operators

fp/no-rest-parameters

Best practice
Error

Forbid the use of rest parameters

fp/no-throw

Best practice
Error

Forbid the use of throw

import/dynamic-import-chunkname

Best practice
Error

Detect missing webpackChunkName in any dynamic imports

import/export

Best practice
Error

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

import/first

Best practice
Error

Detect non-import statements before an import statement

import/no-default-export

Best practice
Warning

Prohibit default exports.

import/no-duplicates

Best practice
Warning

Detect any duplicate imports

import/no-extraneous-dependencies

Best practice
Warning

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
Error

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

import/no-named-default

Best practice
Error

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

jest/no-disabled-tests

Best practice
Error

Disallow disabled tests

jest/no-done-callback

Best practice
Error

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

jest/no-restricted-matchers

Best practice
Error

Disallow specific matchers & modifiers.

jest/prefer-called-with

Best practice
Error

Suggest using toBeCalledWith() or toHaveBeenCalledWith()

jest/prefer-spy-on

Best practice
Warning

Suggest using jest.spyOn()

jest/require-top-level-describe

Best practice
Error

Require test cases and hooks to be inside a describe block

jsx-a11y/aria-proptypes

Best practice
Error

ARIA state and property values must be valid.

jsx-a11y/no-autofocus

Best practice
Error

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
Error

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

no-case-declarations

Best practice
Error

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

no-empty-pattern

Best practice
Error

Disallow empty destructuring patterns

no-self-assign

Best practice
Error

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

no-useless-catch

Best practice
Error

Reports catch clauses that only throw the caught error.

no-useless-escape

Best practice
Error

Disallow unnecessary escape usage

react-hooks/exhaustive-deps

Best practice
Error

Incorrect use of hooks

react-native/no-raw-text

Best practice
Error

Detect raw text outside of Text component

react/display-name

Best practice
Error

Component definition is missing display name

react/forbid-component-props

Best practice
Error

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

react/jsx-boolean-value

Best practice
Error

Enforce boolean attributes notation in JSX

react/jsx-no-literals

Best practice
Error

Disallow the usage of string literals inside JSX components

react/jsx-props-no-spreading

Best practice
Error

Disallow JSX props spreading

react/no-children-prop

Best practice
Error

Prevent passing of children as props

react/no-multi-comp

Best practice
Error

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

react/no-unused-prop-types

Best practice
Warning

Prevent definitions of unused propTypes

react/prop-types

Best practice
Error

Prevent missing props validation in a React component definition

unicorn/no-null

Best practice
Error

Disallow the use of the null literal.

@typescript-eslint/no-extra-semi

Best practice
Informational

Unnecessary semicolon.

no-unsafe-optional-chaining

Best practice
Warning

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

vue/no-deprecated-data-object-declaration

Best practice
Error

Disallow using deprecated object declaration on data

@next/next/google-font-display

Best practice
Warning

Display parameter is missing

no-cond-assign

Best practice
Warning

Expected a conditional expression and instead saw an assignment

jsx-a11y/alt-text

Best practice
Error

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
Informational

Disallows Array constructors.

@next/next/no-head-element

Best practice
Warning

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

no-ex-assign

Best practice
Warning

Do not assign to the exception parameter.

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

Best practice
Warning

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

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

Best practice
Warning

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

@next/next/inline-script-id

Best practice
Error

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

vue/require-default-prop

Best practice
Error

This rule requires default value to be set for each props that are not marked as required.

vue/require-prop-types

Best practice
Error

This rule enforces that a props statement contains type definition.