Skip to content

ESLint core, Import, and RegExp ​

This page documents 123 rules from the current dependency versions and repository configuration. Each entry includes effective severity, scope, upstream description, common messages, and incorrect/correct examples.

Explicit repository rules (69 rules) ​

array-callback-return ​

Array callbacks must return values on all reachable branches, preventing map/filter calls from silently producing undefined.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: {{arrayMethodName}}() expects a value to be returned at the end of {{name}}.; {{arrayMethodName}}() expects a return value from {{name}}.; {{arrayMethodName}}() expects no useless return value from {{name}}.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
items.map((item) => { item.id; });

Correct:

js
items.map((item) => item.id);

camelcase ​

Use camelCase for variables and types; object properties may preserve external protocol field names.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Identifier '{{name}}' is not in camel case.; #{{name}} is not in camel case.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const user_name = "Fast";

Correct:

js
const userName = "Fast";
const payload = { user_name: userName };

curly ​

Simple single-line branches may omit braces; multiline branches require braces, consistently within a conditional chain.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Expected { after '{{name}}'.; Expected { after '{{name}}' condition.; Unnecessary { after '{{name}}'.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
if (ready)
	start();
	log();

Correct:

js
if (ready) {
	start();
	log();
}

default-case-last ​

A default branch is optional, but when present must follow all cases.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Default clause should be the last clause.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
switch (status) { default: reset(); break; case "ready": start(); }

Correct:

js
switch (status) { case "ready": start(); break; default: reset(); }

eqeqeq ​

Requires strict equality while allowing value == null to check both null and undefined.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Expected '{{expectedOperator}}' and instead saw '{{actualOperator}}'.; Use '{{expectedOperator}}' instead of '{{actualOperator}}'.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
if (count == 0) reset();

Correct:

js
if (count === 0) reset();
if (value == null) useFallback();

import-x/default ​

Static analysis of default exports can give false positives without a resolver.

  • Effective severity and scope: disabled by default through an explicit local override
  • Disabled in: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: No default export found in imported module "{{module}}".
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
import api from "./named-only.js";

Correct:

js
import { api } from "./named-only.js";

import-x/first ​

Imports must precede other statements.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Absolute imports should come before relative imports.; Import in body of module; reorder to top.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
initialize();
import { api } from "./api";

Correct:

js
import { api } from "./api";
initialize(api);

import-x/named ​

Static analysis of named exports can give false positives without a resolver.

  • Effective severity and scope: disabled by default through an explicit local override
  • Disabled in: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: {{name}} not found in '{{path}}'; {{name}} not found via {{deepPath}}
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
import { missing } from "./api.js";

Correct:

js
import { request } from "./api.js";

import-x/namespace ​

Static analysis of namespace exports can give false positives without a resolver.

  • Effective severity and scope: disabled by default through an explicit local override
  • Disabled in: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: No exported names found in module '{{module}}'.; Unable to validate computed reference to imported namespace '{{namespace}}'.; Assignment to member of namespace '{{namespace}}'.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
import * as api from "./api.js";
api.missing();

Correct:

js
import * as api from "./api.js";
api.request();

import-x/no-duplicates ​

Merge duplicate imports from the same module to keep bindings and side effects clear.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: '{{module}}' imported multiple times.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
import { readFile } from "node:fs";
import { writeFile } from "node:fs";

Correct:

js
import { readFile, writeFile } from "node:fs";

import-x/no-named-as-default ​

Does not restrict modules exporting both a default value and similarly named exports.

  • Effective severity and scope: disabled by default through an explicit local override
  • Disabled in: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Using exported name '{{name}}' as identifier for default export.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
import request from "./request.js";
request();

Correct:

js
import { request } from "./request.js";
request();

import-x/no-named-as-default-member ​

Does not restrict accessing same-named properties through default imports.

  • Effective severity and scope: disabled by default through an explicit local override
  • Disabled in: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Caution: '{{objectName}}' also has a named export '{{propName}}'. Check if you meant to write 'import {{{propName}}} from '{{sourcePath}}'' instead.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
import api from "./api.js";
api.request();

Correct:

js
import { request } from "./api.js";
request();

import-x/no-unresolved ​

Project resolvers validate Vite and TypeScript aliases; the shared config does not require a specific resolver.

  • Effective severity and scope: disabled by default through an explicit local override
  • Disabled in: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unable to resolve path to module '{{module}}'.; Casing of {{module}} does not match the underlying filesystem.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
import value from "./missing.js";

Correct:

js
import value from "./value.js";

import-x/order ​

Groups and sorts imports by source; ESLint can fix ordering.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: {{error}}; There should be no empty line within import group; There should be no empty line between import groups
  • Example type: Direct code example for an explicit repository rule

Incorrect:

ts
import { local } from "./local";
import path from "node:path";
import { ref } from "vue";

Correct:

ts
import path from "node:path";
import { ref } from "vue";
import { local } from "./local";

import-x/style-imports-last ​

Style imports form the last contiguous group. No autofix is offered because reordering could change CSS cascade behavior.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Not provided
  • Common messages: Style import '{{source}}' must occur after all non-style imports.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

ts
import "./app.css";
import { createApp } from "vue";

Correct:

ts
import { createApp } from "vue";
import "./app.css";

logical-assignment-operators ​

Uses equivalent ||=, &&=, and ??= assignments, including corresponding if-assignment forms.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Assignment (=) can be replaced with operator assignment ({{operator}}).; Convert this assignment to use the operator {{ operator }}.; Logical expression can be replaced with an assignment ({{ operator }}).
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
options.timeout = options.timeout || 3000;

Correct:

js
options.timeout ||= 3000;

no-alert ​

Browser dialogs warn rather than error, allowing prototypes while making production review visible.

  • Effective severity and scope: warn: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected {{name}}.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
alert("Saved");

Correct:

js
showMessage("Saved");

no-case-declarations ​

Switch cases do not create lexical scopes; wrap declarations in braces to prevent cross-case conflicts.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Add {} brackets around the case block.; Unexpected lexical declaration in case block.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
switch (kind) { case "user": const name = getName(); use(name); break; }

Correct:

js
switch (kind) { case "user": { const name = getName(); use(name); break; } }

no-console ​

Build, test, and CLI scripts may write progress and diagnostics to the terminal.

  • Effective severity and scope: warn: JavaScript base, Vue SFC, Vue JSX, UniApp NVue, React JSX, Angular TypeScript, Lodash, Lodash Unified
  • Disabled in: TypeScript base, Framework-neutral TSX, Vue TSX, UniApp TSX, React TSX
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected console statement.; Unexpected console statement. Only these console methods are allowed: {{ allowed }}.; Remove the console.{{ propertyName }}().
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
console.log("debug");

Correct:

js
console.warn("retrying");
console.error(error);

no-constant-condition ​

Disallows accidental constant conditions while permitting loops such as while(true) with explicit exit logic.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected constant condition.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
if (true) start();

Correct:

js
if (ready) start();

no-control-regex ​

Control characters often indicate copying or encoding errors; use recognizable escapes.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected control character(s) in regular expression: {{controlChars}}.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const separator = /\x00/;

Correct:

js
const separator = String.fromCharCode(0);

no-debugger ​

Prevents debugger statements from interrupting released code.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected 'debugger' statement.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
debugger;
start();

Correct:

js
start();

no-empty ​

Allows an empty catch explicitly ignoring failure; other empty blocks are treated as omissions.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Empty {{type}} statement.; Add comment inside empty {{type}} statement.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
if (ready) {}

Correct:

js
try { connect(); } catch {}

no-eval ​

Disallows dynamic execution of string code to prevent injection and preserve static analysis.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: 'eval' can be harmful.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
eval("run()")

Correct:

js
run()

no-implied-eval ​

Disallows string-based code execution through timers and similar APIs.

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Disabled in: TypeScript base, Framework-neutral TSX, Vue SFC, Vue TSX, UniApp NVue, UniApp TSX, React TSX, Angular TypeScript
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Implied eval. Consider passing a function instead of a string.; Implied eval. Do not use execScript().
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
setTimeout("refresh()", 1000);

Correct:

js
setTimeout(() => refresh(), 1000);

no-irregular-whitespace ​

Disallows unusual whitespace that is hard to review or may alter parsing.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Irregular whitespace not allowed.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const value = 1;

Correct:

js
const value = 1;

no-misleading-character-class ​

Unicode combining characters can make character-class matches differ from visual expectations.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected surrogate pair in character class. Use 'u' flag.; Unexpected surrogate pair in character class.; Unexpected combined character in character class.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const emoji = /[👍]/;

Correct:

js
const emoji = /[👍]/u;

no-multi-str ​

Disallows backslash-continued strings; prefer template strings.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Multiline support is limited to browsers supporting ES5 only.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const message = "first\
second";

Correct:

js
const message = "first" +
	"second";

no-new-func ​

Disallows Function-constructor compilation of strings, which bypasses static analysis and security policies.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: The Function constructor is eval.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const add = new Function("left", "right", "return left + right");

Correct:

js
const add = (left, right) => left + right;

no-promise-executor-return ​

Promise executor return values are ignored; return must not be mistaken for Promise resolution.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Return values from promise executor functions cannot be read.; Prepend 'void' to the expression.; Wrap the expression in '{}'.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const value = new Promise((resolve) => resolve(1));

Correct:

js
const value = new Promise((resolve) => { resolve(1); });

no-redeclare ​

The TypeScript extension understands overloads and declaration merging; the core redeclaration rule is disabled to avoid false positives.

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Disabled in: TypeScript base, Framework-neutral TSX, Vue SFC, Vue TSX, UniApp NVue, UniApp TSX, React TSX, Angular TypeScript
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{id}}' is already defined.; '{{id}}' is already defined as a built-in global variable.; '{{id}}' is already defined by a variable declaration.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
var value = 1;
var value = 2;

Correct:

js
let value = 1;
value = 2;

no-regex-spaces ​

Use quantifiers or explicit escapes for consecutive spaces in regular expressions.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Spaces are hard to count. Use {{{length}}}.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const words = /fast  china/;

Correct:

js
const words = /fast {2}china/;

no-restricted-imports ​

Do not mix lodash-es and lodash-unified; keep runtime and type sources consistent.

  • Effective severity and scope: error: Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{importSource}}' import is restricted from being used.; '{{importSource}}' import is restricted from being used. {{customMessage}}; '{{importSource}}' import is restricted from being used by a pattern.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
import debounce from "lodash-es/debounce";

Correct:

js
import debounce from "lodash/debounce";

no-restricted-syntax ​

Disallows labeled statements and with to avoid hard-to-follow jumps and dynamic name resolution.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: {{message}}
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
retryLoop: while (ready) { break retryLoop; }

Correct:

js
while (ready) { break; }

no-use-before-define ​

Declare variables and classes before use; function declaration hoisting is allowed.

  • Effective severity and scope: warn: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{name}}' was used before it was defined.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const value = load();
