BACK TO LIST

JavaScript rules

The Codiga Static Analysis engine checks JavaScript 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.

@typescript-eslint/ban-ts-comment

Best practice
Error

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

Learn more

@typescript-eslint/ban-types

Best practice
Error

Bans specific types and can suggest alternatives (such as String).

@typescript-eslint/explicit-function-return-type

Best practice
Error

Ensure that the values returned from functions are of the expected type

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

Safety
Error

Ensure that the values returned from a module are of the expected type

@typescript-eslint/naming-convention

Code style
Error

Enforces naming conventions for everything across a codebase, in the settings verify if the naming-convention is camelCase, snake_case, etc.

@typescript-eslint/no-empty-function

Best practice
Error

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

@typescript-eslint/no-unsafe-assignment

Safety
Error

Disallows assigning any to variables and properties as it creates a potential safety hole, and source of bugs in your codebase.

@typescript-eslint/no-unsafe-call

Safety
Error

Disallows calling an any type value as it creates a potential safety hole, and source of bugs in your codebase.

@typescript-eslint/no-unsafe-member-access

Safety
Error

Disallows member access on any typed variables as it creates a potential safety hole, and source of bugs in your codebase.

@typescript-eslint/no-unused-expressions

Best practice
Error

Disallow unused expressions. An unused expression which has no effect on the state of the program indicates a logic error.

@typescript-eslint/no-unused-vars

Best practice
Error

Disallow unused variables. Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring

@typescript-eslint/no-var-requires

Best practice
Error

Disallows the use of require statements except in import statements

@typescript-eslint/unbound-method

Safety
Error

Warns when a method is used outside of a method call.

compat/compat

Best practice
Error

This rule enables linting your code for browser compatibility.

constructor-super

Best practice
Error

Constructors of derived classes must call super()

eslint-comments/no-unused-disable

Best practice
Error

Disallow unused eslint-disable comments. Make sure all your rules are defined and are used correctly.

flowtype/no-weak-types

Safety
Error

Warns against weak type annotations any, Object and Function.

for-direction

Error prone
Error

Enforce "for" loop update clause moving the counter in the right direction.

getter-return

Error prone
Error

Enforces that a return statement is present in property getters

import/unambiguous

Security
Error

Warn if a module could be mistakenly parsed as a script by a consumer leveraging Unambiguous JavaScript Grammar to determine correct parsing goal.

jsx-a11y/click-events-have-key-events

Best practice
Error

Enforce onClick is accompanied by at least one of the following: onKeyUp, onKeyDown, onKeyPress

jsx-a11y/no-static-element-interactions

Best practice
Error

Disallow interactions in static elements. Static HTML elements do not have semantic meaning.

key-spacing

Code style
Error

Enforce consistent spacing between keys and values in object literal properties

max-statements

Best practice
Error

Check max number of statements for a function

mocha/prefer-arrow-callback

Unknown
Error

Definition for rule 'mocha/prefer-arrow-callback' was not found.

no-class-assign

Code style
Error

RegistrationForm' is a class.

no-compare-neg-zero

Error prone
Error

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

no-const-assign

Code style
Error

Disallows assigning values to const as they're immutable.

no-control-regex

Error prone
Error

Control characters are special, invisible characters in the ASCII range 0-31. These characters are rarely used in JavaScript strings so a regular expression containing these characters is most likely a mistake.

no-dupe-class-members

Code style
Error

Disallow duplicate name in class members

no-dupe-else-if

Error prone
Error

Disallow duplicate conditions in if-else-if chains

no-dupe-keys

Error prone
Error

Disallow duplicate keys in object literals

no-duplicate-case

Error prone
Error

If a switch statement has duplicate test expressions in case clauses, it is likely that a programmer copied a case clause but forgot to change the test expression.

no-empty-pattern

Best practice
Error

Disallow empty destructuring patterns

no-func-assign

Error prone
Error

Disallow reassigning function declarations

no-global-assign

Best practice
Error

Disallow assignment to native objects or read-only global variables

no-inner-declarations

Error prone
Error

Disallow variable or function declarations in nested blocks

no-irregular-whitespace

Error prone
Error

Irregular whitespace not allowed.

no-misleading-character-class

Error prone
Error

Disallow characters which are made with multiple code points in character class syntax

no-prototype-builtins

Error prone
Error

Disallow use of Object.prototypes builtins directly

no-redeclare

Best practice
Error

Disallow variable redeclaration

no-regex-spaces

Error prone
Error

Disallow multiple spaces in regular expression literals

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-setter-return

Error prone
Error

Setter cannot return a value.

no-shadow-restricted-names

Code style
Error

Disallow shadowing of restricted names

no-unexpected-multiline

Error prone
Error

Disallow confusing multiline expressions

no-unreachable

Error prone
Error

Disallow unreachable code after return, throw, continue, and break statements

no-unsafe-finally

Error prone
Error

Disallow control flow statements in finally blocks