const load = () => 1;

Correct:

js
const load = () => 1;
const value = load();

no-var ​

Use let or const instead of var to avoid function-scope and loop-closure traps.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Unexpected var, use let or const instead.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
var count = 1;

Correct:

js
let count = 1;
const limit = 10;

no-void ​

Standalone createTypeScriptConfigs() also prohibits using the void operator to mark ignored Promises.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Expected 'undefined' and instead saw 'void'.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

ts
void save();

Correct:

ts
save();

no-with ​

With makes name resolution unpredictable and is unavailable in strict mode and ESM.

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Disabled in: TypeScript base, Framework-neutral TSX, Vue SFC, Vue TSX, UniApp NVue, UniApp TSX, React TSX, Angular TypeScript
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected use of 'with' statement.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
with (settings) { apply(theme); }

Correct:

js
apply(settings.theme);

object-shorthand ​

Use object shorthand for matching property/value names; quoted keys need not change.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Expected shorthand for all properties.; Expected longform method syntax for string literal keys.; Expected property shorthand.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const timeout = 1000;
const options = { timeout: timeout };

Correct:

js
const timeout = 1000;
const options = { timeout };

prefer-arrow-callback ​

Use arrows for callbacks not requiring dynamic this; ordinary functions with caller-bound this remain allowed.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Unexpected function expression.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
items.map(function (item) { return item.id; });

Correct:

js
items.map((item) => item.id);

prefer-const ​

Prefer const for unchanged bindings; avoid unreliable conclusions when reads precede assignment.

  • Effective severity and scope: warn: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: '{{name}}' is never reassigned. Use 'const' instead.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
let timeout = 3000;

Correct:

js
const timeout = 3000;

prefer-exponentiation-operator ​

Use the exponentiation operator instead of Math.pow.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Use the '**' operator instead of 'Math.pow'.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const area = Math.pow(size, 2);

Correct:

js
const area = size ** 2;

prefer-object-spread ​

Use object spread instead of Object.assign({}, source) when creating objects; calls mutating existing targets are unchanged.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Use an object spread instead of 'Object.assign' eg: '{ ...foo }'.; Use an object literal instead of 'Object.assign'. eg: '{ foo: bar }'.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const next = Object.assign({}, current, patch);

Correct:

js
const next = { ...current, ...patch };

prefer-rest-params ​

Use named rest parameters instead of arguments for explicit scope, real arrays, and type inference.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Use the rest parameters instead of 'arguments'.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
function join() { return Array.from(arguments).join(","); }

Correct:

js
function join(...values) { return values.join(","); }

prefer-spread ​

Prefer fn(...args) over apply for array-spread calls.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Use the spread operator instead of '.apply()'.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
items.push.apply(items, nextItems);

Correct:

js
items.push(...nextItems);

prefer-template ​

Use template strings for interpolation instead of concatenation with ambiguous conversions.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Unexpected string concatenation.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const name = "Fast";
const message = "Hello, " + name + "!";

Correct:

js
const name = "Fast";
const message = `Hello, ${name}!`;