no-unsafe-negation

Error prone
Error

Disallow negating the left operand of relational operators

no-unused-labels

Best practice
Error

Disallow unused labels. Labels that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring.

no-unused-vars

Code style
Error

Disallow unused variables. Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring

no-useless-catch

Best practice
Error

Disallow unnecessary catch clauses

no-useless-escape

Best practice
Error

Reports unnecessary escapes, as escaping non-special characters in strings, template literals, and regular expressions doesn't have any effect.

node/no-deprecated-api

Best practice
Error

Disallow deprecated APIs

node/no-missing-require

Error prone
Error

Disallow require() expressions which import non-existence modules

promise/catch-or-return

Safety
Error

Ensure that each time a then() is applied to a promise, a catch() is applied as well. Exceptions are made if you are returning that promise.

promise/prefer-await-to-then

Performance
Error

Use async/await style for managing concurrency instead of .then()

react-hooks/rules-of-hooks

Best practice
Error

React: Detects when rules of hooks are not being followed

react-internal/no-production-logging

Unknown
Error

React: Disallow internal logging when running in production

react-native/no-color-literals

Best practice
Error

React: Disallow color literals in styles

react-native/no-inline-styles

Unknown
Error

React: Styles should be defined in css blocks and not as inline of the web component or element

react/destructuring-assignment

Best practice
Error

React: Enforce consistent usage of destructuring assignment of props, state, and context

react/display-name

Best practice
Error

Prevent missing displayName in a React component definition

react/forbid-prop-types

Best practice
Error

React: By default this rule prevents vague prop types with more specific alternatives available (any, array, object), but any prop type can be disabled if desired.

react/jsx-key

Error prone
Error

React: Warn if an element that likely requires a key prop--namely, one present in an array literal or an arrow function expression.

react/jsx-no-duplicate-props

Error prone
Error

React: No duplicate props allowed

react/jsx-no-target-blank

Best practice
Error

React: This rules requires that you accompany target='\_blank' attributes with rel='noreferrer'.

react/jsx-no-undef

Error prone
Error

React: Detects potential ReferenceErrors resulting from misspellings or missing components.

react/no-array-index-key

Unknown
Error

React: Prevent usage of Array index in keys

react/no-children-prop

Best practice
Error

React: Prevent passing of children as props. Children should always be actual children, not passed in as a prop.

react/no-danger

Unknown
Error

React: Prevent usage of dangerous JSX properties

react/no-deprecated

Best practice
Error

React: Prevent usage of deprecated methods

react/no-direct-mutation-state

Error prone
Error

React: NEVER mutate this.state directly, as calling setState() afterwards may replace the mutation you made. Treat this.state as if it were immutable.

react/no-find-dom-node

Best practice
Error

React: Prevent usage of findDOMNode. Facebook will eventually deprecate findDOMNode as it blocks certain improvements in React in the future.

react/no-render-return-value

Best practice
Error

React: Prevent usage of the return value of ReactDOM.render

react/no-string-refs

Best practice
Error

React: Prevent using string references

react/no-unescaped-entities

Error prone
Error

React: Prevent invalid characters from appearing in markup

react/no-unknown-property

Error prone
Error

React: Prevent usage of unknown DOM property

react/prop-types

Best practice
Error

React: Prevent missing props validation in a React component definition

react/require-default-props

Best practice
Error

React: Enforce a defaultProps definition for every prop that is not a required prop

react/require-render-return

Best practice
Error

React: Enforce ES5 or ES6 class for returning value in render function

react/sort-comp

Best practice
Error

React: Enforce component methods order

react/style-prop-object

Best practice
Error

React: Enforce style prop value being an object

require-yield

Code style
Error

Disallow generator functions that do not have yield

security/detect-non-literal-regexp

Security
Error

Detects RegExp(variable), which might allow an attacker to DOS your server with a long-running regular expression.

sonarjs/no-identical-functions

Best practice
Error

When two functions have the same implementation, either it was a mistake - something else was intended - or the duplication was intentional, but may be confusing to maintainers.

standard/no-callback-literal

Best practice
Error

When invoking a callback function which uses the Node.js error-first callback pattern, all of your errors should either use the Error class or a subclass of it. It is also acceptable to use undefined or null if there is no error.

unicorn/consistent-destructuring

Best practice
Error

Use destructured variables over properties

unicorn/prefer-exponentiation-operator

Best practice
Error

Disallow the use of Math.pow in favor of the ** operator

valid-typeof

Error prone
Error

Enforce comparing typeof expressions against valid strings

vue/no-reserved-keys

Best practice
Error

Vue: Disallow overwriting reserved keys in Vue

vue/no-side-effects-in-computed-properties

Best practice
Error

Vue: Disallow side effects in computed properties

xo/throw-new-error

Best practice
Error

Use the new keyword when throwing an error

We use cookies to improve your site experience, including analytics cookies to understand how you use our product and design better experiences. Please read our Cookie Policy.