regexp/confusing-quantifier ​

Adjacent quantifiers can be misleading; warnings request manual review.

  • Effective severity and scope: warn: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: This quantifier is confusing because its minimum is {{min}} but it can match the empty string. Maybe replace it with '{{proposal}}' to reflect that it can match the empty string?
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /(?:a*)+/;

Correct:

js
const pattern = /a*/;

regexp/no-contradiction-with-assertion ​

Assertions contradicting their contents cannot match as intended.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: The alternative {{ alt }} can never be entered because it contradicts with the assertion {{ assertion }}. Either change the alternative or assertion to resolve the contradiction.; The quantifier {{ quant }} can never be entered because its element contradicts with the assertion {{ assertion }}. Change or remove the quantifier or change the assertion to resolve the contradiction.; The quantifier {{ quant }} is always entered despite having a minimum of 0. This is because the assertion {{ assertion }} contradicts with the element(s) after the quantifier. Either set the minimum to 1 ({{ newQuant }}) or change the assertion.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /(?=a)b*/;

Correct:

js
const pattern = /(?=a)a+/;

regexp/no-dupe-characters-character-class ​

Duplicate character-class members usually indicate a typo or range-design error.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Unexpected duplicate {{duplicate}}.; Unexpected duplicate. {{duplicate}} is a duplicate of {{element}}.; {{subsetElement}} is already included in {{element}}.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /[aa-z]/;

Correct:

js
const pattern = /[a-z]/;

regexp/no-dupe-disjunctions ​

Duplicate or fully covered alternatives usually indicate missing conditions.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected duplicate alternative. This alternative can be removed.{{cap}}{{exp}}; Unexpected useless alternative. This alternative is a strict subset of {{others}} and can be removed.{{cap}}{{exp}}; Unexpected useless element. All paths of {{root}} that go through {{nested}} are a strict subset of {{others}}. This element can be removed.{{cap}}{{exp}}
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /(?:fast|fast)/;

Correct:

js
const pattern = /(?:fast|slow)/;

regexp/no-empty-alternative ​

Empty alternatives may be intentional, so they only warn.

  • Effective severity and scope: warn: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: This empty alternative might be a mistake. If not, use a quantifier instead.; Use a quantifier instead.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /(?:fast|)/;

Correct:

js
const pattern = /(?:fast|slow)/;

regexp/no-empty-capturing-group ​

Empty capturing groups capture no useful content.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected capture empty.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /()/;

Correct:

js
const pattern = /(fast)/;

regexp/no-empty-character-class ​

Empty character classes cannot match characters.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: This character class matches no characters because it is empty.; This character class cannot match any characters.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /[]/;

Correct:

js
const pattern = /[a-z]/;

regexp/no-empty-group ​

Empty groups usually indicate an editing omission.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected empty group.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /(?:)/;

Correct:

js
const pattern = /(?:fast)/;

regexp/no-empty-lookarounds-assertion ​

Empty lookarounds impose no useful constraints.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected empty {{kind}}. It will trivially {{result}} all inputs.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /(?=)fast/;

Correct:

js
const pattern = /(?=fast)fast/;

regexp/no-extra-lookaround-assertions ​

Unnecessary nested assertions can alter capture or backtracking boundaries.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: This {{kind}} assertion is useless and can be inlined.; This {{kind}} assertion is useless and can be converted into a group.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /(?=(?=fast))fast/;

Correct:

js
const pattern = /(?=fast)fast/;

regexp/no-invalid-regexp ​

Checks invalid syntax and flags in RegExp constructor strings and literals.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: {{message}}; Duplicate {{flag}} flag.; Regex 'u' and 'v' flags cannot be used together.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = new RegExp("[");

Correct:

js
const pattern = new RegExp("[a-z]");

regexp/no-invisible-character ​

Invisible characters can escape review and produce unexpected matches.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Unexpected invisible character. Use '{{instead}}' instead.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = //u;

Correct:

js
const pattern = /\u200B/u;

regexp/no-misleading-capturing-group ​

Misleading capture boundaries can break backreference and replacement expectations.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: {{quant}} can be removed because it is already included by {{cause}}. This makes the capturing group misleading, because it actually captures less text than its pattern suggests.; {{quant}} can be replaced with {{fix}} because of {{cause}}. This makes the capturing group misleading, because it actually captures less text than its pattern suggests.; Remove {{quant}}.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /(a+)+/;

Correct:

js
const pattern = /a+/;

regexp/no-misleading-unicode-character ​

Visual Unicode forms differing from code points can cause incorrect matches.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: The character(s) {{ graphemes }} are all represented using multiple {{ unit }}.{{ uFlag }}; The character {{ grapheme }} is represented using multiple Unicode code points. The quantifier only applies to the last code point {{ last }} and not to the whole character.; The character {{ grapheme }} is represented using a surrogate pair. The quantifier only applies to the tailing surrogate {{ last }} and not to the whole character.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /[👍]/;

Correct:

js
const pattern = /[👍]/u;

regexp/no-missing-g-flag ​

Global operations such as replaceAll require the g flag to avoid runtime failure or inconsistent behavior.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: The pattern given to the argument of 'String#{{method}}()' requires the 'g' flag, but is missing it.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const text = "item item";
const matches = text.matchAll(/item/);

Correct:

js
const text = "item item";
const matches = text.matchAll(/item/g);

regexp/no-non-standard-flag ​

Disallows nonstandard flags unsupported by JavaScript.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected non-standard flag '{{flag}}'.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = new RegExp("item", "x");

Correct:

js
const pattern = new RegExp("item", "u");

regexp/no-optional-assertion ​

Optional assertions nearly always pass and rarely impose the intended constraint.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: This assertion effectively optional and does not change the pattern. Either remove the assertion or change the parent quantifier '{{quantifier}}'.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /(?:^)?item/;

Correct:

js
const pattern = /^item/;

regexp/no-super-linear-backtracking ​

Prevents input-triggered superlinear backtracking to reduce denial-of-service risk.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: This quantifier can reach itself via the loop {{parent}}. Using any string accepted by {{attack}}, this can be exploited to cause at least polynomial backtracking.{{exp}}; The quantifier {{start}} can exchange characters with {{end}}. Using any string accepted by {{attack}}, this can be exploited to cause at least polynomial backtracking.{{exp}}
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /(a+)+$/;

Correct:

js
const pattern = /^a+$/;

regexp/no-useless-backreference ​

Invalid backreferences cannot refer to the intended capture.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Backreference {{ bref }} will be ignored. It references group {{ group }}{{ otherGroups }} from within that group.; Backreference {{ bref }} will be ignored. It references group {{ group }}{{ otherGroups }} which appears later in the pattern.; Backreference {{ bref }} will be ignored. It references group {{ group }}{{ otherGroups }} which appears before in the same lookbehind.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /\1(a)/;

Correct:

js
const pattern = /(a)\1/;

regexp/no-useless-dollar-replacements ​

Replacement references to nonexistent captures cannot yield the intended result.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '${{ refText }}' replacement will insert '${{ refText }}' because there are less than {{ num }} capturing groups. Use '$$' if you want to escape '$'.; '${{ refText }}' replacement will insert '${{ refText }}' because capturing group is not found. Use '$$' if you want to escape '$'.; '$<{{ refText }}>' replacement will be ignored because the named capturing group is not found. Use '$$' if you want to escape '$'.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const text = "item";
const value = text.replace(/item/g, "$1");

Correct:

js
const text = "item";
const value = text.replace(/(item)/g, "$1");

regexp/no-zero-quantifier &ZeroWidthSpace;

Zero quantifiers prevent participation in matching and usually indicate a boundary typo.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected zero quantifier. The quantifier and its quantified element can be removed without affecting the pattern.; Unexpected zero quantifier. The quantifier and its quantified element do not affecting the pattern. Try to remove the elements but be careful because it contains at least one capturing group.; Remove this zero quantifier.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /item{0}/;

Correct:

js
const pattern = /item/;

regexp/strict &ZeroWidthSpace;

Strictly checks ambiguous or engine-dependent regular-expression structures.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Invalid or incomplete control escape sequence. Either use a valid control escape sequence or escaping the standalone backslash.; Incomplete escape sequence {{expr}}. Either use a valid escape sequence or remove the useless escaping.; Invalid property escape sequence {{expr}}. Either use a valid property escape sequence or remove the useless escaping.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

js
const pattern = /\q/;

Correct:

js
const pattern = /q/;

sort-imports &ZeroWidthSpace;

Sorts members inside import declarations by name; import-x/order handles declaration groups and order.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Imports should be sorted alphabetically.; Member '{{memberName}}' of the import declaration should be sorted alphabetically.; Expected '{{syntaxA}}' syntax before '{{syntaxB}}' syntax.
  • Example type: Direct code example for an explicit repository rule

Incorrect:

ts
import { zebra, alpha } from "./names";

Correct:

ts
import { alpha, zebra } from "./names";

Rules from third-party presets (54 rules) &ZeroWidthSpace;

constructor-super &ZeroWidthSpace;

Checks the corresponding code constraint. Upstream description: Require super() calls in constructors

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Lacked a call of 'super()' in some code paths.; Expected to call 'super()'.; Unexpected duplicate 'super()'.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
class User extends Entity { constructor() {} }

Correct:

js
class User extends Entity { constructor() { super(); } }

for-direction &ZeroWidthSpace;

Checks the corresponding code constraint. Upstream description: Enforce for loop update clause moving the counter in the right direction

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: The update clause in this loop moves the variable in the wrong direction.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
for (let index = 0; index < 10; index--) process(index);

Correct:

js
for (let index = 0; index < 10; index++) process(index);

getter-return &ZeroWidthSpace;

Checks the corresponding code constraint. Upstream description: Enforce return statements in getters

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Expected to return a value in {{name}}.; Expected {{name}} to always return a value.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const user = { get name() { logAccess(); } };

Correct:

js
const user = { get name() { return "Fast"; } };

import-x/export &ZeroWidthSpace;

Checks the corresponding code constraint. Upstream description: Forbid any invalid exports, i.e. re-export of the same name.

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: No named exports found in module '{{module}}'.; Multiple default exports.; Multiple exports of name '{{name}}'.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
export const value = 1;
export { value };

Correct:

js
export const value = 1;

no-async-promise-executor &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow using an async function as a Promise executor

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Promise executor functions should not be async.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const value = new Promise(async (resolve) => resolve(await load()));

Correct:

js
const value = Promise.resolve(load());

no-class-assign &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow reassigning class members

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{name}}' is a class.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
class User {}
User = class Admin {};

Correct:

js
class User {}
const Admin = class extends User {};

no-compare-neg-zero &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow comparing against -0

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Do not use the '{{operator}}' operator to compare against -0.; Replace '-0' with '0' (keeps the current comparison behavior).; Replace with 'Object.is()' (changes the comparison to distinguish -0 from +0).
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
if (value === -0) handle();

Correct:

js
if (Object.is(value, -0)) handle();

no-cond-assign &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow assignment operators in conditional expressions

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected assignment within {{type}}.; Expected a conditional expression and instead saw an assignment.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
if (user = findUser()) render(user);

Correct:

js
const user = findUser();
if (user) render(user);

no-const-assign &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow reassigning const, using, and await using variables

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{name}}' is constant.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const timeout = 1000;
timeout = 2000;

Correct:

js
let timeout = 1000;
timeout = 2000;

no-constant-binary-expression &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow expressions where the operation doesn't affect the value

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected constant binary expression. Compares constantly with the {{otherSide}}-hand side of the '{{operator}}'.; Unexpected constant {{property}} on the left-hand side of a '{{operator}}' expression.; Unexpected comparison to newly constructed object. These two values can never be equal.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const allowed = true || ready;

Correct:

js
const allowed = ready || fallbackAllowed;

no-delete-var &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow deleting variables

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Variables should not be deleted.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
var token;
delete token;

Correct:

js
let token;
token = undefined;

no-dupe-args &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow duplicate arguments in function definitions

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Duplicate param '{{name}}'.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
function add(value, value) { return value; }

Correct:

js
function add(left, right) { return left + right; }

no-dupe-class-members &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow duplicate class members

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Duplicate name '{{name}}'.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
class User { save() {} save() {} }

Correct:

js
class User { save() {} cancel() {} }

no-dupe-else-if &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow duplicate conditions in if-else-if chains

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: This branch can never execute. Its condition is a duplicate or covered by previous conditions in the if-else-if chain.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
if (ready) start(); else if (ready) retry();

Correct:

js
if (ready) start(); else if (retryable) retry();

no-dupe-keys &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow duplicate keys in object literals

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Duplicate key '{{name}}'.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const user = { name: "A", name: "B" };

Correct:

js
const user = { firstName: "A", lastName: "B" };

no-duplicate-case &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow duplicate case labels

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Duplicate case label.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
switch (status) { case "ready": start(); break; case "ready": retry(); }

Correct:

js
switch (status) { case "ready": start(); break; case "failed": retry(); }

no-empty-character-class &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow empty character classes in regular expressions

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Empty class.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const pattern = /[]/;

Correct:

js
const pattern = /[a-z]/;

no-empty-pattern &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow empty destructuring patterns

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected empty {{type}} pattern.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const {} = user;

Correct:

js
const { id } = user;
use(id);

no-empty-static-block &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow empty static blocks

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected empty static block.; Add comment inside empty static block.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
class Cache { static {} }

Correct:

js
class Cache { static { Cache.initialize(); } }

no-ex-assign &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow reassigning exceptions in catch clauses

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Do not assign to the exception parameter.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
try { run(); } catch (error) { error = normalize(error); throw error; }

Correct:

js
try { run(); } catch (error) { throw normalize(error); }

no-extra-boolean-cast &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow unnecessary boolean casts

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: Redundant Boolean call.; Redundant double negation.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
if (!!ready) start();

Correct:

js
if (ready) start();

no-fallthrough &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow fallthrough of case statements

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Found a comment that would permit fallthrough, but case cannot fall through.; Expected a 'break' statement before 'case'.; Expected a 'break' statement before 'default'.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
switch (status) { case "ready": start(); case "done": finish(); }

Correct:

js
switch (status) { case "ready": start(); break; case "done": finish(); }

no-func-assign &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow reassigning function declarations

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{name}}' is a function.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
function load() {}
load = createLoader();

Correct:

js
let load = createLoader();
load = createCachedLoader();

no-global-assign &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow assignments to native objects or read-only global variables

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Read-only global '{{name}}' should not be modified.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
undefined = 1;

Correct:

js
const missingValue = undefined;

no-import-assign &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow assigning to imported bindings

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{name}}' is read-only.; The members of '{{name}}' are read-only.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
import * as api from "./api.js";
api = {};

Correct:

js
import * as api from "./api.js";
api.request();

no-invalid-regexp &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow invalid regular expression strings in RegExp constructors

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: {{message}}.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const pattern = new RegExp("[");

Correct:

js
const pattern = new RegExp("[a-z]");

no-loss-of-precision &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow literal numbers that lose precision

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: This number literal will lose precision at runtime.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const id = 9007199254740993;

Correct:

js
const id = 9007199254740993n;

no-new-native-nonconstructor &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow new operators with global non-constructor functions

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{name}}' cannot be called as a constructor.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const token = new Symbol();

Correct:

js
const token = Symbol();

no-nonoctal-decimal-escape &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow \8 and \9 escape sequences in string literals

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Don't use '{{decimalEscape}}' escape sequence.; Replace '{{original}}' with '{{replacement}}'. This maintains the current functionality.; Replace '{{original}}' with '{{replacement}}' to include the actual backslash character.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const digit = "\8";

Correct:

js
const digit = "8";

no-obj-calls &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow calling global object properties as functions

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{name}}' is not a function.; '{{name}}' is reference to '{{ref}}', which is not a function.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const value = Math();

Correct:

js
const value = Math.max(1, 2);

no-octal &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow octal literals

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Octal literals should not be used.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const mode = 071;

Correct:

js
const mode = 0o71;

no-prototype-builtins &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow calling some Object.prototype methods directly on objects

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Do not access Object.prototype method '{{prop}}' from target object.; Call Object.prototype.{{prop}} explicitly.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
if (payload.hasOwnProperty(key)) use(payload[key]);

Correct:

js
if (Object.hasOwn(payload, key)) use(payload[key]);

no-self-assign &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow assignments where both sides are exactly the same

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{name}}' is assigned to itself.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
user.name = user.name;

Correct:

js
user.name = nextName;

no-setter-return &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow returning values from setters

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Setter cannot return a value.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const user = { set name(value) { return value; } };

Correct:

js
const user = { set name(value) { saveName(value); } };

no-shadow-restricted-names &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow identifiers from shadowing restricted names

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Shadowing of global property '{{name}}'.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const undefined = 1;

Correct:

js
const missingValue = undefined;

no-sparse-arrays &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow sparse arrays

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected comma in middle of array.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const values = [1, , 3];

Correct:

js
const values = [1, undefined, 3];

no-this-before-super &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow this/super before calling super() in constructors

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{kind}}' is not allowed before 'super()'.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
class User extends Entity { constructor() { this.ready = true; super(); } }

Correct:

js
class User extends Entity { constructor() { super(); this.ready = true; } }

no-unassigned-vars &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow let or var variables that are read but never assigned

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{name}}' is always 'undefined' because it's never assigned.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
let result;
render(result);

Correct:

js
const result = load();
render(result);

no-undef &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow the use of undeclared variables unless mentioned in /*global */ comments

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{name}}' is not defined.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
total = price * count;

Correct:

js
const price = 10;
const count = 2;
const total = price * count;

no-unreachable &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow unreachable code after return, throw, continue, and break statements

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unreachable code.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
function load() { return value; log(value); }

Correct:

js
function load() { log(value); return value; }

no-unsafe-finally &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow control flow statements in finally blocks

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unsafe usage of {{nodeType}}.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
function load() { try { return fetchValue(); } finally { return fallback; } }

Correct:

js
function load() { try { return fetchValue(); } finally { release(); } }

no-unsafe-negation &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow negating the left operand of relational operators

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unexpected negating the left operand of '{{operator}}' operator.; Negate '{{operator}}' expression instead of its left operand. This changes the current behavior.; Wrap negation in '()' to make the intention explicit. This preserves the current behavior.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
if (!key in object) handleMissing();

Correct:

js
if (!(key in object)) handleMissing();

no-unsafe-optional-chaining &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow use of optional chaining in contexts where the undefined value is not allowed

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unsafe usage of optional chaining. If it short-circuits with 'undefined' the evaluation will throw TypeError.; Unsafe arithmetic operation on optional chaining. It can result in NaN.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const { name } = user?.profile;

Correct:

js
const name = user?.profile?.name;

no-unused-labels &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow unused labels

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Supported; review semantics and the diff before applying
  • Rule source: Official documentation
  • Common messages: '{{name}}:' is defined but never used.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
retry: run();

Correct:

js
run();

no-unused-private-class-members &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow unused private class members

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{classMemberName}}' is defined but never used.; Remove unused private class member '{{classMemberName}}'.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
class User { #secret = 1; getName() { return "Fast"; } }

Correct:

js
class User { #name; constructor(name) { this.#name = name; } getName() { return this.#name; } }

no-unused-vars &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow unused variables

  • Effective severity and scope: error: JavaScript base, Vue JSX, React JSX, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: '{{varName}}' is {{action}} but never used{{additional}}.; '{{varName}}' is marked as ignored but is used{{additional}}.; Remove unused variable '{{varName}}'.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const unusedValue = load();

Correct:

js
const value = load();
render(value);

no-useless-assignment &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow variable assignments when the value is not used

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: The value assigned to '{{name}}' is not used in subsequent statements.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
function getStatus() { let status = "idle";
status = "ready";
return status; }

Correct:

js
function getStatus() { const status = "ready";
return status; }

no-useless-backreference &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow useless backreferences in regular expressions

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Backreference '{{ bref }}' will be ignored. It references group '{{ group }}'{{ otherGroups }} from within that group.; Backreference '{{ bref }}' will be ignored. It references group '{{ group }}'{{ otherGroups }} which appears later in the pattern.; Backreference '{{ bref }}' will be ignored. It references group '{{ group }}'{{ otherGroups }} which appears before in the same lookbehind.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const pattern = /\1(a)/;

Correct:

js
const pattern = /(a)\1/;

no-useless-catch &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow unnecessary catch clauses

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unnecessary catch clause.; Unnecessary try/catch wrapper.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
try { run(); } catch (error) { throw error; }

Correct:

js
run();

no-useless-escape &ZeroWidthSpace;

Disallows unsafe, invalid, or misleading constructs. Upstream description: Disallow unnecessary escape characters

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Unnecessary escape character: \{{character}}.; Remove the '\'. This maintains the current functionality.; Remove the '\' if it was inserted by mistake.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
const name = "Fast\!";

Correct:

js
const name = "Fast!";

preserve-caught-error &ZeroWidthSpace;

Checks the corresponding code constraint. Upstream description: Disallow losing originally caught error when re-throwing custom errors

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: There is no 'cause' attached to the symptom error being thrown.; The symptom error is being thrown with an incorrect 'cause'.; Include the original caught error as the 'cause' of the symptom error.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
try { connect(); } catch (error) { throw new Error("Connection failed"); }

Correct:

js
try { connect(); } catch (error) { throw new Error("Connection failed", { cause: error }); }

require-yield &ZeroWidthSpace;

Requires the declarations, properties, or structures specified by this rule. Upstream description: Require generator functions to contain yield

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: This generator function does not have 'yield'.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
function* values() { return 1; }

Correct:

js
function* values() { yield 1; }

use-isnan &ZeroWidthSpace;

Checks the corresponding code constraint. Upstream description: Require calls to isNaN() when checking for NaN

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Use the isNaN function to compare with NaN.; 'switch(NaN)' can never match a case clause. Use Number.isNaN instead of the switch.; 'case NaN' can never match. Use Number.isNaN before the switch.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
if (value === NaN) reset();

Correct:

js
if (Number.isNaN(value)) reset();

valid-typeof &ZeroWidthSpace;

Validates the relevant syntax, properties, or arguments. Upstream description: Enforce comparing typeof expressions against valid strings

  • Effective severity and scope: error: JavaScript base, TypeScript base, Framework-neutral TSX, Vue SFC, Vue JSX, Vue TSX, UniApp NVue, UniApp TSX, React JSX, React TSX, Angular TypeScript, Lodash, Lodash Unified
  • Autofix: Unsupported or not declared upstream
  • Rule source: Official documentation
  • Common messages: Invalid typeof comparison value.; Typeof comparisons should be to string literals.; Use '"{{type}}"' instead of '{{type}}'.
  • Example type: Direct code example for a third-party preset rule

Incorrect:

js
if (typeof value === "strnig") reset();

Correct:

js
if (typeof value === "string") reset();