--- url: /guide/index.md --- # Getting Started Rslint is a high-performance, ESLint-compatible linter for JavaScript and TypeScript. Powered by [TypeScript's native compiler](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/), it delivers a faster drop-in experience with type-aware rules and optional type checking in the same run. ## Installation ```sh [npm] npm install @rslint/core -D ``` ```sh [yarn] yarn add @rslint/core -D ``` ```sh [pnpm] pnpm add @rslint/core -D ``` ```sh [bun] bun add @rslint/core -D ``` ```sh [deno] deno add npm:@rslint/core -D ``` ## Quick Start ### Initialize Configuration Run the following command to generate a default configuration file: ```bash npx rslint --init ``` This creates a `rslint.config.ts` (or `.js` / `.mjs` depending on your project setup) with recommended rules enabled. ### Run the Linter ```bash # Lint all files npx rslint . # Lint with auto-fix npx rslint --fix . # Lint with TypeScript type checking (replaces tsc --noEmit) npx rslint --type-check . ``` ### Configuration Preview The generated config uses the flat config format (an array of config entries), similar to ESLint v10: ```ts import { defineConfig, js, ts } from '@rslint/core'; export default defineConfig([ js.configs.recommended, ts.configs.recommended, { rules: { '@typescript-eslint/no-unused-vars': 'error', }, }, ]); ``` For full configuration options, see the [Configuration](/config/index.md) page. ## Editor Integration Install the official [VSCode Extension](/guide/vscode-extension.md) for real-time diagnostics, code actions, and auto-fix on save. --- url: /guide/vscode-extension.md --- # VSCode Extension Install the official extension from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=rstack.rslint). It provides: - Real-time diagnostics as you type - Code actions for auto-fixable rules - Auto-fix on save via `source.fixAll.rslint` - Multi-workspace support The extension works out of the box — it uses the built-in rslint binary and automatically picks up your `rslint.config.ts`. :::tip Rstack extension The unified Rstack extension (`rstack.rstack`) brings Rslint, Rstest, and formatting together in one install and is where new editor features land. This standalone `rstack.rslint` extension will be deprecated in the future, so we recommend that existing users migrate now and that new setups use `rstack.rstack`. To switch, install `rstack.rstack` from the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=rstack.rstack) or, for Cursor, Trae, and VSCodium, from [Open VSX](https://open-vsx.org/extension/rstack/rstack). Disable or uninstall `rstack.rslint` so only one copy of Rslint runs, then re-enter settings under `rstack.rslint.*` as described in the [migration notes](https://github.com/rstackjs/rstack-editor/blob/main/packages/vscode/README.md#coming-from-the-standalone-extensions). ::: ## Auto-fix on Save To automatically fix lint issues when you save a file, add the following to your VS Code settings (`.vscode/settings.json`): ```json { "editor.codeActionsOnSave": { "source.fixAll.rslint": "explicit" } } ``` | Value | Behavior | | ------------ | ---------------------------------------------------------- | | `"explicit"` | Fix on manual save (Ctrl+S / Cmd+S) only — **recommended** | | `"always"` | Fix on every save, including auto-save | | `"never"` | Disable auto-fix on save | ## Settings | Setting | Default | Description | | ---------------------- | ---------- | ----------------------------------------------------------- | | `rslint.enable` | `true` | Enable or disable the linter | | `rslint.binPath` | `built-in` | Binary source: `built-in`, `local` (workspace), or `custom` | | `rslint.customBinPath` | — | Path to a custom rslint binary (when `binPath` is `custom`) | | `rslint.trace.server` | `off` | LSP trace level: `off`, `messages`, or `verbose` | --- url: /guide/type-checking.md --- # Type Checking Rslint runs TypeScript semantic checks alongside or instead of lint rules. Explicit projects are checked program-wide. Automatic service discovery selects additional projects from lint targets. Each checked Program retains its complete roots and dependencies. - `--type-check` — lint rules **and** type-check, in one pass. - `--type-check-only` — type-check only; lint phase is skipped entirely. ## Quick start Point rslint at your tsconfig(s) via `languageOptions.parserOptions.project`: ```js // rslint.config.mjs export default [ { files: ['**/*.ts'], languageOptions: { parserOptions: { project: ['./tsconfig.json'] }, }, }, ]; ``` Then: ```bash rslint --type-check . # lint + type-check rslint --type-check-only . # type-check only ``` For ordinary linting, each file's final matching configuration must enable `project` or `projectService` to provide type information. Without either option, lint rules that do not require types still run. The type-check flags retain a separate program-wide scope, described in [What gets type-checked](#what-gets-type-checked). An entry's [`basePath`](/config/base-path.md) anchors explicit project literals or globs unless the target has an explicit `tsconfigRootDir`. The final matching `project` value keeps the authored base of the entry that supplies it when that root is omitted or reset. ## Automatic project discovery With an explicit [`projectService: true`](/config/language-options.md#languageoptionsparseroptionsprojectservice), rslint discovers configs whose `files` or `include` roots contain the selected files. Discovery reads config metadata and does not build Programs to probe imports. Nested tsconfigs and project references are followed; a tsconfig beside the lint config does not override the source's local project. With service enabled and no explicit project declarations, `rslint --type-check-only packages/app/src/file.ts` finds that file's project and checks the whole project, including sibling files. It does not first build an implicit root project for that service target. No arguments select the current directory's lint scope for discovery. Type-check-only never executes lint rules. Unowned service targets use source-only gap linting. TypeScript presets do not enable service; if another matching entry enables it, set `projectService: false` to use ordinary explicit projects. An effective project string or array, including \[], conflicts with enabled service. Effective conflicts, service/root options and false/null clears are evaluated from the same matching config used for lint rules. A matching `projectService: false` overrides earlier service settings. An explicit `project` from the file's final merged configuration still applies; declarations from unmatched entries do not. JavaScript also accepts null for this service reset; the public type is boolean. Unmatched service/root/clear settings do not affect another target. Program-wide checking of an owner with no targets follows the separate scope rules below. ## What gets type-checked `parserOptions.project` accepts one or more tsconfig paths: ```js // Single tsconfig parserOptions: { project: ['./tsconfig.json'] } // Multiple tsconfigs (monorepo, separate test/build configs, …) parserOptions: { project: ['./tsconfig.json', './packages/*/tsconfig.json'], } ``` For linting, Rslint uses each target file's final merged `parserOptions`. Only entries matching that file contribute settings. A later `project` replaces the earlier list; `[]`, `false`, or JavaScript `null` clears it. Relative project paths keep the authored base of the entry supplying that value, unless an effective absolute `tsconfigRootDir` overrides it. Resetting `tsconfigRootDir` to JavaScript `null` restores that authored base. Target binding prefers direct roots across the effective list, then import membership. If neither `project` nor `projectService` is enabled for a target, ordinary lint uses source-only gap linting, even when a `tsconfig.json` exists beside the Rslint config. Enable `projectService: true` to discover projects automatically, or set `project` explicitly. These options provide type information; they do not select additional lint files. Program-wide checking is separate. `--type-check` and `--type-check-only` retain the governing owner's complete explicit declaration list, including entries that do not match a lint target and earlier declarations replaced for linting. Each applicable root context checks that entire list. In combined `--type-check` mode, lint rules still use each target's effective project settings. The construction scope depends on the operation: | Operation | Project scope | | ---------------------------------------------- | ------------------------------------------------------------------------- | | Plain CLI lint of the whole cwd | Validate effective candidates and select projects using target membership | | Focused file/subdirectory CLI lint or API lint | Select needed projects using root and import membership | | `--type-check` or `--type-check-only` | Check complete explicit declaration lists, plus service-selected Programs | When service/root/clear options require target discovery, all actual targets contribute their effective `tsconfigRootDir` contexts to program-wide explicit checking, including service and clear targets. Each context checks the whole declaration list. Without an explicit root, the declarations keep their authored bases. A per-target clear changes lint binding; it does not remove these type-check projects. For program-wide type checking only, when there are no explicit paths, targets whose effective service/clear settings allow the historical default can request `tsconfig.json` in the governing config directory. A declaration of `project: []` suppresses this default when no paths were declared; it does not remove earlier explicit declarations. Neither `basePath` nor `tsconfigRootDir` moves this default lookup. If an owner has no selected targets at all, program-wide checking retains its original declaration/default lookup without guessing effective scoped options. An empty service-only scope therefore builds no Programs in plain lint, but type-check-only can still check the owner's default tsconfig. These scope rules belong to Rslint; ESLint has no corresponding type-check flags. Shared explicit projects are constructed once per invocation. File-symlink declarations remain distinct because TypeScript resolves relative paths from the declared location. Explicit and service modes can require separate Programs for the same tsconfig because reference source and declaration-output behavior differs. Ordinary explicit-project ownership probes may construct complete candidates to inspect import membership even when the target ultimately uses gap linting. **Every checked Program includes its tsconfig root files and dependencies loaded through imports and references.** These filters affect lint targets and service/root context discovery, but do not trim a checked Program or the owner's program-wide type-check declaration list: - rslint config's `files` patterns - rslint config's `ignores` patterns (root-level or per-entry) - `.gitignore` - CLI file / directory arguments — `rslint --type-check-only foo.ts` still type-checks every file in the program(s), not just `foo.ts` If a file is included by tsconfig but matched by rslint `ignores`, lint rules do not run on it, but **type errors for it are still reported**. The tsconfig's `exclude` filters `include` discovery; imports and references can still bring an excluded file into the Program. `// @ts-nocheck` disables semantic checking of that file. ### Gap files Selected files without a project under their applicable binding settings (root-level scripts, ad-hoc config files, etc.) are called _gap files_. This includes JavaScript, TypeScript, and the other supported script extensions. The lint loader parses and binds them without providing a TypeChecker, so rules that do not require type information still run while type-aware rules are skipped. The source-only fallback itself does not participate in program-wide type checking. If the same file also belongs to a checked explicit or service Program, `--type-check` can still report TypeScript diagnostics for it through that Program. This fallback does not create a tsconfig for automatic project discovery. With `projectService: true`, discovery can find an owning project that an explicit project list missed, such as a nested tsconfig. When discovery finds no owning project, the file follows the same gap fallback. Other files keep their selected projects. Actual config or Program failures still report errors. In the editor, an invalid effective project setting, such as a missing project path or conflicting project options, appears as an Rslint error on the affected document. Files that do not match that setting continue using their own configuration, and ignored files do not receive this error. Correcting the setting restores normal lint diagnostics and fixes. To enable type information for a gap file, include it in a project selected by its effective parser settings. Upstream typescript-eslint instead rejects unowned service files by default and supports `allowDefaultProject` to provide type information for allowed files outside configured projects. Rslint does not yet support that option; its source-only gap fallback is not equivalent. ## Output Type errors carry `TypeScript(TS)` as the rule name and severity `error`: ``` TypeScript(TS2322) — [error] Type 'string' is not assignable to type 'number'. ╭─┴──────────( src/utils.ts:3:7 )───── │ 2 │ const name = 'hello'; │ 3 │ const count: number = name; │ 4 │ ╰──────────────────────────────── ``` Chained errors indent the TypeScript message chain: ``` TypeScript(TS2322) — [error] Type 'B' is not assignable to type 'A'. The types of 'x.y.z' are incompatible between these types. Type 'number' is not assignable to type 'string'. ``` Type errors appear in every output format (`default`, `jsonline`, `github`, `gitlab`). ### Lifecycle status The default format uses mode-specific start and completed status lines: ``` # Plain lint start Linting... error Lint failed with 3 errors and 1 warning in 120ms (42 files, 5 rules, 8 threads) # --type-check start Linting and type checking... error Lint and type check failed with 3 lint errors, 2 TypeScript errors, and 1 warning in 120ms (47 files, 5 rules, 8 threads) # --type-check-only start Type checking... error Type check failed with 2 TypeScript errors in 80ms (42 files, 8 threads) ``` In combined mode, the displayed file count is the canonical, deduplicated union of lint targets and root files from every compiler-capable tsconfig Program. It is not the larger of two counts: partially overlapping sets still contribute every distinct file. In color-enabled terminals, the complete parenthesized execution details are rendered dim. ### Exit codes | Code | When | | :--: | -------------------------------------------------------------------- | | 0 | No errors. (Warnings still allowed unless `--max-warnings` rejects.) | | 1 | At least one error (lint or type), or a runtime failure. | | 2 | Flag misuse — `--type-check-only` combined with `--fix` or `--rule`. | ## Alignment with `tsc --noEmit` For any given program, `--type-check` (and `--type-check-only`) produces the same diagnostics as `tsc --noEmit` / `tsgo --noEmit` — same error code, same file, same line and column. One intentional difference: TypeScript diagnostics without a source-file anchor (e.g. `TS18003` "No inputs were found in config file", `TS5108` removed-option warnings) are not reported, because rslint output is per file. Run `tsc --noEmit` directly to surface these configuration-level errors. ## Replacing `tsc --noEmit` in CI ```yaml # Before — two steps steps: - run: npx tsc --noEmit - run: npx rslint . # After — one combined step steps: - run: npx rslint --type-check . ``` For inline annotations on PR diffs: ```yaml - run: npx rslint --type-check --format github . ``` If your CI keeps lint and type-check as separate jobs, use `--type-check-only` in the type-check job: ```yaml jobs: type-check: steps: - run: npx rslint --type-check-only . lint: steps: - run: npx rslint . ``` ## `--type-check-only` Skips every lint rule and runs only the type-check phase. Pure explicit-project configuration retains its path without lint-target discovery. New service/root/clear options can require target discovery to determine their applicable contexts; explicit checking still uses the complete declaration lists described above. ```bash rslint --type-check-only . ``` `--type-check-only` implies `--type-check`; passing both is redundant. ### vs. `--type-check` | Flag | Lint rules | Type diagnostics | Suppresses lint-phase warnings \* | | ------------------- | :--------: | :--------------: | :------------------------------------------: | | `--type-check` | ✓ | ✓ | no | | `--type-check-only` | ✗ | ✓ | yes | \* The lint phase emits per-file stderr warnings like ` was not found, skipping` and ` is ignored because of a matching ignore pattern`. These are suppressed in `--type-check-only`. Ignored files can still be checked through the program-wide explicit declarations or a service-selected Program (see [What gets type-checked](#what-gets-type-checked)). ## Flag matrix | Flag | `--type-check` | `--type-check-only` | | ---------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------ | | `--fix` | Applies lint fixes. Type errors have no auto-fix. | **Rejected** (exit code 2). | | `--rule` | Overrides lint rules normally. | **Rejected** (exit code 2). | | `--quiet` | Suppresses warnings; type errors always shown. | No-op — the lint phase produces nothing. | | `--format` | Type errors rendered in the chosen format. | Same. | | `--max-warnings` | Counts lint warnings only. | Always zero warnings (lint phase skipped). | | File/dir args | Scope lint targets and new parser contexts; explicit checking remains program-wide. | Scope new parser contexts; explicit checking remains program-wide. | --- url: /guide/eslint-plugins.md --- # ESLint Plugin Compatibility rslint can run community ESLint plugins' rules alongside its own native rules. Plugin diagnostics merge into the same report, and it works the same way in the CLI and the VS Code extension. ## Usage Import the plugin, register it in `plugins` under a prefix of your choice, and enable its rules under `'/'`: ```js import examplePlugin from 'eslint-plugin-example'; export default [ { files: ['**/*.ts'], plugins: { example: examplePlugin }, rules: { 'example/some-rule': 'error', }, }, ]; ``` A few things to know: - **Built-in vs. community.** Built-in (native) plugins are named in an array — `plugins: ['@typescript-eslint']`. A community plugin is mounted as an object — `plugins: { example: examplePlugin }`. One entry uses one form; to use both, add a second config entry. - **Module config required.** A community plugin is a live object, so configure it in a `.js` / `.mjs` / `.ts` / `.mts` module. - **Pick any prefix** that doesn't clash with a [built-in plugin prefix](/config/plugins.md#built-in-plugins); rslint reports a clear error if it does. - **Fixes work.** A plugin rule's autofixes and suggestions apply through `--fix` and the editor's `source.fixAll`. ## Unsupported ESLint APIs A plugin rule's `create(context)` gets the standard ESLint v10 surface: `context.report` (with `messageId` / `data` / `fix` / `suggest`), `context.options`, `context.settings`, `context.languageOptions`, AST and esquery visitors, and `sourceCode` (tokens, comments, and scope analysis such as `getScope` and `getDeclaredVariables`). These ESLint APIs are **not** available to plugin rules — a rule that relies on one loads without error but never reports: | ESLint API | Where you'd use it | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | | `sourceCode.parserServices` — `program`, `getTypeChecker()`, `esTreeNodeToTSNodeMap` | type-aware rules (enabled by `languageOptions.parserOptions.project`) | | `languageOptions.parser` | a custom parser in the config | | `processor` | a config's processor | | `onCodePathStart` / `onCodePathEnd` / `onCodePathSegmentStart` / `onCodePathSegmentEnd` / `onCodePathSegmentLoop` / `onUnreachableCodePathSegmentStart` / `onUnreachableCodePathSegmentEnd` | code-path (control-flow) analysis | --- url: /guide/inline-directives.md --- # Inline Directives Rslint supports inline comments to disable or enable rules in source code. Both `rslint-` and `eslint-` prefixed directives are supported and fully equivalent. ## Disable for the rest of the file ```ts /* rslint-disable */ // Disables all rules from this point forward /* rslint-disable @typescript-eslint/no-explicit-any */ // Disables a specific rule from this point forward ``` ## Re-enable rules ```ts /* rslint-enable */ // Re-enables all previously disabled rules /* rslint-enable @typescript-eslint/no-explicit-any */ // Re-enables a specific rule ``` ## Disable for the current line ```ts const x: any = 1; // rslint-disable-line // Disables all rules for this line only const y: any = 2; // rslint-disable-line @typescript-eslint/no-explicit-any // Disables a specific rule for this line ``` ## Disable for the next line ```ts /* rslint-disable-next-line */ const x: any = 1; /* rslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-call */ // Disables multiple specific rules for the next line const y: any = fn(); ``` ## Notes - `eslint-disable` / `eslint-enable` and their variants are also supported for ESLint compatibility. The two prefixes can be mixed freely (e.g. `rslint-disable` paired with `eslint-enable`). - Both single-line (`//`) and multi-line (`/* */`) comment styles are supported. - Omitting rule names disables/enables all rules. - Multiple rule names can be separated by commas. - An inline description can be added after `--` (e.g., `rslint-disable-next-line no-console -- temporary workaround`). --- url: /guide/cli.md --- # CLI Reference ## Usage ```bash rslint [options] [files/directories...] ``` ## Options | Flag | Description | | --------------------- | ------------------------------------------------------------------------------------------------- | | `--init` | Generate a default config file, or migrate an existing JSON config to JS/TS | | `-c, --config ` | Specify which JS/TS module config file to use | | `--fix` | Automatically fix problems | | `--type-check` | Enable TypeScript semantic type checking ([details](/guide/type-checking.md)) | | `--type-check-only` | Run TypeScript semantic type checking without lint rules ([details](/guide/type-checking.md)) | | `--format ` | Output format: `default`, `jsonline`, `github`, or `gitlab` ([details](/guide/output-formats.md)) | | `--quiet` | Report errors only, suppress warnings | | `--timing [all\|n]` | Print a per-rule timing table after the run (see [details](#rule-timing)) | | `--max-warnings ` | Exit with error if warning count exceeds this number | | `--rule ` | Override a rule's severity or options (repeatable, see [details](#rule-overrides)) | | `--no-color` | Disable colored output ([details](/guide/environment-variables.md)) | | `--force-color` | Force colored output ([details](/guide/environment-variables.md)) | | `--help`, `-h` | Show help information | ## File and Directory Arguments You can pass file paths, directory paths, or a mix of both. Rslint discovers the config file by walking upward from the target location. ```bash # Lint specific files rslint src/index.ts src/utils.ts # Lint a directory (only files under that directory are linted) rslint src/ # Mix files and directories rslint src/ lib/utils.ts # Use with --fix rslint --fix src/index.ts ``` When no arguments are given, rslint scopes linting to the current working directory. ### Config Discovery For each target file or directory, rslint searches for `rslint.config.{js,mjs,ts,mts}` starting from that location and walking upward to the filesystem root. The nearest successfully loaded config is used. If a discovered config cannot be loaded, rslint warns and tries its next ancestor; the command fails when none of the discovered candidates can be loaded. `.cjs` and `.cts` config files are not discovered automatically, but remain supported when passed explicitly with `--config` or `-c`. In monorepo setups, rslint automatically discovers nested configs and applies the nearest one to each file: ```bash # Lint from monorepo root (discovers all sub-package configs) rslint # Lint a specific package rslint packages/foo/ # Lint files from different packages (each uses its nearest config) rslint packages/foo/src/a.ts packages/bar/src/b.ts ``` Use `--config` or `-c` to override automatic config discovery: ```bash rslint --config custom.config.ts src/ rslint -c custom.config.ts src/ ``` ## Rule Overrides Use `--rule` to override a rule's severity or options from the command line, without modifying your config file. This is useful for quick debugging, CI one-offs, or temporarily enabling/disabling rules. ```bash # Override severity rslint --rule 'no-console: off' rslint --rule 'no-debugger: error' rslint --rule 'no-debugger: warn' # Override severity with options (JSON array format) rslint --rule 'no-console: ["error", {"allow": ["warn", "error"]}]' # Plugin rules rslint --rule '@typescript-eslint/no-explicit-any: off' # Multiple overrides rslint --rule 'no-console: off' --rule 'no-debugger: error' ``` `--rule` can appear anywhere in the argument list — before or after file paths and other flags: ```bash rslint --rule 'no-console: off' src/ rslint src/ --rule 'no-console: off' rslint src/ --rule 'no-console: off' --format github ``` **Behavior:** - CLI rules have the **highest precedence** and override all config file entries, including per-file overrides. - When the same rule is specified multiple times, the **last one wins**. - Rules that don't exist in the registry are silently ignored. ## Rule Timing Use `--timing` to print a per-rule timing table after the run, sorted by total time. Pass a number to keep only the top N rules (`all`, the default, prints every rule): ```bash rslint --timing src/ rslint --timing 10 src/ ``` ``` Rule | Source | Time (ms) | Files | Relative ----------------------------------------|--------|-----------|-------|--------- @typescript-eslint/no-misused-promises | native | 1203.5 | 842 | 31.2% @typescript-eslint/no-floating-promises | native | 801.2 | 842 | 20.8% jsdoc/no-types | js | 311.4 | 842 | 8.1% no-control-regex | native | 102.9 | 842 | 2.7% ``` - **Source** — `native` for built-in Go rules, `js` for rules run through the ESLint plugin compatibility layer. - **Time (ms)** — total time spent in the rule across all files: building its listeners plus running them during AST traversal, including diagnostic and fix construction. - **Files** — number of distinct files the rule executed on. - **Relative** — the rule's share of the summed rule time. The table is written to stderr, so machine-readable output formats such as `jsonline` stay parseable. Files are linted by parallel workers, so summed rule time can exceed the run's wall-clock time. With `--fix`, times accumulate across all re-lint passes. Rules executed through the ESLint plugin compatibility layer are included: their time is measured inside the Node.js worker (rule `create` plus listener invocations), excluding parse and IPC overhead. ## Exit Codes | Code | Meaning | | ---- | ------------------------------------------------- | | `0` | No errors (warnings may be present) | | `1` | Errors found, or warnings exceed `--max-warnings` | | `2` | Invalid command-line usage or flag combinations | --- url: /guide/js-api.md --- # JavaScript API The JavaScript API lets you run rslint programmatically — lint files or in-memory source from a JavaScript runtime script, an editor integration, or a build tool. It is designed for JavaScript runtime hosts such as Node.js, Bun, or Deno when they can load npm packages and provide the Node-compatible filesystem and process APIs that `@rslint/core` uses. Its surface is aligned with [ESLint](https://eslint.org/docs/latest/integrate/nodejs-api)'s v10 programmatic API shape, so most ESLint API code ports over with minimal changes. With automatic discovery, the native engine selects config candidates and file ownership while the JavaScript host evaluates and normalizes the selected JS or TS modules. Explicit config files and inline overrides use the same public API. This guide focuses on common workflows. For complete method signatures and lifecycle details, see the [`Rslint` reference](/api/rslint.md). ## Getting started ```ts import { Rslint } from '@rslint/core'; const rslint = new Rslint(); const results = await rslint.lintFiles(['src/**/*.ts']); for (const result of results) { console.log(result.filePath, result.errorCount, result.warningCount); } ``` `new Rslint(options)` creates a linter instance. Both `lintFiles` and `lintText` are async and return an ESLint-shaped `LintResult[]`. ## Linting files [`lintFiles`](/api/rslint.md#lintfiles) takes one or more glob patterns resolved against `cwd`. It keeps supported source-file extensions that are not excluded by global config ignores or `.gitignore`. With automatic discovery, each selected file is routed to its nearest loadable config, so files in different monorepo packages can use different configs. ```ts const results = await rslint.lintFiles(['src/**/*.ts', 'test/**/*.ts']); ``` Results are ordered by the linted file's path (deterministic), not by glob-walk order. If no file matches the patterns, `lintFiles` returns an empty array rather than throwing — unlike ESLint v10, whose default `errorOnUnmatchedPattern` throws on an unmatched glob. ## Linting a string [`lintText`](/api/rslint.md#linttext) lints an in-memory string as if it lived at `filePath`: ```ts const [result] = await rslint.lintText('const x = 1', { filePath: 'example.ts', }); ``` `lintText` always returns exactly one result — for the linted buffer. If you omit `filePath`, the result's `filePath` is the `""` sentinel (matching ESLint). ## In-memory linting See [In-memory projects](/api/rslint.md#in-memory-projects) for the complete constructor contract and path behavior. By default `lintText` still reads the config and tsconfig from disk. To provide the source, config, tsconfig, and project files from memory, combine `overrideConfigFile: true` (use only the inline config), an inline `overrideConfig`, and a `virtualFiles` overlay: ```ts const rslint = new Rslint({ cwd: '/', // stable root for the virtual paths below overrideConfigFile: true, // use only overrideConfig — skip config discovery overrideConfig: [ { files: ['**/*.ts'], // The tsconfig + parserOptions.project below are needed ONLY for // type-aware rules (like no-for-in-array). Other rules need neither. languageOptions: { parserOptions: { project: ['./tsconfig.json'] } }, plugins: ['@typescript-eslint'], rules: { '@typescript-eslint/no-for-in-array': 'error' }, }, ], virtualFiles: { 'tsconfig.json': JSON.stringify({ compilerOptions: { strict: true }, files: ['./a.ts'], }), }, }); const [result] = await rslint.lintText( 'const a = [1];\nfor (const k in a) {}\n', { filePath: 'a.ts' }, ); ``` `virtualFiles` is an in-memory file overlay (path → content) — an rslint extension; ESLint has no in-memory file map. Put the `tsconfig.json` that `parserOptions.project` names, plus any dependency files, in the overlay. The overlay does not disable filesystem fallback: rslint may still consult disk for `.gitignore` and TypeScript resolution, so this API is not a filesystem sandbox. **Declaring plugins.** A rule from a plugin (`@typescript-eslint/*`, `unicorn/*`, and so on) runs only when that plugin is listed in `plugins` — rslint enforces this exactly like ESLint. Core rules (no `/` prefix) need no declaration. **Type-aware vs non-type-aware rules.** The `tsconfig.json` and `parserOptions.project` matter only for **type-aware** rules, which need a real TypeScript program (see [Type Checking](/guide/type-checking.md)). If your config has only rules that do not require type information, you can drop both — no tsconfig, no `parserOptions.project`. **Use relative paths** in `virtualFiles` keys and inside the tsconfig: - **`virtualFiles` keys**: prefer relative paths (`'tsconfig.json'`). Keys are always resolved against `cwd`. An absolute key like `'/tsconfig.json'` happens to match only when `cwd` is `/`; with any other `cwd` it lands at the filesystem root. - **`parserOptions.project`**: relative paths resolve from the config entry's effective base. In this override-only example that base is `cwd`; a `basePath` changes it. For a discovered config module it is normally the module directory. - **Inside the tsconfig** (`files` and `include`): relative paths resolve from the tsconfig's own directory. A bare POSIX-absolute path (such as `/a.ts`) has no drive letter on Windows, so it won't match the overlay. **Pin the tsconfig to explicit `files`** — a broad `include` glob is expanded against the real filesystem and scans from the tsconfig's directory (which is `cwd` in this example). ## Auto-fixing Pass `fix: true`. A result whose file received at least one applied fix carries an `output` string — the full final source, even if later fixes restored the input; results with no applied fix have no `output`. Rslint repeats linting and fixing until no fix is produced, a fix cycle restores the input, or ten writable rounds have run. `messages` and all diagnostic counts describe the final source in `output`, so successfully fixed findings are no longer reported. If the round limit leaves a fixable finding, its `message.fix` range also targets that final source. **Write fixes to disk** with the static [`Rslint.outputFixes`](/api/rslint.md#outputfixes): ```ts const rslint = new Rslint({ fix: true }); const results = await rslint.lintFiles(['src/**/*.ts']); await Rslint.outputFixes(results); // writes fixed files back to disk ``` `Rslint.outputFixes` writes back only results whose `filePath` is absolute. A `lintText` result is absolute — and so will be written — when you pass a `filePath`; only a result with no `filePath` (the non-absolute `""` sentinel) is skipped. **Apply fixes in memory** — to fix without touching disk, read `output` directly and don't call `outputFixes`: ```ts const rslint = new Rslint({ fix: true /* + your in-memory config */ }); const [result] = await rslint.lintText('let x = foo!!.bar', { filePath: 'a.ts', }); const fixed = result.output ?? 'let x = foo!!.bar'; // fixed source, or the original if nothing changed ``` `lintText` with `fix: true` never writes to disk — the fixed source comes back as `result.output`. For edit-level control, each `result.messages[].fix` is a `{ range: [start, end], text }` edit (UTF-16 offsets) you can splice into the source yourself; for more than one fix prefer `output`, which is already the safely merged whole-file result. ## Lifecycle Each `Rslint` instance owns a long-lived rslint engine child process. You **don't** need to call `close()` — like ESLint, a one-off script exits cleanly on its own (the idle child is unref'd, so it never blocks the event loop). Call [`close()`](/api/rslint.md#close) only in a long-running host (an editor server, a watch process) that creates many instances, to free each child promptly: ```ts const rslint = new Rslint(); try { await rslint.lintFiles(['src/**/*.ts']); } finally { await rslint.close(); } ``` Or use `await using` for automatic disposal at the end of scope: ```ts await using rslint = new Rslint(); await rslint.lintFiles(['src/**/*.ts']); ``` Native `await using` needs a runtime with explicit resource management support, which Node.js 22 lacks (a bare `.mjs` throws a SyntaxError). Compile with a `using`-aware toolchain such as TypeScript 5.2+, or use the `try` / `finally` form above, which does not rely on native `using` syntax. ## Result shape Both methods resolve to `LintResult[]`: | Field | Type | Description | | --------------------- | --------------- | ------------------------------------------------------------------- | | `filePath` | `string` | Absolute path, or `""` for `lintText` called with no filePath | | `messages` | `LintMessage[]` | Diagnostics for this file | | `errorCount` | `number` | Number of error-severity messages | | `warningCount` | `number` | Number of warning-severity messages | | `fixableErrorCount` | `number` | Errors that have an auto-fix | | `fixableWarningCount` | `number` | Warnings that have an auto-fix | | `output` | `string?` | Final source — present when `fix: true` applied at least one fix | Each `LintMessage`: | Field | Type | Description | | ----------------------- | -------------------------------------------- | ---------------------------------------------------------------------------- | | `ruleId` | `string \| null` | The rule that produced the message (`null` if none) | | `severity` | `1 \| 2` | `2` = error, `1` = warning | | `message` | `string` | Human-readable message | | `messageId` | `string?` | Stable message id, when the rule provides one | | `line` / `column` | `number` | 1-based position (`column` counts UTF-16 code units) | | `endLine` / `endColumn` | `number?` | 1-based end position, when available | | `fix` | `{ range: [number, number]; text: string }?` | Flat UTF-16 offset range + replacement text | | `suggestions` | `LintSuggestion[]?` | Suggested fixes (each with `desc`, `fix`, and optional `messageId` / `data`) | ## Options [`new Rslint(options)`](/api/rslint.md#constructor) accepts: | Option | Type | Default | Description | | -------------------- | ------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `cwd` | `string` | current cwd | Working directory for targets and discovery; also the authored base of inline entries without `basePath` | | `overrideConfig` | `RslintConfigEntry \| RslintConfig \| null` | — | Extra config appended after the resolved/discovered config; `basePath` inherits the ConfigArray base, while entries without it keep Rslint's existing `cwd`-relative behavior | | `overrideConfigFile` | `string \| true \| null` | `null` | `string`: use this module; `basePath` resolves from `cwd`, while entries without it retain the module-directory base. `true`: use only the inline override; otherwise discover | | `fix` | `boolean` | `false` | Apply rule auto-fixes; results carry `output` | | `virtualFiles` | `Record` | — | In-memory file overlay (path → content); unresolved reads may fall back to disk | See the [`basePath` configuration reference](/config/base-path.md) for the full source matrix. --- url: /guide/output-formats.md --- # Output Formats Use the `--format` flag to control how diagnostics are rendered. ## default Human-readable terminal output with colored code snippets and diagnostic highlighting. ```bash rslint . ``` ``` start Linting... src/index.ts:5:7 error @typescript-eslint/no-unused-vars 'foo' is declared but its value is never read. error Lint failed with 1 error in 42ms (12 files, 1 rule, 8 threads) ``` In color-enabled terminals, `start` is cyan and bold, `success` is green, and `error` is red. The complete parenthesized execution details are rendered dim. With `--type-check`, type errors are also included (see [Type Checking](/guide/type-checking.md) for details): ```bash rslint --type-check . ``` ``` start Linting and type checking... src/index.ts:5:7 error @typescript-eslint/no-unused-vars 'foo' is declared but its value is never read. src/utils.ts:3:7 error TypeScript(TS2322) Type 'string' is not assignable to type 'number'. error Lint and type check failed with 1 lint error and 1 TypeScript error in 85ms (14 files, 1 rule, 8 threads) ``` Combined mode reports one canonical file count: the deduplicated union of lint targets and compiler roots. This remains accurate when CLI arguments and rslint ignore patterns restrict the lint phase while type-check follows each tsconfig's program-wide scope. The machine-readable formats below emit diagnostics only on stdout. They do not include default-format lifecycle/status text, thread counts, or fix counts. With `--timing`, the timing table remains on stderr. ## jsonline One diagnostic per line as compact JSON. Suitable for programmatic consumption. ```bash rslint --format jsonline . ``` ## github GitHub Actions workflow command format. Creates annotations directly on pull request diffs. ```bash rslint --format github . ``` ## gitlab [GitLab Code Quality report](https://docs.gitlab.com/ci/testing/code_quality/) format. A single JSON array, suitable for the `codequality` report artifact that GitLab CI uses to annotate merge requests. ```bash rslint --format gitlab . > gl-code-quality-report.json ``` ```json [ { "description": "'foo' is declared but its value is never read.", "check_name": "@typescript-eslint/no-unused-vars", "fingerprint": "27e4b8b16cb47e2d6e6d4b8b6f6c6b6f", "severity": "major", "location": { "path": "src/index.ts", "lines": { "begin": 5, "end": 5 }, "positions": { "begin": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 10 } } } } ] ``` Error diagnostics map to `major` severity and warnings map to `minor`. To wire this into a pipeline, add the report as a `codequality` artifact in `.gitlab-ci.yml`: ```yaml lint: script: - rslint --format gitlab . > gl-code-quality-report.json artifacts: reports: codequality: gl-code-quality-report.json ``` --- url: /guide/ci-integration.md --- # CI Integration ## GitHub Actions Use `--format github` to get inline annotations on pull request diffs: ```yaml name: Lint on: [push, pull_request] jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 22 - run: npm ci - run: npx rslint --format github . ``` Rslint auto-detects the `GITHUB_ACTIONS` environment variable and enables colored output in CI. ## Other CI Environments ```bash # Fail on any error npx rslint . # Lint with type checking npx rslint --type-check . # Fail on errors or if warnings exceed threshold npx rslint --max-warnings 10 . # Report errors only (cleaner CI logs) npx rslint --quiet . ``` --- url: /guide/environment-variables.md --- # Environment Variables Rslint respects the following environment variables: | Variable | Description | | ---------------- | -------------------------------------------------------------------- | | `NO_COLOR` | Disable colored output | | `FORCE_COLOR` | Force colored output | | `GITHUB_ACTIONS` | Automatically detected — enables colored output in GitHub Actions CI | CLI flags `--no-color` and `--force-color` take precedence over environment variables. --- url: /guide/typescript-versions.md --- # Bundled TypeScript Versions TypeScript releases and commits bundled with each Rslint version. | Rslint | TypeScript release | TypeScript commit | | --- | --- | --- | | npmv0.9.3 | No release tag | [`1f70213d4922`](https://github.com/microsoft/TypeScript/commit/1f70213d4922b434345f639b441681e470c7cfc1) | | npmv0.9.2 | No release tag | [`1f70213d4922`](https://github.com/microsoft/TypeScript/commit/1f70213d4922b434345f639b441681e470c7cfc1) | A TypeScript release is shown only when its tag points to the exact recorded commit. Other revisions are identified by their commit hash. TypeScript's Go compiler moved from the archived [microsoft/typescript-go](https://github.com/microsoft/typescript-go) repository to [microsoft/TypeScript](https://github.com/microsoft/TypeScript). We therefore track bundled TypeScript versions from **Rslint v0.9.2** onward, without backfilling **v0.9.1 and earlier**. --- url: /config/index.md --- # Configuration overview This page lists Rslint's user-facing configuration options. Rslint uses an ESLint-style flat config: the configuration exports an array, and later matching entries override earlier ones. See [Configuration File](/config/configuration-file.md) to create a config, understand config discovery, and learn how entries are merged. ## Configuration options matching [`basePath`](/config/base-path)[`files`](/config/files)[`ignores`](/config/ignoring-files) linting [`rules`](/config/rules)[`plugins`](/config/plugins)[`settings`](/config/settings) [languageOptions](/config/language-options) [`languageOptions.ecmaVersion`](/config/language-options#languageoptionsecmaversion)[`languageOptions.sourceType`](/config/language-options#languageoptionssourcetype)[`languageOptions.parserOptions.projectService`](/config/language-options#languageoptionsparseroptionsprojectservice)[`languageOptions.parserOptions.project`](/config/language-options#languageoptionsparseroptionsproject)[`languageOptions.globals`](/config/language-options#languageoptionsglobals) --- url: /config/configuration-file.md --- # Configuration File Rslint uses JS/TS module configuration with a flat config array aligned with ESLint v10. ## Supported filenames During automatic discovery, Rslint checks config files in the following order: 1. `rslint.config.js` 2. `rslint.config.mjs` 3. `rslint.config.ts` 4. `rslint.config.mts` Automatic discovery does not consider `.cjs` or `.cts` config files. They can still be selected explicitly with `--config` or API `overrideConfigFile`. ## Config discovery When you run `rslint`, it searches for a config file by walking **upward** from the target file or directory to the filesystem root. It uses the nearest candidate that loads successfully and falls back to an ancestor when a nearer candidate cannot be loaded. - `rslint src/foo.ts` — searches from `src/` upward - `rslint src/` — searches from `src/` upward - `rslint` (no args) — searches from the current working directory upward In a monorepo, different files can automatically use different config files based on their location: ```text monorepo/ ├── rslint.config.ts ← root config ├── packages/ │ ├── foo/ │ │ ├── rslint.config.ts ← used for files under foo/ │ │ └── src/ │ └── bar/ │ └── src/ ← no config, inherits root ``` When linting from the monorepo root, Rslint automatically discovers all nested configs and applies the nearest one to each file. ### Global ignores and nested configs For directory or no-argument lint runs, global ignores in a parent config prevent nested configs in ignored directories from contributing lint targets. ```ts // monorepo/rslint.config.ts export default defineConfig([ // Global ignore — blocks directory target discovery in these directories { ignores: ['**/fixtures/**', 'e2e/**'] }, js.configs.recommended, ts.configs.recommended, ]); ``` With this config, a `rslint.config.ts` inside `e2e/` or any `fixtures/` directory is not used by a root directory traversal. An explicitly named file is still resolved from its nearest config. :::tip Only **global ignore entries** (entries containing `ignores` plus optional `name` or `basePath`, with no configuration fields) block directory target discovery. Entry-level ignores do not affect config discovery. See [`ignores`](/config/ignoring-files.md) for the distinction. ::: You can specify a config file explicitly, which overrides automatic discovery: ```bash rslint --config path/to/rslint.config.ts . ``` ## Path resolution and `basePath` Relative config paths normally resolve from the config entry's authored directory. Use `basePath` to give one entry a different starting directory. See the [`basePath` configuration reference](/config/base-path.md) for its complete matching, TypeScript project, config-source, and `.gitignore` behavior. To generate a default config, run: ```bash rslint --init ``` ## Basic configuration A typical TypeScript project configuration: ```ts import { defineConfig, globalIgnores, js, ts } from '@rslint/core'; export default defineConfig([ // Files excluded from all rules globalIgnores(['**/dist/**', '**/fixtures/**']), // Presets with recommended rules js.configs.recommended, ts.configs.recommended, // Custom rule overrides { rules: { '@typescript-eslint/no-unused-vars': 'error', '@typescript-eslint/array-type': ['warn', { default: 'array-simple' }], }, }, ]); ``` :::tip When using both JavaScript and TypeScript recommended presets, place `js.configs.recommended` before `ts.configs.recommended`. The TypeScript preset disables ESLint core rules that are handled by TypeScript-aware rules, and later config entries override earlier ones. ::: See the [Configuration overview](/config/index.md) for every available option and [Rules & Presets](/config/rules-and-presets.md) for the available presets. ## Config merging When multiple config entries match a file, they are merged in array order: 1. **Global ignores** — entries containing `ignores` plus optional `name` or `basePath`, with no configuration fields, remove files from the target set 2. **Selector union** — the implicit default baseline and effective explicit `files` entries decide whether the config selects the file 3. **Files matching** — entries whose explicit `files` patterns don't match are skipped; entries without `files` cascade across the selector union 4. **Entry-level ignores** — matching entries do not select or configure the file, but cannot remove a target selected elsewhere 5. **Rules** — later entries override earlier ones; a severity-only value retains earlier options 6. **Plugins** — union from all matching entries 7. **Settings** — ordinary nested objects merge recursively; arrays and scalar values are replaced 8. **Language options** — ordinary nested objects merge recursively; arrays and scalar values are replaced If no entry matches a selected file, no lint rules run for it, but the file is still parsed and included in the result so parser diagnostics remain visible. This applies to default-baseline files found during directory discovery as well as explicitly requested supported files. Global ignores remove matching targets; CLI and JavaScript API runs apply `.gitignore` as an additional global ignore source. ## Migrating a legacy JSON configuration Rslint no longer loads `rslint.json` or `rslint.jsonc` while linting. Passing one to `--config` is rejected; automatic discovery ignores those filenames. Run `rslint --init` in a project that still has a legacy JSON/JSONC file to migrate it to a JS/TS module config. The migration preserves custom rules and settings while deduplicating rules already covered by recommended presets. The migration also preserves each entry's parser options and file matching scope. TypeScript presets do not set `projectService`, so migration retains explicit project discovery settings without adding automatic discovery. If an entry uses `tsconfigRootDir: null` to reset an inherited boundary, migration writes a JavaScript config (`.js` for an ESM package, otherwise `.mjs`), even when a tsconfig exists. This preserves the runtime reset; the public TypeScript type only accepts a string. Enabling `checkJs` and `strictNullChecks` for the generated JavaScript config still checks against that type. --- url: /config/rules-and-presets.md --- # Rules & Presets Presets provide ready-to-use groups of rules. Add them directly to the flat config array, then use a later [`rules`](/config/rules.md) entry for project-specific overrides. ## Available presets | Preset | Description | View rules | | --- | --- | --- | | `js.configs.recommended` | JavaScript recommended rules | [View rules →](/rules/?preset=js.configs.recommended) | | `ts.configs.recommended` | TypeScript recommended rules | [View rules →](/rules/?preset=ts.configs.recommended) | | `ts.configs.recommendedTypeChecked` | TypeScript recommended rules, including typed ones | [View rules →](/rules/?preset=ts.configs.recommendedTypeChecked) | | `ts.configs.strict` | TypeScript recommended rules plus opinionated extras | [View rules →](/rules/?preset=ts.configs.strict) | | `ts.configs.strictTypeChecked` | TypeScript strict rules, including typed ones | [View rules →](/rules/?preset=ts.configs.strictTypeChecked) | | `ts.configs.stylistic` | TypeScript consistency rules | [View rules →](/rules/?preset=ts.configs.stylistic) | | `ts.configs.stylisticTypeChecked` | TypeScript consistency rules, including typed ones | [View rules →](/rules/?preset=ts.configs.stylisticTypeChecked) | | `reactPlugin.configs.recommended` | React rules | [View rules →](/rules/?preset=reactPlugin.configs.recommended) | | `reactHooksPlugin.configs.recommended` | React Hooks rules | [View rules →](/rules/?preset=reactHooksPlugin.configs.recommended) | | `importPlugin.configs.recommended` | Import/export rules | [View rules →](/rules/?preset=importPlugin.configs.recommended) | | `nodePlugin.configs.recommended` | Node.js rules for mixed CommonJS and ES modules | [View rules →](/rules/?preset=nodePlugin.configs.recommended) | | `nodePlugin.configs.recommendedModule` | Node.js rules for ES modules | [View rules →](/rules/?preset=nodePlugin.configs.recommendedModule) | | `nodePlugin.configs.recommendedScript` | Node.js rules for CommonJS | [View rules →](/rules/?preset=nodePlugin.configs.recommendedScript) | | `promisePlugin.configs.recommended` | Promise rules | [View rules →](/rules/?preset=promisePlugin.configs.recommended) | | `jestPlugin.configs.recommended` | Jest rules | [View rules →](/rules/?preset=jestPlugin.configs.recommended) | | `jestPlugin.configs.style` | Jest style rules | [View rules →](/rules/?preset=jestPlugin.configs.style) | | `rstestPlugin.configs.recommended` | Rstest rules | [View rules →](/rules/?preset=rstestPlugin.configs.recommended) | | `unicornPlugin.configs.recommended` | Unicorn rules | [View rules →](/rules/?preset=unicornPlugin.configs.recommended) | | `jsxA11yPlugin.configs.recommended` | JSX a11y rules | [View rules →](/rules/?preset=jsxA11yPlugin.configs.recommended) | Import presets from `@rslint/core`: ```ts import { defineConfig, js, ts, reactPlugin, reactHooksPlugin, importPlugin, nodePlugin, promisePlugin, jestPlugin, rstestPlugin, unicornPlugin, jsxA11yPlugin, } from '@rslint/core'; ``` ## Choosing a TypeScript preset The `ts.configs.*` presets mirror typescript-eslint's own layering. Pick one baseline: | Baseline | What it covers | | ------------------------ | ------------------------------------------------------------------------------------- | | `recommended` | Rules that catch code likely to be buggy, using syntax alone | | `recommendedTypeChecked` | `recommended` plus the rules that read type information | | `strict` | `recommended` plus opinionated rules that catch more bugs at the cost of more reports | | `strictTypeChecked` | `strict` plus the rules that read type information | `stylistic` and `stylisticTypeChecked` hold the consistency rules. Layer one after the baseline: ```ts export default defineConfig([ js.configs.recommended, ts.configs.strictTypeChecked, ts.configs.stylisticTypeChecked, ]); ``` Every `ts.configs.*` preset declares the `@typescript-eslint` plugin. Like upstream, presets do not set project discovery options. Enable `parserOptions.projectService: true` explicitly for automatic discovery, or use `parserOptions.project` to select TypeScript projects. Type-aware rules run only for files with a selected project; [gap files](/guide/type-checking.md#gap-files) retain source-only linting. To configure a rule manually, see [`rules`](/config/rules.md). To enable rules outside a preset, see [`plugins`](/config/plugins.md). The complete [Rules](/rules/index.md) reference documents rule-specific options. --- url: /config/base-path.md --- # basePath - **Type:** `string` `basePath` sets the directory from which one flat-config entry is matched. It is a literal directory path, not a glob. Its per-file configuration is inactive outside that directory; explicit TypeScript projects retain the [owner-wide behavior](#typescript-projects) described below. ```ts { basePath: 'packages/app', files: ['src/**/*.ts'], ignores: ['src/generated/**'], languageOptions: { parserOptions: { project: ['./tsconfig.json'] }, }, rules: { 'no-debugger': 'error', }, } ``` In this example, `files`, `ignores`, and the explicit `project` path all start from `packages/app`. `basePath` changes only their starting directory; `files` and `ignores` keep the same glob syntax and matching behavior as entries without `basePath`. An entry containing only `basePath`, `ignores`, and an optional `name` is still a [global ignore entry](/config/ignoring-files.md#global-and-entry-level-ignores). Its patterns are scoped to the effective base directory and participate in normal lint-target and config-candidate traversal. ## Resolution base A relative `basePath` resolves from the ConfigArray base. That base depends on how the config was selected: | Config entry source | `basePath` resolves from | Relative paths when `basePath` is absent | | ------------------------------------------------------------------ | --------------------------- | -------------------------------------------------- | | Automatically discovered config module | Config module directory | Config module directory | | Explicit `--config`, API `overrideConfigFile`, or fixed LSP config | Invocation/workspace cwd | Config module directory (existing Rslint behavior) | | API inline `overrideConfig` in automatic-discovery mode | Discovered config directory | API `cwd` | | API inline `overrideConfig` with an explicit config or no config | API `cwd` | API `cwd` | An inline override therefore uses the discovered module directory for `basePath` in automatic mode, and API `cwd` with an explicit config or `overrideConfigFile: true`. This matches how ESLint appends `overrideConfig` to the selected ConfigArray. Relative fields in an inline entry without `basePath` keep Rslint's existing API-`cwd` behavior. For example, if `/project` invokes an external config: ```bash cd /project rslint --config /configs/rslint.config.ts ``` Then `basePath: 'app'` means `/project/app`, not `/configs/app`. Absolute paths are used as written. An empty string is also valid and still counts as an authored `basePath`; this matters when an inline override's ordinary path origin differs from its ConfigArray base. Glob characters are literal in `basePath`, so `basePath: 'packages/*'` names a directory containing `*` rather than selecting every package. ## TypeScript projects `basePath` moves explicit `languageOptions.parserOptions.project` literals and globs unless the target has an explicit `tsconfigRootDir`. It does not move the governing config's implicit `tsconfig.json` fallback or the automatic discovery boundary. Each declaration retains its own base, including after a null root reset. Ordinary project strings and arrays form the governing owner's declaration list in their original order. Later arrays do not replace earlier declarations; `project: []` suppresses the default fallback only when the list has no paths. New false/null values, service and root settings use the target's matching entries. A final matching false/null disables that target's explicit/default binding, while an enabled service may still run. An effective `project: []` conflicts with enabled service. See [parser options](/config/language-options.md#languageoptionsparseroptionsproject). Because explicit projects are collected for the governing config, a missing project can still report an error even when the entry's `files` patterns select no lint target. See [`languageOptions.parserOptions.project`](/config/language-options.md#languageoptionsparseroptionsproject) for the complete project behavior. ## Directory and ignore boundaries For directory-ignore decisions, a scoped global ignore does not match the effective base directory itself. When `basePath` points above the selected ConfigArray base, a scoped global ignore cannot prune that base itself. Descendants still match normally relative to `basePath`. `basePath` does not move: - The config owner or requested scan root - The root used to collect `.gitignore` files - The existing `files` or `ignores` matcher and glob grammar See [`.gitignore` integration](/config/ignoring-files.md#gitignore-integration) for its independent collection rules. The directory named by `basePath` does not need to exist when the config loads. Non-string values are rejected immediately; a missing explicit TypeScript project is validated separately. --- url: /config/files.md --- # files - **Type:** `(string | string[])[]` Glob selectors specifying which files a config entry applies to. Top-level selectors are ORed. Patterns in a nested array are ANDed, so `files: [['**/*.js', '!**/*.test.js']]` selects JavaScript files except test files. ```ts { files: ['**/*.ts', '**/*.tsx'], rules: { '@typescript-eslint/no-explicit-any': 'error', }, } ``` If `files` is omitted, the entry cascades across files selected by the config's implicit or explicit selectors. If `files` is present, its outer array must be non-empty. Use an omitted `files` field for shared or default entries; `files: []` is invalid. A nested empty AND group (`files: [[]]`) is valid and matches vacuously. ## Lint target selection Lint targets are selected from the CLI or API target range and are limited to Rslint's supported script extensions. Rslint always includes its default extension baseline and adds other supported candidates selected by explicit `files` entries unless the same entry's `ignores` excludes them. A `files` selector cannot make an unsupported source extension lintable. The implicit default baseline is: - `.js` - `.mjs` - `.cjs` - `.jsx` - `.ts` - `.tsx` - `.mts` - `.cts` Global ignores then remove targets; CLI and JavaScript API runs also apply `.gitignore`. An entry-level ignore cannot remove a path selected by the baseline or another entry. It only prevents its own selector and config contribution. See [`ignores`](/config/ignoring-files.md) for details. Every selected target is parsed even when no config entry contributes rules, so syntax diagnostics can still be reported. This includes default-baseline files found by a directory or no-argument scan and explicitly requested supported files that do not match a config entry's `files`. ## TypeScript project coverage File selection is independent of a tsconfig's `include`. A file in tsconfig but outside Rslint's lint target set will not run lint rules. A selected file not covered by a tsconfig declared by its governing config still runs rules that do not require type information. :::tip Selected files not covered by a tsconfig declared by their governing config automatically receive a reduced rule set: only rules that do not require type information run. To enable type-aware rules, add the file to one of that config's tsconfigs. See [`languageOptions.parserOptions.project`](/config/language-options.md#languageoptionsparseroptionsproject). ::: When an entry has `basePath`, its `files` patterns resolve from that directory, and its per-file configuration is inactive outside it. See the [`basePath` configuration reference](/config/base-path.md) for the path-origin and TypeScript project rules. --- url: /config/ignoring-files.md --- # ignores - **Type:** `string[]` Glob patterns for files to exclude. The behavior depends on whether `ignores` appears in a global ignore entry or alongside other configuration fields. ## Global and entry-level ignores An entry containing `ignores` and no fields other than optional `name` and `basePath` acts as a global ignore: matching files are removed from the lint target set. An entry-level ignore prevents that entry's `files` selector, rules, and options from contributing. It cannot remove a path selected by the default extension baseline or another entry, so such a path may still receive configuration or a zero-rule syntax pass. ```ts // Global ignore entry { ignores: ['**/dist/**', '**/fixtures/**'], } // Entry-level ignore (only applies to this entry) { files: ['**/*.ts'], ignores: ['**/*.test.ts'], rules: { /* ... */ }, } ``` ## The `globalIgnores` helper Writing a global-ignore entry is common enough that `@rslint/core` exports a `globalIgnores` helper, mirroring ESLint v10. It returns a config entry containing the given patterns, so the global-ignore intent is explicit: ```ts import { defineConfig, globalIgnores } from '@rslint/core'; export default defineConfig([ globalIgnores(['**/dist/**', '**/fixtures/**']), // ... other entries ]); ``` This is exactly equivalent to writing the entry by hand: ```ts { ignores: ['**/dist/**', '**/fixtures/**'], } ``` `globalIgnores` throws a `TypeError` if it receives a non-array or an empty array. ## Pattern types in global ignores Global ignore patterns affect both file matching and directory traversal (including config discovery in monorepos): | Pattern | Effect | | ---------- | ---------------------------------------------------- | | `dir/**` | Ignores directory and all contents, blocks traversal | | `dir/**/*` | Ignores files inside, but allows directory traversal | | `dir/*` | Ignores direct children files only | Use `dir/**` to completely exclude a directory. Use `dir/**/*` when the walker must still enter the directory so later negations can make selected files or config candidates reachable. An automatically discovered `rslint.config.*` that still matches the file-cover ignore is not loaded; explicitly negate that candidate when you want it to become a config boundary. You can use `!` negation patterns to re-include specific files. Patterns are evaluated sequentially — later patterns override earlier ones: ```ts // Global ignore: re-include specific file { ignores: ['build/**/*', '!build/test.js'], } // Entry-level ignore: re-include a subdirectory { files: ['**/*.ts'], ignores: ['vendor/**/*', '!vendor/keep/**/*'], rules: { /* ... */ }, } // Across separate global ignore entries { ignores: ['build/**/*'] }, { ignores: ['!build/test.js'] }, ``` :::warning For directory-level patterns (`dir/**`), `!` negation cannot re-include files because the directory traversal is blocked entirely. Use `dir/**/*` instead if you need negation: ```ts // ✅ dir/**/* allows traversal — negation works { ignores: ['build/**/*', '!build/test.js'], } // ❌ dir/** blocks traversal — negation has no effect { ignores: ['build/**', '!build/test.js'], } ``` ::: :::tip `node_modules` and `.git` are automatically excluded by rslint — you don't need to add them to ignores. ::: ## .gitignore integration The CLI, JavaScript API, and LSP automatically read `.gitignore` files and treat their patterns as additional global ignores. Automatically discovered configs and ordinary LSP files start collection at the governing config directory. An explicitly selected invocation-wide config (`--config`, API `overrideConfigFile`, or the LSP `configPath` setting) starts at the invocation or workspace-folder `cwd`, even when the config file is elsewhere. A requested directory outside `cwd` gets its own independent Git scope. Collection never searches a scope's parents. In the editor, saved `.gitignore` changes refresh diagnostics for open files. An entry's [`basePath`](/config/base-path.md) does not move these `.gitignore` roots. It only scopes that authored entry and rebases its own `ignores` patterns. - **Nested `.gitignore` files** inside one Git scope are supported — each one only affects its own directory subtree - **Parent patterns cascade** to child directories within that scope (e.g., root `dist/` also ignores `packages/app/dist/`) - **Child `.gitignore` can override** parent patterns with `!` negation - **Multiple requested directory scopes stay independent** — patterns from one sibling directory never apply to another, including through filesystem aliases - **Child configs are boundaries** — they do not inherit `.gitignore` files from a parent config directory - Config `!` negation can also override `.gitignore` patterns (they are evaluated sequentially in the same global ignores list) ```text # .gitignore dist/ coverage/ *.log # packages/app/.gitignore !dist/ # re-include dist/ under packages/app/ ``` To make a lint target reachable, re-include it in the applicable `.gitignore` policy or with a later global ignore entry in `rslint.config.*`: ```text # .gitignore dist/* !dist/important.ts ``` Configuration discovery is independent of `.gitignore`: an automatically discovered or explicitly selected `rslint.config.*` is still loaded when its path matches an ignore rule. `.gitignore` is applied later, when Go selects lint targets inside that config's ownership scope. --- url: /config/rules.md --- # rules - **Type:** `Record` - **RuleSeverity:** `'off' | 'warn' | 'error' | 0 | 1 | 2` Configures individual rules with a severity level and optional positional options. Plugin rule keys combine the configured plugin prefix with its rule name. For ordinary prefixes, the first `/` separates them: `custom/group/rule` means rule `group/rule` in plugin `custom`. Prefixes starting with `@` follow ESLint's scoped syntax and split at the last `/`: `@scope/plugin/rule` belongs to plugin `@scope/plugin`. Use the complete rule key in `--rule` arguments and disable comments as well. | Value | Description | | -------------- | ----------------------------------------- | | `"error"`, `2` | Reports as an error; causes non-zero exit | | `"warn"`, `1` | Reports as a warning | | `"off"`, `0` | Disables the rule | Use a severity directly when a rule has no options to configure: ```ts { rules: { '@typescript-eslint/no-explicit-any': 'error', '@typescript-eslint/require-await': 'off', }, } ``` Use an array to pass every item after the severity to the rule as a positional option: ```ts { rules: { '@typescript-eslint/array-type': ['warn', { default: 'array-simple' }], '@typescript-eslint/no-unused-vars': [ 'error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', }, ], }, } ``` Invalid severities and rule value shapes are rejected while the configuration is loaded. ## Merging Later matching config entries override earlier entries. When a later entry changes only the severity, the rule keeps options from the earlier entry. Supplying any positional option in the later array replaces all earlier options. ```ts export default defineConfig([ { rules: { '@typescript-eslint/no-unused-vars': ['error', { args: 'all' }], }, }, { files: ['tests/**'], rules: { // Keeps { args: 'all' } while changing the severity. '@typescript-eslint/no-unused-vars': 'warn', }, }, ]); ``` See [Rules & Presets](/config/rules-and-presets.md) for preset selection, or browse the complete [Rules](/rules/index.md) reference for rule-specific options. --- url: /config/plugins.md --- # plugins - **Type:** `string[] | Record` Enables plugins for a config entry. Rslint accepts either an array of built-in plugin names or an object containing third-party ESLint plugin instances. ## Built-in plugins Use the array form for plugins whose rules are implemented natively by Rslint. A name declares a rule namespace; its rules become available under the `/` prefix inside [`rules`](/config/rules.md). | Plugin | Rules Prefix | | --- | --- | | `@typescript-eslint` | `@typescript-eslint/*` | | `react` | `react/*` | | `react-hooks` | `react-hooks/*` | | `import` | `import/*` | | `node` | `node/*` | | `promise` | `promise/*` | | `jest` | `jest/*` | | `rstest` | `rstest/*` | | `unicorn` | `unicorn/*` | | `jsx-a11y` | `jsx-a11y/*` | ```ts { files: ['**/*.ts'], plugins: ['@typescript-eslint'], rules: { '@typescript-eslint/no-explicit-any': 'error', }, } ``` ESLint core rules, such as `no-unused-vars` or `prefer-const`, are not part of a plugin. Enable them directly in `rules` without listing anything here. Presets such as `ts.configs.recommended` already include their own `plugins` entry, so this field is only needed when configuring plugin rules outside a preset. ## Third-party ESLint plugins Use the object form to map a prefix to an imported plugin object. These JavaScript rules run in the Node plugin worker and are routed through the same per-file flat config as native rules. This form requires a JS/TS config because JSON cannot carry a live plugin object. ```ts import examplePlugin from 'eslint-plugin-example'; export default defineConfig([ { files: ['**/*.ts'], plugins: { example: examplePlugin }, rules: { 'example/some-rule': 'error', }, }, ]); ``` A single entry uses one plugin form. To combine built-in and third-party plugins, declare them in separate config entries; matching entries are merged before linting. A third-party prefix may not collide with a built-in plugin name. See [ESLint plugin compatibility](/guide/eslint-plugins.md) for the supported and unsupported ESLint APIs. --- url: /config/language-options.md --- # languageOptions - **Type:** `object` Configures the JavaScript language environment and TypeScript project information for matching files. Nested language options from matching entries merge recursively; later arrays and scalar values replace earlier values. Ordinary explicit-project loading retains the separate [owner declaration list](#languageoptionsparseroptionsproject) described below. ## languageOptions.ecmaVersion - **Type:** `number | 'latest'` - **Default:** `'latest'` Selects the standard ECMAScript globals exposed to native rules. Accepted numbers match ESLint and Espree: `3`, `5`, edition aliases `6` through `17`, or years `2015` through `2026`. Edition aliases are normalized to their year (`6` is ES2015 and `17` is ES2026). The `'latest'` value remains semantic rather than being frozen into the config, so it follows the ESLint version targeted by Rslint. This option currently selects globals; it does not change TypeScript's parser target. ```ts { languageOptions: { ecmaVersion: 'latest', }, } ``` ## languageOptions.sourceType - **Type:** `'module' | 'script' | 'commonjs'` - **Default:** exact lowercase `.cjs` extension → `'commonjs'`; every other filename → `'module'` Selects the module kind used by the per-file language context, including CommonJS globals (`require`, `module`, `exports`, `global`) and whether the top-level scope is the global object. When omitted, a filename with an exact lowercase `.cjs` extension resolves to `'commonjs'`; every other filename, including unknown extensions and extension-less filenames, resolves to `'module'` before rules see the value, matching ESLint. An authored value applies on every extension. This option does not change TypeScript parsing or compiler module resolution. Support in an individual native rule depends on that rule consulting the configured value; rules that still document syntax-based module detection continue to use that behavior. Set `sourceType` directly on `languageOptions`; the legacy `languageOptions.parserOptions.sourceType` location is not supported. ```ts { files: ['scripts/**/*.js'], languageOptions: { sourceType: 'commonjs', }, } ``` ## languageOptions.parserOptions.projectService - **Type:** `boolean` Discovers a TypeScript config that directly includes each selected file through `files` or `include`. Enable it explicitly; TypeScript presets do not set this option, matching typescript-eslint presets. Discovery starts beside the source file, checking `tsconfig.json`, then `jsconfig.json`, and continues through ancestors when a config does not own the file. Project references can lead to custom config names such as `tsconfig.app.json`. The nearest owning project wins over a different tsconfig beside the Rslint config or in the current working directory. Reference ownership follows TypeScript's source redirects and reference order. Each selected project keeps its complete root files and dependencies; selecting one lint file limits lint execution, not the type context. JavaScript files use the same discovery. A JS file explicitly listed in `files` can receive types even with `allowJs: false`; that option still controls JS glob inclusion. Files reached only through imports or triple-slash references are not configured lint roots and use gap linting, whether they are JS or TS. ```ts { languageOptions: { parserOptions: { projectService: true, }, }, } ``` `projectService: true` cannot be combined with an effective `project` string, array or `[]`, including values inherited from different matching entries. A final matching `project: false` or `project: null` clears that conflict and disables explicit binding for the target; service can still select a project. A final matching `projectService: false` disables automatic discovery and the implicit default project, but preserves the owner's explicit declarations described below. JavaScript configurations and legacy JSON migration also accept `projectService: null` as a runtime reset, outside the public TypeScript type. A selected file that does not belong to a discovered project uses Rslint's existing [source-only gap fallback](/guide/type-checking.md#gap-files). Syntax diagnostics and rules that do not require types still run; type-aware rules are skipped. Other files in the same lint request keep their own project context. Config and Program failures are still errors. This differs from typescript-eslint, which can admit imported-only files and rejects unowned files unless `allowDefaultProject` permits them. Rslint does not create a typed default project. To force source-only linting even when a file has an owning project, set both `projectService: false` and `project: false` for that file scope. Object options such as `allowDefaultProject`, `defaultProject`, and `loadTypeScriptPlugins`, as well as `extraFileExtensions`, are not implemented. `project: true` is also unsupported; use `projectService: true` for automatic discovery. When a tsconfig sets `disableReferencedProjectLoad`, Rslint stops discovering projects through those references. This is independent of earlier linted files. Upstream can still use previously loaded referenced projects; Rslint does not reproduce that history-dependent exception. `disableSolutionSearching` stops further ancestor search. ## languageOptions.parserOptions.tsconfigRootDir - **Type:** `string` - **Default:** the directory of the governing Rslint config file; API `cwd` for inline-only configuration An absolute directory for the host operating system that stops upward project discovery when the search reaches it. Trailing separators and dot segments are normalized before comparing the boundary. It does not select a tsconfig by itself. If the target is outside this directory's ancestor chain, it can still discover its own ancestors. Project references and `extends` may point outside the boundary. The final value after matching and merging must be absolute; a relative or empty string in an unmatched or overridden entry does not fail the request. JavaScript configurations and legacy JSON migration also accept `null` to reset an inherited boundary to the default. This is runtime compatibility, outside the public TypeScript type. JavaScript configurations checked with `checkJs` and `strictNullChecks` are still subject to that type. A later `undefined` preserves an inherited value. Go resolves the default from the config file selected for each target. An explicitly selected config uses that file's directory, including custom filenames. Imported presets, helper modules, object or rules spread, and `basePath` do not change it. With API `overrideConfigFile: true`, the inline configuration uses API `cwd`; an inline override appended to a loaded config retains that config's default directory. This follows typescript-eslint's documented config-directory default. Its implementation instead infers candidates from preset access on the JavaScript call stack: missing candidates fall back to process cwd, and multiple candidates can produce an ambiguity error. Rslint uses its known config owner directly. These heuristic edge cases differ; no preset access or process-global candidate state is involved. Validation applies to the final matched value. Invalid types, relative paths and empty strings in unmatched entries or replaced by a later value do not fail a lint request. An explicitly set `tsconfigRootDir` also anchors every relative `project` declaration for that target, preserving declaration order. Without it, or after a null reset, each declaration retains its own authored path origin described below. It does not move Rslint's implicit governing-directory `tsconfig.json` fallback when no project paths are declared. | Configuration | Default discovery boundary | | ------------------------------------------------------ | ------------------------------------------------ | | Root config used from a package cwd | Root config directory | | Nested config owns the target | Nested config directory | | Explicit `--config` / `overrideConfigFile` | Selected config file's directory | | Imported or transformed presets, including JSON copies | Governing config directory | | Inline-only API config | API `cwd` | | Loaded config plus inline overrides or `basePath` | Governing config directory | | Explicit absolute `tsconfigRootDir` | That directory | | Later `null` / `undefined` | Restore the default / retain the inherited value | A root config can therefore allow ancestor discovery into a large root TypeScript project even when linting a single package. Set an explicit package boundary if that is the intended scope; selected Programs retain their complete files and dependencies. ## languageOptions.parserOptions.project - **Type:** `string | string[] | false | null` Specifies explicit `tsconfig.json` paths. Glob patterns are supported for monorepos. Files included by these tsconfigs receive full type information, enabling type-aware rules such as `@typescript-eslint/no-floating-promises` and `@typescript-eslint/await-thenable`. Files outside all tsconfigs are still linted, but only rules that do not require type information run. ```ts { languageOptions: { parserOptions: { projectService: false, project: ['./tsconfig.json', './packages/*/tsconfig.json'], }, }, } ``` Rslint collects explicit project strings and arrays from the governing config in declaration order. The list includes entries whose `files`, `ignores` or `basePath` do not match the target; a missing declaration can therefore fail the load. The first project listing the target as a root wins. Only when no project lists it as a root does Rslint try import membership in declaration order. Adding `projectService` or `tsconfigRootDir` does not change this ordinary project order. This declaration list differs from typescript-eslint's final matching `project` value. Matching and merging still determine the effective service/root options, project/service conflicts and the new `false`/`null` clear values. | Entries in order | Ordinary target binding | | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | | `project: 'a.json'`, then `project: 'b.json'` | Search a, then b, with direct-root priority | | `project: 'a.json'`, then `project: []` | Keep a; \[] does not erase earlier declarations | | Final matching `project: false` or `null` | Use no explicit/default project for that target; enabled service may still run | | `project: 'a.json'`, then false, then `project: 'b.json'` | Final clear is canceled; search the original a, b list again | | Matching `projectService: false`, with an explicit declaration in an unmatched entry | Disable automatic/default discovery but keep that explicit declaration | When an entry has `basePath`, its explicit project literals and globs resolve from that directory unless the target has an explicit `tsconfigRootDir`. The directory remains literal even if its name contains glob characters. A later null root reset restores each declaration's original base. Targets with different roots keep separate eligible project lists even if their Programs contain overlapping files. When both project settings are omitted, Rslint retains the governing config directory's default `tsconfig.json` fallback; neither `basePath` nor `tsconfigRootDir` moves this implicit lookup. A declaration of `project: []` suppresses fallback when no paths were declared. A final matching false/null or `projectService: false` disables default binding for that target. Unmatched false/null does not disable another target's fallback. See [`basePath`](/config/base-path.md) for path origins. Plain CLI/API lint selects projects from target membership. Whole-directory CLI lint still validates every explicit declaration of its active ordinary owners, even when a project does not need to be built. Files without a direct project may require building additional projects to check import membership. `--type-check` and `--type-check-only` retain [program-wide explicit checking](/guide/type-checking.md#what-gets-type-checked), including declarations outside the lint target scope. These modes also check complete service-selected Programs. A per-target clear does not erase the owner's program-wide declarations. ## languageOptions.globals - **Type:** `Record` Declares globals available to matching files. Values are normalized before rules or third-party plugins receive the scope: - Writable: `true`, `'true'`, `'writable'`, `'writeable'` - Read-only: `false`, `null`, `'false'`, `'readonly'`, `'readable'` - Disabled: `'off'` A disabled value removes a declaration inherited from an earlier matching entry, including an ECMAScript built-in. The read-only and writable levels are distinct wherever a rule acts on assignment: `no-global-assign` reports writes to a read-only global and allows them on a writable one. ```ts { languageOptions: { globals: { BUILD_ID: 'readonly', testRuntime: 'writable', }, }, } ``` ECMAScript built-ins are declared according to `languageOptions.ecmaVersion` (`Array` from ES3, `Promise` from ES2015, and so on). Globals added by a runtime — `window` and `document` in browsers, or `process` and `__dirname` in Node.js — are not enabled by default. `@rslint/core` includes the [`globals`](https://www.npmjs.com/package/globals) catalog and exports its environment maps directly, so no extra dependency is required: ```ts import { defineConfig, globals } from '@rslint/core'; export default defineConfig([ { files: ['**/*.js'], languageOptions: { globals: { ...globals.browser, BUILD_ID: 'readonly', }, }, }, ]); ``` The export has the same set names, global names, and boolean access values as importing the npm package directly: `false` means read-only and `true` means writable. In the published package, each set is synchronously loaded and cached the first time its property is read, so importing `@rslint/core` does not parse the complete catalog. Compose multiple environments with ordinary object spreads; later spreads and explicit properties take precedence: ```ts languageOptions: { globals: { ...globals.browser, ...globals.worker, location: 'off', }, } ``` `globals.node` includes the CommonJS globals (`require`, `module`, `exports`, `__dirname`, and `__filename`); use `globals.nodeBuiltin` for Node.js ESM files that should not receive them. The included catalog also exposes the upstream `builtin`, `es3`, `es5`, and `es20xx` maps for API parity, but `languageOptions.ecmaVersion` is the preferred way to select standard-language globals because it keeps parsing and both rule runtimes on the same edition. Every map is an explicit globals declaration. It does not change the parser edition, and it can intentionally override the edition-derived set. For example, an upstream host map containing `Temporal` declares that name even when `ecmaVersion` is `2025`. Loaded maps are shared and cached, so compose and override them with object spreads instead of mutating `globals.browser` or another map in place. Enumerating only `Object.keys(globals)` remains lazy; reading or spreading the complete `globals` object necessarily loads every map. Flat config continues to merge individual global names in matching-entry order. Scope environment maps with `files`, and use a later explicit `{ process: 'off' }` when one inherited global must be removed. :::tip TypeScript's compiler and type-aware rules can resolve declarations from `lib.dom.d.ts`, `@types/node`, and project `.d.ts` files. ESLint-compatible global rules such as `no-undef` and `no-global-assign` intentionally use the flat config's globals instead of TypeScript ambient declarations. The TypeScript presets disable `no-undef`; if you enable such a global rule for TypeScript files, configure their runtime environments too. ::: --- url: /config/settings.md --- # settings - **Type:** `Record` Provides shared settings to all rules in a matching config entry. Native rules and compatible third-party ESLint rules can read these values from their rule context. ```ts { files: ['**/*.tsx'], settings: { react: { version: 'detect', }, 'jsx-a11y': { polymorphicPropName: 'as', }, }, } ``` When multiple matching entries provide `settings`, ordinary nested objects are merged recursively. Later arrays and scalar values replace earlier values. ```ts export default defineConfig([ { settings: { react: { version: 'detect', runtime: 'automatic' }, }, }, { files: ['legacy/**'], settings: { // Keeps version and replaces runtime for matching files. react: { runtime: 'classic' }, }, }, ]); ``` --- url: /rules/index.md --- # Rules Implementation Overview 671Fully Implemented 22Partial Implemented 33Partial Tested 726Total Rules All Rules Select a GroupSelect a StatusPreset | Rule Name | Group | Preset | Since | Status | Failing Cases | | --- | --- | --- | --- | --- | --- | | accessor-pairs | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | adjacent-overload-signatures | @typescript-eslint | ✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | alt-text | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | always-return | eslint-plugin-promise | ✅promisePlugin.configs.recommended | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | anchor-ambiguous-text | eslint-plugin-jsx-a11y | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | anchor-has-content | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | anchor-is-valid | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | aria-activedescendant-has-tabindex | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | aria-props | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | aria-proptypes | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | aria-role | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | aria-unsupported-elements | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | array-callback-return | eslint | | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | array-type | @typescript-eslint | ✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-impl | 1.array-type (nested)2.schema validation | | arrow-body-style | eslint | | [Added in v0.6.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.3) | full | No failing cases | | autocomplete-valid | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | avoid-new | eslint-plugin-promise | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | await-thenable | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | ban-ts-comment | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | ban-tslint-comment | @typescript-eslint | ✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | block-scoped-var | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | boolean-prop-naming | eslint-plugin-react | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | button-has-type | eslint-plugin-react | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | callback-return | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | camelcase | eslint | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | capitalized-comments | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | catch-error-name | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | catch-or-return | eslint-plugin-promise | ✅promisePlugin.configs.recommended | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | checked-requires-onchange-or-readonly | eslint-plugin-react | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | class-literal-property-style | @typescript-eslint | ✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | class-methods-use-this | @typescript-eslint | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | class-methods-use-this | eslint | | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | click-events-have-key-events | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | complexity | eslint | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | consistent-date-clone | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | consistent-each-for | rstest | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | consistent-generic-constructors | @typescript-eslint | ✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | consistent-indexed-object-style | @typescript-eslint | ✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | consistent-return | @typescript-eslint | | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | consistent-return | eslint | | [Added in v0.8.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.0) | full | No failing cases | | consistent-rstest-namespace | rstest | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | consistent-test-filename | rstest | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | consistent-test-it | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | consistent-this | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | consistent-tuple-labels | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | consistent-type-assertions | @typescript-eslint | ✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | consistent-type-definitions | @typescript-eslint | ✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | consistent-type-exports | @typescript-eslint | | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | consistent-type-imports | @typescript-eslint | | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | constructor-super | eslint | ✅js.configs.recommended | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | control-has-associated-label | eslint-plugin-jsx-a11y | | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | curly | eslint | | [Added in v0.6.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.3) | full | No failing cases | | default | eslint-plugin-import | ✅importPlugin.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | default-case | eslint | | [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) | full | No failing cases | | default-case-last | eslint | | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | default-param-last | @typescript-eslint | | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | default-param-last | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | destructuring-assignment | eslint-plugin-react | | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | display-name | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | dot-notation | @typescript-eslint | ✅ts.configs.stylisticTypeChecked | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | dot-notation | eslint | | [Added in v0.1.13](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.13) | partial-impl | 1.Skipped test case at line 1672.Skipped test case at line 1723.Skipped test case at line 1774.Skipped test case at line 1825.Skipped test case at line 187 | | empty-brace-spaces | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | eqeqeq | eslint | | [Added in v0.4.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.1) | full | No failing cases | | error-message | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) | full | No failing cases | | exhaustive-deps | eslint-plugin-react-hooks | ✅reactHooksPlugin.configs.recommended | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | expect-expect | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | expect-expect | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | explicit-function-return-type | @typescript-eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | explicit-member-accessibility | @typescript-eslint | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | explicit-module-boundary-types | @typescript-eslint | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | explicit-timer-delay | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | exports-style | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | file-extension-in-import | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | filename-case | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | first | eslint-plugin-import | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | for-direction | eslint | ✅js.configs.recommended | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | forbid-component-props | eslint-plugin-react | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | forbid-dom-props | eslint-plugin-react | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | forbid-elements | eslint-plugin-react | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | forbid-foreign-prop-types | eslint-plugin-react | | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | forbid-prop-types | eslint-plugin-react | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | forward-ref-uses-ref | eslint-plugin-react | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | func-name-matching | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | func-names | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | func-style | eslint | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | function-component-definition | eslint-plugin-react | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | getter-return | eslint | ✅js.configs.recommended | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | global-require | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | grouped-accessor-pairs | eslint | | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | guard-for-in | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | handle-callback-err | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | hashbang | eslint-plugin-node | ✅nodePlugin.configs.recommended✅nodePlugin.configs.recommendedModule✅nodePlugin.configs.recommendedScript | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | heading-has-content | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | hoisted-apis-on-top | rstest | | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | hook-use-state | eslint-plugin-react | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | html-has-lang | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | id-denylist | eslint | | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | id-length | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | id-match | eslint | | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | iframe-has-title | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | iframe-missing-sandbox | eslint-plugin-react | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | img-redundant-alt | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | init-declarations | @typescript-eslint | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | init-declarations | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | interactive-supports-focus | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | jsx-boolean-value | eslint-plugin-react | | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | jsx-child-element-spacing | eslint-plugin-react | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | jsx-closing-bracket-location | eslint-plugin-react | | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | jsx-closing-tag-location | eslint-plugin-react | | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | jsx-curly-brace-presence | eslint-plugin-react | | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | jsx-curly-newline | eslint-plugin-react | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | jsx-curly-spacing | eslint-plugin-react | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | jsx-equals-spacing | eslint-plugin-react | | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | jsx-filename-extension | eslint-plugin-react | | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | jsx-first-prop-new-line | eslint-plugin-react | | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | jsx-fragments | eslint-plugin-react | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | jsx-handler-names | eslint-plugin-react | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | jsx-indent | eslint-plugin-react | | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | jsx-indent-props | eslint-plugin-react | | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | jsx-key | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | jsx-max-depth | eslint-plugin-react | | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | jsx-max-props-per-line | eslint-plugin-react | | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | jsx-no-bind | eslint-plugin-react | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | jsx-no-comment-textnodes | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | jsx-no-duplicate-props | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | jsx-no-leaked-render | eslint-plugin-react | | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | jsx-no-literals | eslint-plugin-react | | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | jsx-no-script-url | eslint-plugin-react | | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | jsx-no-target-blank | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | jsx-no-undef | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | jsx-no-useless-fragment | eslint-plugin-react | | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | jsx-one-expression-per-line | eslint-plugin-react | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | jsx-pascal-case | eslint-plugin-react | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | jsx-props-no-multi-spaces | eslint-plugin-react | | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | jsx-props-no-spread-multi | eslint-plugin-react | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | jsx-props-no-spreading | eslint-plugin-react | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | jsx-sort-props | eslint-plugin-react | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | jsx-uses-react | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | partial-test | No failing cases | | jsx-uses-vars | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | partial-test | No failing cases | | jsx-wrap-multilines | eslint-plugin-react | | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | label-has-associated-control | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | lang | eslint-plugin-jsx-a11y | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | logical-assignment-operators | eslint | | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | max-classes-per-file | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | max-depth | eslint | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | max-expects | eslint-plugin-jest | | [Added in v0.6.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.1) | full | No failing cases | | max-expects | rstest | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | max-lines | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | max-lines-per-function | eslint | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | max-nested-callbacks | eslint | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | max-nested-describe | eslint-plugin-jest | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | max-nested-describe | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | max-params | @typescript-eslint | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | max-params | eslint | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | max-statements | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | media-has-caption | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | member-ordering | @typescript-eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | method-signature-style | @typescript-eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | mouse-events-have-key-events | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | namespace | eslint-plugin-import | ✅importPlugin.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | naming-convention | @typescript-eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | partial-impl | 1.Skipped test case at line 12852.Skipped test case at line 2286 | | new-cap | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | new-for-builtins | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | newline-after-import | eslint-plugin-import | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-access-key | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | no-access-state-in-setstate | eslint-plugin-react | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-adjacent-inline-elements | eslint-plugin-react | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | no-alert | eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-alias-methods | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-alias-methods | rstest | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-aria-hidden-on-focusable | eslint-plugin-jsx-a11y | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-array-concat-in-loop | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | no-array-constructor | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) | full | No failing cases | | no-array-constructor | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-array-delete | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-array-fill-with-reference-type | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-array-from-fill | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | no-array-front-mutation | eslint-plugin-unicorn | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | no-array-index-key | eslint-plugin-react | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-array-reverse | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-array-sort | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-arrow-function-lifecycle | eslint-plugin-react | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | no-async-mock-factory | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-async-promise-executor | eslint | ✅js.configs.recommended | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | no-autofocus | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | no-await-expression-member | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | no-await-in-loop | eslint | | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | no-await-in-promise-methods | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-base-to-string | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-test | No failing cases | | no-bitwise | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-callback-in-promise | eslint-plugin-promise | ✅promisePlugin.configs.recommended | [Added in v0.6.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.4) | full | No failing cases | | no-callback-literal | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-caller | eslint | | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | no-case-declarations | eslint | ✅js.configs.recommended | [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) | full | No failing cases | | no-children-prop | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-class-assign | eslint | ✅js.configs.recommended | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | no-commented-out-tests | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | no-commented-out-tests | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) | full | No failing cases | | no-compare-neg-zero | eslint | ✅js.configs.recommended | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | no-cond-assign | eslint | ✅js.configs.recommended | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | no-conditional-expect | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-conditional-expect | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.8.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.0) | full | No failing cases | | no-conditional-in-test | eslint-plugin-jest | | [Added in v0.7.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.1) | full | No failing cases | | no-conditional-in-test | rstest | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-conditional-tests | rstest | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | no-confusing-non-null-assertion | @typescript-eslint | ✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-confusing-set-timeout | eslint-plugin-jest | | [Added in v0.6.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.3) | full | No failing cases | | no-confusing-void-expression | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-impl | 1.Skipped test case at line 118 | | no-console | eslint | | [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) | full | No failing cases | | no-const-assign | eslint | ✅js.configs.recommended | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | no-constant-binary-expression | eslint | ✅js.configs.recommended | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | no-constant-condition | eslint | ✅js.configs.recommended | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | no-constructor-return | eslint | | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | no-continue | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | no-control-regex | eslint | ✅js.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-cycle | eslint-plugin-import | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-danger | eslint-plugin-react | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-danger-with-children | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-debugger | eslint | ✅js.configs.recommended | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | no-default-export | eslint-plugin-import | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-delete-var | eslint | ✅js.configs.recommended | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-deprecated | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | partial-impl | 1.Skipped test case at line 17102.Skipped test case at line 30173.Skipped test case at line 3095 | | no-deprecated | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-deprecated-api | eslint-plugin-node | ✅nodePlugin.configs.recommended✅nodePlugin.configs.recommendedModule✅nodePlugin.configs.recommendedScript | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-deprecated-functions | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-did-mount-set-state | eslint-plugin-react | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-did-update-set-state | eslint-plugin-react | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-direct-mutation-state | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-disabled-tests | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | no-disabled-tests | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) | full | No failing cases | | no-distracting-elements | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | no-div-regex | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | no-document-cookie | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | no-done-callback | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-dupe-args | eslint | ✅js.configs.recommended | [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) | full | No failing cases | | no-dupe-class-members | @typescript-eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-dupe-class-members | eslint | ✅js.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-dupe-else-if | eslint | ✅js.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-dupe-keys | eslint | ✅js.configs.recommended | [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) | full | No failing cases | | no-duplicate-case | eslint | ✅js.configs.recommended | [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) | full | No failing cases | | no-duplicate-enum-values | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | no-duplicate-hooks | eslint-plugin-jest | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-duplicate-hooks | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-duplicate-imports | eslint | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-duplicate-type-constituents | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-impl | 1.Skipped test case at line 2322.Skipped test case at line 246 | | no-duplicates | eslint-plugin-import | ✅importPlugin.configs.recommended | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-dynamic-delete | @typescript-eslint | ✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.3.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.2) | full | No failing cases | | no-else-return | eslint | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-empty | eslint | ✅js.configs.recommended | [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) | full | No failing cases | | no-empty-character-class | eslint | ✅js.configs.recommended | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | no-empty-function | @typescript-eslint | ✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.1.6](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.6) | full | No failing cases | | no-empty-function | eslint | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-empty-interface | @typescript-eslint | | [Added in v0.1.6](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.6) | full | No failing cases | | no-empty-object-type | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-empty-pattern | eslint | ✅js.configs.recommended | [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) | full | No failing cases | | no-empty-static-block | eslint | ✅js.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-eq-null | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | no-eval | eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-ex-assign | eslint | ✅js.configs.recommended | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | no-explicit-any | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.1.13](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.13) | full | No failing cases | | no-export | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.6.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.3) | full | No failing cases | | no-exports-assign | eslint-plugin-node | ✅nodePlugin.configs.recommended✅nodePlugin.configs.recommendedModule✅nodePlugin.configs.recommendedScript | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-exports-in-scripts | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | no-extend-native | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-extra-bind | eslint | | [Added in v0.3.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.4) | full | No failing cases | | no-extra-boolean-cast | eslint | ✅js.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-extra-label | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-extra-non-null-assertion | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) | full | No failing cases | | no-extraneous-class | @typescript-eslint | ✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | no-extraneous-import | eslint-plugin-node | ✅nodePlugin.configs.recommended✅nodePlugin.configs.recommendedModule✅nodePlugin.configs.recommendedScript | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-extraneous-require | eslint-plugin-node | ✅nodePlugin.configs.recommended✅nodePlugin.configs.recommendedModule✅nodePlugin.configs.recommendedScript | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-fallthrough | eslint | ✅js.configs.recommended | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-find-dom-node | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-floating-promises | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-focused-tests | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | no-focused-tests | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | no-for-in-array | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-func-assign | eslint | ✅js.configs.recommended | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | no-global-assign | eslint | ✅js.configs.recommended | [Added in v0.3.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.4) | full | No failing cases | | no-hooks | eslint-plugin-jest | | [Added in v0.3.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.4) | full | No failing cases | | no-hooks | rstest | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-identical-title | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | no-identical-title | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) | full | No failing cases | | no-implicit-coercion | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-implicit-globals | eslint | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | no-implied-eval | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-implied-eval | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-import-assign | eslint | ✅js.configs.recommended | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | no-import-node-test | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | no-import-type-side-effects | @typescript-eslint | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-importing-rstest-globals | rstest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | no-inferrable-types | @typescript-eslint | ✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) | full | No failing cases | | no-inline-comments | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-inner-declarations | eslint | | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | partial-impl | 1.Skipped test case at line 106 | | no-instanceof-builtins | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-interactive-element-to-noninteractive-role | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | no-interpolation-in-snapshots | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.7.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.0) | full | No failing cases | | no-interpolation-in-snapshots | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.8.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.0) | full | No failing cases | | no-invalid-fetch-options | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-invalid-html-attribute | eslint-plugin-react | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | no-invalid-regexp | eslint | ✅js.configs.recommended | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | partial-impl | 1.Skipped test case at line 412.Skipped test case at line 433.Skipped test case at line 444.Skipped test case at line 455.Skipped test case at line 466.Skipped test case at line 477.Skipped test case at line 488.Skipped test case at line 499.Skipped test case at line 5010.Skipped test case at line 5111.Skipped test case at line 5212.Skipped test case at line 5413.Skipped test case at line 5514.Skipped test case at line 5815.Skipped test case at line 6016.Skipped test case at line 6217.Skipped test case at line 6318.Skipped test case at line 18119.Skipped test case at line 18720.Skipped test case at line 19221.Skipped test case at line 19822.Skipped test case at line 20423.Skipped test case at line 20924.Skipped test case at line 21425.Skipped test case at line 21926.Skipped test case at line 22427.Skipped test case at line 230 | | no-invalid-remove-event-listener | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-invalid-this | @typescript-eslint | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-invalid-this | eslint | | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | no-invalid-void-type | @typescript-eslint | ✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | no-irregular-whitespace | eslint | ✅js.configs.recommended | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | no-is-mounted | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-iterator | eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-jasmine-globals | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-label-var | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-labels | eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-lone-blocks | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-lonely-if | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-loop-func | @typescript-eslint | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-loop-func | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-loss-of-precision | eslint | ✅js.configs.recommended | [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) | partial-impl | 1.Skipped test case at line 392.Skipped test case at line 433.Skipped test case at line 474.Skipped test case at line 515.Skipped test case at line 806.Skipped test case at line 210 | | no-magic-array-flat-depth | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | no-magic-numbers | @typescript-eslint | | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | no-magic-numbers | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-meaningless-void-operator | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-test | No failing cases | | no-misleading-character-class | eslint | ✅js.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-missing-import | eslint-plugin-node | ✅nodePlugin.configs.recommended✅nodePlugin.configs.recommendedModule✅nodePlugin.configs.recommendedScript | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-missing-require | eslint-plugin-node | ✅nodePlugin.configs.recommended✅nodePlugin.configs.recommendedModule✅nodePlugin.configs.recommendedScript | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-misused-new | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | no-misused-promises | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-misused-spread | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-test | No failing cases | | no-mixed-enums | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-mixed-requires | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-mocks-import | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-mocks-import | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.7.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.2) | full | No failing cases | | no-multi-assign | eslint | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-multi-comp | eslint-plugin-react | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-multi-str | eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-multiple-resolved | eslint-plugin-promise | | [Added in v0.6.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.2) | full | No failing cases | | no-mutable-exports | eslint-plugin-import | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-namespace | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.1.6](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.6) | partial-test | No failing cases | | no-namespace | eslint-plugin-react | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | no-native | eslint-plugin-promise | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-negated-condition | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | no-negation-in-equality-check | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-nested-ternary | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-nested-ternary | eslint-plugin-unicorn | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-nesting | eslint-plugin-promise | ✅promisePlugin.configs.recommended | [Added in v0.6.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.2) | full | No failing cases | | no-new | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-new-buffer | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-new-func | eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-new-native-nonconstructor | eslint | ✅js.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-new-object | eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-new-require | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-new-statics | eslint-plugin-promise | ✅promisePlugin.configs.recommended | [Added in v0.6.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.3) | full | No failing cases | | no-new-symbol | eslint | | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | no-new-wrappers | eslint | | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | no-non-null-asserted-nullish-coalescing | @typescript-eslint | ✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) | full | No failing cases | | no-non-null-asserted-optional-chain | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) | full | No failing cases | | no-non-null-assertion | @typescript-eslint | ✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) | full | No failing cases | | no-noninteractive-element-interactions | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | no-noninteractive-element-to-interactive-role | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | no-noninteractive-tabindex | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | no-nonoctal-decimal-escape | eslint | ✅js.configs.recommended | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-null | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | no-obj-calls | eslint | ✅js.configs.recommended | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | no-object-as-default-parameter | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | no-object-constructor | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-octal | eslint | ✅js.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-octal-escape | eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-param-reassign | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-path-concat | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-plusplus | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | no-process-env | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-process-exit | eslint-plugin-node | ✅nodePlugin.configs.recommended✅nodePlugin.configs.recommendedModule✅nodePlugin.configs.recommendedScript | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-promise-executor-return | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | no-promise-in-callback | eslint-plugin-promise | ✅promisePlugin.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-proto | eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-prototype-builtins | eslint | ✅js.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-redeclare | @typescript-eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | partial-impl | 1.Skipped test case at line 522.Skipped test case at line 613.Skipped test case at line 734.Skipped test case at line 825.Skipped test case at line 896.Skipped test case at line 957.Skipped test case at line 4248.Skipped test case at line 4459.Skipped test case at line 47910.Skipped test case at line 519 | | no-redeclare | eslint | ✅js.configs.recommended | [Added in v0.7.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.0) | partial-impl | 1.Skipped test case at line 28 | | no-redundant-roles | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | no-redundant-should-component-update | eslint-plugin-react | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-redundant-type-constituents | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-regex-spaces | eslint | ✅js.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-render-return-value | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-require-imports | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.1.6](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.6) | full | No failing cases | | no-restricted-exports | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-restricted-globals | eslint | | [Added in v0.7.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.0) | full | No failing cases | | no-restricted-import | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-restricted-imports | @typescript-eslint | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-restricted-imports | eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-restricted-jest-methods | eslint-plugin-jest | | [Added in v0.7.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.0) | full | No failing cases | | no-restricted-matchers | eslint-plugin-jest | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-restricted-matchers | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-restricted-paths | eslint-plugin-import | | [Added in v0.8.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.0) | full | No failing cases | | no-restricted-properties | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-restricted-require | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-restricted-rstest-methods | rstest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | no-restricted-syntax | eslint | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-restricted-types | @typescript-eslint | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-return-assign | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-return-in-finally | eslint-plugin-promise | ✅promisePlugin.configs.recommended | [Added in v0.6.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.4) | full | No failing cases | | no-return-wrap | eslint-plugin-promise | ✅promisePlugin.configs.recommended | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-script-url | eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-self-assign | eslint | ✅js.configs.recommended | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | no-self-compare | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-self-import | eslint-plugin-import | | [Added in v0.1.8](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.8) | full | No failing cases | | no-sequences | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-set-state | eslint-plugin-react | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-setter-return | eslint | ✅js.configs.recommended | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | no-shadow | @typescript-eslint | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | partial-impl | 1.Skipped test case at line 2102.Skipped test case at line 2543.Skipped test case at line 9424.Skipped test case at line 9705.Skipped test case at line 991 | | no-shadow | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-shadow-restricted-names | eslint | ✅js.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-sparse-arrays | eslint | ✅js.configs.recommended | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | no-standalone-expect | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-standalone-expect | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | no-static-element-interactions | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | no-static-only-class | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | no-string-refs | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-sync | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-template-curly-in-string | eslint | | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | partial-test | No failing cases | | no-ternary | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | no-test-prefixes | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.4.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.1) | full | No failing cases | | no-thenable | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-this-alias | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | no-this-assignment | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-this-before-super | eslint | ✅js.configs.recommended | [Added in v0.3.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.3) | full | No failing cases | | no-this-in-sfc | eslint-plugin-react | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-this-outside-of-class | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | no-throw-literal | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-top-level-await | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-type-alias | @typescript-eslint | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-typos | eslint-plugin-react | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-unassigned-vars | eslint | ✅js.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-undef | eslint | | [Added in v0.3.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.3) | full | No failing cases | | no-undef-init | eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-undefined | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | no-underscore-dangle | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-unescaped-entities | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-unexpected-multiline | eslint | ✅js.configs.recommended | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-unknown-property | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-unmodified-loop-condition | eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-unnecessary-array-flat-depth | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | no-unnecessary-array-splice-count | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-unnecessary-assertion | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-unnecessary-boolean-literal-compare | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-impl | 1.Skipped test case at line 1292.Skipped test case at line 969 | | no-unnecessary-condition | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | partial-impl | 1.Skipped test case at line 9022.Skipped test case at line 3089 | | no-unnecessary-parameter-property-assignment | @typescript-eslint | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-unnecessary-qualifier | @typescript-eslint | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-unnecessary-slice-end | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-unnecessary-template-expression | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-unnecessary-type-arguments | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-unnecessary-type-assertion | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-unnecessary-type-constraint | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-unnecessary-type-conversion | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-unnecessary-type-parameters | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.8.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.0) | full | No failing cases | | no-unneeded-async-expect-function | eslint-plugin-jest | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-unneeded-ternary | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-unpublished-bin | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-unpublished-import | eslint-plugin-node | ✅nodePlugin.configs.recommended✅nodePlugin.configs.recommendedModule✅nodePlugin.configs.recommendedScript | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-unpublished-require | eslint-plugin-node | ✅nodePlugin.configs.recommended✅nodePlugin.configs.recommendedModule✅nodePlugin.configs.recommendedScript | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-unreachable | eslint | ✅js.configs.recommended | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-unreachable-loop | eslint | | [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) | full | No failing cases | | no-unreadable-iife | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-unreadable-new-expression | eslint-plugin-unicorn | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | no-unsafe | eslint-plugin-react | | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | no-unsafe-argument | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-unsafe-assignment | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-impl | 1.Skipped test case at line 59 | | no-unsafe-call | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-unsafe-declaration-merging | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-unsafe-enum-comparison | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-unsafe-finally | eslint | ✅js.configs.recommended | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-unsafe-function-type | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-unsafe-member-access | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-unsafe-negation | eslint | ✅js.configs.recommended | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | no-unsafe-optional-chaining | eslint | ✅js.configs.recommended | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-unsafe-return | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-unsafe-string-replacement | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-unsafe-type-assertion | @typescript-eslint | | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-unsafe-unary-minus | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | no-unstable-nested-components | eslint-plugin-react | | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | no-unsupported-features/es-builtins | eslint-plugin-node | ✅nodePlugin.configs.recommended✅nodePlugin.configs.recommendedModule✅nodePlugin.configs.recommendedScript | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-unsupported-features/es-syntax | eslint-plugin-node | ✅nodePlugin.configs.recommended✅nodePlugin.configs.recommendedModule✅nodePlugin.configs.recommendedScript | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-unsupported-features/node-builtins | eslint-plugin-node | ✅nodePlugin.configs.recommended✅nodePlugin.configs.recommendedModule✅nodePlugin.configs.recommendedScript | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-unused-class-component-methods | eslint-plugin-react | | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | no-unused-expressions | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-unused-expressions | eslint | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | partial-impl | 1.Skipped test case at line 2202.Skipped test case at line 2223.Skipped test case at line 2264.Skipped test case at line 232 | | no-unused-labels | eslint | ✅js.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-unused-private-class-members | @typescript-eslint | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-unused-private-class-members | eslint | ✅js.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-unused-prop-types | eslint-plugin-react | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-unused-state | eslint-plugin-react | | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | no-unused-vars | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-impl | 1.Skipped test case at line 572.Skipped test case at line 3183.Skipped test case at line 3274.Skipped test case at line 5065.Skipped test case at line 9176.Skipped test case at line 9227.Skipped test case at line 9308.Skipped test case at line 9369.Skipped test case at line 94410.Skipped test case at line 94911.Skipped test case at line 95812.Skipped test case at line 1613.Skipped test case at line 3514.Skipped test case at line 23115.Skipped test case at line 38816.Skipped test case at line 40617.Skipped test case at line 42418.Skipped test case at line 43919.Skipped test case at line 45420.Skipped test case at line 47121.Skipped test case at line 49222.Skipped test case at line 67023.Skipped test case at line 68324.Skipped test case at line 70225.Skipped test case at line 79026.Skipped test case at line 13527.Skipped test case at line 16128.Skipped test case at line 37529.Skipped test case at line 42830.Skipped test case at line 70231.Skipped test case at line 72732.Skipped test case at line 77733.Skipped test case at line 79334.Skipped test case at line 80235.Skipped test case at line 81136.Skipped test case at line 4937.Skipped test case at line 48738.Skipped test case at line 2307 | | no-unused-vars | eslint | ✅js.configs.recommended | [Added in v0.7.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.1) | full | No failing cases | | no-use-before-define | @typescript-eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-use-before-define | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | no-useless-assignment | eslint | ✅js.configs.recommended | [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) | full | No failing cases | | no-useless-backreference | eslint | ✅js.configs.recommended | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-useless-call | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-useless-catch | eslint | ✅js.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-useless-computed-key | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-useless-concat | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-useless-constructor | @typescript-eslint | ✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-useless-constructor | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-useless-default-assignment | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-useless-empty-export | @typescript-eslint | | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-test | No failing cases | | no-useless-error-capture-stack-trace | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | no-useless-escape | eslint | ✅js.configs.recommended | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | no-useless-rename | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-useless-return | eslint | | [Added in v0.8.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.0) | full | No failing cases | | no-useless-switch-case | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | no-var | eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | no-var-requires | @typescript-eslint | | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-test | No failing cases | | no-void | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | no-warning-comments | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | no-webpack-loader-syntax | eslint-plugin-import | | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | no-will-update-set-state | eslint-plugin-react | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | no-with | eslint | ✅js.configs.recommended | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | no-wrapper-object-types | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | no-xor-as-exponentiation | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | no-zero-fractions | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | non-nullable-type-assertion-style | @typescript-eslint | ✅ts.configs.stylisticTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | number-literal-case | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | object-shorthand | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | one-var | eslint | | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | only-throw-error | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | operator-assignment | eslint | | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | order | eslint-plugin-import | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | padding-around-after-all-blocks | eslint-plugin-jest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-after-all-blocks | rstest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-after-each-blocks | eslint-plugin-jest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-after-each-blocks | rstest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-all | eslint-plugin-jest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-all | rstest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-before-all-blocks | eslint-plugin-jest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-before-all-blocks | rstest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-before-each-blocks | eslint-plugin-jest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-before-each-blocks | rstest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-describe-blocks | eslint-plugin-jest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-describe-blocks | rstest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-expect-groups | eslint-plugin-jest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-expect-groups | rstest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-test-blocks | eslint-plugin-jest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | padding-around-test-blocks | rstest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | param-names | eslint-plugin-promise | ✅promisePlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | parameter-properties | @typescript-eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | prefer-add-event-listener-options | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | prefer-array-flat | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.7.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.1) | full | No failing cases | | prefer-array-flat-map | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | prefer-array-some | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) | full | No failing cases | | prefer-arrow-callback | eslint | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | prefer-as-const | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | prefer-await-to-callbacks | eslint-plugin-promise | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-await-to-then | eslint-plugin-promise | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | prefer-blob-reading-methods | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | prefer-called-exactly-once-with | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | prefer-called-once | rstest | | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | prefer-called-times | rstest | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | prefer-called-with | eslint-plugin-jest | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | prefer-called-with | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-catch | eslint-plugin-promise | | [Added in v0.6.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.4) | full | No failing cases | | prefer-comparison-matcher | eslint-plugin-jest | | [Added in v0.7.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.0) | full | No failing cases | | prefer-comparison-matcher | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-const | eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.3.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.3) | full | No failing cases | | prefer-date-now | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-destructuring | @typescript-eslint | | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | prefer-destructuring | eslint | | [Added in v0.7.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.1) | full | No failing cases | | prefer-dom-node-append | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-each | eslint-plugin-jest | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | prefer-each | rstest | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | prefer-ending-with-an-expect | eslint-plugin-jest | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | prefer-ending-with-an-expect | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-enum-initializers | @typescript-eslint | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | prefer-equality-matcher | eslint-plugin-jest | | [Added in v0.6.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.2) | full | No failing cases | | prefer-equality-matcher | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-es6-class | eslint-plugin-react | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | prefer-expect-resolves | eslint-plugin-jest | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | prefer-expect-type-of | rstest | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | prefer-exponentiation-operator | eslint | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | partial-impl | 1.Skipped test case at line 332.Skipped test case at line 433.Skipped test case at line 474.Skipped test case at line 51 | | prefer-find | @typescript-eslint | ✅ts.configs.stylisticTypeChecked | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | prefer-for-of | @typescript-eslint | ✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | prefer-function-type | @typescript-eslint | ✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | prefer-global-number-constants | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-global/buffer | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-global/console | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-global/process | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-global/text-decoder | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-global/text-encoder | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-global/url | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-global/url-search-params | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-hooks-in-order | eslint-plugin-jest | | [Added in v0.6.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.3) | full | No failing cases | | prefer-hooks-in-order | rstest | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | prefer-hooks-on-top | eslint-plugin-jest | | [Added in v0.6.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.3) | full | No failing cases | | prefer-hooks-on-top | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-identifier-import-export-specifiers | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-import-in-mock | rstest | | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | prefer-importing-jest-globals | eslint-plugin-jest | | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | prefer-importing-rstest-globals | rstest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | prefer-includes | @typescript-eslint | ✅ts.configs.stylisticTypeChecked | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | prefer-jest-mocked | eslint-plugin-jest | | [Added in v0.6.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.4) | full | No failing cases | | prefer-literal-enum-member | @typescript-eslint | ✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) | full | No failing cases | | prefer-lowercase-title | eslint-plugin-jest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-lowercase-title | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-named-capture-group | eslint | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | partial-impl | 1.Skipped test case at line 262.Skipped test case at line 273.Skipped test case at line 28 | | prefer-namespace-keyword | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) | full | No failing cases | | prefer-node-protocol | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-node-protocol | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) | full | No failing cases | | prefer-nullish-coalescing | @typescript-eslint | ✅ts.configs.stylisticTypeChecked | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | partial-impl | 1.Skipped test case at line 2486 | | prefer-number-properties | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | prefer-numeric-literals | eslint | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | prefer-object-has-own | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | prefer-object-spread | eslint | | [Added in v0.7.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.1) | full | No failing cases | | prefer-optional-catch-binding | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-optional-chain | @typescript-eslint | ✅ts.configs.stylisticTypeChecked | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | prefer-promise-reject-errors | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-test | No failing cases | | prefer-promise-reject-errors | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | prefer-promises/dns | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-promises/fs | eslint-plugin-node | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-read-only-props | eslint-plugin-react | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | prefer-readonly | @typescript-eslint | | [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) | full | No failing cases | | prefer-readonly-parameter-types | @typescript-eslint | | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | prefer-reduce-type-parameter | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | prefer-reflect-apply | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-regex-literals | eslint | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | partial-impl | 1.Skipped test case at line 732.Skipped test case at line 743.Skipped test case at line 824.Skipped test case at line 835.Skipped test case at line 846.Skipped test case at line 857.Skipped test case at line 86 | | prefer-regexp-exec | @typescript-eslint | ✅ts.configs.stylisticTypeChecked | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | prefer-rest-params | eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | prefer-return-this-type | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | prefer-rs-mocked | rstest | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | prefer-set-has | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) | full | No failing cases | | prefer-set-size | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-spread | eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked✅ts.configs.stylistic✅ts.configs.stylisticTypeChecked | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | prefer-spy-on | eslint-plugin-jest | | [Added in v0.6.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.4) | full | No failing cases | | prefer-stateless-function | eslint-plugin-react | | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | prefer-strict-boolean-matchers | rstest | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | prefer-strict-equal | eslint-plugin-jest | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | prefer-strict-equal | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-string-starts-ends-with | @typescript-eslint | ✅ts.configs.stylisticTypeChecked | [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) | full | No failing cases | | prefer-string-trim-start-end | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | prefer-tag-over-role | eslint-plugin-jsx-a11y | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | prefer-template | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | prefer-ternary | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | prefer-then-catch | eslint-plugin-unicorn | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | prefer-to-be | eslint-plugin-jest | ✅jestPlugin.configs.style | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | prefer-to-be | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-to-be-falsy | rstest | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | prefer-to-be-truthy | rstest | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | prefer-to-contain | eslint-plugin-jest | ✅jestPlugin.configs.style | [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) | full | No failing cases | | prefer-to-contain | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-to-have-been-called | eslint-plugin-jest | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | prefer-to-have-been-called | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-to-have-been-called-times | eslint-plugin-jest | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | prefer-to-have-been-called-times | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-to-have-length | eslint-plugin-jest | ✅jestPlugin.configs.style | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | prefer-to-have-length | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | prefer-todo | eslint-plugin-jest | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | prefer-todo | rstest | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | prefer-ts-expect-error | @typescript-eslint | | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | prefer-type-error | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | preserve-caught-error | eslint | ✅js.configs.recommended | [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) | full | No failing cases | | promise-function-async | @typescript-eslint | | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-test | No failing cases | | prop-types | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | radix | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | react-in-jsx-scope | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | partial-test | No failing cases | | related-getter-setter-pairs | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | require-array-join-separator | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.7.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.0) | full | No failing cases | | require-array-sort-compare | @typescript-eslint | | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-test | No failing cases | | require-atomic-updates | eslint | | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | require-await | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | require-await | eslint | | [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) | full | No failing cases | | require-awaited-expect-poll | rstest | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | require-hook | eslint-plugin-jest | | [Added in v0.7.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.2) | full | No failing cases | | require-hook | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | require-local-test-context-for-concurrent-snapshots | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | require-mock-type-parameters | rstest | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | require-number-to-fixed-digits-argument | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.7.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.0) | full | No failing cases | | require-optimization | eslint-plugin-react | | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | require-post-message-target-origin | eslint-plugin-unicorn | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | require-render-return | eslint-plugin-react | ✅reactPlugin.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | require-test-timeout | rstest | | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | require-to-throw-message | eslint-plugin-jest | | [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) | full | No failing cases | | require-to-throw-message | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | require-top-level-describe | eslint-plugin-jest | | [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) | full | No failing cases | | require-top-level-describe | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | require-unicode-regexp | eslint | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | require-yield | eslint | ✅js.configs.recommended | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | restrict-plus-operands | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-test | No failing cases | | restrict-template-expressions | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | return-await | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-test | No failing cases | | role-has-required-aria-props | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | role-supports-aria-props | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | rules-of-hooks | eslint-plugin-react-hooks | ✅reactHooksPlugin.configs.recommended | [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) | full | No failing cases | | scope | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | self-closing-comp | eslint-plugin-react | | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | sort-comp | eslint-plugin-react | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | sort-imports | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | sort-keys | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | sort-prop-types | eslint-plugin-react | | [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) | full | No failing cases | | sort-vars | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | spec-only | eslint-plugin-promise | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | static-property-placement | eslint-plugin-react | | [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) | full | No failing cases | | strict | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | strict-boolean-expressions | @typescript-eslint | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | partial-impl | 1.Skipped test case at line 3550 | | strict-void-return | @typescript-eslint | | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | style-prop-object | eslint-plugin-react | | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | switch-exhaustiveness-check | @typescript-eslint | | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | full | No failing cases | | symbol-description | eslint | | [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) | full | No failing cases | | tabindex-no-positive | eslint-plugin-jsx-a11y | ✅jsxA11yPlugin.configs.recommended | [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) | full | No failing cases | | testdata | eslint | | Unreleased | partial-test | No failing cases | | throw-new-error | eslint-plugin-unicorn | ✅unicornPlugin.configs.recommended | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | triple-slash-reference | @typescript-eslint | ✅ts.configs.recommended✅ts.configs.recommendedTypeChecked✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | unbound-method | @typescript-eslint | ✅ts.configs.recommendedTypeChecked✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-test | No failing cases | | unbound-method | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | unicode-bom | eslint | | [Added in v0.8.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.0) | full | No failing cases | | unified-signatures | @typescript-eslint | ✅ts.configs.strict✅ts.configs.strictTypeChecked | [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) | full | No failing cases | | use-isnan | eslint | ✅js.configs.recommended | [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) | full | No failing cases | | use-unknown-in-catch-callback-variable | @typescript-eslint | ✅ts.configs.strictTypeChecked | [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) | partial-test | No failing cases | | valid-describe-callback | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.3.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.4) | full | No failing cases | | valid-expect | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | valid-expect | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | valid-expect-in-promise | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | valid-expect-in-promise | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) | full | No failing cases | | valid-expect-with-promise | rstest | | [Added in v0.9.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.3) | full | No failing cases | | valid-params | eslint-plugin-promise | ✅promisePlugin.configs.recommended | [Added in v0.6.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.3) | full | No failing cases | | valid-title | eslint-plugin-jest | ✅jestPlugin.configs.recommended | [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) | full | No failing cases | | valid-title | rstest | ✅rstestPlugin.configs.recommended | [Added in v0.8.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.0) | full | No failing cases | | valid-typeof | eslint | ✅js.configs.recommended | [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) | full | No failing cases | | vars-on-top | eslint | | [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) | full | No failing cases | | void-dom-elements-no-children | eslint-plugin-react | | [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) | full | No failing cases | | warn-todo | rstest | | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | | yoda | eslint | | [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) | full | No failing cases | --- url: /rules/eslint/accessor-pairs.md --- # accessor-pairs [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'accessor-pairs': 'error', }, }, ]); ``` Enforce getter and setter pairs in objects and classes. ## Rule Details By default the rule flags setters declared without a matching getter. It can optionally flag getters declared without a matching setter, and also extends to class bodies and TypeScript type-literal / interface members. Examples of **incorrect** code for this rule: ```javascript const obj = { set a(value) { this.val = value; }, }; const obj2 = { d: 1 }; Object.defineProperty(obj2, 'c', { set: function (value) { this.val = value; }, }); ``` Examples of **correct** code for this rule: ```javascript const obj = { set a(value) { this.val = value; }, get a() { return this.val; }, }; ``` ## Options All options are boolean with the following defaults: - `setWithoutGet` (default `true`): report setters without a matching getter. - `getWithoutSet` (default `false`): report getters without a matching setter. - `enforceForClassMembers` (default `true`): apply to class declarations and expressions. - `enforceForTSTypes` (default `false`): apply to TypeScript type literals and interfaces. ## Original Documentation - [ESLint: accessor-pairs](https://eslint.org/docs/latest/rules/accessor-pairs) - [Source code](https://github.com/eslint/eslint/blob/v10.2.1/lib/rules/accessor-pairs.js) --- url: /rules/eslint/array-callback-return.md --- # array-callback-return [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'array-callback-return': 'error', }, }, ]); ``` ## Rule Details Enforces `return` statements in callbacks of array methods such as `map`, `filter`, `find`, `findIndex`, `findLast`, `findLastIndex`, `every`, `some`, `reduce`, `reduceRight`, `flatMap`, `sort`, `toSorted`, and `Array.from`. Callbacks for these methods must return a value; otherwise, the code likely contains a mistake. ### Options - `allowImplicit` (default: `false`): When set to `true`, allows callbacks to implicitly return `undefined` by using `return;` without a value. - `checkForEach` (default: `false`): When set to `true`, also checks that `forEach` callbacks do not return a value. - `allowVoid` (default: `false`): When set to `true` along with `checkForEach`, allows `forEach` callbacks to return `void` expressions (e.g., `void bar(x)`). Examples of **incorrect** code for this rule: ```javascript var squares = [1, 2, 3].map(function (x) { x * x; }); var bools = [1, 2, 3].filter(function (x) { if (x > 2) { return true; } // missing return in else path }); // with checkForEach: true [1, 2, 3].forEach((x) => x * x); ``` Examples of **correct** code for this rule: ```javascript var squares = [1, 2, 3].map(function (x) { return x * x; }); var bools = [1, 2, 3].filter(function (x) { return x > 2; }); [1, 2, 3].forEach((x) => { console.log(x); }); // with checkForEach: true and allowVoid: true [1, 2, 3].forEach((x) => void bar(x)); ``` ## Original Documentation - [ESLint: array-callback-return](https://eslint.org/docs/latest/rules/array-callback-return) - [Source code](https://github.com/eslint/eslint/blob/v9.39.1/lib/rules/array-callback-return.js) --- url: /rules/eslint/arrow-body-style.md --- # arrow-body-style [Added in v0.6.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.3) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'arrow-body-style': 'error', }, }, ]); ``` ## Rule Details This rule enforces or disallows the use of braces around arrow function bodies. Arrow functions have two syntactic forms for their function bodies. They may be defined with a _block_ body (denoted with curly braces) `() => { ... }` or with a single expression `() => ...`, whose value is implicitly returned. This rule has a string option and an object option. The string option is one of: - `"as-needed"` (default) enforces no braces where they can be omitted. - `"always"` enforces braces around the function body. - `"never"` enforces no braces around the function body (forbids any use of braces). The object option (only available with `"as-needed"`): - `requireReturnForObjectLiteral: true` requires braces and an explicit return for object literals. Default is `false`. ### `"as-needed"` Examples of **incorrect** code for this rule with the default `"as-needed"` option: ```javascript let foo = () => { return 0; }; let foo = () => { return { bar: { foo: 1, bar: 2, }, }; }; ``` Examples of **correct** code for this rule with the default `"as-needed"` option: ```javascript let foo = () => 0; let foo = () => ({ bar: { foo: 1, bar: 2 } }); let foo = () => { let retVal = 0; return retVal; }; let foo = () => { /* do nothing */ }; let foo = () => { // do nothing. }; let foo = () => ({ bar: 0 }); ``` ### `requireReturnForObjectLiteral` Examples of **incorrect** code for this rule with the `{ "requireReturnForObjectLiteral": true }` option: ```json { "arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }] } ``` ```javascript let foo = () => ({}); let foo = () => ({ bar: 0 }); ``` Examples of **correct** code for this rule with the `{ "requireReturnForObjectLiteral": true }` option: ```json { "arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }] } ``` ```javascript let foo = () => {}; let foo = () => { return { bar: 0 }; }; ``` ### `"always"` Examples of **incorrect** code for this rule with the `"always"` option: ```json { "arrow-body-style": ["error", "always"] } ``` ```javascript let foo = () => 0; ``` Examples of **correct** code for this rule with the `"always"` option: ```json { "arrow-body-style": ["error", "always"] } ``` ```javascript let foo = () => { return 0; }; ``` ### `"never"` Examples of **incorrect** code for this rule with the `"never"` option: ```json { "arrow-body-style": ["error", "never"] } ``` ```javascript let foo = () => { return 0; }; let foo = (data, name) => { data[name] = true; return data; }; ``` Examples of **correct** code for this rule with the `"never"` option: ```json { "arrow-body-style": ["error", "never"] } ``` ```javascript let foo = () => 0; let foo = () => ({ foo: 0 }); ``` ## Differences from ESLint - When an arrow function with a block body is immediately followed on the next line (no semicolon in between) by a token starting with `/` — e.g. `() => { return x }` then `/re/.test(y)` — rslint reports the rule but does not auto-fix it; ESLint removes the braces. ## Original Documentation - [ESLint: arrow-body-style](https://eslint.org/docs/latest/rules/arrow-body-style) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/arrow-body-style.js) --- url: /rules/eslint/block-scoped-var.md --- # block-scoped-var [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'block-scoped-var': 'error', }, }, ]); ``` ## Rule Details The `block-scoped-var` rule generates warnings when variables are used outside of the block in which they were defined. This emulates C-style block scope. Examples of **incorrect** code for this rule: ```javascript function doIf() { if (true) { var build = true; } console.log(build); } function doIfElse() { if (true) { var build = true; } else { var build = false; } } function doTryCatch() { try { var build = 1; } catch (e) { var f = build; } } function doFor() { for (var x = 1; x < 10; x++) { var y = f(x); } console.log(y); } class C { static { if (something) { var build = true; } build = false; } } ``` Examples of **correct** code for this rule: ```javascript function doIf() { var build; if (true) { build = true; } console.log(build); } function doIfElse() { var build; if (true) { build = true; } else { build = false; } } function doTryCatch() { var build; var f; try { build = 1; } catch (e) { f = build; } } function doFor() { for (var x = 1; x < 10; x++) { var y = f(x); console.log(y); } } class C { static { var build = false; if (something) { build = true; } } } ``` ## Options This rule has no options. ## Original Documentation - [ESLint: block-scoped-var](https://eslint.org/docs/latest/rules/block-scoped-var) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/block-scoped-var.js) --- url: /rules/eslint/camelcase.md --- # camelcase [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'camelcase': 'error', }, }, ]); ``` ## Rule Details This rule enforces camelcase naming by reporting identifiers with internal underscores. Leading and trailing underscores and all-uppercase constants are allowed. Examples of **incorrect** code for this rule: ```javascript const favorite_color = "blue"; obj.favorite_color = "blue"; ``` Examples of **correct** code for this rule: ```javascript const favoriteColor = "blue"; const FAVORITE_COLOR = "blue"; const _favoriteColor = "blue"; obj.favorite_color(); ``` ## Options - `"properties": "always"` (default) checks property declarations and writes; `"never"` permits underscored property names. - `"ignoreDestructuring": true` permits a destructured binding when it keeps the source property name, while later uses are still checked. - `"ignoreImports": true` permits a named import when its local and exported names are identical, while later uses are still checked. - `"ignoreGlobals": true` skips configured and comment-declared globals; unresolved names are still checked. - `"allow"` accepts exact names or JavaScript regular expression patterns. Examples of **correct** code with property checks disabled: ```json { "camelcase": ["error", { "properties": "never" }] } ``` ```javascript const response = { response_code: 200 }; response.response_code = 201; ``` Examples of **correct** code with destructured source names ignored: ```json { "camelcase": ["error", { "ignoreDestructuring": true }] } ``` ```javascript const { response_code } = response; ``` Examples of **correct** code with an allow pattern: ```json { "camelcase": ["error", { "allow": ["^UNSAFE_"] }] } ``` ```javascript function UNSAFE_componentWillMount() {} ``` ## Original Documentation - [ESLint: camelcase](https://eslint.org/docs/latest/rules/camelcase) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/camelcase.js) --- url: /rules/eslint/capitalized-comments.md --- # capitalized-comments [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'capitalized-comments': 'error', }, }, ]); ``` ## Rule Details This rule enforces a consistent style of comments across your codebase, specifically by either requiring or disallowing a capitalized letter as the first word character in a comment. This rule will not issue warnings when non-cased letters are used. By default, this rule requires a non-lowercase letter at the beginning of comments. Examples of **incorrect** code for this rule: ```javascript // lowercase comment ``` Examples of **correct** code for this rule: ```javascript // Capitalized comment // 1. Non-letter at beginning of comment // 丈 Non-Latin character at beginning of comment /* istanbul ignore next */ /* jscs:enable */ /* jshint asi:true */ /* global foo */ /* globals foo */ /* exported myVar */ // https://github.com ``` ## Options This rule has two options: a string value `"always"` or `"never"` which determines whether capitalization of the first word of a comment should be required or forbidden, and optionally an object containing more configuration parameters for the rule. Here are the supported object options: - `ignorePattern`: A string representing a regular expression pattern of words that should be ignored by this rule. If the first word of a comment matches the pattern, this rule will not report that comment. - Note that the following words are always ignored by this rule: `["jscs", "jshint", "eslint", "rslint", "istanbul", "global", "globals", "exported"]`. - `ignoreInlineComments`: If this is `true`, the rule will not report on comments in the middle of code. By default, this is `false`. - `ignoreConsecutiveComments`: If this is `true`, the rule will not report on a comment which violates the rule, as long as the comment immediately follows another comment. By default, this is `false`. Here is an example configuration: ```json { "capitalized-comments": [ "error", "always", { "ignorePattern": "pragma|ignored", "ignoreInlineComments": true } ] } ``` ### `"always"` Using the `"always"` option means that this rule will report any comments which start with a lowercase letter. This is the default configuration for this rule. Configuration comments and comments which start with URLs are never reported. Examples of **incorrect** code for this rule: ```javascript /* eslint capitalized-comments: ["error", "always"] */ // lowercase comment ``` Examples of **correct** code for this rule: ```javascript /* eslint capitalized-comments: ["error", "always"] */ // Capitalized comment ``` ### `"never"` Using the `"never"` option means that this rule will report any comments which start with an uppercase letter. Examples of **incorrect** code with the `"never"` option: ```javascript /* eslint capitalized-comments: ["error", "never"] */ // Capitalized comment ``` Examples of **correct** code with the `"never"` option: ```javascript /* eslint capitalized-comments: ["error", "never"] */ // lowercase comment ``` ### `ignorePattern` The `ignorePattern` option takes a string value, which is used as a regular expression applied to the first word of a comment. Examples of **correct** code with the `"ignorePattern"` option set to `"pragma"`: ```json { "capitalized-comments": ["error", "always", { "ignorePattern": "pragma" }] } ``` ```javascript function foo() { /* pragma wrap(true) */ } ``` ### `ignoreInlineComments` Setting the `ignoreInlineComments` option to `true` means that comments in the middle of code (with a token on the same line as the beginning of the comment, and another token on the same line as the end of the comment) will not be reported by this rule. Examples of **correct** code with the `"ignoreInlineComments"` option set to `true`: ```json { "capitalized-comments": ["error", "always", { "ignoreInlineComments": true }] } ``` ```javascript function foo(/* ignored */ a) {} ``` The exemption applies to a block comment with a token on the same line as its start and a token on the same line as its end, which is what "in the middle of code" means here: ```javascript foo(/* ignored */ bar); foo(/* ignored still ignored */ bar); ``` ### `ignoreConsecutiveComments` If the `ignoreConsecutiveComments` option is set to `true`, then comments which otherwise violate the rule will not be reported as long as they immediately follow another comment. This can be applied more than once. Examples of **correct** code with `ignoreConsecutiveComments` set to `true`: ```json { "capitalized-comments": ["error", "always", { "ignoreConsecutiveComments": true }] } ``` ```javascript foo(); // This comment is valid since it has the correct capitalization. // this comment is ignored since it follows another comment, // and this one as well because it follows yet another comment. ``` Examples of **incorrect** code with `ignoreConsecutiveComments` set to `true`: ```javascript /* eslint capitalized-comments: ["error", "always", { "ignoreConsecutiveComments": true }] */ foo(); // this comment is invalid, but only on this line. // this comment does NOT get reported, since it is a consecutive comment. ``` ### Use Different Options for Line and Block Comments If you wish to have a different configuration for line comments and block comments, you can do so by using two different object configurations (note that the capitalization option will be enforced consistently for line and block comments): ```json { "capitalized-comments": [ "error", "always", { "line": { "ignorePattern": "pragma|ignored" }, "block": { "ignoreInlineComments": true, "ignorePattern": "ignored" } } ] } ``` Examples of **incorrect** code with different line and block comment configuration: ```javascript /* eslint capitalized-comments: ["error", "always", { "block": { "ignorePattern": "blockignore" } }] */ // capitalized line comment, this is incorrect, blockignore does not help here /* lowercased block comment, this is incorrect too */ ``` Examples of **correct** code with different line and block comment configuration: ```javascript /* eslint capitalized-comments: ["error", "always", { "block": { "ignorePattern": "blockignore" } }] */ // Uppercase line comment, this is correct /* blockignore lowercase block comment, this is correct due to ignorePattern */ ``` ## Differences from ESLint - An `ignorePattern` that is not a valid regular expression never matches any comment, instead of throwing an error when the rule is configured. - `rslint` joins the list of always-ignored words, so `// rslint-disable-next-line no-console` is treated the same as its `eslint-` equivalent. ## Original Documentation - [ESLint: capitalized-comments](https://eslint.org/docs/latest/rules/capitalized-comments) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/capitalized-comments.js) --- url: /rules/eslint/class-methods-use-this.md --- # class-methods-use-this [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'class-methods-use-this': 'error', }, }, ]); ``` ## Rule Details This rule requires class instance methods to use `this` or `super`. Methods that do not depend on an instance can often be ordinary functions or static methods instead. Examples of **incorrect** code for this rule: ```javascript class Formatter { format(value) { return String(value); } } ``` Examples of **correct** code for this rule: ```javascript class Formatter { format(value) { return this.prefix + value; } static createDefault() { return new Formatter(); } } ``` ## Options ### `exceptMethods` Use `exceptMethods` to exempt methods whose instance shape is required by an external API. ```json { "class-methods-use-this": ["error", { "exceptMethods": ["render", "#reset"] }] } ``` ```javascript class Component { render() { return null; } #reset() {} } ``` ### `enforceForClassFields` `enforceForClassFields` defaults to `true`. Set it to `false` to ignore arrow functions and function expressions used as instance field initializers. ```json { "class-methods-use-this": ["error", { "enforceForClassFields": false }] } ``` ```javascript class Component { render = () => null; } ``` ### `ignoreOverrideMethods` Use `ignoreOverrideMethods` to ignore TypeScript members marked with `override`. ```json { "class-methods-use-this": ["error", { "ignoreOverrideMethods": true }] } ``` ```typescript class Derived extends Base { override render() { return null; } } ``` ### `ignoreClassesWithImplements` Use `"all"` to ignore every member of a TypeScript class with an `implements` clause, or `"public-fields"` to ignore only its public members. ```json { "class-methods-use-this": ["error", { "ignoreClassesWithImplements": "all" }] } ``` ```typescript interface Service { run(): void; } class Worker implements Service { run() {} } ``` ## Original Documentation - [ESLint: class-methods-use-this](https://eslint.org/docs/latest/rules/class-methods-use-this) - [Source code](https://github.com/eslint/eslint/blob/v10.9.0/lib/rules/class-methods-use-this.js) --- url: /rules/eslint/complexity.md --- # complexity [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'complexity': 'error', }, }, ]); ``` Enforce a maximum cyclomatic complexity allowed in a program. ## Rule Details Cyclomatic complexity measures the number of linearly independent paths through a program's source code. This rule allows setting a cyclomatic complexity threshold per function. Functions whose complexity exceeds the threshold are reported. The complexity counter is seeded at 1 (a single execution path) and increased by 1 for every branching construct: `if`, `else if`, `for`, `for…in`, `for…of`, `while`, `do…while`, `switch` cases, conditional expressions (`?:`), logical operators (`&&`, `||`, `??`), logical assignment operators (`&&=`, `||=`, `??=`), `catch` clauses, optional chaining links (`?.`), default parameter values (`function f(x = 1)`), and destructuring defaults (`const { x = 1 } = obj`). Class field initializers and class static blocks each form their own complexity scope (separate from the enclosing function), matching ESLint's `class-field-initializer` and `class-static-block` code-path origins. A class field whose initializer is itself a function or arrow does NOT create a separate field-initializer scope — the function takes over. Examples of **incorrect** code for this rule with the default `{ "max": 20 }`: ```javascript function a(x) { if (true) { return x; } else if (false) { return x + 1; } else { return 4; // 3rd path exceeds limit if max is 2 } } ``` Examples of **correct** code for this rule with the default `{ "max": 20 }`: ```javascript function a(x) { if (true) { return x; } else { return 4; } } ``` ## Options This rule accepts either a number (the threshold) or an object. ### `max` (default: `20`) Sets the maximum cyclomatic complexity allowed. ```json { "complexity": ["error", { "max": 2 }] } ``` ```javascript function a(x) { if (true) { return x; } else if (false) { return x + 1; } else { return 4; } } ``` The deprecated property `maximum` is also recognized; when both `maximum` and `max` are present, `maximum` wins if its value is truthy (mirroring ESLint's `option.maximum || option.max` coercion). ### `variant` (default: `"classic"`) Selects the complexity calculation method. - `"classic"` — Standard McCabe cyclomatic complexity. Each `case` clause adds 1. - `"modified"` — Each `switch` statement adds 1 regardless of how many `case` clauses it contains, and individual `case` clauses do not add to the complexity. ```json { "complexity": ["error", { "max": 3, "variant": "modified" }] } ``` ```javascript function a(x) { switch (x) { case 1: return 1; case 2: return 2; case 3: return 3; default: return 0; } } ``` ## Original Documentation - [ESLint: complexity](https://eslint.org/docs/latest/rules/complexity) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/complexity.js) --- url: /rules/eslint/consistent-return.md --- # consistent-return [Added in v0.8.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'consistent-return': 'error', }, }, ]); ``` ## Rule Details This rule requires `return` statements to either always or never specify values. A function is inconsistent when one `return` in it hands back a value and another does not, or when it returns a value on one path and runs off the end of its body on another — because falling off the end hands back `undefined`. The check applies to each function on its own. A nested function is judged separately from the function that contains it, and the first `return` reached in a function sets the expectation for the rest of it. Two shapes are exempt from the "runs off the end" half of the check, because returning a value from them is how a constructor overrides the object being built: a class `constructor`, and a function whose own name starts with an uppercase letter. Examples of **incorrect** code for this rule: ```javascript function doSomething(condition) { if (condition) { return true; } else { return; } } function doSomethingElse(condition) { if (condition) { return true; } } ``` Examples of **correct** code for this rule: ```javascript function doSomething(condition) { if (condition) { return true; } else { return false; } } function Foo() { if (!(this instanceof Foo)) { return new Foo(); } } ``` ## Options ### `treatUndefinedAsUnspecified` When `true`, `return undefined;` and `return void 0;` are read as returning nothing, so they pair with a bare `return;`. It defaults to `false`. Examples of **correct** code for this rule with `{ "treatUndefinedAsUnspecified": true }`: ```json { "consistent-return": ["error", { "treatUndefinedAsUnspecified": true }] } ``` ```javascript function doSomething(condition) { if (condition) { return undefined; } else { return; } } ``` Examples of **incorrect** code for this rule with `{ "treatUndefinedAsUnspecified": true }`: ```json { "consistent-return": ["error", { "treatUndefinedAsUnspecified": true }] } ``` ```javascript function doSomething(condition) { if (condition) { return true; } return undefined; } ``` ## Original Documentation - [ESLint: consistent-return](https://eslint.org/docs/latest/rules/consistent-return) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/consistent-return.js) --- url: /rules/eslint/consistent-this.md --- # consistent-this [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'consistent-this': 'error', }, }, ]); ``` ## Rule Details It is often necessary to capture the current execution context in order to make it available subsequently, for example in a callback. This rule enforces two things about variables with the designated alias names for `this`: - If a variable with a designated name is declared, it must be either initialized (in the declaration) or assigned (in the same scope as the declaration) the value `this`. - If a variable is initialized or assigned the value `this`, the name of the variable must be a designated alias. Examples of **incorrect** code for this rule with the default `"that"` option: ```javascript let that = 42; let self = this; that = 42; self = this; ``` Examples of **correct** code for this rule with the default `"that"` option: ```javascript let that = this; const self = 42; let foo; that = this; foo.bar = this; ``` Examples of **incorrect** code for this rule with the default `"that"` option, if the variable is not initialized: ```javascript let that; function f() { that = this; } ``` Examples of **correct** code for this rule with the default `"that"` option, if the variable is not initialized: ```javascript let that; that = this; ``` ```javascript let foo = 42, that; that = this; ``` ## Options This rule has one or more string options: designated alias names for `this` (default `"that"`). Examples of **incorrect** code for this rule with `"self", "vm"`: ```json { "consistent-this": ["error", "self", "vm"] } ``` ```javascript let self = this; let vm = 42; ``` ## Differences from ESLint - rslint always treats a nested block (`if`, `for`, `try`, a bare `{}`, ...) as a different scope from its enclosing function, so an alias declared in the function and assigned `this` only inside such a block is still reported. ESLint's behavior here depends on the configured ECMAScript version: under `ecmaVersion: 5` it does not create a separate scope for the block, so the same code is accepted. ## Original Documentation - [ESLint: consistent-this](https://eslint.org/docs/latest/rules/consistent-this) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/consistent-this.js) --- url: /rules/eslint/constructor-super.md --- # constructor-super [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'constructor-super': 'error', }, }, ]); ``` ## Rule Details Verifies that constructors of derived classes (classes that extend another class) call `super()`, and that constructors of non-derived classes do not call `super()`. Also detects duplicate `super()` calls in the same constructor and ensures `super()` is called in all code paths. Examples of **incorrect** code for this rule: ```javascript class A extends B { constructor() { // missing super() call } } class A { constructor() { super(); // super() in non-derived class } } class A extends B { constructor() { super(); super(); // duplicate super() call } } ``` Examples of **correct** code for this rule: ```javascript class A extends B { constructor() { super(); } } class A { constructor() { // no super() needed } } class A extends B { constructor(cond) { if (cond) { super(true); } else { super(false); } } } ``` ## Original Documentation - [ESLint: constructor-super](https://eslint.org/docs/latest/rules/constructor-super) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/constructor-super.js) --- url: /rules/eslint/curly.md --- # curly [Added in v0.6.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.3) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'curly': 'error', }, }, ]); ``` ## Rule Details This rule enforces consistent use of curly braces around blocks that follow `if`, `else`, `for`, `for...in`, `for...of`, `while`, and `do...while` statements. By default it requires braces everywhere, but it can also be configured to forbid them where they are unnecessary. Examples of **incorrect** code for this rule: ```javascript if (foo) foo++; while (bar) baz(); if (foo) { baz(); } else qux(); ``` Examples of **correct** code for this rule: ```javascript if (foo) { foo++; } while (bar) { baz(); } if (foo) { baz(); } else { qux(); } ``` ## Options The rule accepts a primary string option and an optional secondary `"consistent"` modifier: `["error", "multi", "consistent"]`. ### `"all"` (default) Requires braces around every block. ### `"multi"` Forbids braces around blocks that contain a single statement, and requires them when the block contains two or more statements. ```json { "curly": ["error", "multi"] } ``` Examples of **incorrect** code for `"multi"`: ```javascript if (foo) { foo++; } for (var i = 0; foo; i++) { doSomething(); } ``` Examples of **correct** code for `"multi"`: ```javascript if (foo) foo++; while (true) { doSomething(); doSomethingElse(); } ``` ### `"multi-line"` Allows brace-less single-line statements, but requires braces once a statement spans multiple lines. ```json { "curly": ["error", "multi-line"] } ``` Examples of **correct** code for `"multi-line"`: ```javascript if (foo) foo++; else doSomething(); while (true) { doSomething(); doSomethingElse(); } ``` ### `"multi-or-nest"` Forces brace-less syntax for a single-line statement, and requires braces for a multi-line statement or a statement that contains a nested block. ```json { "curly": ["error", "multi-or-nest"] } ``` Examples of **correct** code for `"multi-or-nest"`: ```javascript if (foo) bar(); if (foo) { bar(); baz(); } ``` ### `"consistent"` Used together with `"multi"`, `"multi-line"`, or `"multi-or-nest"`, this option forces all branches of an `if`/`else if`/`else` chain to agree: either all have braces or none do. ```json { "curly": ["error", "multi", "consistent"] } ``` Examples of **correct** code for `["multi", "consistent"]`: ```javascript if (foo) { bar(); } else { baz(); } if (foo) bar(); else baz(); ``` ## Original Documentation - [ESLint: curly](https://eslint.org/docs/latest/rules/curly) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/curly.js) --- url: /rules/eslint/default-case.md --- # default-case [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'default-case': 'error', }, }, ]); ``` ## Rule Details Require `default` cases in `switch` statements. The rule also allows an opt-out comment such as `// no default`. Examples of **incorrect** code for this rule: ```javascript switch (a) { case 1: break; } ``` Examples of **correct** code for this rule: ```javascript switch (a) { case 1: break; default: break; } switch (a) { case 1: break; // no default } ``` ## Options - `commentPattern`: A regular expression pattern for the opt-out comment. Default: `^no default$` (case-insensitive). ## Original Documentation - [ESLint: default-case](https://eslint.org/docs/latest/rules/default-case) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/default-case.js) --- url: /rules/eslint/default-case-last.md --- # default-case-last [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'default-case-last': 'error', }, }, ]); ``` ## Rule Details Enforce `default` clauses in `switch` statements to be last. A `switch` statement can optionally have a `default` clause. If present, it's usually the last clause, but it doesn't need to be. It is also allowed to put the `default` clause before all `case` clauses, or anywhere between. The behavior is mostly the same as if it was the last clause. The `default` clause is still executed only if there is no match in the `case` clauses (including those defined after the `default`), but there is also the ability to "fall through" from the `default` clause to the following clause in the list. However, such flow is not common and can be confusing. This rule enforces `default` clauses in `switch` statements to be last, after all `case` clauses. Examples of **incorrect** code for this rule: ```javascript switch (foo) { default: bar(); break; case 1: baz(); break; } switch (foo) { case 1: break; default: break; case 2: break; } ``` Examples of **correct** code for this rule: ```javascript switch (foo) { case 1: bar(); break; default: baz(); break; } switch (foo) { case 1: break; } ``` ## Original Documentation - [ESLint: default-case-last](https://eslint.org/docs/latest/rules/default-case-last) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/default-case-last.js) --- url: /rules/eslint/default-param-last.md --- # default-param-last [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'default-param-last': 'error', }, }, ]); ``` ## Rule Details Default parameters are most useful at the end of a parameter list, where callers can omit them. This rule reports default or optional parameters followed by required parameters. Examples of **incorrect** code for this rule: ```javascript function createUser(isAdmin = false, id) {} function connect(host = "localhost", port) {} ``` Examples of **correct** code for this rule: ```javascript function createUser(id, isAdmin = false) {} function connect(port, host = "localhost") {} ``` The rule also supports TypeScript optional parameters and parameter properties. Examples of **incorrect** TypeScript code for this rule: ```typescript function format(value?: string, radix: number) {} class Client { constructor(public endpoint = "localhost", private retries: number) {} } ``` Examples of **correct** TypeScript code for this rule: ```typescript function format(radix: number, value?: string) {} class Client { constructor(private retries: number, public endpoint = "localhost") {} } ``` ## Original Documentation - [ESLint: default-param-last](https://eslint.org/docs/latest/rules/default-param-last) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/default-param-last.js) --- url: /rules/eslint/dot-notation.md --- # dot-notation [Added in v0.1.13](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.13) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'dot-notation': 'error', }, }, ]); ``` ## Rule Details Enforce dot notation whenever possible. Dot notation (`obj.foo`) is generally preferred over bracket notation (`obj["foo"]`) for readability, since bracket notation is really only needed when the property name isn't a valid identifier or is computed dynamically. The rule provides autofixes to convert bracket notation to dot notation (and, with `allowKeywords: false`, dot notation to bracket notation for reserved words) when it's safe to do so. Examples of **incorrect** code for this rule: ```javascript const x = foo["bar"]; ``` Examples of **correct** code for this rule: ```javascript const x = foo.bar; const y = foo["bar-baz"]; // not a valid identifier const z = foo[getKey()]; // computed access ``` ### Options This rule accepts a single options object with two properties: - `allowKeywords` (default `true`) — when `false`, reserved words (`class`, `default`, `new`, …) must use bracket notation instead of dot notation. - `allowPattern` (default `""`) — a regular expression; bracket-accessed keys matching it are left alone even if they could be written with dot notation. Examples of **incorrect** code for this rule with `{ "allowKeywords": false }`: ```json { "dot-notation": ["error", { "allowKeywords": false }] } ``` ```javascript const x = foo.class; ``` Examples of **correct** code for this rule with `{ "allowKeywords": false }`: ```json { "dot-notation": ["error", { "allowKeywords": false }] } ``` ```javascript const x = foo["class"]; ``` Examples of **correct** code for this rule with `{ "allowPattern": "^[a-z]+(_[a-z]+)+$" }`: ```json { "dot-notation": ["error", { "allowPattern": "^[a-z]+(_[a-z]+)+$" }] } ``` ```javascript const x = foo["snake_case"]; ``` ## Original Documentation - [ESLint: dot-notation](https://eslint.org/docs/latest/rules/dot-notation) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/dot-notation.js) --- url: /rules/eslint/eqeqeq.md --- # eqeqeq [Added in v0.4.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'eqeqeq': 'error', }, }, ]); ``` ## Rule Details Requires the use of `===` and `!==` instead of `==` and `!=`. Using strict equality operators helps avoid unexpected type coercion in comparisons. ### Options This rule supports three modes: - `"always"` (default): Always require `===` and `!==`. Supports a `null` sub-option: - `"always"` (default): Enforce strict equality for null comparisons too - `"ignore"`: Skip enforcement for null comparisons - `"never"`: Enforce `==`/`!=` for null comparisons and `===`/`!==` for everything else - `"smart"`: Allow `==` for typeof comparisons, same-type literal comparisons, and null checks - `"allow-null"`: Shorthand for `["always", {"null": "ignore"}]` Examples of **incorrect** code for this rule: ```javascript a == b; a != b; typeof a == 'number'; // in "always" mode ``` Examples of **correct** code for this rule: ```javascript a === b; a !== b; typeof a === 'number'; // With "smart" option: typeof a == 'number'; null == a; 'hello' == 'world'; // With "allow-null" option: a == null; null != a; ``` ## Original Documentation - [ESLint: eqeqeq](https://eslint.org/docs/latest/rules/eqeqeq) - [Source code](https://github.com/eslint/eslint/blob/v10.2.0/lib/rules/eqeqeq.js) --- url: /rules/eslint/for-direction.md --- # for-direction [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'for-direction': 'error', }, }, ]); ``` ## Rule Details Enforces that the update clause in a `for` loop moves the counter variable in the correct direction relative to the loop's stop condition. A `for` loop with a counter that moves in the wrong direction will run infinitely. Examples of **incorrect** code for this rule: ```javascript for (var i = 0; i < 10; i--) {} for (var i = 10; i >= 0; i++) {} for (var i = 0; i < 10; i -= 1) {} ``` Examples of **correct** code for this rule: ```javascript for (var i = 0; i < 10; i++) {} for (var i = 10; i >= 0; i--) {} for (var i = 0; i < 10; i += 1) {} ``` ## Original Documentation - [ESLint: for-direction](https://eslint.org/docs/latest/rules/for-direction) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/for-direction.js) --- url: /rules/eslint/func-name-matching.md --- # func-name-matching [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'func-name-matching': 'error', }, }, ]); ``` ## Rule Details This rule requires function names to match the name of the variable or property to which they are assigned. The rule will ignore property assignments where the property name is a literal that is not a valid identifier in the ECMAScript version specified in your configuration (which defaults to the latest version). Examples of **incorrect** code for this rule: ```javascript let foo = function bar() {}; foo = function bar() {}; const obj = { foo: function bar() {} }; obj.foo = function bar() {}; obj["foo"] = function bar() {}; ({ ["foo"]: function bar() {} }); class C { foo = function bar() {}; } ``` Examples of **incorrect** code for this rule with `"never"`: ```json { "func-name-matching": ["error", "never"] } ``` ```javascript let foo = function foo() {}; foo = function foo() {}; const obj = { foo: function foo() {} }; obj.foo = function foo() {}; obj["foo"] = function foo() {}; ({ ["foo"]: function foo() {} }); class C { foo = function foo() {}; } ``` Examples of **correct** code for this rule: ```javascript const foo = function foo() {}; const foo1 = function () {}; const foo2 = () => {}; foo = function foo() {}; const obj = { foo: function foo() {} }; obj.foo = function foo() {}; obj["foo"] = function foo() {}; obj["foo//bar"] = function foo() {}; obj[foo] = function bar() {}; const obj1 = { [foo]: function bar() {} }; const obj2 = { "foo//bar": function foo() {} }; const obj3 = { foo: function () {} }; obj["x" + 2] = function bar() {}; const [bar] = [function bar() {}]; ({ [foo]: function bar() {} }); class C { foo = function foo() {}; baz = function () {}; } // private names are ignored class D { #foo = function foo() {}; #bar = function foo() {}; baz() { this.#foo = function foo() {}; this.#foo = function bar() {}; } } module.exports = function foo(name) {}; module["exports"] = function foo(name) {}; ``` Examples of **correct** code for this rule with `"never"`: ```json { "func-name-matching": ["error", "never"] } ``` ```javascript let foo = function bar() {}; const foo1 = function () {}; const foo2 = () => {}; foo = function bar() {}; const obj = { foo: function bar() {} }; obj.foo = function bar() {}; obj["foo"] = function bar() {}; obj["foo//bar"] = function foo() {}; obj[foo] = function foo() {}; const obj1 = { foo: function bar() {} }; const obj2 = { [foo]: function foo() {} }; const obj3 = { "foo//bar": function foo() {} }; const obj4 = { foo: function () {} }; obj["x" + 2] = function bar() {}; const [bar] = [function bar() {}]; ({ [foo]: function bar() {} }); class C { foo = function bar() {}; baz = function () {}; } // private names are ignored class D { #foo = function foo() {}; #bar = function foo() {}; baz() { this.#foo = function foo() {}; this.#foo = function bar() {}; } } module.exports = function foo(name) {}; module["exports"] = function foo(name) {}; ``` ## Options This rule takes an optional string of `"always"` or `"never"` (when omitted, it defaults to `"always"`), and an optional options object with two properties `considerPropertyDescriptor` and `includeCommonJSModuleExports`. ### considerPropertyDescriptor A boolean value that defaults to `false`. If `considerPropertyDescriptor` is set to true, the check will take into account the use of `Object.create`, `Object.defineProperty`, `Object.defineProperties`, and `Reflect.defineProperty`. Examples of **correct** code for the `{ "considerPropertyDescriptor": true }` option: ```json { "func-name-matching": ["error", { "considerPropertyDescriptor": true }] } ``` ```javascript const obj = {}; Object.create(obj, { foo: { value: function foo() {} } }); Object.defineProperty(obj, "bar", { value: function bar() {} }); Object.defineProperties(obj, { baz: { value: function baz() {} } }); Reflect.defineProperty(obj, "foo", { value: function foo() {} }); ``` Examples of **incorrect** code for the `{ "considerPropertyDescriptor": true }` option: ```json { "func-name-matching": ["error", { "considerPropertyDescriptor": true }] } ``` ```javascript const obj = {}; Object.create(obj, { foo: { value: function bar() {} } }); Object.defineProperty(obj, "bar", { value: function baz() {} }); Object.defineProperties(obj, { baz: { value: function foo() {} } }); Reflect.defineProperty(obj, "foo", { value: function value() {} }); ``` ### includeCommonJSModuleExports A boolean value that defaults to `false`. If `includeCommonJSModuleExports` is set to true, `module.exports` and `module["exports"]` will be checked by this rule. Examples of **incorrect** code for the `{ "includeCommonJSModuleExports": true }` option: ```json { "func-name-matching": ["error", { "includeCommonJSModuleExports": true }] } ``` ```javascript module.exports = function foo(name) {}; module["exports"] = function foo(name) {}; ``` ## Differences from ESLint - For a property whose name comes from a string literal, rslint decides whether that name is a valid identifier using ts-go's current Unicode character table. ESLint's `esutils@2.0.3` uses frozen tables for both its ES5 and ES6 checks. This can make rslint check a property that ESLint leaves unchecked: for example, `{ "ᢅ": function foo() {} }` under `ecmaVersion: 5`, or `{ "𐕰": function foo() {} }` under a modern version. Assignment expressions have the same character-table difference at every configured version because ESLint always uses its default ES5 check on that path, while rslint uses ts-go's current table. - With `considerPropertyDescriptor` enabled, an `Object.defineProperties()` or `Object.create()` descriptor map is checked against its entry's key when that key is an identifier (e.g. `{ bar: { value: function bar() {} } }`). ESLint also reports entries keyed by a string or numeric literal (e.g. `{ "bar": { value: function baz() {} } }`), but names the property `undefined` in the message; rslint leaves those entries unchecked. ## Original Documentation - [ESLint: func-name-matching](https://eslint.org/docs/latest/rules/func-name-matching) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/func-name-matching.js) --- url: /rules/eslint/func-names.md --- # func-names [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'func-names': 'error', }, }, ]); ``` ## Rule Details A pattern that's becoming more common is to give function expressions names to aid in debugging. For example: ```javascript Foo.prototype.bar = function bar() {}; ``` Adding the second `bar` in the above example is optional. If you leave off the function name then when the function throws an exception you are likely to get something similar to `anonymous function` in the stack trace. If you provide the optional name for a function expression then you will get the name of the function expression in the stack trace. This rule can enforce or disallow the use of named function expressions. Examples of **incorrect** code for this rule with the default `"always"` option: ```javascript Foo.prototype.bar = function () {}; const cat = { meow: function () {}, }; (function () { // ... })(); export default function () {} ``` Examples of **correct** code for this rule with the default `"always"` option: ```javascript Foo.prototype.bar = function bar() {}; const cat = { meow() {}, }; (function bar() { // ... })(); export default function foo() {} ``` ## Options This rule has a string option: - `"always"` (default) requires function expressions to have a name. - `"as-needed"` requires function expressions to have a name, if the name isn't assigned automatically per the ECMAScript specification. - `"never"` disallows named function expressions, except in recursive functions, where a name is needed. This rule has an object option: - `"generators": "always" | "as-needed" | "never"` - `"always"` require named generators. - `"as-needed"` require named generators if the name isn't assigned automatically per the ECMAScript specification. - `"never"` disallow named generators where possible. When a value for `generators` is not provided the behavior for generator functions falls back to the base option. Function expressions and function declarations in `export default` declarations must have a name under both `"always"` and `"as-needed"`. ### as-needed ECMAScript 6 introduced a `name` property on all functions. The value of `name` is determined by evaluating the code around the function to see if a name can be inferred. For example, a function assigned to a variable will automatically have a `name` property equal to the name of the variable. The value of `name` is then used in stack traces for easier debugging. Examples of **incorrect** code for this rule with the `"as-needed"` option: ```json { "func-names": ["error", "as-needed"] } ``` ```javascript Foo.prototype.bar = function () {}; (function () { // ... })(); export default function () {} ``` Examples of **correct** code for this rule with the `"as-needed"` option: ```json { "func-names": ["error", "as-needed"] } ``` ```javascript const bar = function () {}; const cat = { meow: function () {}, }; class C { #bar = function () {}; baz = function () {}; } quux ??= function () {}; (function bar() { // ... })(); export default function foo() {} ``` ### never Examples of **incorrect** code for this rule with the `"never"` option: ```json { "func-names": ["error", "never"] } ``` ```javascript Foo.prototype.bar = function bar() {}; (function bar() { // ... })(); ``` Examples of **correct** code for this rule with the `"never"` option: ```json { "func-names": ["error", "never"] } ``` ```javascript Foo.prototype.bar = function () {}; (function () { // ... })(); ``` ### generators Examples of **incorrect** code for this rule with the `"always", { "generators": "as-needed" }` options: ```json { "func-names": ["error", "always", { "generators": "as-needed" }] } ``` ```javascript (function* () { // ... })(); ``` Examples of **correct** code for this rule with the `"always", { "generators": "as-needed" }` options: ```json { "func-names": ["error", "always", { "generators": "as-needed" }] } ``` ```javascript const foo = function* () {}; ``` Examples of **incorrect** code for this rule with the `"always", { "generators": "never" }` options: ```json { "func-names": ["error", "always", { "generators": "never" }] } ``` ```javascript const foo = bar(function* baz() {}); ``` Examples of **correct** code for this rule with the `"always", { "generators": "never" }` options: ```json { "func-names": ["error", "always", { "generators": "never" }] } ``` ```javascript const foo = bar(function* () {}); ``` Examples of **incorrect** code for this rule with the `"as-needed", { "generators": "never" }` options: ```json { "func-names": ["error", "as-needed", { "generators": "never" }] } ``` ```javascript const foo = bar(function* baz() {}); ``` Examples of **correct** code for this rule with the `"as-needed", { "generators": "never" }` options: ```json { "func-names": ["error", "as-needed", { "generators": "never" }] } ``` ```javascript const foo = bar(function* () {}); ``` Examples of **incorrect** code for this rule with the `"never", { "generators": "always" }` options: ```json { "func-names": ["error", "never", { "generators": "always" }] } ``` ```javascript const foo = bar(function* () {}); ``` Examples of **correct** code for this rule with the `"never", { "generators": "always" }` options: ```json { "func-names": ["error", "never", { "generators": "always" }] } ``` ```javascript const foo = bar(function* baz() {}); ``` ## Original Documentation - [ESLint: func-names](https://eslint.org/docs/latest/rules/func-names) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/func-names.js) --- url: /rules/eslint/func-style.md --- # func-style [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'func-style': 'error', }, }, ]); ``` ## Rule Details There are two ways of defining functions in JavaScript: `function` declarations and function expressions assigned to variables. Function expressions can either be arrow functions or use the `function` keyword with an optional name. ```javascript // function declaration function doSomething() { // ... } // arrow function expression assigned to a variable const doSomethingElse = () => { // ... }; // function expression assigned to a variable const doSomethingAgain = function () { // ... }; ``` The primary difference between `function` declarations and function expressions is that declarations are _hoisted_ to the top of the scope in which they are defined, which allows using the function before its declaration; a function expression must be defined before it is used. This rule enforces a particular type of function style, either `function` declarations or expressions assigned to variables. This rule does not apply to all functions. A callback function passed as an argument to another function, or a method assigned to an object, is not checked by this rule. Examples of **incorrect** code for this rule with the default `"expression"` option: ```javascript function foo() { // ... } ``` Examples of **correct** code for this rule with the default `"expression"` option: ```javascript const foo = function () { // ... }; const foo1 = () => {}; ``` Overloaded function declarations (multiple declarations of the same name with different parameter or return types) are never reported by this rule, regardless of the configured style: ```typescript function process(value: string): string; function process(value: number): number; function process(value: unknown) { return value; } ``` Examples of **incorrect** code for this rule with the `"declaration"` option: ```json { "func-style": ["error", "declaration"] } ``` ```javascript const foo = function () { // ... }; const foo1 = () => {}; ``` Examples of **correct** code for this rule with the `"declaration"` option: ```json { "func-style": ["error", "declaration"] } ``` ```javascript function foo() { // ... } // Methods (functions assigned to objects) are not checked by this rule SomeObject.foo = function () { // ... }; ``` ## Options This rule has a string option: - `"expression"` (default) requires the use of function expressions instead of function declarations - `"declaration"` requires the use of function declarations instead of function expressions This rule has an object option: - `"allowArrowFunctions"`: `true` (default `false`) allows the use of arrow functions when the string option is `"declaration"`. Arrow functions are always allowed when the string option is `"expression"`, regardless of this option. - `"allowTypeAnnotation"`: `true` (default `false`) allows a function expression or arrow function whose variable declaration has a type annotation, regardless of `allowArrowFunctions`. This option applies only when the string option is `"declaration"`. - `"overrides"`: - `"namedExports"`: `"expression" | "declaration" | "ignore"` overrides the function style required for named exports. `"ignore"` accepts either style. ### allowArrowFunctions Examples of additional **correct** code for this rule with `{ "allowArrowFunctions": true }`: ```json { "func-style": ["error", "declaration", { "allowArrowFunctions": true }] } ``` ```javascript const foo = () => {}; ``` ### allowTypeAnnotation Examples of **incorrect** code for this rule with `{ "allowTypeAnnotation": true }`: ```json { "func-style": ["error", "declaration", { "allowTypeAnnotation": true }] } ``` ```typescript const foo = function (): void {}; ``` Examples of **correct** code for this rule with `{ "allowTypeAnnotation": true }`: ```json { "func-style": ["error", "declaration", { "allowTypeAnnotation": true }] } ``` ```typescript type Fn = () => undefined; const foo: Fn = function () {}; const bar: Fn = () => {}; ``` ### overrides.namedExports Examples of **incorrect** code for this rule with `{ "overrides": { "namedExports": "expression" } }`: ```json { "func-style": [ "error", "declaration", { "overrides": { "namedExports": "expression" } } ] } ``` ```javascript export function foo() { // ... } ``` Examples of **correct** code for this rule with `{ "overrides": { "namedExports": "expression" } }`: ```json { "func-style": [ "error", "declaration", { "overrides": { "namedExports": "expression" } } ] } ``` ```javascript export const foo = function () { // ... }; export const bar = () => {}; ``` Examples of **incorrect** code for this rule with `{ "overrides": { "namedExports": "declaration" } }`: ```json { "func-style": [ "error", "expression", { "overrides": { "namedExports": "declaration" } } ] } ``` ```javascript export const foo = function () { // ... }; export const bar = () => {}; ``` Examples of **correct** code for this rule with `{ "overrides": { "namedExports": "declaration" } }`: ```json { "func-style": [ "error", "expression", { "overrides": { "namedExports": "declaration" } } ] } ``` ```javascript export function foo() { // ... } ``` Examples of **correct** code for this rule with `{ "overrides": { "namedExports": "ignore" } }`: ```json { "func-style": [ "error", "expression", { "overrides": { "namedExports": "ignore" } } ] } ``` ```javascript export const foo = function () { // ... }; export const bar = () => {}; export function baz() { // ... } ``` ## Original Documentation - [ESLint: func-style](https://eslint.org/docs/latest/rules/func-style) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/func-style.js) --- url: /rules/eslint/getter-return.md --- # getter-return [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'getter-return': 'error', }, }, ]); ``` ## Rule Details Enforces that property getters contain a `return` statement that returns a value. This applies to getter methods in object literals, class declarations, and property descriptors passed to `Object.defineProperty`, `Object.defineProperties`, `Reflect.defineProperty`, and `Object.create`. ### Options - `allowImplicit` (default: `false`): When set to `true`, allows getters to implicitly return `undefined` by using `return;` without a value. Examples of **incorrect** code for this rule: ```javascript var obj = { get name() { // no return }, }; class Foo { get bar() { // no return } } Object.defineProperty(obj, 'prop', { get: function () { // no return }, }); ``` Examples of **correct** code for this rule: ```javascript var obj = { get name() { return 'foo'; }, }; class Foo { get bar() { return this._bar; } } Object.defineProperty(obj, 'prop', { get: function () { return this._prop; }, }); // Throw statements are valid exit paths class AbstractFoo { get value() { throw new Error('Not implemented'); } } // All code paths must return or throw class Bar { get value() { if (condition) { return this._value; } else { throw new Error('Invalid state'); } } } ``` Examples of **correct** code with `{ allowImplicit: true }`: ```javascript var obj = { get name() { return; }, }; ``` ## Original Documentation - [ESLint: getter-return](https://eslint.org/docs/latest/rules/getter-return) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/getter-return.js) --- url: /rules/eslint/grouped-accessor-pairs.md --- # grouped-accessor-pairs [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'grouped-accessor-pairs': 'error', }, }, ]); ``` ## Rule Details This rule requires getter and setter definitions for the same property to be adjacent in object literals and classes. It can also enforce whether the getter or setter appears first and, when configured, checks TypeScript interface and type-literal accessors. Examples of **incorrect** code for this rule: ```javascript const value = { get name() {}, other: true, set name(next) {}, }; ``` Examples of **correct** code for this rule: ```javascript const value = { get name() {}, set name(next) {}, other: true, }; ``` Examples of **incorrect** code for this rule with `"getBeforeSet"`: ```json { "grouped-accessor-pairs": ["error", "getBeforeSet"] } ``` ```javascript const value = { set name(next) {}, get name() {}, }; ``` Examples of **incorrect** TypeScript code when type accessors are enforced: ```json { "grouped-accessor-pairs": [ "error", "anyOrder", { "enforceForTSTypes": true } ] } ``` ```typescript interface Value { get name(): string; other: boolean; set name(next: string); } ``` ## Original Documentation - [ESLint: grouped-accessor-pairs](https://eslint.org/docs/latest/rules/grouped-accessor-pairs) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/grouped-accessor-pairs.js) --- url: /rules/eslint/guard-for-in.md --- # guard-for-in [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'guard-for-in': 'error', }, }, ]); ``` ## Rule Details Require `for-in` loops to include an `if` statement. Iterating a `for-in` loop over an object exposes inherited prototype properties in addition to the object's own keys, so the body should typically be guarded (e.g. with `Object.hasOwn`, `Object.prototype.hasOwnProperty.call`, or a short-circuit `continue`) to filter unwanted properties. Examples of **incorrect** code for this rule: ```javascript for (key in foo) { doSomething(key); } ``` Examples of **correct** code for this rule: ```javascript for (key in foo) { if (Object.hasOwn(foo, key)) { doSomething(key); } } for (key in foo) { if (Object.prototype.hasOwnProperty.call(foo, key)) { doSomething(key); } } for (key in foo) { if (!Object.hasOwn(foo, key)) continue; doSomething(key); } ``` ## Original Documentation - [ESLint: guard-for-in](https://eslint.org/docs/latest/rules/guard-for-in) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/guard-for-in.js) --- url: /rules/eslint/id-denylist.md --- # id-denylist [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'id-denylist': 'error', }, }, ]); ``` ## Rule Details Generic names can lead to hard-to-decipher code. This rule lets you list identifier names that should not be used, and reports every place the code introduces one. The rule catches denied identifiers that are: - variable declarations - function declarations - object properties assigned to during object creation - class fields - class methods It leaves alone denied identifiers that are: - function calls and their arguments, so you can keep calling functions you do not control - property reads, so you can keep reading properties of objects you do not control - references to global variables the code does not declare, whose names you do not control Examples of **incorrect** code for this rule: ```json { "id-denylist": ["error", "data", "callback"] } ``` ```javascript const data = { ...values }; function callback() { // ... } element.callback = function () { // ... }; const itemSet = { data: [...values], }; class Foo { data = []; } class Bar { #data = []; } class Baz { callback() {} } class Qux { #callback() {} } ``` Examples of **correct** code for this rule: ```json { "id-denylist": ["error", "data", "callback"] } ``` ```javascript const encodingOptions = { ...values }; function processFileResult() { // ... } element.successHandler = function () { // ... }; const itemSet = { entities: [...values], }; callback(); foo.callback(); foo.data; class Foo { items = []; } class Bar { #items = []; } class Baz { method() {} } class Qux { #method() {} } ``` ## Options The rule takes one or more strings: the names of the denied identifiers. ```json { "id-denylist": ["error", "data", "err", "e", "cb", "callback"] } ``` ## Differences from ESLint - TypeScript 6 rejects legacy `assert` import attributes before lint rules run. ESLint can still lint that syntax with parser versions that accept it. Current `with` import attributes, including import types, are checked normally. - Implicit TypeScript type globals use scope-manager's default `esnext` catalog. An explicitly customized `parserOptions.lib` does not change that catalog in rslint, so additional host-library types may still be reported. ## Original Documentation - [ESLint: id-denylist](https://eslint.org/docs/latest/rules/id-denylist) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/id-denylist.js) --- url: /rules/eslint/id-length.md --- # id-length [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'id-length': 'error', }, }, ]); ``` ## Rule Details Very short identifier names like `e`, `x`, `_t` or very long ones like `hashGeneratorResultOutputContainerObject` can make code harder to read and potentially less maintainable. This rule enforces a minimum and/or maximum identifier length convention. This rule counts [graphemes](https://unicode.org/reports/tr29/#Default_Grapheme_Cluster_Table) instead of using UTF-16 code unit length. Examples of **incorrect** code for this rule with the default options: ```javascript const x = 5; obj.e = document.body; const foo = function (e) {}; try { dangerousStuff(); } catch (e) { // ignore as many do } const myObj = { a: 1 }; (a) => { a * a; }; class y {} class Foo { x() {} } function bar(...x) {} function baz([x]) {} const [z] = arr; const { prop: [i], } = {}; function qux({ x }) {} const { j } = {}; const { prop: a } = {}; ({ prop: obj.x } = {}); ``` Examples of **correct** code for this rule with the default options: ```javascript const num = 5; function _f() { return 42; } obj.el = document.body; const foo = function (evt) { /* do stuff */ }; try { dangerousStuff(); } catch (error) { // ignore as many do } const myObj = { apple: 1 }; (num) => { num * num; }; function bar(num = 0) {} class MyClass {} class Foo { method() {} } function baz(...args) {} function qux([longName]) {} const { prop } = {}; const [longName] = arr; function foobar({ prop }) {} const { a: property } = {}; ({ prop: obj.longName } = {}); const data = { x: 1 }; // excused because of quotes data["y"] = 3; // excused because of calculated property access ``` ## Options This rule has an object option: - `"min"` (default: `2`) enforces a minimum identifier length - `"max"` (default: unlimited) enforces a maximum identifier length - `"properties": "always"` (default) enforces identifier length convention for property names - `"properties": "never"` ignores identifier length convention for property names - `"exceptions"` allows an array of specified identifier names - `"exceptionPatterns"` array of strings representing regular expression patterns, allows identifiers that match any of the patterns ### min Examples of **incorrect** code for this rule with `{ "min": 4 }`: ```json { "id-length": ["error", { "min": 4 }] } ``` ```javascript const val = 5; function foo(e) {} ``` ### max Examples of **incorrect** code for this rule with `{ "max": 10 }`: ```json { "id-length": ["error", { "max": 10 }] } ``` ```javascript const reallyLongVarName = 5; function reallyLongFuncName() { return 42; } ``` ### properties Examples of **correct** code for this rule with `{ "properties": "never" }`: ```json { "id-length": ["error", { "properties": "never" }] } ``` ```javascript const myObj = { a: 1 }; ({ a: obj.x.y.z } = {}); ``` ### exceptions Examples of additional **correct** code for this rule with `{ "exceptions": ["x", "y", "z"] }`: ```json { "id-length": ["error", { "exceptions": ["x", "y", "z"] }] } ``` ```javascript const x = 5; function y() { return 42; } ``` ### exceptionPatterns Examples of additional **correct** code for this rule with `{ "exceptionPatterns": ["^E|S$"] }`: ```json { "id-length": ["error", { "exceptionPatterns": ["^E|S$"] }] } ``` ```javascript const E = 5; function S() { return 42; } ``` ## Original Documentation - [ESLint: id-length](https://eslint.org/docs/latest/rules/id-length) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/id-length.js) --- url: /rules/eslint/id-match.md --- # id-match [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'id-match': 'error', }, }, ]); ``` ## Rule Details This rule requires every identifier in the source to match a regular expression, so a project can enforce one naming convention — `camelCase`, `snake_case`, a required prefix — across variables, functions, classes, parameters and, optionally, properties and class fields. The pattern is the rule's first option and is read as a JavaScript regular expression with the `u` flag. It is matched anywhere in the name unless it is anchored, so `^[a-z]+$` requires the whole name to be lowercase while `[a-z]+` only requires the name to contain a lowercase run. TypeScript names count as identifiers too: type aliases, interfaces, type parameters, enums and their members, namespaces, and the names a type annotation refers to are all held to the pattern. References to known globals such as `Object` or `Array` are left alone unless that reference resolves to a declaration in the file. In TypeScript, the same is true of a reference used as a type when its name is a recognized standard-library type such as `Record` or `Partial`. A valid type or namespace reference is likewise left alone when it resolves to a global declaration supplied by another project file. Fixed syntax names such as the key of an import attribute (`with { type: "json" }`) and `import.meta` / `new.target` are also left alone. By contrast, `Missing_NS` in `type T = Missing_NS.Member`, `Record` in the value expression `Record;`, and a type declared or imported by the current file are checked. Examples of **incorrect** code for this rule: ```json { "id-match": ["error", "^[a-z]+$"] } ``` ```javascript var first_name = 'Ada'; function no_under() {} class My_Class {} ``` Examples of **correct** code for this rule: ```json { "id-match": ["error", "^[a-z]+$"] } ``` ```javascript var name = 'Ada'; function greet() {} no_under(); var myDate = new Date(); ``` ## Options This rule has a string as its first option (the pattern, default `"^.+$"`) and an object as its second. ### properties `properties` (default `false`) also checks property names: the keys of object literals, and the property of a member access when that member access is the assigned-to side of an assignment. Examples of **incorrect** code with `{ "properties": true }`: ```json { "id-match": ["error", "^[^_]+$", { "properties": true }] } ``` ```javascript var obj = { no_under: 1 }; obj.no_under = 2; ``` Examples of **correct** code with `{ "properties": true }`: ```json { "id-match": ["error", "^[^_]+$", { "properties": true }] } ``` ```javascript var obj = { valid: 1 }; var value = other.no_under; if (other.no_under) { } ``` ### classFields `classFields` (default `false`) also checks class field names, including private ones. A class method is checked whatever this option says. Examples of **incorrect** code with `{ "classFields": true }`: ```json { "id-match": ["error", "^[^_]+$", { "classFields": true }] } ``` ```javascript class Foo { _bar = 1; #_baz = 2; } ``` Examples of **correct** code with `{ "classFields": true }`: ```json { "id-match": ["error", "^[^_]+$", { "classFields": true }] } ``` ```javascript class Foo { bar = 1; #baz = 2; } ``` ### onlyDeclarations `onlyDeclarations` (default `false`) narrows the check to variable declarations, function declarations, and the parameters of a function declaration. A name that is only read is left alone. Examples of **incorrect** code with `{ "onlyDeclarations": true }`: ```json { "id-match": ["error", "^[a-z]+$", { "onlyDeclarations": true }] } ``` ```javascript var __foo = 'Ada'; ``` Examples of **correct** code with `{ "onlyDeclarations": true }`: ```json { "id-match": ["error", "^[a-z]+$", { "onlyDeclarations": true }] } ``` ```javascript __foo = 'Ada'; ``` ### ignoreDestructuring `ignoreDestructuring` (default `false`) leaves a destructured name alone when it repeats a property of the source object. A name the destructuring introduces — a rename, or a rest element — is still checked. Examples of **incorrect** code with `{ "ignoreDestructuring": true }`: ```json { "id-match": ["error", "^[^_]+$", { "ignoreDestructuring": true }] } ``` ```javascript var { category_id: category_alias } = query; var { categoryId, ...other_props } = query; ``` Examples of **correct** code with `{ "ignoreDestructuring": true }`: ```json { "id-match": ["error", "^[^_]+$", { "ignoreDestructuring": true }] } ``` ```javascript var { category_id } = query; var { category_id = 1 } = query; ``` ## Differences from ESLint - Given `External_NS` as a global namespace supplied by another TypeScript project file, rslint does not report it in `type T = External_NS.Member` when it fails the configured pattern; ESLint does. Both skip `Record` in `type U = Record`. ## Original Documentation - [ESLint: id-match](https://eslint.org/docs/latest/rules/id-match) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/id-match.js) --- url: /rules/eslint/init-declarations.md --- # init-declarations [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'init-declarations': 'error', }, }, ]); ``` ## Rule Details Require or disallow initialization in variable declarations. This rule applies to `var`, `let`, `const`, `using`, and `await using` declarations. It reports each declarator whose initialization does or does not match the configured mode. Examples of **incorrect** code for this rule with `"always"` (the default): ```javascript function foo() { var bar; let baz; } ``` Examples of **correct** code for this rule with `"always"`: ```javascript function foo() { var bar = 1; let baz = 2; const qux = 3; } ``` Examples of **incorrect** code for this rule with `"never"`: ```json { "init-declarations": ["error", "never"] } ``` ```javascript function foo() { var bar = 1; let baz = 2; for (let i = 0; i < 1; i++) {} } ``` Examples of **correct** code for this rule with `"never"`: ```javascript function foo() { var bar; let baz; const buzz = 1; } ``` `const`, `using`, and `await using` declarations always require an initializer, so `"never"` never flags them. Examples of **correct** code for this rule with `{ "ignoreForLoopInit": true }`: ```json { "init-declarations": ["error", "never", { "ignoreForLoopInit": true }] } ``` ```javascript for (let i = 0; i < 1; i++) {} ``` A destructuring declarator (`var { a } = obj;`, `var [a] = arr;`) is never reported, in either mode. `declare var`/`declare let`/`declare const`, and any declaration nested inside a `declare namespace`/`declare module`/ambient `.d.ts` context, is exempt in both modes. ## Options This rule takes up to two options: 1. A string, either `"always"` (default) or `"never"`. 2. When the first option is `"never"`, an object with: - `ignoreForLoopInit`: when `true`, allows initialization in a `for` loop's declaration even under `"never"`. Default `false`. ## Original Documentation - [ESLint: init-declarations](https://eslint.org/docs/latest/rules/init-declarations) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/init-declarations.js) --- url: /rules/eslint/logical-assignment-operators.md --- # logical-assignment-operators [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'logical-assignment-operators': 'error', }, }, ]); ``` ## Rule Details This rule requires or disallows the logical assignment operators `&&=`, `||=`, and `??=`. By default (`"always"`) it reports an assignment or a logical expression that duplicates its own target and can be written with a logical assignment operator instead. Examples of **incorrect** code for this rule: ```javascript a = a || b; a = a && b; a = a ?? b; a || (a = b); a && (a = b); a ?? (a = b); ``` Examples of **correct** code for this rule: ```javascript a ||= b; a &&= b; a ??= b; a = b || c; a || (b = c); ``` ### enforceForIfStatements With `{ "enforceForIfStatements": true }` the rule also reports an `if` statement whose only purpose is to assign to the value it tests. ```json { "logical-assignment-operators": ["error", "always", { "enforceForIfStatements": true }] } ``` Examples of **incorrect** code: ```javascript if (a) a = b; if (!a) a = b; if (Boolean(a)) a = b; if (a == null) a = b; if (a === null || a === undefined) a = b; ``` Examples of **correct** code: ```javascript if (a) b = c; if (a) a = b; else a = c; if (predicate(a)) a = b; ``` ### never With `"never"` the rule reports every logical assignment operator and prefers the expanded form. ```json { "logical-assignment-operators": ["error", "never"] } ``` Examples of **incorrect** code: ```javascript a ||= b; a &&= b; a ??= b; ``` Examples of **correct** code: ```javascript a = a || b; a = a && b; a = a ?? b; ``` ## Fixes and suggestions The rewrite is applied automatically when it cannot change how many times a getter or a setter runs, and is offered as a suggestion otherwise. For `a = a || b` and for the `never` option, the target has to be a plain identifier. For `a || (a = b)` and for `if` statements, a single property access such as `a.b` also qualifies, as long as an `if` condition is a single test rather than a `||` chain. A bare name inside a non-strict `with` block may resolve to a property, so it counts as a single property access rather than a plain identifier. A TypeScript assertion makes the two sides count as different values, so `a = a! || b` and `a[b!] || (a[b!] = c)` are left alone. ## Original Documentation - [ESLint: logical-assignment-operators](https://eslint.org/docs/latest/rules/logical-assignment-operators) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/logical-assignment-operators.js) --- url: /rules/eslint/max-classes-per-file.md --- # max-classes-per-file [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'max-classes-per-file': 'error', }, }, ]); ``` ## Rule Details This rule enforces that each file may contain only a particular number of classes and no more. Examples of **incorrect** code for this rule: ```javascript class Foo {} class Bar {} ``` Examples of **correct** code for this rule: ```javascript class Foo {} ``` ## Options This rule may be configured with either an object or a number. If the option is an object, it may contain one or both of: - `ignoreExpressions`: a boolean option (defaulted to `false`) to ignore class expressions. - `max`: a numeric option (defaulted to 1) to specify the maximum number of classes. Examples of **correct** code for this rule with `{ "max-classes-per-file": ["error", 2] }`: ```json { "max-classes-per-file": ["error", 2] } ``` ```javascript class Foo {} class Bar {} ``` Examples of **correct** code for this rule with `{ "max-classes-per-file": ["error", { "ignoreExpressions": true }] }`: ```json { "max-classes-per-file": ["error", { "ignoreExpressions": true }] } ``` ```javascript class VisitorFactory { forDescriptor(descriptor) { return class { visit(node) { return `Visiting ${descriptor}.`; } }; } } ``` ## Original Documentation - [ESLint: max-classes-per-file](https://eslint.org/docs/latest/rules/max-classes-per-file) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/max-classes-per-file.js) --- url: /rules/eslint/max-depth.md --- # max-depth [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'max-depth': 'error', }, }, ]); ``` ## Rule Details This rule enforces a maximum depth that blocks can be nested to reduce code complexity. Examples of **incorrect** code for this rule with the default `{ "max": 4 }` option: ```javascript function foo() { for (;;) { // Depth 1 while (true) { // Depth 2 if (true) { // Depth 3 if (true) { // Depth 4 if (true) { // Depth 5 } } } } } } ``` Examples of **correct** code for this rule with the default `{ "max": 4 }` option: ```javascript function foo() { for (;;) { // Depth 1 while (true) { // Depth 2 if (true) { // Depth 3 if (true) { // Depth 4 } } } } } ``` ## Options This rule accepts a number, or an object with `max` (default: `4`). The legacy `maximum` key is also accepted for backward compatibility. Examples of **incorrect** code for this rule with `{ "max": 2 }`: ```json { "max-depth": ["error", { "max": 2 }] } ``` ```javascript function foo() { if (true) { if (false) { if (true) { } } } } ``` Examples of **correct** code for this rule with `{ "max": 2 }`: ```json { "max-depth": ["error", { "max": 2 }] } ``` ```javascript function foo() { if (true) { if (false) { } } } ``` `else if` chains are treated as a single depth level. Class static blocks reset the nesting counter — code inside `static {}` is measured from depth 0. ```javascript function foo() { if (true) { // Depth 1 class C { static { if (true) { // Depth 1 (resets in static block) if (true) { // Depth 2 } } } } } } ``` ## Original Documentation - [ESLint: max-depth](https://eslint.org/docs/latest/rules/max-depth) - [Source code](https://github.com/eslint/eslint/blob/v10.2.1/lib/rules/max-depth.js) --- url: /rules/eslint/max-lines.md --- # max-lines [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'max-lines': 'error', }, }, ]); ``` Enforce a maximum number of lines per file. ## Rule Details Large files tend to do a lot of things and can make it hard to follow what's going on. This rule caps the number of lines in a file. With the `{ "max": 3 }` option: ```json { "max-lines": ["error", 3] } ``` Examples of **incorrect** code for this rule: ```javascript let a, b, c, d; ``` Examples of **correct** code for this rule: ```javascript let a, b, c; ``` ## Options This rule accepts a number (the maximum allowed) or an object with the following properties: - `max` (default `300`): the maximum number of lines allowed in a file. - `skipBlankLines` (default `false`): ignore lines made up purely of whitespace. - `skipComments` (default `false`): ignore lines containing just comments (a comment that shares a line with code does not exclude that line). ### `skipBlankLines` ```json { "max-lines": ["error", { "max": 2, "skipBlankLines": true }] } ``` Examples of **correct** code with the above configuration: ```javascript var a = 1; var b = 2; ``` ### `skipComments` ```json { "max-lines": ["error", { "max": 2, "skipComments": true }] } ``` Examples of **correct** code with the above configuration: ```javascript // a header comment var a = 1; var b = 2; ``` ## Original Documentation - [ESLint: max-lines](https://eslint.org/docs/latest/rules/max-lines) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/max-lines.js) --- url: /rules/eslint/max-lines-per-function.md --- # max-lines-per-function [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'max-lines-per-function': 'error', }, }, ]); ``` Enforce a maximum number of lines of code in a function. ## Rule Details Long functions are harder to follow than short ones. This rule reports any function whose body — including its declaration line and the closing brace — exceeds the configured line limit. By default, the rule checks for a maximum of 50 lines per function. Comments and blank lines are counted, and IIFEs are skipped. Examples of **incorrect** code for this rule with the default `{ "max": 50 }` option (function body shortened for brevity): ```javascript function longFunction() { // imagine 50 more lines here } ``` Examples of **correct** code for this rule with the default option: ```javascript function shortFunction() { doThing(); return result; } ``` ## Options This rule accepts a number (the maximum allowed) or an object with the following properties: - `max` (default `50`): maximum number of lines a function may contain. - `skipBlankLines` (default `false`): ignore lines made up purely of whitespace. - `skipComments` (default `false`): ignore lines that contain only comments (a line with both code and a comment still counts). - `IIFEs` (default `false`): when `true`, IIFEs are checked like other functions; when `false`, they are skipped. ### `max` ```json { "max-lines-per-function": ["error", { "max": 2 }] } ``` Examples of **incorrect** code for this rule with `{ "max": 2 }`: ```javascript function name() { var x = 5; var y = 2; } ``` Examples of **correct** code for this rule with `{ "max": 3 }`: ```javascript function name() { var x = 5; } ``` ### `skipBlankLines` ```json { "max-lines-per-function": ["error", { "max": 3, "skipBlankLines": true }] } ``` Examples of **correct** code for this rule with the above configuration: ```javascript function name() { var x = 5; var y = 2; } ``` ### `skipComments` ```json { "max-lines-per-function": ["error", { "max": 3, "skipComments": true }] } ``` Examples of **correct** code for this rule with the above configuration: ```javascript function name() { // a comment var x = 5; var y = 2; } ``` ### `IIFEs` ```json { "max-lines-per-function": ["error", { "max": 2, "IIFEs": true }] } ``` Examples of **incorrect** code for this rule with the above configuration: ```javascript (function () { var x = 0; var y = 0; })(); ``` ## Original Documentation - [ESLint: max-lines-per-function](https://eslint.org/docs/latest/rules/max-lines-per-function) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/max-lines-per-function.js) --- url: /rules/eslint/max-nested-callbacks.md --- # max-nested-callbacks [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'max-nested-callbacks': 'error', }, }, ]); ``` ## Rule Details This rule enforces a maximum depth that callbacks can be nested to improve code readability. A common anti-pattern is "callback hell" — deeply nested callbacks that grow rightward and become hard to follow. A function expression or arrow function counts toward the nesting depth only when it is passed directly to a call (as a call argument or as the callee of an immediately-invoked call). Function-likes assigned to variables, object or class properties, array elements, JSX attributes, default parameter values, or used as `new` arguments / tagged-template arguments do not increase the counter. Examples of **incorrect** code for this rule with the default `{ "max": 10 }` option: ```javascript foo1(function () { foo2(function () { foo3(function () { foo4(function () { foo5(function () { foo6(function () { foo7(function () { foo8(function () { foo9(function () { foo10(function () { foo11(function () {}); }); }); }); }); }); }); }); }); }); }); ``` Examples of **correct** code for this rule with the default `{ "max": 10 }` option: ```javascript foo1(handleFoo1); function handleFoo1() { foo2(handleFoo2); } function handleFoo2() { foo3(handleFoo3); } ``` ## Options This rule accepts a number, or an object with the following properties: - `max` (default `10`): the maximum nesting depth allowed. - `maximum`: deprecated alias for `max`. When both keys are present and `maximum` is truthy, `maximum` wins (matching ESLint's `option.maximum || option.max` coercion). ### `max` Examples of **incorrect** code for this rule with `{ "max": 3 }`: ```json { "max-nested-callbacks": ["error", { "max": 3 }] } ``` ```javascript foo1(function () { foo2(function () { foo3(function () { foo4(function () {}); }); }); }); ``` Examples of **correct** code for this rule with `{ "max": 3 }`: ```json { "max-nested-callbacks": ["error", { "max": 3 }] } ``` ```javascript foo1(function () { foo2(function () { foo3(function () {}); }); }); ``` Arrow functions are counted the same as function expressions: ```javascript foo1(() => { foo2(() => { foo3(() => { foo4(() => {}); }); }); }); ``` ## Original Documentation - [ESLint: max-nested-callbacks](https://eslint.org/docs/latest/rules/max-nested-callbacks) - [Source code](https://github.com/eslint/eslint/blob/v10.3.0/lib/rules/max-nested-callbacks.js) --- url: /rules/eslint/max-params.md --- # max-params [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'max-params': 'error', }, }, ]); ``` ## Rule Details This rule enforces a maximum number of parameters allowed in function definitions. Examples of **incorrect** code for this rule with the default `{ "max": 3 }` option: ```javascript function foo1(bar, baz, qux, qxx) { doSomething(); } let foo2 = (bar, baz, qux, qxx) => { doSomething(); }; ``` Examples of **correct** code for this rule with the default `{ "max": 3 }` option: ```javascript function foo1(bar, baz, qux) { doSomething(); } let foo2 = (bar, baz, qux) => { doSomething(); }; ``` ## Options This rule accepts a number (the maximum allowed) or an object with the following properties: - `max` (default `3`): the maximum number of parameters allowed. - `countThis` (default `"except-void"`): TypeScript-only handling for `this` declarations. Use `"always"` to count `this`, `"never"` to ignore it, or `"except-void"` to ignore only `this: void`. - `maximum`: deprecated alias for `max`. When both keys are present and `maximum` is truthy, `maximum` wins (matching ESLint's `option.maximum || option.max` coercion). - `countVoidThis`: deprecated alias for `countThis`. `true` maps to `"always"` and `false` maps to `"except-void"`. ### `max` Examples of **incorrect** code for this rule with `{ "max": 2 }`: ```json { "max-params": ["error", { "max": 2 }] } ``` ```javascript function foo(bar, baz, qux) { doSomething(); } ``` Examples of **correct** code for this rule with `{ "max": 2 }`: ```json { "max-params": ["error", { "max": 2 }] } ``` ```javascript function foo(bar, baz) { doSomething(); } ``` ### `countThis` Examples of **correct** TypeScript code for this rule with `{ "max": 2, "countThis": "never" }`: ```json { "max-params": ["error", { "max": 2, "countThis": "never" }] } ``` ```typescript function hasThis(this: unknown[], first: string, second: string) { doSomething(); } ``` Examples of **incorrect** TypeScript code for this rule with `{ "max": 2, "countThis": "always" }`: ```json { "max-params": ["error", { "max": 2, "countThis": "always" }] } ``` ```typescript function hasThis(this: void, first: string, second: string) { doSomething(); } ``` ## Original Documentation - [ESLint: max-params](https://eslint.org/docs/latest/rules/max-params) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/max-params.js) --- url: /rules/eslint/max-statements.md --- # max-statements [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'max-statements': 'error', }, }, ]); ``` ## Rule Details This rule enforces a maximum number of statements allowed in function blocks. Examples of **incorrect** code for this rule with the default `{ "max": 10 }` option: ```javascript function foo() { const foo1 = 1; const foo2 = 2; const foo3 = 3; const foo4 = 4; const foo5 = 5; const foo6 = 6; const foo7 = 7; const foo8 = 8; const foo9 = 9; const foo10 = 10; const foo11 = 11; // Too many. } ``` Examples of **correct** code for this rule with the default `{ "max": 10 }` option: ```javascript function foo() { const foo1 = 1; const foo2 = 2; const foo3 = 3; const foo4 = 4; const foo5 = 5; const foo6 = 6; const foo7 = 7; const foo8 = 8; const foo9 = 9; return function () { // 10 // The number of statements in the inner function does not count toward the // statement maximum. let bar; let baz; return 42; }; } ``` Note that this rule does not apply to class static blocks, and that statements in class static blocks do not count as statements in the enclosing function. Examples of **correct** code for this rule with `{ "max": 2 }` option: ```json { "max-statements": ["error", 2] } ``` ```javascript function foo() { let one; let two = class { static { let three; let four; let five; if (six) { let seven; let eight; let nine; } } }; } ``` Examples of additional **correct** code for this rule with the `{ "max": 10 }, { "ignoreTopLevelFunctions": true }` options: ```json { "max-statements": ["error", 10, { "ignoreTopLevelFunctions": true }] } ``` ```javascript function foo() { const foo1 = 1; const foo2 = 2; const foo3 = 3; const foo4 = 4; const foo5 = 5; const foo6 = 6; const foo7 = 7; const foo8 = 8; const foo9 = 9; const foo10 = 10; const foo11 = 11; } ``` `ignoreTopLevelFunctions` only ignores a function's statement count when it is the single top-level function in the file — for example, a module wrapped entirely in one IIFE. When more than one top-level function exists, each one is still checked individually. ## Original Documentation - [ESLint: max-statements](https://eslint.org/docs/latest/rules/max-statements) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/max-statements.js) --- url: /rules/eslint/new-cap.md --- # new-cap [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'new-cap': 'error', }, }, ]); ``` ## Rule Details This rule requires constructor names to begin with an uppercase letter and requires functions whose names begin with an uppercase letter to be called with `new`. Examples of **incorrect** code for this rule: ```javascript const friend = new person(); const colleague = Person(); ``` Examples of **correct** code for this rule: ```javascript const friend = new Person(); const value = Boolean(input); ``` The object option supports `newIsCap`, `capIsNew`, `newIsCapExceptions`, `newIsCapExceptionPattern`, `capIsNewExceptions`, `capIsNewExceptionPattern`, and `properties`. The two checks and property checking are enabled by default. ```json { "new-cap": [ "error", { "newIsCapExceptions": ["events"], "capIsNewExceptionPattern": "\\.Factory$", "properties": false } ] } ``` ```javascript const emitter = new events(); const value = library.Factory(); const widget = new library.widget(); ``` ## Differences from ESLint ESLint's exception lookup also accepts names inherited from `Object.prototype`, such as `constructor` and `toString`, because its exception map is a plain JavaScript object. This is an upstream implementation accident. rslint uses an explicit string set, so lowercase constructor names are reported unless they are configured in `newIsCapExceptions`. ## Original Documentation - [ESLint: new-cap](https://eslint.org/docs/latest/rules/new-cap) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/new-cap.js) --- url: /rules/eslint/no-alert.md --- # no-alert [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-alert': 'error', }, }, ]); ``` ## Rule Details Disallow the use of `alert`, `confirm`, and `prompt`. JavaScript's `alert`, `confirm`, and `prompt` functions are widely considered to be obtrusive as UI elements and should be replaced by a more appropriate custom UI implementation. Furthermore, `alert` is often used while debugging code, which should be removed before deployment to production. Examples of **incorrect** code for this rule: ```javascript alert('here!'); confirm('Are you sure?'); prompt("What's your name?", 'John Doe'); window.alert('here!'); globalThis.confirm('Are you sure?'); this.prompt("What's your name?"); ``` Examples of **correct** code for this rule: ```javascript customAlert('Something happened!'); customConfirm('Are you sure?'); customPrompt('Who are you?'); function foo() { var alert = myCustomLib.customAlert; alert(); } ``` ## Original Documentation - [ESLint: no-alert](https://eslint.org/docs/latest/rules/no-alert) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-alert.js) --- url: /rules/eslint/no-array-constructor.md --- # no-array-constructor [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-array-constructor': 'error', }, }, ]); ``` ## Rule Details Use of the `Array` constructor to construct a new array is generally discouraged in favor of array literal notation because of the single-argument pitfall and because the `Array` global may be redefined. The exception is when the `Array` constructor is used to intentionally create sparse arrays of a specified size by giving the constructor a single numeric argument. This rule disallows `Array` constructors. Examples of **incorrect** code for this rule: ```javascript Array(); Array(0, 1, 2); new Array(0, 1, 2); Array(...args); ``` Examples of **correct** code for this rule: ```javascript Array(500); new Array(someOtherArray.length); [0, 1, 2]; const createArray = Array => new Array(); ``` This rule additionally supports TypeScript type syntax. Examples of **correct** code for this rule: ```typescript new Array(1, 2, 3); new Array(); Array(1, 2, 3); Array(); Array?.foo(); ``` Examples of **incorrect** code for this rule: ```typescript new Array(); new Array(0, 1, 2); Array?.(x, y); Array?.(0, 1, 2); ``` ## Differences from ESLint - When the array constructor call is fixed onto a new line right after certain TypeScript-only constructs — a type alias (`type T = Foo`), an ambient or overload function declaration (`declare function foo()`), an import-equals declaration (`import Foo = Bar`), or an `as`/`satisfies` type cast — rslint's autofix inserts a leading `;` that ESLint omits (e.g. `type T = Foo\n;[0, 1]` instead of `type T = Foo\n[0, 1]`). The extra semicolon never changes the resulting code's behavior. - In TypeScript files, rslint treats `Array` as a predefined library variable even when `parserOptions.lib` is explicitly empty. For example, with `parserOptions.lib: []` and `globals: { Array: "off" }`, rslint still reports and fixes `Array()`, while typescript-eslint does not. Native rule contexts do not currently expose parser-specific library selection. ## Original Documentation - [ESLint: no-array-constructor](https://eslint.org/docs/latest/rules/no-array-constructor) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-array-constructor.js) --- url: /rules/eslint/no-async-promise-executor.md --- # no-async-promise-executor [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-async-promise-executor': 'error', }, }, ]); ``` ## Rule Details Disallows passing an `async` function as the executor to `new Promise()`. Using an async executor is usually a mistake because if the async executor throws an error, the error will be lost and will not cause the newly-constructed Promise to reject. Additionally, if a Promise executor uses `await`, this is usually a sign that it is not actually necessary to use the `new Promise` constructor. Examples of **incorrect** code for this rule: ```javascript const result = new Promise(async (resolve, reject) => { resolve(await foo); }); const result = new Promise(async function (resolve, reject) { resolve(await foo); }); ``` Examples of **correct** code for this rule: ```javascript const result = new Promise((resolve, reject) => { resolve(foo); }); const result = new Promise(function (resolve, reject) { readFile('foo.txt', function (err, data) { if (err) reject(err); else resolve(data); }); }); ``` ## Original Documentation - [ESLint: no-async-promise-executor](https://eslint.org/docs/latest/rules/no-async-promise-executor) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-async-promise-executor.js) --- url: /rules/eslint/no-await-in-loop.md --- # no-await-in-loop [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-await-in-loop': 'error', }, }, ]); ``` ## Rule Details Disallows `await` expressions inside loop bodies (`for`, `for-in`, `for-of`, `while`, `do-while`). Using `await` in a loop is usually a sign that the program is not taking full advantage of the parallelization benefits of `async`/`await`, as each iteration waits for the previous one to complete. The operations can often be refactored to use `Promise.all()` instead. This rule allows `await` in `for-await-of` loops, since those are designed to work with async iterables. However, a `for-await-of` nested inside another loop will be flagged. Examples of **incorrect** code for this rule: ```javascript async function foo(things) { for (const thing of things) { await bar(thing); } } async function foo(things) { while (things.length) { await bar(things.pop()); } } ``` Examples of **correct** code for this rule: ```javascript async function foo(things) { await Promise.all(things.map((thing) => bar(thing))); } async function foo(things) { for await (const thing of asyncIterable) { console.log(thing); } } ``` ## Original Documentation - [ESLint: no-await-in-loop](https://eslint.org/docs/latest/rules/no-await-in-loop) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-await-in-loop.js) --- url: /rules/eslint/no-bitwise.md --- # no-bitwise [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-bitwise': 'error', }, }, ]); ``` ## Rule Details The use of bitwise operators in JavaScript is very rare and often `&` or `|` is simply a mistyped `&&` or `||`, which will lead to unexpected behavior. This rule disallows bitwise operators. Examples of **incorrect** code for this rule: ```javascript var x = y | z; var x = y & z; var x = y ^ z; var x = ~z; var x = y << z; var x = y >> z; var x = y >>> z; x |= y; x &= y; x ^= y; x <<= y; x >>= y; x >>>= y; ``` Examples of **correct** code for this rule: ```javascript var x = y || z; var x = y && z; var x = y > z; var x = y < z; x += y; ``` ## Options This rule accepts a single object option with the following properties: ### `allow` - Type: `string[]` (subset of `"|"`, `"&"`, `"^"`, `"<<"`, `">>"`, `">>>"`, `"|="`, `"&="`, `"^="`, `"<<="`, `">>="`, `">>>="`, `"~"`) - Default: `[]` Whitelists the listed bitwise operators as exceptions. Only operators exactly matching a string in this list are allowed; all others still report. Example configuration: ```json { "no-bitwise": ["error", { "allow": ["~"] }] } ``` Examples of **correct** code with the above configuration: ```javascript ~[1, 2, 3].indexOf(1) === -1; ``` ### `int32Hint` - Type: `boolean` - Default: `false` When `true`, permits the `x | 0` idiom commonly used to coerce a number to a 32-bit integer. Only `|` with a literal `0` on the right-hand side is allowed — `0 | x`, `x & 0`, `x | 1`, `x | -0`, and `x | 0n` still report. Example configuration: ```json { "no-bitwise": ["error", { "int32Hint": true }] } ``` Examples of **correct** code with the above configuration: ```javascript var b = a | 0; ``` ## Original Documentation - [ESLint: no-bitwise](https://eslint.org/docs/latest/rules/no-bitwise) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-bitwise.js) --- url: /rules/eslint/no-caller.md --- # no-caller [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-caller': 'error', }, }, ]); ``` ## Rule Details Disallows the use of `arguments.caller` and `arguments.callee`. The use of `arguments.caller` and `arguments.callee` make several code optimizations impossible. They have been deprecated in future versions of JavaScript and their use is forbidden in ECMAScript 5 strict mode. Examples of **incorrect** code for this rule: ```javascript function foo(n) { if (n <= 0) { return; } arguments.callee(n - 1); } [1, 2, 3, 4, 5].map(function (n) { return !(n > 1) ? 1 : arguments.callee(n - 1) * n; }); ``` Examples of **correct** code for this rule: ```javascript function foo(n) { if (n <= 0) { return; } foo(n - 1); } [1, 2, 3, 4, 5].map(function factorial(n) { return !(n > 1) ? 1 : factorial(n - 1) * n; }); ``` ## Original Documentation - [ESLint: no-caller](https://eslint.org/docs/latest/rules/no-caller) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-caller.js) --- url: /rules/eslint/no-case-declarations.md --- # no-case-declarations [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-case-declarations': 'error', }, }, ]); ``` ## Rule Details Disallow lexical declarations in case clauses. Lexical declarations (`let`, `const`, `function`, `class`) in case clauses are visible in the entire switch block but only get initialized when assigned, which can lead to unexpected behavior. Examples of **incorrect** code for this rule: ```javascript switch (foo) { case 1: let x = 1; break; case 2: const y = 2; break; case 3: function f() {} break; case 4: class C {} break; } ``` Examples of **correct** code for this rule: ```javascript switch (foo) { case 1: { let x = 1; break; } case 2: { const y = 2; break; } case 3: { function f() {} break; } default: { class C {} } } ``` ## Original Documentation - [ESLint: no-case-declarations](https://eslint.org/docs/latest/rules/no-case-declarations) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-case-declarations.js) --- url: /rules/eslint/no-class-assign.md --- # no-class-assign [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-class-assign': 'error', }, }, ]); ``` ## Rule Details Disallows reassigning variables that were declared as class declarations. Reassigning a class declaration is almost always a mistake, as it overwrites the class with a different value. This rule checks for assignments, increment/decrement operations, and destructuring assignments that target a class name. Examples of **incorrect** code for this rule: ```javascript class A {} A = 0; class B {} B += 1; class C {} ({ C } = obj); ``` Examples of **correct** code for this rule: ```javascript class A {} var a = new A(); let B = class {}; B = 0; // B is a variable, not a class declaration class C {} function fn(C) { C = 0; // C is a parameter, not the class } ``` ## Original Documentation - [ESLint: no-class-assign](https://eslint.org/docs/latest/rules/no-class-assign) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-class-assign.js) --- url: /rules/eslint/no-compare-neg-zero.md --- # no-compare-neg-zero [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-compare-neg-zero': 'error', }, }, ]); ``` ## Rule Details Disallows comparing against `-0` using equality and relational operators (`==`, `===`, `!=`, `!==`, `>`, `>=`, `<`, `<=`). Comparing directly to `-0` does not work as intended because `+0 === -0` is `true`. To check whether a value is `-0`, use `Object.is(x, -0)` instead. Examples of **incorrect** code for this rule: ```javascript if (x === -0) { } if (x == -0) { } if (x > -0) { } if (x !== -0) { } ``` Examples of **correct** code for this rule: ```javascript if (x === 0) { } if (Object.is(x, -0)) { } if (x > 0) { } ``` ## Original Documentation - [ESLint: no-compare-neg-zero](https://eslint.org/docs/latest/rules/no-compare-neg-zero) - [Source code](https://github.com/eslint/eslint/blob/v9.39.1/lib/rules/no-compare-neg-zero.js) --- url: /rules/eslint/no-cond-assign.md --- # no-cond-assign [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-cond-assign': 'error', }, }, ]); ``` ## Rule Details Disallows assignment operators in test expressions (`if`, `while`, `do-while`, `for`, and ternary). Assignments in tests are frequently a typo where the developer meant to use a comparison operator (`===`) instead of an assignment operator (`=`). In the default `"except-parens"` mode, a top-level assignment is allowed when extra parentheses signal that it is intentional. A ternary test needs two explicit pairs because, unlike a statement test, it has no grammar parentheses. In `"always"` mode, assignments descended from a test expression are flagged, stopping at nested function boundaries. An assignment in a ternary branch is not part of that ternary's test, so it is allowed when the ternary is outside another conditional test. If the whole ternary is itself an outer test, `"always"` mode reports the assignment against that outer conditional. Assignments in statement bodies are allowed in both modes. Examples of **incorrect** code for this rule: ```javascript if (x = 0) { } while (x = next()) {} var result = (x = next()) ? y : z; ``` Examples of **correct** code for this rule: ```javascript if (x === 0) { } while ((x = next())) {} // extra parens signal intent if (x === 0 || (y = getValue())) { } for (; (a = b); ) {} var result = ((x = next())) ? y : z; var branchResult = x ? (y = 1) : z; // assignment is in a branch, not the test ``` ## Original Documentation - [ESLint: no-cond-assign](https://eslint.org/docs/latest/rules/no-cond-assign) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/no-cond-assign.js) --- url: /rules/eslint/no-console.md --- # no-console [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-console': 'error', }, }, ]); ``` ## Rule Details Disallow the use of `console`. In environments where `console` is not intended (such as production code), using `console` may be considered a debugging leftover. Examples of **incorrect** code for this rule: ```javascript console.log('message'); console.warn('warning'); console.error('error'); ``` Examples of **correct** code for this rule: ```javascript // With option { "allow": ["warn", "error"] } console.warn('warning'); console.error('error'); ``` ## Options - `allow`: An array of console method names that are allowed (e.g., `["warn", "error"]`). ## Original Documentation - [ESLint: no-console](https://eslint.org/docs/latest/rules/no-console) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-console.js) --- url: /rules/eslint/no-const-assign.md --- # no-const-assign [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-const-assign': 'error', }, }, ]); ``` ## Rule Details Disallows reassigning variables declared with `const`, `using`, or `await using`. These constant bindings cannot be reassigned after their initial declaration. Attempting to modify them (via assignment, increment, decrement, or destructuring assignment) is always a mistake and would throw a `TypeError` at runtime. Examples of **incorrect** code for this rule: ```javascript const x = 1; x = 2; const y = 0; y++; const { z } = obj; z = 3; const [a, b] = [1, 2]; [a, b] = [3, 4]; using resource = acquireResource(); resource = acquireOtherResource(); ``` Examples of **correct** code for this rule: ```javascript const x = 1; console.log(x); let y = 0; y = 1; const obj = {}; obj.key = 'value'; // mutating properties is fine using resource = acquireResource(); resource.use(); ``` ## Original Documentation - [ESLint: no-const-assign](https://eslint.org/docs/latest/rules/no-const-assign) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-const-assign.js) --- url: /rules/eslint/no-constant-binary-expression.md --- # no-constant-binary-expression [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-constant-binary-expression': 'error', }, }, ]); ``` ## Rule Details Disallows expressions where the operation is guaranteed to always produce the same result, indicating a likely logic error. This includes comparisons against newly constructed objects (which can never be referentially equal to anything), constant short-circuit expressions where the left-hand side determines the result regardless of the right-hand side, and comparisons that always evaluate to the same boolean value. Examples of **incorrect** code for this rule: ```javascript if (x === []) {} // always false, new array is never === to anything const value = x ?? "default" || y; // constant ?? on left when left is non-nullish if (x === true && "foo") {} // constant && with literal left side if ({} === {}) {} // two new objects are never equal ``` Examples of **correct** code for this rule: ```javascript if (x === someVar) { } const value = x ?? y; if (x && y) { } if (x === null) { } ``` ## Original Documentation - [ESLint: no-constant-binary-expression](https://eslint.org/docs/latest/rules/no-constant-binary-expression) - [Source code](https://github.com/eslint/eslint/blob/v9.39.1/lib/rules/no-constant-binary-expression.js) --- url: /rules/eslint/no-constant-condition.md --- # no-constant-condition [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-constant-condition': 'error', }, }, ]); ``` ## Rule Details Disallows constant expressions in conditions of `if`, `while`, `do-while`, `for` statements, and ternary expressions. A constant condition is one that always evaluates to the same truthy or falsy value, such as a literal, an always-truthy expression like an object literal, or a compile-time computable expression. This usually indicates a programmer error. By default, `while (true)` loops are allowed (via the `"allExceptWhileTrue"` option) since they are a common pattern for intentional infinite loops with a `break` inside. Examples of **incorrect** code for this rule: ```javascript if (true) { } if ('hello') { } while (1) {} for (; false; ) {} var result = 0 ? a : b; ``` Examples of **correct** code for this rule: ```javascript if (x === 0) { } while (true) {} // allowed by default while (condition) {} for (; i < 10; i++) {} var result = x ? a : b; ``` ## Original Documentation - [ESLint: no-constant-condition](https://eslint.org/docs/latest/rules/no-constant-condition) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-constant-condition.js) --- url: /rules/eslint/no-constructor-return.md --- # no-constructor-return [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-constructor-return': 'error', }, }, ]); ``` ## Rule Details Disallows `return` statements that return a value from class constructors. Returning a value from a constructor of a class is usually a mistake, as the returned value is only used when the constructor is called without `new`. Bare `return` statements (without a value) are allowed for flow control purposes. Examples of **incorrect** code for this rule: ```javascript class A { constructor() { return 'value'; } } class B { constructor() { return { something: true }; } } ``` Examples of **correct** code for this rule: ```javascript class A { constructor() { this.value = 42; } } class B { constructor() { if (!valid) { return; // bare return for flow control is fine } this.init(); } } ``` ## Original Documentation - [ESLint: no-constructor-return](https://eslint.org/docs/latest/rules/no-constructor-return) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-constructor-return.js) --- url: /rules/eslint/no-continue.md --- # no-continue [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-continue': 'error', }, }, ]); ``` ## Rule Details Disallows `continue` statements. When used incorrectly, `continue` makes code less testable, less readable, and less maintainable. Structured control flow statements such as `if` should be used instead. Examples of **incorrect** code for this rule: ```javascript let sum = 0, i; for (i = 0; i < 10; i++) { if (i >= 5) { continue; } sum += i; } ``` ```javascript let sum = 0, i; labeledLoop: for (i = 0; i < 10; i++) { if (i >= 5) { continue labeledLoop; } sum += i; } ``` Examples of **correct** code for this rule: ```javascript let sum = 0, i; for (i = 0; i < 10; i++) { if (i < 5) { sum += i; } } ``` ## Original Documentation - [ESLint: no-continue](https://eslint.org/docs/latest/rules/no-continue) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-continue.js) --- url: /rules/eslint/no-control-regex.md --- # no-control-regex [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-control-regex': 'error', }, }, ]); ``` ## Rule Details Disallows control characters (U+0000 through U+001F) in regular expressions. Control characters are rarely intended in patterns and usually indicate a typo. The rule flags: - Unescaped raw characters in the U+0000–U+001F range - `\xHH` escapes with `HH` in `00`–`1F` - `\uHHHH` escapes with `HHHH` in `0000`–`001F` - `\u{H...}` escapes (under the `u` or `v` flag) resolving to U+0000–U+001F Symbolic control escapes such as `\t`, `\n`, `\r`, `\v`, `\f`, `\0`, and `\cX` are allowed. Examples of **incorrect** code for this rule: ```javascript var pattern1 = /\x00/; var pattern2 = /\x0C/; var pattern3 = /\x1F/; var pattern4 = /\u000C/; var pattern5 = /\u{C}/u; var pattern6 = new RegExp('\x0C'); var pattern7 = new RegExp('\\x0C'); ``` Examples of **correct** code for this rule: ```javascript var pattern1 = /\x20/; var pattern2 = /\u0020/; var pattern3 = /\u{20}/u; var pattern4 = /\t/; var pattern5 = /\n/; var pattern6 = new RegExp('\x20'); var pattern7 = new RegExp('\\t'); var pattern8 = new RegExp('\\n'); ``` ## Original Documentation - [ESLint: no-control-regex](https://eslint.org/docs/latest/rules/no-control-regex) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/no-control-regex.js) --- url: /rules/eslint/no-debugger.md --- # no-debugger [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-debugger': 'error', }, }, ]); ``` ## Rule Details Disallows the use of `debugger` statements. The `debugger` statement is used to tell the JavaScript runtime to pause execution and open a debugging session. These statements should be removed before deploying code to production, as they can halt execution and are only useful during development. Examples of **incorrect** code for this rule: ```javascript function check(value) { debugger; return value > 0; } ``` Examples of **correct** code for this rule: ```javascript function check(value) { return value > 0; } ``` ## Original Documentation - [ESLint: no-debugger](https://eslint.org/docs/latest/rules/no-debugger) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-debugger.js) --- url: /rules/eslint/no-delete-var.md --- # no-delete-var [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-delete-var': 'error', }, }, ]); ``` ## Rule Details Disallows the use of the `delete` operator on variables. The purpose of the `delete` operator is to remove a property from an object. Using the `delete` operator on a variable might lead to unexpected behavior. Examples of **incorrect** code for this rule: ```javascript var x; delete x; ``` Examples of **correct** code for this rule: ```javascript var obj = { x: 1 }; delete obj.x; ``` ## Original Documentation - [ESLint: no-delete-var](https://eslint.org/docs/latest/rules/no-delete-var) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-delete-var.js) --- url: /rules/eslint/no-div-regex.md --- # no-div-regex [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-div-regex': 'error', }, }, ]); ``` ## Rule Details Disallows equal signs explicitly at the beginning of regular expression literals, since `/=` at the start of a regular expression can be visually confused with a division-assignment operator. Examples of **incorrect** code for this rule: ```javascript function bar() { return /=foo/; } ``` Examples of **correct** code for this rule: ```javascript function bar() { return /[=]foo/; } ``` ## Original Documentation - [ESLint: no-div-regex](https://eslint.org/docs/latest/rules/no-div-regex) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-div-regex.js) --- url: /rules/eslint/no-dupe-args.md --- # no-dupe-args [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-dupe-args': 'error', }, }, ]); ``` ## Rule Details Disallow duplicate arguments in `function` definitions. If more than one parameter has the same name in a function definition, the last occurrence "shadows" the preceding ones. Examples of **incorrect** code for this rule: ```javascript function foo(a, b, a) { console.log(a); } var bar = function (a, b, a) {}; ``` Examples of **correct** code for this rule: ```javascript function foo(a, b, c) { console.log(a, b, c); } var bar = function (a, b, c) {}; ``` ## Differences from ESLint When a parameter name appears more than twice (e.g., `function foo(a, a, a)`), rslint reports an error on **each** duplicate occurrence (2 errors), while ESLint reports only once per duplicated name (1 error). This provides more precise diagnostic locations. ## Original Documentation - [ESLint: no-dupe-args](https://eslint.org/docs/latest/rules/no-dupe-args) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-dupe-args.js) --- url: /rules/eslint/no-dupe-class-members.md --- # no-dupe-class-members [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-dupe-class-members': 'error', }, }, ]); ``` ## Rule Details Disallow duplicate names in class members. If there are declarations of the same name in class members, the last declaration silently overwrites the earlier ones, which can cause unexpected behavior. Examples of **incorrect** code for this rule: ```javascript class A { bar() {} bar() {} } class B { bar() {} get bar() {} } class C { bar; bar; } class D { bar; bar() {} } class E { static bar() {} static bar() {} } ``` Examples of **correct** code for this rule: ```javascript class A { bar() {} qux() {} } class B { get bar() {} set bar(value) {} } class C { bar; qux; } class D { bar; qux() {} } class E { static bar() {} bar() {} } ``` TypeScript method overload signatures are allowed: ```typescript class A { foo(value: string): void; foo(value: number): void; foo(value: string | number) {} } ``` ## Original Documentation - [ESLint: no-dupe-class-members](https://eslint.org/docs/latest/rules/no-dupe-class-members) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-dupe-class-members.js) --- url: /rules/eslint/no-dupe-else-if.md --- # no-dupe-else-if [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-dupe-else-if': 'error', }, }, ]); ``` ## Rule Details Disallow duplicate conditions in if-else-if chains. If an `else if` condition is identical to a previous condition in the same chain, the branch can never execute. Examples of **incorrect** code for this rule: ```javascript if (a) { foo(); } else if (a) { bar(); } if (a) { foo(); } else if (b) { bar(); } else if (a) { baz(); } ``` Examples of **correct** code for this rule: ```javascript if (a) { foo(); } else if (b) { bar(); } if (a === 1) { foo(); } else if (a === 2) { bar(); } if (a) { foo(); } else if (b) { bar(); } else { baz(); } ``` ## Original Documentation - [ESLint: no-dupe-else-if](https://eslint.org/docs/latest/rules/no-dupe-else-if) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-dupe-else-if.js) --- url: /rules/eslint/no-dupe-keys.md --- # no-dupe-keys [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-dupe-keys': 'error', }, }, ]); ``` ## Rule Details Disallow duplicate keys in object literals. Multiple properties with the same key in object literals can cause unexpected behavior. Examples of **incorrect** code for this rule: ```javascript var foo = { bar: 'baz', bar: 'qux', }; var foo = { bar: 'baz', bar: 'qux', }; ``` Examples of **correct** code for this rule: ```javascript var foo = { bar: 'baz', qux: 'quux', }; // getter and setter with same name is valid var foo = { get bar() {}, set bar(v) {}, }; ``` ## Original Documentation - [ESLint: no-dupe-keys](https://eslint.org/docs/latest/rules/no-dupe-keys) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-dupe-keys.js) --- url: /rules/eslint/no-duplicate-case.md --- # no-duplicate-case [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-duplicate-case': 'error', }, }, ]); ``` ## Rule Details Disallow duplicate case labels in `switch` statements. Duplicate case labels indicate a probable mistake. Examples of **incorrect** code for this rule: ```javascript switch (a) { case 1: break; case 1: break; } switch (a) { case 'a': break; case 'a': break; } ``` Examples of **correct** code for this rule: ```javascript switch (a) { case 1: break; case 2: break; } switch (a) { case 'a': break; case 'b': break; } ``` ## Original Documentation - [ESLint: no-duplicate-case](https://eslint.org/docs/latest/rules/no-duplicate-case) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-duplicate-case.js) --- url: /rules/eslint/no-duplicate-imports.md --- # no-duplicate-imports [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-duplicate-imports': 'error', }, }, ]); ``` ## Rule Details Disallow duplicate module imports. Multiple `import` statements (and optionally `export ... from` re-exports) referencing the same module can usually be merged into a single statement, which makes dependencies easier to scan and avoids redundant module entries. Examples of **incorrect** code for this rule: ```javascript import { merge } from "lodash-es"; import { find } from "lodash-es"; ``` ```javascript import { merge } from "lodash-es"; import _ from "lodash-es"; ``` Examples of **correct** code for this rule: ```javascript import { merge, find } from "lodash-es"; ``` ```javascript import _, { merge, find } from "lodash-es"; ``` A namespace import together with a named import is allowed because the two forms cannot be merged into a single statement: ```javascript import * as bar from "os"; import { baz } from "os"; ``` ## Options This rule accepts an options object with the following properties: - `includeExports` (default: `false`) — when `true`, also flag `export { ... } from`, `export * from`, and `export * as ns from` re-exports that duplicate (or could be merged with) an earlier import or export of the same module. - `allowSeparateTypeImports` (default: `false`) — when `true`, a declaration-level `import type` / `export type` does NOT collide with a non-type import/export of the same module, so `import { foo } from "m"` and `import type { Bar } from "m"` are allowed. Specifier-level `type` keywords (`import { type Foo } from "m"`) do NOT count for this exemption — they only apply when the entire declaration is type-only. ### `includeExports` Examples of **incorrect** code with `{ "includeExports": true }`: ```json { "no-duplicate-imports": ["error", { "includeExports": true }] } ``` ```javascript import os from "os"; export { something } from "os"; ``` ```json { "no-duplicate-imports": ["error", { "includeExports": true }] } ``` ```javascript export * from "os"; export * from "os"; ``` Examples of **correct** code with `{ "includeExports": true }`: ```json { "no-duplicate-imports": ["error", { "includeExports": true }] } ``` ```javascript import os from "os"; export * from "os"; ``` A `import * as` plus an `export { x } from` of the same module is allowed because the two forms cannot be merged into a single statement: ```json { "no-duplicate-imports": ["error", { "includeExports": true }] } ``` ```javascript import * as os from "os"; export { something } from "os"; ``` ### `allowSeparateTypeImports` Examples of **correct** code with `{ "allowSeparateTypeImports": true }`: ```json { "no-duplicate-imports": ["error", { "allowSeparateTypeImports": true }] } ``` ```javascript import { foo } from "module"; import type { Bar } from "module"; ``` Examples of **incorrect** code with `{ "allowSeparateTypeImports": true }`: ```json { "no-duplicate-imports": ["error", { "allowSeparateTypeImports": true }] } ``` ```javascript import { type Foo } from "module"; import { type Bar } from "module"; ``` ```json { "no-duplicate-imports": ["error", { "allowSeparateTypeImports": true }] } ``` ```javascript import type { Merge } from "lodash-es"; import type { Find } from "lodash-es"; ``` ## Original Documentation - [ESLint: no-duplicate-imports](https://eslint.org/docs/latest/rules/no-duplicate-imports) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-duplicate-imports.js) --- url: /rules/eslint/no-else-return.md --- # no-else-return [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-else-return': 'error', }, }, ]); ``` ## Rule Details Disallow `else` blocks after `return` statements in `if` statements. When every preceding branch returns, the `else` block is unnecessary and its contents can be placed after the `if` statement. Examples of **incorrect** code for this rule: ```javascript function foo() { if (x) { return y; } else { return z; } } ``` ```javascript function foo() { if (x) { return y; } else if (z) { return w; } else { return q; } } ``` Examples of **correct** code for this rule: ```javascript function foo() { if (x) { return y; } return z; } ``` ```javascript function foo() { if (x) { doSomething(); } else { return y; } } ``` ## Options This rule has an object option: - `allowElseIf` (default: `true`): allows `else if` blocks after a `return`. Examples of **correct** code for this rule with `{ "allowElseIf": true }`: ```json { "no-else-return": ["error", { "allowElseIf": true }] } ``` ```javascript function foo() { if (error) { return "failed"; } else if (loading) { return "loading"; } } ``` Examples of **incorrect** code for this rule with `{ "allowElseIf": false }`: ```json { "no-else-return": ["error", { "allowElseIf": false }] } ``` ```javascript function foo() { if (error) { return "failed"; } else if (loading) { return "loading"; } } ``` ## Original Documentation - [ESLint: no-else-return](https://eslint.org/docs/latest/rules/no-else-return) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-else-return.js) --- url: /rules/eslint/no-empty.md --- # no-empty [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-empty': 'error', }, }, ]); ``` ## Rule Details Disallow empty block statements. Empty block statements, while not technically errors, usually occur due to refactoring that wasn't completed. They can cause confusion when reading code. Examples of **incorrect** code for this rule: ```javascript if (foo) { } while (foo) {} switch (foo) { } try { doSomething(); } catch (e) {} ``` Examples of **correct** code for this rule: ```javascript if (foo) { // empty } while (foo) { /* todo */ } try { doSomething(); } catch (e) { // expected } function foo() {} ``` ## Options - `allowEmptyCatch`: If `true`, allows empty `catch` clauses (i.e., which do not contain a comment). Default: `false`. ## Original Documentation - [ESLint: no-empty](https://eslint.org/docs/latest/rules/no-empty) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/no-empty.js) --- url: /rules/eslint/no-empty-character-class.md --- # no-empty-character-class [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-empty-character-class': 'error', }, }, ]); ``` ## Rule Details Disallows empty character classes `[]` in regular expression literals. An empty character class in a regular expression does not match anything and is almost certainly a mistake. Note that `[^]` (a negated empty class) is allowed since it matches any character. With the ES2024 `v` flag (unicodeSets), character classes can be nested. This rule also detects empty classes inside nested structures such as set subtraction (`--`) and intersection (`&&`). This rule does not check `new RegExp()` constructor calls — only regex literals. Examples of **incorrect** code for this rule: ```javascript var foo = /^abc[]/; var foo = /foo[]bar/; var foo = /[]]/; // v-flag (ES2024) var foo = /[[]]/v; var foo = /[a--[]]/v; var foo = /[a&&[]]/v; ``` Examples of **correct** code for this rule: ```javascript var foo = /^abc[a-zA-Z]/; var foo = /[^]/; var foo = /[\\[]/; var foo = /\\[]/; // v-flag (ES2024) var foo = /[[^]]/v; var foo = /[a--b]/v; var foo = /[[a][b]]/v; ``` ## Original Documentation - [ESLint: no-empty-character-class](https://eslint.org/docs/latest/rules/no-empty-character-class) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-empty-character-class.js) --- url: /rules/eslint/no-empty-function.md --- # no-empty-function [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-empty-function': 'error', }, }, ]); ``` ## Rule Details Disallow empty functions. Empty functions can hide incomplete refactors; add a comment to intentionally empty function bodies, or configure an allowed function kind. Examples of **incorrect** code for this rule: ```javascript function noop() {} const handler = () => {}; class Service { connect() {} } ``` Examples of **correct** code for this rule: ```javascript function noop() { // intentionally empty } const handler = () => value; class Service { connect() { start(); } } ``` TypeScript parameter-property constructors are also allowed: ```typescript class Store { constructor(private readonly id: string) {} } ``` ## Options - `allow`: An array of empty function kinds to permit. Default: `[]`. Allowed values: - `functions` - `arrowFunctions` - `generatorFunctions` - `methods` - `generatorMethods` - `getters` - `setters` - `constructors` - `asyncFunctions` - `asyncMethods` - `privateConstructors` - `protectedConstructors` - `decoratedFunctions` - `overrideMethods` Examples of **correct** code for this rule with `{ "allow": ["constructors"] }`: ```json { "no-empty-function": ["error", { "allow": ["constructors"] }] } ``` ```javascript class Service { constructor() {} } ``` Examples of **correct** code for this rule with `{ "allow": ["decoratedFunctions"] }`: ```json { "no-empty-function": ["error", { "allow": ["decoratedFunctions"] }] } ``` ```typescript class Service { @bound handle() {} } ``` ## Original Documentation - [ESLint: no-empty-function](https://eslint.org/docs/latest/rules/no-empty-function) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-empty-function.js) --- url: /rules/eslint/no-empty-pattern.md --- # no-empty-pattern [Added in v0.2.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-empty-pattern': 'error', }, }, ]); ``` ## Rule Details Disallow empty destructuring patterns. Empty destructuring patterns do not create any variables and may be a sign of a mistake. Examples of **incorrect** code for this rule: ```javascript var {} = foo; var [] = foo; var { a: {}, } = foo; var { a: [], } = foo; function foo({}) {} function foo([]) {} ``` Examples of **correct** code for this rule: ```javascript var { a } = foo; var [a] = foo; var { a = {} } = foo; var { a: { b }, } = foo; function foo({ a }) {} function foo([a]) {} ``` ## Options - `allowObjectPatternsAsParameters`: If `true`, allows empty object patterns as function parameters. Default: `false`. ## Original Documentation - [ESLint: no-empty-pattern](https://eslint.org/docs/latest/rules/no-empty-pattern) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-empty-pattern.js) --- url: /rules/eslint/no-empty-static-block.md --- # no-empty-static-block [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-empty-static-block': 'error', }, }, ]); ``` ## Rule Details Disallow empty class static blocks. Empty static blocks usually indicate that a refactor was left unfinished or that an intentional placeholder needs an explanatory comment. Examples of **incorrect** code for this rule: ```javascript class Foo { static {} } class Bar { static { } } ``` Examples of **correct** code for this rule: ```javascript class Foo { static { initialize(); } } class Bar { static { // intentionally empty } } ``` ## Original Documentation - [ESLint: no-empty-static-block](https://eslint.org/docs/latest/rules/no-empty-static-block) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-empty-static-block.js) --- url: /rules/eslint/no-eq-null.md --- # no-eq-null [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-eq-null': 'error', }, }, ]); ``` ## Rule Details Comparing to `null` without a type-checking operator (`==` or `!=`) can have unintended results as the comparison will evaluate to `true` when comparing not just to `null`, but also to `undefined`. The `no-eq-null` rule aims to reduce potential bugs and unwanted behavior by ensuring that comparisons to `null` only match `null`, and not also `undefined`. As such, it will flag comparisons to `null` when using `==` and `!=`. Examples of **incorrect** code for this rule: ```javascript if (foo == null) { bar(); } while (qux != null) { baz(); } ``` Examples of **correct** code for this rule: ```javascript if (foo === null) { bar(); } while (qux !== null) { baz(); } ``` ## Original Documentation - [ESLint: no-eq-null](https://eslint.org/docs/latest/rules/no-eq-null) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-eq-null.js) --- url: /rules/eslint/no-eval.md --- # no-eval [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-eval': 'error', }, }, ]); ``` ## Rule Details Disallow the use of `eval()`. JavaScript's `eval()` function is potentially dangerous and is often misused. Using `eval()` on untrusted code can open a program up to several different injection attacks. The use of `eval()` in most contexts can be substituted for a better, alternative approach to a problem. Examples of **incorrect** code for this rule: ```javascript eval('var a = 0'); var foo = eval; this.eval('var a = 0'); window.eval('var a = 0'); global.eval('var a = 0'); globalThis.eval('var a = 0'); ``` Examples of **correct** code for this rule: ```javascript var obj = { eval: function () {} }; obj.eval('var a = 0'); class A { eval() {} } new A().eval('var a = 0'); ``` ### Options This rule has an option to allow indirect calls to `eval`. Indirect calls to `eval` are less dangerous than direct calls because they cannot dynamically change the scope. ```json { "no-eval": ["error", { "allowIndirect": true }] } ``` With `{ "allowIndirect": true }`, the following patterns are **correct**: ```javascript (0, eval)('var a = 0'); var EVAL = eval; EVAL('var a = 0'); window.eval('var a = 0'); ``` ## Original Documentation - [ESLint: no-eval](https://eslint.org/docs/latest/rules/no-eval) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-eval.js) --- url: /rules/eslint/no-ex-assign.md --- # no-ex-assign [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-ex-assign': 'error', }, }, ]); ``` ## Rule Details Disallow assign another value to the exception parameter a catch clause in a try statement accidentally or purposely. Since there is no arguments object to offer alternative access to this data, assignment of the parameter is absolutely destructive. Examples of **correct** code for this rule: ```javascript try { } catch (e) { three = 2 + 1; } try { } catch ({ e }) { this.something = 2; } function foo() { try { } catch (e) { return false; } } ``` Examples of **incorrect** code for this rule: ```javascript try { } catch (e) { e = 10; } try { } catch (ex) { ex = 10; } try { } catch (ex) { [ex] = []; } try { } catch (ex) { ({ x: ex = 0 } = {}); } try { } catch ({ message }) { message = 10; } ``` ## Original Documentation - [ESLint: no-ex-assign](https://eslint.org/docs/latest/rules/no-ex-assign) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-ex-assign.js) --- url: /rules/eslint/no-extend-native.md --- # no-extend-native [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-extend-native': 'error', }, }, ]); ``` Disallows directly modifying the prototype of native built-in objects (`Object`, `Array`, `Function`, `String`, `Number`, `Boolean`, `Symbol`, `Map`, `Set`, `Promise`, `Error`, `RegExp`, `Date`, `BigInt`, `WeakRef`, `FinalizationRegistry`, etc.). ## Rule Details Extending native prototypes is generally regarded as a bad practice because it breaks assumptions other code makes about builtins, can collide with future language additions, and is invisible to the rest of the program until it is triggered at runtime. The rule reports two extension patterns: 1. Direct assignment, including compound and logical assignments: `Builtin.prototype.foo = ...`, `Builtin.prototype.foo ??= ...`. 2. `Object.defineProperty(Builtin.prototype, ...)` and `Object.defineProperties(Builtin.prototype, ...)`. References to the builtin that are shadowed by a local declaration in scope (e.g. `function foo() { var Object = function () {}; Object.prototype.p = 0 }`) are not reported. Examples of **incorrect** code for this rule: ```javascript Object.prototype.a = "a"; Object.defineProperty(Array.prototype, "times", { value: 999 }); ``` Examples of **correct** code for this rule: ```javascript // Modifications to user-defined objects are allowed. x.prototype.p = 0; // Property access on the constructor (not on its prototype) is allowed. Object.toString.bind = 0; ``` ## Options ```json { "no-extend-native": ["error", { "exceptions": ["Object"] }] } ``` | Option | Type | Default | Description | | ------------ | ------------------- | ------- | -------------------------------------------------------------------- | | `exceptions` | `string[]` (unique) | `[]` | Names of built-in objects whose prototype is allowed to be extended. | With `{ "exceptions": ["Object"] }`, the following becomes valid: ```javascript Object.prototype.g = 0; ``` ## Original Documentation - [ESLint: no-extend-native](https://eslint.org/docs/latest/rules/no-extend-native) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-extend-native.js) --- url: /rules/eslint/no-extra-bind.md --- # no-extra-bind [Added in v0.3.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.4) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-extra-bind': 'error', }, }, ]); ``` ## Rule Details Disallows unnecessary calls to `.bind()`. If a function expression does not use `this`, calling `.bind()` on it is unnecessary. Arrow functions never have their own `this` binding, so `.bind()` on an arrow function is always unnecessary. Examples of **incorrect** code for this rule: ```javascript var x = function () { foo(); }.bind(bar); var x = (() => { foo(); }).bind(bar); var x = function () { (function () { this.bar(); })(); }.bind(baz); ``` Examples of **correct** code for this rule: ```javascript var x = function () { this.foo(); }.bind(bar); var x = function (a) { return a + 1; }.bind(foo, bar); var x = f.bind(bar); ``` ## Original Documentation - [ESLint: no-extra-bind](https://eslint.org/docs/latest/rules/no-extra-bind) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-extra-bind.js) --- url: /rules/eslint/no-extra-boolean-cast.md --- # no-extra-boolean-cast [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-extra-boolean-cast': 'error', }, }, ]); ``` ## Rule Details Disallows unnecessary boolean casts. Using `!!` (double negation) or `Boolean()` to convert a value to boolean is redundant when the value is already in a boolean context, such as the test of an `if` statement. `new Boolean(x)` is never flagged because it produces a Boolean **object** (always truthy) rather than a primitive, so replacing it with a plain value would change semantics. Examples of **incorrect** code for this rule: ```javascript if (!!foo) { } while (!!foo) {} do {} while (!!foo); for (; !!foo; ) {} !!foo ? bar : baz; !!!foo; if (Boolean(foo)) { } !Boolean(foo); ``` Examples of **correct** code for this rule: ```javascript if (foo) { } while (foo) {} var bar = !!foo; var bar = Boolean(foo); function baz() { return !!foo; } if (new Boolean(foo)) { } // always truthy — not equivalent to `if (foo)` ``` ## Options This rule accepts a single options object. ### `enforceForLogicalOperands` (legacy) When `true`, the rule also reports redundant boolean casts that are operands of `||` or `&&` when the overall logical expression is used in a boolean context. ```json { "no-extra-boolean-cast": ["error", { "enforceForLogicalOperands": true }] } ``` ```javascript if (x || !!y) { } // reported ``` ### `enforceForInnerExpressions` A superset of `enforceForLogicalOperands`. Additionally reports redundant casts on the right-hand side of `??`, on the branches of ternaries, and on the last expression of a sequence (`a, b, c`). ```json { "no-extra-boolean-cast": ["error", { "enforceForInnerExpressions": true }] } ``` ```javascript if (x ?? !!y) { } // reported if (cond ? Boolean(a) : b) { } // reported if ((a, b, Boolean(c))) { } // reported ``` ## Original Documentation - [ESLint: no-extra-boolean-cast](https://eslint.org/docs/latest/rules/no-extra-boolean-cast) - [Source code](https://github.com/eslint/eslint/blob/v10.2.1/lib/rules/no-extra-boolean-cast.js) --- url: /rules/eslint/no-extra-label.md --- # no-extra-label [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-extra-label': 'error', }, }, ]); ``` ## Rule Details This rule disallows labels that are only used on loops or switch statements that have no nested breakable statement — in those cases a bare `break` / `continue` already refers to the directly-enclosing loop or switch, so the label adds no information and can confuse readers who expect labels to control deeper nesting. Examples of **incorrect** code for this rule: ```javascript A: while (a) { break A; } B: for (let i = 0; i < 10; ++i) { break B; } C: switch (a) { case 0: break C; } ``` Examples of **correct** code for this rule: ```javascript while (a) { break; } A: { break A; } B: while (a) { while (b) { break B; } } C: switch (a) { case 0: while (b) { break C; } } ``` ## Options This rule has no options. ## Original Documentation - [ESLint: no-extra-label](https://eslint.org/docs/latest/rules/no-extra-label) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-extra-label.js) --- url: /rules/eslint/no-fallthrough.md --- # no-fallthrough [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-fallthrough': 'error', }, }, ]); ``` ## Rule Details Disallow fallthrough of `case` statements. A case clause that has statements but does not end with a control flow statement (`break`, `return`, `throw`, `continue`) will fall through to the next case, which is usually a programming error. Empty case clauses (with no statements) are allowed by default. A comment containing "falls through" or "fall through" (case-insensitive) between the current case and the next will suppress the warning. Examples of **incorrect** code for this rule: ```javascript switch (foo) { case 0: a(); case 1: b(); break; } switch (foo) { case 0: a(); default: b(); } ``` Examples of **correct** code for this rule: ```javascript switch (foo) { case 0: a(); break; case 1: b(); break; } switch (foo) { case 0: case 1: a(); break; } switch (foo) { case 0: a(); /* falls through */ case 1: b(); break; } function bar() { switch (foo) { case 0: a(); return; case 1: b(); } } ``` ## Options ### `commentPattern` A custom regular expression pattern to match fallthrough comments, applied case-sensitively as `new RegExp(commentPattern, "u")`. By default matches `/falls?\s?through/iu`. ```json { "no-fallthrough": ["error", { "commentPattern": "break[\\s\\w]*omitted" }] } ``` ### `allowEmptyCase` When set to `true`, allows case clauses containing only empty statements (`;`) to fall through without a comment. ```json { "no-fallthrough": ["error", { "allowEmptyCase": true }] } ``` ### `reportUnusedFallthroughComment` When set to `true`, reports fallthrough comments on cases that cannot actually fall through (e.g., cases ending with `break`). ```json { "no-fallthrough": ["error", { "reportUnusedFallthroughComment": true }] } ``` ## Original Documentation - [ESLint: no-fallthrough](https://eslint.org/docs/latest/rules/no-fallthrough) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-fallthrough.js) --- url: /rules/eslint/no-func-assign.md --- # no-func-assign [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-func-assign': 'error', }, }, ]); ``` ## Rule Details Disallows reassigning variables that were declared as function declarations. Reassigning a function declaration is almost always a mistake, as it overwrites the function with a different value. This rule checks for assignments, increment/decrement operations, and destructuring assignments that target a function name. Examples of **incorrect** code for this rule: ```javascript function foo() {} foo = bar; function foo() {} foo += 1; function foo() {} [foo] = arr; ``` Examples of **correct** code for this rule: ```javascript function foo() {} foo(); var foo = function () {}; foo = bar; // foo is a variable, not a function declaration function foo(foo) { foo = bar; // foo is a parameter, not the function } function foo() { var foo = bar; // foo is a local variable, not the function } ``` ## Original Documentation - [ESLint: no-func-assign](https://eslint.org/docs/latest/rules/no-func-assign) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-func-assign.js) --- url: /rules/eslint/no-global-assign.md --- # no-global-assign [Added in v0.3.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.4) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-global-assign': 'error', }, }, ]); ``` ## Rule Details Disallows assignments to native objects or read-only global variables. Built-in globals such as `Object`, `Array`, `String`, `Number`, `Math`, `JSON`, `undefined`, `NaN`, `Infinity`, and others should not be reassigned, as doing so can cause unexpected behavior throughout the application. Examples of **incorrect** code for this rule: ```javascript String = 'hello'; Array = 1; undefined = true; NaN++; ``` Examples of **correct** code for this rule: ```javascript var x = String(123); var y = new Array(1, 2, 3); // Shadowed by local declaration var String; String = 'hello'; // Shadowed by function parameter function foo(Array) { Array = 1; } ``` Globals declared through [`languageOptions.globals`](/config/language-options.md#languageoptionsglobals) or a `/* global */` comment carry their own access level: a `readonly` name is reported like a built-in, and a `writable` name may be reassigned — including a built-in whose declaration lifts the default. The environment maps exported as `globals` from `@rslint/core` use `false` for read-only names and `true` for writable names, so they feed the same access checks directly. Examples of **incorrect** code with `globals: { BUILD_ID: 'readonly' }`: ```javascript BUILD_ID = 'dev'; ``` Examples of **correct** code with `globals: { Object: 'writable' }`: ```javascript Object = {}; ``` ## Options This rule accepts an optional object with an `exceptions` property, which is an array of global names that should be allowed to be reassigned: ```json { "no-global-assign": ["error", { "exceptions": ["Object"] }] } ``` ## Original Documentation - [ESLint: no-global-assign](https://eslint.org/docs/latest/rules/no-global-assign) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-global-assign.js) --- url: /rules/eslint/no-implicit-coercion.md --- # no-implicit-coercion [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-implicit-coercion': 'error', }, }, ]); ``` Disallow shorthand type conversions in favor of explicit `Boolean()` / `Number()` / `String()` calls. ## Rule Details In JavaScript, type conversions are often performed using shorthand syntax. While these idioms work, they obscure intent; the rule flags them so they can be replaced with explicit conversions. Patterns flagged: - `!!foo` instead of `Boolean(foo)` - `~foo.indexOf(bar)` (or `lastIndexOf`) instead of `foo.indexOf(bar) !== -1` - `+foo` or `-(-foo)` instead of `Number(foo)` - `1 * foo` or `foo * 1` instead of `Number(foo)` - `foo - 0` instead of `Number(foo)` - `"" + foo` / `foo + ""` (including ` ` \`\`) instead of `String(foo)` - `foo += ""` instead of `foo = String(foo)` - Template shorthand `` `${foo}` `` instead of `String(foo)` — only when the `disallowTemplateShorthand` option is enabled. ### Options ```json { "no-implicit-coercion": [ "error", { "boolean": true, "number": true, "string": true, "disallowTemplateShorthand": false, "allow": [] } ] } ``` - `boolean` (default `true`) — disallow boolean shorthand conversions (`!!`, `~`). - `number` (default `true`) — disallow numeric shorthand conversions (`+`, `- -`, `- 0`, `* 1`). - `string` (default `true`) — disallow string shorthand conversions (`"" +`, `+= ""`). - `disallowTemplateShorthand` (default `false`) — also disallow `` `${foo}` `` as a coercion. - `allow` — operators to exempt from the above. Allowed values: `"~"`, `"!!"`, `"+"`, `"- -"`, `"-"`, `"*"`. ### Fix vs suggestion Only `!!foo` → `Boolean(foo)` applies as an autofix (and only when `Boolean` is not shadowed in scope). The other rewrites are offered as suggestions because they can change runtime behavior — `Number(1n)` throws, `foo.indexOf(x) !== -1` differs from `~foo.indexOf(x)` on non-array targets, etc. ## Examples Incorrect: ```javascript const b = !!foo; const b1 = ~foo.indexOf('.'); const n = +foo; const n2 = foo - 0; const n3 = 1 * foo; const s = '' + foo; foo += ''; ``` Correct: ```javascript const b = Boolean(foo); const b1 = foo.indexOf('.') !== -1; const n = Number(foo); const s = String(foo); ``` ## Original Documentation - [ESLint: no-implicit-coercion](https://eslint.org/docs/latest/rules/no-implicit-coercion) - [Source code](https://github.com/eslint/eslint/blob/v10.2.1/lib/rules/no-implicit-coercion.js) --- url: /rules/eslint/no-implicit-globals.md --- # no-implicit-globals [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-implicit-globals': 'error', }, }, ]); ``` ## Rule Details It is the best practice to avoid 'polluting' the global scope with variables that are intended to be local to the script. Global variables created from a script can produce name collisions with global variables created from another script, which will usually lead to runtime errors or unexpected behavior. This rule disallows: - Declarations that create one or more variables in the global scope. - Global variable leaks. - Redeclarations of read-only global variables and assignments to read-only global variables. There is an explicit way to create a global variable when needed, by assigning to a property of the global object. By default, this rule does not check `const`, `let` and `class` declarations. ### `var` and `function` declarations This rule disallows `var` and `function` declarations at the top-level scope. Examples of **incorrect** code for this rule: ```javascript var foo = 1; function bar() {} ``` Examples of **correct** code for this rule: ```javascript // explicitly set on window window.foo = 1; window.bar = function () {}; // intended to be scope to this file (function () { var foo = 1; function bar() {} })(); ``` ### Global variable leaks An assignment to an undeclared variable creates a new global variable, even inside a function. This will happen even if the code is in a function. Examples of **incorrect** code for this rule: ```javascript foo = 1; Bar.prototype.baz = function () { a = 1; // Intended to be this.a = 1; }; ``` ### Read-only global variables This rule also disallows redeclarations of read-only global variables and assignments to read-only global variables. A read-only global variable can be a built-in ES global (e.g. `Array`), or a global variable defined as `readonly` in the configuration file or in a `/*global */` comment. Examples of **incorrect** code for this rule: ```javascript /*global foo:readonly*/ foo = 1; Array = []; var Object; ``` ### exported You can use `/* exported variableName */` block comments to indicate that a variable is intentionally being made available for use in other scripts (for example, by loading them in the same page). Examples of **correct** code for `/* exported variableName */`: ```javascript /* exported global_var */ var global_var = 42; ``` ## Options This rule has an object option with one option: - Set `"lexicalBindings"` to `true` if you want this rule to check `const`, `let` and `class` declarations as well. ### `const`, `let` and `class` declarations Examples of **incorrect** code for this rule with `{ "lexicalBindings": true }`: ```json { "no-implicit-globals": ["error", { "lexicalBindings": true }] } ``` ```javascript const foo = 1; let baz; class Bar {} ``` Examples of **correct** code for this rule with `{ "lexicalBindings": true }`: ```json { "no-implicit-globals": ["error", { "lexicalBindings": true }] } ``` ```javascript { const foo = 1; let baz; class Bar {} } (function () { const foo = 1; let baz; class Bar {} })(); ``` ## Differences from ESLint - For a script parsed by ESLint with `languageOptions.parserOptions.ecmaFeatures.globalReturn: true`, ESLint treats the top level as a function scope and does not report its `var` or function declarations. Rslint treats the same source as a global script and reports those declarations. - In TypeScript scripts, ESLint reports ambient `var` and function declarations and, with `lexicalBindings: true`, ambient `let`, `const`, and class declarations. Rslint does not report these declarations. - For an overloaded global function in a TypeScript script, ESLint reports every overload signature and the implementation. Rslint reports only the implementation. - In TypeScript assignment targets, rslint reports only runtime value targets. For `[foo as (x: T) => U] = value`, rslint reports `foo`; ESLint also reports the function-type parameter name `x`. - Rslint recognizes value writes through nested erased assertions. For `(foo satisfies T) = value`, rslint reports `foo`, while ESLint does not. - With `/* exported __proto__ */`, rslint suppresses the global-declaration diagnostic just as it does for other exported names. ESLint 10.9.1 still reports `__proto__` because of an upstream directive-parser bug. - On invalid TypeScript accepted through parser recovery, such as `[foo] = value` or `[foo + bar] = value`, ESLint may emit assignment diagnostics that rslint does not. ## Original Documentation - [ESLint: no-implicit-globals](https://eslint.org/docs/latest/rules/no-implicit-globals) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/no-implicit-globals.js) --- url: /rules/eslint/no-implied-eval.md --- # no-implied-eval [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-implied-eval': 'error', }, }, ]); ``` ## Rule Details Disallow the use of `eval()`-like methods. Passing a string as the first argument to `setTimeout`, `setInterval`, or `execScript` causes the string to be evaluated as JavaScript — a form of implied `eval()`. This rule flags such calls, whether made directly or through a global object reference (`window`, `global`, `globalThis`, or `self`). Examples of **incorrect** code for this rule: ```javascript setTimeout('alert(\'Hi!\');', 100); setInterval('alert(\'Hi!\');', 100); execScript('alert(\'Hi!\')'); window.setTimeout('count = 5', 10); window.setInterval('foo = bar', 10); globalThis.setTimeout(`code ${foo}`); self.setInterval('foo' + bar); ``` Examples of **correct** code for this rule: ```javascript setTimeout(function () { alert('Hi!'); }, 100); setInterval(function () { alert('Hi!'); }, 100); execScript(function () { alert('Hi!'); }); const handler = () => alert('Hi!'); setTimeout(handler, 100); window.setTimeout(handler, 100); ``` ## Original Documentation - [ESLint: no-implied-eval](https://eslint.org/docs/latest/rules/no-implied-eval) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-implied-eval.js) --- url: /rules/eslint/no-import-assign.md --- # no-import-assign [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-import-assign': 'error', }, }, ]); ``` ## Rule Details Disallows assigning to imported bindings. Imports are read-only references to values exported from other modules. Assigning to an import binding is always a mistake, as it will either throw a runtime error or silently fail. For namespace imports (`import * as ns`), writing to any member of the namespace object is also disallowed, since namespace objects are frozen. Examples of **incorrect** code for this rule: ```javascript import mod from 'mod'; mod = 0; import { named } from 'mod'; named = 0; named++; import * as ns from 'mod'; ns = 0; ns.prop = 0; ns.prop++; ``` Examples of **correct** code for this rule: ```javascript import mod from 'mod'; mod.prop = 0; // Writing to a property of a default import is fine import { named } from 'mod'; named.prop = 0; // Writing to a property of a named import is fine import * as ns from 'mod'; ns.named.prop = 0; // Writing to nested properties is fine ``` ## Original Documentation - [ESLint: no-import-assign](https://eslint.org/docs/latest/rules/no-import-assign) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-import-assign.js) --- url: /rules/eslint/no-inline-comments.md --- # no-inline-comments [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-inline-comments': 'error', }, }, ]); ``` ## Rule Details Some style guides disallow a comment on the same line as code. Comments alone on a line, or on a line consisting entirely of whitespace, are allowed. This rule disallows comments on the same line as code. Examples of **incorrect** code for this rule: ```javascript var a = 1; // declaring a to 1 function getRandomNumber() { return 4; // chosen by fair dice roll. // guaranteed to be random. } /* A block comment before code */ var b = 2; var c = 3; /* A block comment after code */ ``` Examples of **correct** code for this rule: ```javascript // This is a comment above a line of code var foo = 5; var bar = 5; //This is a comment below a line of code ``` ### JSX exception Comments that are the only content of a JSX expression container are not considered inline, since there is no code on either side of them. ```jsx var a = (
{/* comment */}

Some heading

); ``` ## Options This rule accepts a single options object with the following property: - `ignorePattern` (string) - a pattern of comments to ignore ### ignorePattern Examples of **correct** code for this rule with the `{ "ignorePattern": "webpackChunkName:\\s.+" }` option: ```json { "no-inline-comments": ["error", { "ignorePattern": "webpackChunkName:\\s.+" }] } ``` ```javascript import(/* webpackChunkName: "my-chunk-name" */ './locale/en'); ``` ## Original Documentation - [ESLint: no-inline-comments](https://eslint.org/docs/latest/rules/no-inline-comments) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-inline-comments.js) --- url: /rules/eslint/no-inner-declarations.md --- # no-inner-declarations [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-inner-declarations': 'error', }, }, ]); ``` ## Rule Details Disallow variable and/or function declarations outside the root of a program, function body, or class static block body. With the `"both"` option, this also applies to `var` declarations in `for`, `for-in`, and `for-of` headers. It does not apply to `let`, `const`, `using`, or `await using`, which are block-scoped. By default, nested function declarations are allowed only when the code is in strict mode and `languageOptions.ecmaVersion` is `2015` or newer. Use the `blockScopedFunctions` option to disallow them in those contexts too. Examples of **incorrect** code for this rule with the default options in a non-strict script: ```javascript if (test) { function doSomething() {} } ``` Examples of **incorrect** code for this rule with `{ blockScopedFunctions: "disallow" }`: ```json { "no-inner-declarations": [ "error", "functions", { "blockScopedFunctions": "disallow" } ] } ``` ```javascript "use strict"; if (test) { function doSomething() {} } while (test) { function doSomething() {} } ``` Examples of **correct** code for this rule with the default options: ```javascript function doSomething() {} function doSomethingElse() { function doAnotherThing() {} } "use strict"; if (test) { function doSomething() {} } export function foo() {} ``` Examples of **incorrect** code for this rule with the `"both"` option: ```json { "no-inner-declarations": ["error", "both"] } ``` ```javascript if (test) { var x = 1; } function doSomething() { if (test) { var x = 1; } } for (var i = 0; i < items.length; i++) {} for (var key in object) {} for (var value of values) {} ``` Examples of **correct** code for this rule with the `"both"` option: ```json { "no-inner-declarations": ["error", "both"] } ``` ```javascript var x = 1; function doSomething() { var y = 2; } if (test) { let x = 1; } for (const value of values) {} ``` ## Options - `"functions"` (default): Only disallows `function` declarations in nested blocks (when `blockScopedFunctions` is `"disallow"`). - `"both"`: Disallows both `function` declarations (when `blockScopedFunctions` is `"disallow"`) and `var` declarations in nested blocks. - `{ blockScopedFunctions: "allow" | "disallow" }` (default `"allow"`): With `"allow"`, nested function declarations are permitted only in strict code when `languageOptions.ecmaVersion` is `2015` or newer. With `"disallow"`, they are always checked. ## Original Documentation - [ESLint: no-inner-declarations](https://eslint.org/docs/latest/rules/no-inner-declarations) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-inner-declarations.js) --- url: /rules/eslint/no-invalid-regexp.md --- # no-invalid-regexp [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-invalid-regexp': 'error', }, }, ]); ``` ## Rule Details Disallows invalid regular expression strings in `RegExp` constructors. This rule validates patterns and flags passed to `new RegExp(pattern, flags)` and `RegExp(pattern, flags)` when the arguments are string literals. Valid flags are: `d`, `g`, `i`, `m`, `s`, `u`, `v`, `y`. Examples of **incorrect** code for this rule: ```javascript RegExp('.', 'z'); // invalid flag 'z' new RegExp('.', 'aa'); // duplicate flag 'a' RegExp('.', 'uv'); // 'u' and 'v' flags are mutually exclusive RegExp('['); // unterminated character class RegExp('('); // unterminated group new RegExp('\\'); // trailing backslash ``` Examples of **correct** code for this rule: ```javascript RegExp('.'); new RegExp('.', 'im'); new RegExp('.', 'gmi'); new RegExp(pattern, 'g'); // non-literal pattern, skipped new RegExp('.', flags); // non-literal flags, skipped ``` ## Options ### `allowConstructorFlags` An array or string of additional flags to allow in RegExp constructors. For example, to allow the `a` and `z` flags: ```json { "allowConstructorFlags": "az" } ``` ## Known Limitations The following ECMAScript regex features are not yet fully supported in pattern validation: - Unicode property long names (`\p{Letter}`) and `Script=` syntax (`\p{Script=Latin}`) - `v`-flag set notation (`[A--B]`, `[A&&B]`, `[A--[0-9]]`) - Surrogate pair named capture groups (`(?<\ud835\udc9c>.)`) - `v`-flag specific parsing (`[[]` with `v` flag) - Duplicate named capture groups outside alternatives (`(?a)(?b)`) Flag validation (invalid flags, duplicate flags, `u`/`v` conflict) and `allowConstructorFlags` are fully aligned with ESLint. ## Original Documentation - [ESLint: no-invalid-regexp](https://eslint.org/docs/latest/rules/no-invalid-regexp) - [Source code](https://github.com/eslint/eslint/blob/v10.2.0/lib/rules/no-invalid-regexp.js) --- url: /rules/eslint/no-invalid-this.md --- # no-invalid-this [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-invalid-this': 'error', }, }, ]); ``` ## Rule Details Under strict mode, `this` keywords outside of classes or class-like objects might be `undefined` and raise a `TypeError`. This rule applies **only** in strict mode; sloppy-mode code (a plain script with no `"use strict"` directive and no ES module syntax) is never flagged. Top-level `this` at the top of a script always refers to the global object and is valid. Top-level `this` in an ES module is always invalid, since its value is `undefined`. For `this` inside functions, this rule judges from the following conditions whether or not the function is a constructor: - The name of the function starts with uppercase. - The function is assigned to a variable which starts with an uppercase letter. - The function is a constructor of ES2015 classes. This rule judges from the following conditions whether or not the function is a method: - The function is on an object literal. - The function is assigned to a property. - The function is a method / getter / setter of ES2015 classes. And this rule allows `this` keywords in functions below: - The `call` / `apply` / `bind` method of the function is called directly. - The function is a callback of array methods (such as `.forEach()`) if `thisArg` is given. - The function has an `@this` tag in its JSDoc comment. - The function declares an explicit `this` parameter (`function foo(this: SomeType)`). And this rule always allows `this` keywords in the following contexts: - At the top level of scripts. - In class field initializers. - In class static blocks. Otherwise, this rule warns on `this` keywords. Examples of **incorrect** code for this rule in strict mode: ```typescript 'use strict'; (function () { this.a = 0; baz(() => this); })(); function foo() { this.a = 0; baz(() => this); } var foo = function () { this.a = 0; baz(() => this); }; foo(function () { this.a = 0; baz(() => this); }); var obj = { aaa: function () { return function foo() { // There is a method `aaa`, but `foo` is not a method. this.a = 0; baz(() => this); }; }, }; foo.forEach(function () { this.a = 0; baz(() => this); }); ``` Examples of **correct** code for this rule in strict mode: ```typescript 'use strict'; this.a = 0; baz(() => this); function Foo() { // OK, this is in a legacy style constructor. this.a = 0; baz(() => this); } class Foo { constructor() { // OK, this is in a constructor. this.a = 0; baz(() => this); } } var obj = { foo() { // OK, this is in a method (this function is on an object literal). this.a = 0; }, }; var obj = { get foo() { // OK, this is in a method (this function is on an object literal). return this.a; }, }; Object.defineProperty(obj, 'foo', { value: function foo() { // OK, this is in a method (this function is on an object literal). this.a = 0; }, }); obj.foo = function foo() { // OK, this is in a method (this function assigns to a property). this.a = 0; }; class Baz { // OK, this is in a class field initializer. a = this.b; // OK, static initializers also have valid this. static a = this.b; foo() { // OK, this is in a method. this.a = 0; baz(() => this); } static foo() { // OK, this is in a method (static methods also have valid this). this.a = 0; baz(() => this); } static { // OK, static blocks also have valid this. this.a = 0; baz(() => this); } } var foo = function foo() { // OK, the bind method of this function is called directly. this.a = 0; }.bind(obj); foo.forEach(function () { // OK, thisArg of .forEach() is given. this.a = 0; baz(() => this); }, thisArg); /** @this Foo */ function foo() { // OK, this function has a @this tag in its JSDoc comment. this.a = 0; } function foo(this: SomeType) { // OK, this function has an explicit `this` parameter. this.a = 0; } ``` ## Options This rule has an object option, with one option: - `"capIsConstructor": false` (default `true`) disables the assumption that a function whose name starts with an uppercase letter is a constructor. ### `capIsConstructor` By default, this rule always allows the use of `this` in functions whose name starts with an uppercase letter and anonymous functions that are assigned to a variable whose name starts with an uppercase letter, assuming that those functions are used as constructor functions. Set `"capIsConstructor"` to `false` if you want those functions to be treated as regular functions. Examples of **incorrect** code for this rule with `{ "capIsConstructor": false }`: ```json { "no-invalid-this": ["error", { "capIsConstructor": false }] } ``` ```typescript 'use strict'; function Foo() { this.a = 0; } var Bar = function Foo() { this.a = 0; }; Baz = function () { this.a = 0; }; ``` Examples of **correct** code for this rule with `{ "capIsConstructor": false }`: ```json { "no-invalid-this": ["error", { "capIsConstructor": false }] } ``` ```typescript 'use strict'; obj.Foo = function Foo() { // OK, this is in a method. this.a = 0; }; ``` ## Differences from ESLint - rslint does not expose ESLint's legacy `parserOptions.ecmaFeatures.globalReturn` escape hatch. ## When Not To Use It If you do not want to be notified about usage of the `this` keyword outside of classes or class-like objects, you can safely disable this rule. ## Original Documentation - [ESLint: no-invalid-this](https://eslint.org/docs/latest/rules/no-invalid-this) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-invalid-this.js) --- url: /rules/eslint/no-irregular-whitespace.md --- # no-irregular-whitespace [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-irregular-whitespace': 'error', }, }, ]); ``` ## Rule Details Disallows irregular whitespace characters outside of strings, comments, regular expressions, and template literals. Irregular whitespace characters can cause issues with various parsers and can be difficult to debug. The following characters are considered irregular whitespace: - `\u000B` - Line Tabulation - `\u000C` - Form Feed - `\u0085` - Next Line - `\u00A0` - No-Break Space - `\u1680` - Ogham Space Mark - `\u180E` - Mongolian Vowel Separator - `\u2000` - En Quad through `\u200B` - Zero Width Space - `\u202F` - Narrow No-Break Space - `\u205F` - Medium Mathematical Space - `\u3000` - Ideographic Space - `\uFEFF` - Zero Width No-Break Space (BOM) - `\u2028` - Line Separator - `\u2029` - Paragraph Separator Examples of **incorrect** code for this rule: ```javascript var any\u00A0= 'thing'; ``` Examples of **correct** code for this rule: ```javascript var any = 'thing'; ``` Examples of **correct** code for this rule with `{ "skipStrings": true }` (default): ```json { "no-irregular-whitespace": ["error", { "skipStrings": true }] } ``` ```javascript var foo = ' '; ``` Examples of **correct** code for this rule with `{ "skipComments": true }`: ```json { "no-irregular-whitespace": ["error", { "skipComments": true }] } ``` ```javascript // Comment with irregular whitespace /* Block comment with irregular whitespace */ ``` Examples of **correct** code for this rule with `{ "skipTemplates": true }`: ```json { "no-irregular-whitespace": ["error", { "skipTemplates": true }] } ``` ```javascript var foo = ` `; ``` ## Options | Option | Type | Default | Description | | --------------- | --------- | ------- | ------------------------------------------------- | | `skipStrings` | `boolean` | `true` | Allow irregular whitespace in string literals | | `skipComments` | `boolean` | `false` | Allow irregular whitespace in comments | | `skipRegExps` | `boolean` | `false` | Allow irregular whitespace in regular expressions | | `skipTemplates` | `boolean` | `false` | Allow irregular whitespace in template literals | | `skipJSXText` | `boolean` | `false` | Allow irregular whitespace in JSX text | ## Original Documentation - [ESLint: no-irregular-whitespace](https://eslint.org/docs/latest/rules/no-irregular-whitespace) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-irregular-whitespace.js) --- url: /rules/eslint/no-iterator.md --- # no-iterator [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-iterator': 'error', }, }, ]); ``` ## Rule Details Disallow the use of the `__iterator__` property. The `__iterator__` property was a SpiderMonkey extension to JavaScript that could be used to create custom iterators compatible with `for...in` and `for each...in` loops. However, this property is now obsolete, so it should not be used. The standard `Symbol.iterator` property should be used instead to define the iteration protocol. Examples of **incorrect** code for this rule: ```javascript Foo.prototype.__iterator__ = function () {}; var a = test.__iterator__; var a = test['__iterator__']; ``` Examples of **correct** code for this rule: ```javascript var __iterator__ = null; var a = test[__iterator__]; Foo.prototype[Symbol.iterator] = function () {}; ``` ## Original Documentation - [ESLint: no-iterator](https://eslint.org/docs/latest/rules/no-iterator) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-iterator.js) --- url: /rules/eslint/no-label-var.md --- # no-label-var [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-label-var': 'error', }, }, ]); ``` ## Rule Details This rule aims to create clearer code by disallowing the bad practice of creating a label that shares a name with a variable that is in scope. Examples of **incorrect** code for this rule: ```javascript var x = foo; function bar() { x: for (;;) { break x; } } ``` Examples of **correct** code for this rule: ```javascript // The variable that has the same name as the label is not in scope. function foo() { var q = t; } function bar() { q: for (;;) { break q; } } ``` ## Options This rule has no options. ## Differences from ESLint - On files without type information, only declarations written in the file plus [configured globals](/config/language-options.md#languageoptionsglobals) (`languageOptions.globals` / `/* global foo */`) are checked; clashes with built-in globals (`Promise`, `Array`, …) are not reported in that case. The `globals` catalog exported by `@rslint/core` can supply runtime-specific declarations. ## Original Documentation - [ESLint: no-label-var](https://eslint.org/docs/latest/rules/no-label-var) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-label-var.js) --- url: /rules/eslint/no-labels.md --- # no-labels [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-labels': 'error', }, }, ]); ``` ## Rule Details Disallow labeled statements. Labels tend to be used only rarely and are frowned upon as a remedial form of flow control that is more error prone and harder to understand. This rule aims to eliminate the use of labeled statements in JavaScript and reports whenever a labeled statement is encountered and whenever `break` or `continue` are used with a label. Examples of **incorrect** code for this rule: ```javascript label: while (true) {} label: while (true) { break label; } label: while (true) { continue label; } ``` Examples of **correct** code for this rule: ```javascript var f = { label: foo() }; while (true) {} while (true) { break; } while (true) { continue; } ``` ## Options - `allowLoop` (boolean, default `false`): When `true`, allows labels attached to loop statements. - `allowSwitch` (boolean, default `false`): When `true`, allows labels attached to switch statements. Examples of **correct** code with `{ "allowLoop": true }`: ```javascript A: while (a) { break A; } A: do { if (b) { break A; } } while (a); A: for (var a in obj) { for (;;) { switch (a) { case 0: continue A; } } } ``` Examples of **correct** code with `{ "allowSwitch": true }`: ```javascript A: switch (a) { case 0: break A; } ``` ## Original Documentation - [ESLint: no-labels](https://eslint.org/docs/latest/rules/no-labels) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-labels.js) --- url: /rules/eslint/no-lone-blocks.md --- # no-lone-blocks [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-lone-blocks': 'error', }, }, ]); ``` ## Rule Details This rule disallows nested (non-function) lone blocks. A lone block is a block that is not part of an `if`, `for`, `while`, `function`, `try`, class static block, or other statement that naturally introduces one. In ES6+, a block can be useful to scope `let`, `const`, `class`, `function`, or `using` declarations — this rule only flags blocks that do not contain such block-scoped bindings. Examples of **incorrect** code for this rule: ```javascript {} { var x = 1; } if (foo) { bar(); { baz(); } } function foo() { { var x = 1; } } class C { static { { foo(); } } } ``` Examples of **correct** code for this rule: ```javascript while (foo) { bar(); } if (foo) { if (bar) { baz(); } } { let x = 1; } { const y = 2; } { class Bar {} } switch (foo) { case bar: { baz(); } } class C { static { foo(); } } ``` ## Original Documentation - [ESLint: no-lone-blocks](https://eslint.org/docs/latest/rules/no-lone-blocks) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-lone-blocks.js) --- url: /rules/eslint/no-lonely-if.md --- # no-lonely-if [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-lonely-if': 'error', }, }, ]); ``` ## Rule Details If an `if` statement is the only statement in the `else` block, it is often clearer to use an `else if` form. ```javascript if (foo) { // ... } else { if (bar) { // ... } } ``` should be rewritten as ```javascript if (foo) { // ... } else if (bar) { // ... } ``` This rule disallows `if` statements as the only statement in `else` blocks. Examples of **incorrect** code for this rule: ```javascript if (condition) { // ... } else { if (anotherCondition) { // ... } } if (condition) { // ... } else { if (anotherCondition) { // ... } else { // ... } } ``` Examples of **correct** code for this rule: ```javascript if (condition) { // ... } else if (anotherCondition) { // ... } if (condition) { // ... } else if (anotherCondition) { // ... } else { // ... } if (condition) { // ... } else { if (anotherCondition) { // ... } doSomething(); } ``` ## When Not To Use It Disable this rule if the code is clearer without requiring the `else if` form. ## Original Documentation - [ESLint: no-lonely-if](https://eslint.org/docs/latest/rules/no-lonely-if) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-lonely-if.js) --- url: /rules/eslint/no-loop-func.md --- # no-loop-func [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-loop-func': 'error', }, }, ]); ``` Disallow function declarations that contain unsafe references inside loop statements. ## Rule Details Writing functions within loops tends to result in errors due to the way the function creates a closure around the loop. For example: ```javascript for (var i = 10; i; i--) { (function() { return i; })(); } ``` Generally speaking, it is safer to keep the closure code outside of the loop, or to use `let` / `const` for loop variables so each iteration produces a fresh binding. This rule disallows any function within a loop that contains unsafe references (e.g. to modified variables). Examples of **incorrect** code for this rule: ```javascript for (var i = 0; i < 10; i++) { funcs[i] = function() { return i; }; } for (var i = 0; i < 10; i++) { funcs[i] = () => i; } for (var i = 0; i < 10; i++) { funcs[i] = function() { return i; }; funcs[i](); } var foo = 100; for (var i = 0; i < 10; i++) { funcs[i] = function() { return foo; }; foo += 1; } var foo = 100; check(function() { return foo; }); foo = 200; ``` Examples of **correct** code for this rule: ```javascript var a = function() {}; for (var i = 0; i < 10; i++) { funcs[i] = a; } for (let i = 0; i < 10; i++) { funcs[i] = function() { return i; }; } const foo = 100; for (var i = 0; i < 10; i++) { funcs[i] = function() { return foo; }; } // IIFEs are fine because they execute immediately. for (var i = 0; i < 10; i++) { funcs[i] = (function() { return i; })(); } ``` ## Original Documentation - [ESLint: no-loop-func](https://eslint.org/docs/latest/rules/no-loop-func) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-loop-func.js) --- url: /rules/eslint/no-loss-of-precision.md --- # no-loss-of-precision [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-loss-of-precision': 'error', }, }, ]); ``` ## Rule Details Disallow number literals that lose precision at runtime when converted to a JavaScript `Number`. JavaScript numbers are stored as double-precision floating-point values. If a number literal contains more significant digits than the runtime value can preserve, the literal may evaluate to a different number than the source text suggests. Examples of **incorrect** code for this rule: ```javascript const a = 9007199254740993; const b = 5123000000000000000000000000001; const c = 1230000000000000000000000.0; const d = .1230000000000000000000000; const e = 0x20000000000001; const f = 0x2_000000000_0001; ``` Examples of **correct** code for this rule: ```javascript const a = 12345; const b = 123.456; const c = 123e34; const d = 12300000000000000000000000; const e = 0x1fffffffffffff; const f = 9007199254740991; const g = 9007_1992547409_91; ``` ## Options This rule has no options. ## Original Documentation - [ESLint: no-loss-of-precision](https://eslint.org/docs/latest/rules/no-loss-of-precision) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-loss-of-precision.js) --- url: /rules/eslint/no-magic-numbers.md --- # no-magic-numbers [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-magic-numbers': 'error', }, }, ]); ``` ## Rule Details "Magic numbers" are numbers that occur multiple times in code without an explicit meaning. They should preferably be replaced by named constants. The `no-magic-numbers` rule aims to make code more readable and refactoring easier by ensuring that special numbers are declared as constants to make their meaning explicit. Examples of **incorrect** code for this rule: ```javascript const dutyFreePrice = 100, finalPrice = dutyFreePrice + dutyFreePrice * 0.25; const data = ['foo', 'bar', 'baz']; const dataLast = data[2]; let SECONDS; SECONDS = 60; ``` Examples of **correct** code for this rule: ```javascript const TAX = 0.25; const dutyFreePrice = 100, finalPrice = dutyFreePrice + dutyFreePrice * TAX; ``` ## Options This rule accepts an object with the following properties: - `ignore` (default `[]`): an array of numbers to ignore. Values may be `number` or a `string` parsed as a `bigint` literal (e.g. `"100n"`). - `ignoreArrayIndexes` (default `false`): whether numbers used as array indexes are considered okay. - `ignoreDefaultValues` (default `false`): whether numbers used in default value assignments are considered okay. - `ignoreClassFieldInitialValues` (default `false`): whether numbers used as initial values of class fields are considered okay. - `enforceConst` (default `false`): whether to check for the `const` keyword in variable declarations of numbers. - `detectObjects` (default `false`): whether to detect numbers when setting object properties. - `ignoreEnums` (default `false`, TypeScript only): whether numbers used in enum members are considered okay. - `ignoreNumericLiteralTypes` (default `false`, TypeScript only): whether numbers used in numeric literal types are considered okay. - `ignoreReadonlyClassProperties` (default `false`, TypeScript only): whether numbers used in `readonly` class properties are considered okay. - `ignoreTypeIndexes` (default `false`, TypeScript only): whether numbers used to index types are considered okay. ### `ignore` Examples of **correct** code for this rule with `{ "ignore": [1] }`: ```json { "no-magic-numbers": ["error", { "ignore": [1] }] } ``` ```javascript const data = ['foo', 'bar', 'baz']; const dataLast = data.length && data[data.length - 1]; ``` Examples of **correct** code for this rule with `{ "ignore": ["1n"] }`: ```json { "no-magic-numbers": ["error", { "ignore": ["1n"] }] } ``` ```javascript foo(1n); ``` ### `ignoreArrayIndexes` This option allows only valid array indexes: numbers that will be coerced to one of `"0"`, `"1"`, `"2"` ... `"4294967294"`. Examples of **correct** code for this rule with `{ "ignoreArrayIndexes": true }`: ```json { "no-magic-numbers": ["error", { "ignoreArrayIndexes": true }] } ``` ```javascript const item = data[2]; data[100] = a; f(data[0]); a = data[-0]; // same as data[0], -0 will be coerced to "0" a = data[10n]; // same as data[10], 10n will be coerced to "10" a = data[4294967294]; // max array index ``` Examples of **incorrect** code for this rule with `{ "ignoreArrayIndexes": true }`: ```json { "no-magic-numbers": ["error", { "ignoreArrayIndexes": true }] } ``` ```javascript f(2); // not used as array index a = data[-1]; a = data[2.5]; a = data[4294967295]; // above the max array index ``` ### `ignoreDefaultValues` Examples of **correct** code for this rule with `{ "ignoreDefaultValues": true }`: ```json { "no-magic-numbers": ["error", { "ignoreDefaultValues": true }] } ``` ```javascript const { tax = 0.25 } = accountancy; function mapParallel(concurrency = 3) {} ``` ### `ignoreClassFieldInitialValues` Examples of **correct** code for this rule with `{ "ignoreClassFieldInitialValues": true }`: ```json { "no-magic-numbers": ["error", { "ignoreClassFieldInitialValues": true }] } ``` ```javascript class C { foo = 2; bar = -3; #baz = 4; static qux = 5; } ``` Examples of **incorrect** code for this rule with `{ "ignoreClassFieldInitialValues": true }`: ```json { "no-magic-numbers": ["error", { "ignoreClassFieldInitialValues": true }] } ``` ```javascript class C { foo = 2 + 3; } ``` ### `enforceConst` Examples of **incorrect** code for this rule with `{ "enforceConst": true }`: ```json { "no-magic-numbers": ["error", { "enforceConst": true }] } ``` ```javascript let TAX = 0.25; ``` ### `detectObjects` Examples of **incorrect** code for this rule with `{ "detectObjects": true }`: ```json { "no-magic-numbers": ["error", { "detectObjects": true }] } ``` ```javascript const magic = { tax: 0.25, }; ``` ### `ignoreEnums` Examples of **correct** TypeScript code for this rule with `{ "ignoreEnums": true }`: ```json { "no-magic-numbers": ["error", { "ignoreEnums": true }] } ``` ```typescript enum foo { SECOND = 1000, } ``` ### `ignoreNumericLiteralTypes` Examples of **correct** TypeScript code for this rule with `{ "ignoreNumericLiteralTypes": true }`: ```json { "no-magic-numbers": ["error", { "ignoreNumericLiteralTypes": true }] } ``` ```typescript type Foo = 1 | 2 | 3; ``` ### `ignoreReadonlyClassProperties` Examples of **correct** TypeScript code for this rule with `{ "ignoreReadonlyClassProperties": true }`: ```json { "no-magic-numbers": ["error", { "ignoreReadonlyClassProperties": true }] } ``` ```typescript class Foo { readonly A = 1; public static readonly B = 2; } ``` ### `ignoreTypeIndexes` Examples of **correct** TypeScript code for this rule with `{ "ignoreTypeIndexes": true }`: ```json { "no-magic-numbers": ["error", { "ignoreTypeIndexes": true }] } ``` ```typescript type Foo = Bar[0]; type Baz = Parameters[2]; ``` ## Original Documentation - [ESLint: no-magic-numbers](https://eslint.org/docs/latest/rules/no-magic-numbers) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-magic-numbers.js) --- url: /rules/eslint/no-misleading-character-class.md --- # no-misleading-character-class [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-misleading-character-class': 'error', }, }, ]); ``` ## Rule Details Disallow characters whose visual rendering is made from multiple code points (combining marks, surrogate pairs, regional indicators, emoji-modifier sequences, joined ZWJ sequences) from appearing inside a regex character class `[...]`. Such sequences cannot be matched as a single unit by the regex engine and therefore produce surprising matches. Examples of **incorrect** code for this rule: ```javascript /^[Á]$/u; // a + combining acute /^[❇️]$/u; // base + variation selector /^[👶🏻]$/u; // base emoji + skin tone modifier /^[🇯🇵]$/u; // two regional indicator symbols /^[👨‍👩‍👦]$/u; // ZWJ-joined family sequence /^[👍]$/; // astral character without `u` / `v` flag new RegExp("[🎵]"); ``` Examples of **correct** code for this rule: ```javascript /^[abc]$/; /^[👍]$/u; /^[\q{👶🏻}]$/v; // v-flag grouping preserves the sequence new RegExp("^[]$"); /[\ud83d\udc4d]/; /[\u00B7\u0300-\u036F]/u; ``` ### Options This rule accepts an options object: ```json { "no-misleading-character-class": ["error", { "allowEscape": true }] } ``` - `allowEscape` (boolean, default `false`) — when enabled, allows combining the troublesome characters inside a character class as long as the combining portion is written using a backslash escape sequence. This applies to regex literals and to `RegExp(...)` calls whose first argument is a string or no-substitution template literal. Examples of **correct** code with `{ "allowEscape": true }`: ```javascript /[\ud83d\udc4d]/; // surrogate pair written with escapes /[A\u0301]/; // combining acute written with escape new RegExp("[\\uD83D\\uDC4D]"); // surrogate pair in string literal ``` ## Differences from ESLint - The scope of recognition for the `RegExp(...)` constructor is limited to calls where the callee is a recognized global `RegExp` constructor and the pattern or flags are statically known strings. Spread arguments and unresolved runtime expressions are ignored. - When a regex literal is passed to `RegExp(...)` with an unresolved second flags argument, rslint does not report on the literal because the runtime flags may override the literal's own flags. - Suggestions to add the `u` flag use a simplified heuristic to decide whether the pattern remains valid under the flag. Patterns with identity escapes on letters (e.g. `/[👍]\a/`) are correctly detected as unfixable; more exotic cases may rarely produce a suggestion that ESLint would suppress. - In rare edge cases where a character written as `\q{...}` or `\p{...}` escape appears outside its valid flag context (e.g. without the v flag), the scanner may still treat it as a breaker rather than a plain character. - TypeScript-only code that repeatedly merges the same name across namespace, type-only, decorator, and parameter scopes can differ in whether an assigned `RegExp` alias is considered local. Ordinary lexical bindings and namespace shadowing are supported. ## Original Documentation - [ESLint: no-misleading-character-class](https://eslint.org/docs/latest/rules/no-misleading-character-class) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-misleading-character-class.js) --- url: /rules/eslint/no-multi-assign.md --- # no-multi-assign [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-multi-assign': 'error', }, }, ]); ``` ## Rule Details This rule disallows chained assignment expressions within a single statement, such as `a = b = c`. Chained assignments are often a sign of a typo (`foo = bar == 0` was meant) and they hide whether each name is being declared or merely reassigned, which can lead to surprising scope and `const`-vs-`let` mistakes. Examples of **incorrect** code for this rule: ```javascript var a = b = c = 5; const foo = bar = "baz"; let a = b = c; class Foo { a = b = 10; } a = b = "quux"; ``` Examples of **correct** code for this rule: ```javascript var a = 5; var b = 5; var c = 5; const foo = "baz"; const bar = "baz"; let a = 5; let b = 5; let c = 5; class Foo { a = 10; b = 10; } a = "quux"; b = "quux"; ``` ## Options This rule has an object option: - `"ignoreNonDeclaration"`: When set to `true`, allows chained assignments that do not introduce new declarations (i.e. plain `AssignmentExpression`s). Defaults to `false`. Examples of **correct** code for this rule with `{ "ignoreNonDeclaration": true }`: ```json { "no-multi-assign": ["error", { "ignoreNonDeclaration": true }] } ``` ```javascript let a; let b; a = b = "baz"; const x = {}; const y = {}; x.one = y.one = 1; ``` Examples of **incorrect** code for this rule with `{ "ignoreNonDeclaration": true }`: ```json { "no-multi-assign": ["error", { "ignoreNonDeclaration": true }] } ``` ```javascript let a = b = "baz"; const foo = bar = 1; class Foo { a = b = 10; } ``` ## Original Documentation - [ESLint: no-multi-assign](https://eslint.org/docs/latest/rules/no-multi-assign) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-multi-assign.js) --- url: /rules/eslint/no-multi-str.md --- # no-multi-str [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-multi-str': 'error', }, }, ]); ``` ## Rule Details Disallows multiline strings created using a trailing backslash before a line break. This syntax was historically an undocumented feature of JavaScript and should be avoided. Examples of **incorrect** code for this rule: ```javascript var x = 'Line 1 \ Line 2'; ``` Examples of **correct** code for this rule: ```javascript var x = 'Line 1 ' + 'Line 2'; var x = `Line 1 Line 2`; ``` ## Original Documentation - [ESLint: no-multi-str](https://eslint.org/docs/latest/rules/no-multi-str) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-multi-str.js) --- url: /rules/eslint/no-negated-condition.md --- # no-negated-condition [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-negated-condition': 'error', }, }, ]); ``` ## Rule Details Negated conditions are more difficult to understand. Code can be made more readable by inverting the condition instead. This rule disallows negated conditions in either of the following: - `if` statements which have an `else` branch - ternary expressions Examples of **incorrect** code for this rule: ```javascript if (!a) { doSomething(); } else { doSomethingElse(); } if (a != b) { doSomething(); } else { doSomethingElse(); } if (a !== b) { doSomething(); } else { doSomethingElse(); } !a ? c : b; ``` Examples of **correct** code for this rule: ```javascript if (!a) { doSomething(); } if (!a) { doSomething(); } else if (b) { doSomething(); } if (a != b) { doSomething(); } a ? b : c; ``` ## Original Documentation - [ESLint: no-negated-condition](https://eslint.org/docs/latest/rules/no-negated-condition) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-negated-condition.js) --- url: /rules/eslint/no-nested-ternary.md --- # no-nested-ternary [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-nested-ternary': 'error', }, }, ]); ``` ## Rule Details Disallows nested ternary expressions. Nesting ternary expressions can make code more difficult to understand; prefer an `if` statement or extract the logic into named variables. Examples of **incorrect** code for this rule: ```javascript var thing = foo ? bar : baz === qux ? quxx : foobar; foo ? (baz === qux ? quxx : foobar) : bar; ``` Examples of **correct** code for this rule: ```javascript var thing = foo ? bar : foobar; var thing; if (foo) { thing = bar; } else if (baz === qux) { thing = quxx; } else { thing = foobar; } ``` ## Original Documentation - [ESLint: no-nested-ternary](https://eslint.org/docs/latest/rules/no-nested-ternary) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-nested-ternary.js) --- url: /rules/eslint/no-new.md --- # no-new [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-new': 'error', }, }, ]); ``` ## Rule Details Disallows the use of `new` operators outside of assignments or comparisons. The goal of `new` with a constructor is to create a new object of a particular type and assign or compare that object. A `new` expression used as a standalone statement discards the resulting object, which usually means the constructor should have been a plain function call instead. Examples of **incorrect** code for this rule: ```javascript new Thing(); ``` Examples of **correct** code for this rule: ```javascript var thing = new Thing(); Thing(); ``` ## Original Documentation - [ESLint: no-new](https://eslint.org/docs/latest/rules/no-new) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-new.js) --- url: /rules/eslint/no-new-func.md --- # no-new-func [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-new-func': 'error', }, }, ]); ``` ## Rule Details Disallows creating functions from strings using the `Function` constructor. Passing a string to the `Function` constructor requires the engine to parse that string, similar to `eval`. Examples of **incorrect** code for this rule: ```javascript var a = new Function('a', 'b', 'return a + b'); var b = Function('a', 'b', 'return a + b'); var c = Function.call(null, 'a', 'b', 'return a + b'); var d = Function.apply(null, ['a', 'b', 'return a + b']); var e = Function.bind(null, 'a', 'b', 'return a + b')(); var f = Function.bind(null, 'a', 'b', 'return a + b'); ``` Examples of **correct** code for this rule: ```javascript var x = function (a, b) { return a + b; }; ``` ## Original Documentation - [ESLint: no-new-func](https://eslint.org/docs/latest/rules/no-new-func) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/no-new-func.js) --- url: /rules/eslint/no-new-native-nonconstructor.md --- # no-new-native-nonconstructor [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-new-native-nonconstructor': 'error', }, }, ]); ``` ## Rule Details Disallows using the `new` operator with native global functions that are not constructors. Examples of **incorrect** code for this rule: ```javascript const foo = new Symbol('foo'); const bar = new BigInt(9007199254740991); ``` Examples of **correct** code for this rule: ```javascript const foo = Symbol('foo'); const bar = BigInt(9007199254740991); function baz(Symbol) { const qux = new Symbol('baz'); } const SymbolCtor = Symbol; new SymbolCtor(); ``` ## Original Documentation - [ESLint: no-new-native-nonconstructor](https://eslint.org/docs/latest/rules/no-new-native-nonconstructor) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-new-native-nonconstructor.js) --- url: /rules/eslint/no-new-object.md --- # no-new-object [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-new-object': 'error', }, }, ]); ``` ## Rule Details Disallow `Object` constructors. The object literal notation `{}` is preferable. Examples of **incorrect** code for this rule: ```javascript var myObject = new Object(); new Object(); ``` Examples of **correct** code for this rule: ```javascript var myObject = {}; var myObject = new CustomObject(); var foo = new foo.Object(); ``` ## Original Documentation - [ESLint: no-new-object](https://eslint.org/docs/latest/rules/no-new-object) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-new-object.js) --- url: /rules/eslint/no-new-symbol.md --- # no-new-symbol [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-new-symbol': 'error', }, }, ]); ``` ## Rule Details Disallows `new Symbol()`. `Symbol` is not intended to be used with the `new` operator, but to be called as a function. Calling `new Symbol()` throws a `TypeError` at runtime because `Symbol` is not a constructor. Examples of **incorrect** code for this rule: ```javascript var foo = new Symbol('foo'); new Symbol(); ``` Examples of **correct** code for this rule: ```javascript var foo = Symbol('foo'); ``` ## Original Documentation - [ESLint: no-new-symbol](https://eslint.org/docs/latest/rules/no-new-symbol) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-new-symbol.js) --- url: /rules/eslint/no-new-wrappers.md --- # no-new-wrappers [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-new-wrappers': 'error', }, }, ]); ``` ## Rule Details Disallows the use of `new` operators with `String`, `Number`, and `Boolean` as constructors. There are three primitive types in JavaScript that have wrapper objects: string, number, and boolean. These are represented by the constructors `String`, `Number`, and `Boolean`, respectively. Using these constructors to create new instances is generally considered bad practice because the primitive wrapper objects behave differently than their primitive counterparts in certain cases (e.g., `typeof new Boolean(false)` returns `"object"`). Examples of **incorrect** code for this rule: ```javascript var stringObject = new String('Hello world'); var numberObject = new Number(33); var booleanObject = new Boolean(false); ``` Examples of **correct** code for this rule: ```javascript var text = String(someValue); var num = Number('33'); var bool = Boolean(someValue); ``` ## Original Documentation - [ESLint: no-new-wrappers](https://eslint.org/docs/latest/rules/no-new-wrappers) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-new-wrappers.js) --- url: /rules/eslint/no-nonoctal-decimal-escape.md --- # no-nonoctal-decimal-escape [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-nonoctal-decimal-escape': 'error', }, }, ]); ``` ## Rule Details Disallows `\8` and `\9` escape sequences in string literals. Although `"\8"` and `"\9"` evaluate to the same characters as `"8"` and `"9"`, they are non-octal decimal escape sequences kept only for backward compatibility with web JavaScript. Browsers must support them, but Annex B explicitly allows non-web environments to omit them. The recommended fix is to drop the leading backslash, switch the digit to its `\uXXXX` form, or — when the goal really is to include a backslash — escape the backslash itself. Examples of **incorrect** code for this rule: ```javascript "\8"; "\9"; const foo = "w\8less"; const bar = "December 1\9"; const baz = "Don't use \8 and \9 escapes."; const quux = "\0\8"; ``` Examples of **correct** code for this rule: ```javascript "8"; "9"; const foo = "w8less"; const bar = "December 19"; const baz = "Don't use \\8 and \\9 escapes."; const quux = "\0\u0038"; ``` ## Options This rule has no options. ## Original Documentation - [ESLint: no-nonoctal-decimal-escape](https://eslint.org/docs/latest/rules/no-nonoctal-decimal-escape) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-nonoctal-decimal-escape.js) --- url: /rules/eslint/no-obj-calls.md --- # no-obj-calls [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-obj-calls': 'error', }, }, ]); ``` ## Rule Details Disallows calling global objects (`Math`, `JSON`, `Reflect`, `Atomics`, `Intl`) as functions or constructors. These are namespace objects that provide properties and methods but are not themselves callable. Attempting to call them will throw a `TypeError` at runtime. Examples of **incorrect** code for this rule: ```javascript var x = Math(); var y = JSON(); var z = Reflect(); var a = new Math(); var b = new JSON(); ``` Examples of **correct** code for this rule: ```javascript var x = Math.random(); var y = JSON.parse('{}'); var z = Reflect.get(obj, 'key'); var a = new Intl.Segmenter(); var b = Math.PI; ``` ## Original Documentation - [ESLint: no-obj-calls](https://eslint.org/docs/latest/rules/no-obj-calls) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-obj-calls.js) --- url: /rules/eslint/no-object-constructor.md --- # no-object-constructor [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-object-constructor': 'error', }, }, ]); ``` ## Rule Details Use of the `Object` constructor to construct a new empty object is generally discouraged in favor of object literal notation because of conciseness and because the `Object` global may be redefined. The exception is when the `Object` constructor is used to intentionally wrap a specified value which is passed as an argument. This rule disallows calling the `Object` constructor without an argument. Examples of **incorrect** code for this rule: ```javascript Object(); new Object(); ``` Examples of **correct** code for this rule: ```javascript Object("foo"); const obj = { a: 1, b: 2 }; const isObject = (value) => value === Object(value); const createObject = (Object) => new Object(); ``` ## Differences from ESLint - When the object constructor call is fixed onto a new line right after certain TypeScript-only constructs — a type alias (`type T = Foo`), an ambient or overload function declaration (`declare function foo()`), an import-equals declaration (`import Foo = Bar`), or an `as`/`satisfies` type cast — rslint's suggested fix inserts a leading `;` that ESLint omits (e.g. `type T = Foo\n;({})` instead of `type T = Foo\n({})`). The extra semicolon never changes the resulting code's behavior. ## Original Documentation - [ESLint: no-object-constructor](https://eslint.org/docs/latest/rules/no-object-constructor) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-object-constructor.js) --- url: /rules/eslint/no-octal.md --- # no-octal [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-octal': 'error', }, }, ]); ``` ## Rule Details Disallows octal literals — integer numerals whose source form starts with a leading zero followed by another digit (e.g. `071`, `00`, `08`). Octal numeric literals were deprecated in ECMAScript 5 and are forbidden in strict mode; the leading-zero notation has also been a long-standing source of confusion (`08` is decimal 8, but `017` is decimal 15). Prefer the explicit `0o...` octal notation introduced in ES2015. Examples of **incorrect** code for this rule: ```javascript const num = 071; const result = 5 + 07; const leadingDigit = 08; const leadingDecimal = 09.1; ``` Examples of **correct** code for this rule: ```javascript const num = "071"; const hex = 0x1234; const binary = 0b101; const modernOctal = 0o17; const zero = 0; const decimal = 0.1; ``` ## Options This rule has no options. ## Original Documentation - [ESLint: no-octal](https://eslint.org/docs/latest/rules/no-octal) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-octal.js) --- url: /rules/eslint/no-octal-escape.md --- # no-octal-escape [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-octal-escape': 'error', }, }, ]); ``` ## Rule Details Disallows octal escape sequences in string literals. As of the ECMAScript 5 specification, octal escape sequences in string literals are deprecated and should not be used. Unicode escape sequences should be used instead. Examples of **incorrect** code for this rule: ```javascript var foo = 'Copyright \251'; var foo = '\1'; var foo = '\01'; var foo = '\08'; ``` Examples of **correct** code for this rule: ```javascript var foo = 'Copyright \u00A9'; var foo = '\x51'; var foo = '\0'; var foo = '\\1'; ``` ## Original Documentation - [ESLint: no-octal-escape](https://eslint.org/docs/latest/rules/no-octal-escape) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-octal-escape.js) --- url: /rules/eslint/no-param-reassign.md --- # no-param-reassign [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-param-reassign': 'error', }, }, ]); ``` ## Rule Details Disallow reassigning function parameters. Reassigning a parameter mutates the caller-visible `arguments` object in non-strict code and can hide bugs caused by unintentional overwrites. With the `props` option, the rule also forbids modifying properties on parameters. Examples of **incorrect** code for this rule: ```javascript function foo(bar) { bar = 13; } function foo(bar) { bar++; } function foo(bar) { for (bar in baz) { } } ``` Examples of **correct** code for this rule: ```javascript function foo(bar) { var baz = bar; } ``` ## Options ```json { "no-param-reassign": ["error", { "props": false }] } ``` ```json { "no-param-reassign": [ "error", { "props": true, "ignorePropertyModificationsFor": ["acc", "e"], "ignorePropertyModificationsForRegex": ["^ctx"] } ] } ``` - `props` (default `false`) — when `true`, assignments to properties of a parameter (e.g. `bar.x = 0`, `delete bar.x`, `++bar.x`) are also reported. - `ignorePropertyModificationsFor` (requires `props: true`) — parameter names for which property modifications are allowed. - `ignorePropertyModificationsForRegex` (requires `props: true`) — regular expressions matching parameter names for which property modifications are allowed. Examples of **incorrect** code with `{ "props": true }`: ```json { "no-param-reassign": ["error", { "props": true }] } ``` ```javascript function foo(bar) { bar.prop = 'value'; } function foo(bar) { delete bar.aaa; } function foo(bar) { bar.aaa++; } ``` Examples of **correct** code with `{ "props": true, "ignorePropertyModificationsFor": ["bar"] }`: ```json { "no-param-reassign": [ "error", { "props": true, "ignorePropertyModificationsFor": ["bar"] } ] } ``` ```javascript function foo(bar) { bar.prop = 'value'; } ``` ## Original Documentation - [ESLint: no-param-reassign](https://eslint.org/docs/latest/rules/no-param-reassign) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-param-reassign.js) --- url: /rules/eslint/no-plusplus.md --- # no-plusplus [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-plusplus': 'error', }, }, ]); ``` ## Rule Details Because the unary `++` and `--` operators are subject to automatic semicolon insertion, differences in whitespace can change the semantics of source code. This rule disallows the unary operators `++` and `--`. Examples of **incorrect** code for this rule: ```javascript let foo = 0; foo++; let bar = 42; bar--; for (let i = 0; i < l; i++) { doSomething(i); } ``` Examples of **correct** code for this rule: ```javascript let foo = 0; foo += 1; let bar = 42; bar -= 1; for (let i = 0; i < l; i += 1) { doSomething(i); } ``` ## Options This rule has an object option. - `"allowForLoopAfterthoughts": true` allows unary operators `++` and `--` in the afterthought (final expression) of a `for` loop. ### allowForLoopAfterthoughts Examples of **correct** code for this rule with the `{ "allowForLoopAfterthoughts": true }` option: ```json { "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }] } ``` ```javascript for (let i = 0; i < l; i++) { doSomething(i); } for (let i = l; i >= 0; i--) { doSomething(i); } for (let i = 0, j = l; i < l; i++, j--) { doSomething(i, j); } ``` Examples of **incorrect** code for this rule with the `{ "allowForLoopAfterthoughts": true }` option: ```javascript for (let i = 0; i < l; j = i++) { doSomething(i, j); } for (let i = l; i--; ) { doSomething(i); } for (let i = 0; i < l; ) i++; ``` ## Original Documentation - [ESLint: no-plusplus](https://eslint.org/docs/latest/rules/no-plusplus) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-plusplus.js) --- url: /rules/eslint/no-promise-executor-return.md --- # no-promise-executor-return [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-promise-executor-return': 'error', }, }, ]); ``` ## Rule Details The `new Promise` constructor accepts a single argument, called an _executor_. The executor's return value is ignored: it cannot be read and it does not affect the promise in any way, so returning a value from it is usually a mistake. This rule disallows returning values from Promise executor functions. Only `return` without a value is allowed, as it's a control flow statement. Examples of **incorrect** code for this rule: ```javascript new Promise((resolve, reject) => { if (someCondition) { return defaultResult; } getSomething((err, result) => { if (err) { reject(err); } else { resolve(result); } }); }); new Promise((resolve, reject) => getSomething((err, data) => { if (err) { reject(err); } else { resolve(data); } }), ); new Promise(() => { return 1; }); new Promise((r) => r(1)); ``` Examples of **correct** code for this rule: ```javascript // Turn the inline return into two lines new Promise((resolve, reject) => { if (someCondition) { resolve(defaultResult); return; } getSomething((err, result) => { if (err) { reject(err); } else { resolve(result); } }); }); // Add curly braces new Promise((resolve, reject) => { getSomething((err, data) => { if (err) { reject(err); } else { resolve(data); } }); }); new Promise((r) => { r(1); }); // or just use Promise.resolve Promise.resolve(1); ``` ## Options This rule takes one option, an object, with the following properties: - `allowVoid`: If set to `true` (`false` by default), this rule will allow returning void values. ### allowVoid Examples of **correct** code for this rule with the `{ "allowVoid": true }` option: ```json { "no-promise-executor-return": ["error", { "allowVoid": true }] } ``` ```javascript new Promise((resolve, reject) => { if (someCondition) { return void resolve(defaultResult); } getSomething((err, result) => { if (err) { reject(err); } else { resolve(result); } }); }); new Promise( (resolve, reject) => void getSomething((err, data) => { if (err) { reject(err); } else { resolve(data); } }), ); new Promise((r) => void r(1)); ``` ## Original Documentation - [ESLint: no-promise-executor-return](https://eslint.org/docs/latest/rules/no-promise-executor-return) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-promise-executor-return.js) --- url: /rules/eslint/no-proto.md --- # no-proto [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-proto': 'error', }, }, ]); ``` ## Rule Details Disallow the use of the `__proto__` property. When an object is created with the `new` operator, `__proto__` is set to the original "prototype" property of the object's constructor function. `Object.getPrototypeOf` is the preferred method of getting the object's prototype. To change an object's prototype, use `Object.setPrototypeOf`. Examples of **incorrect** code for this rule: ```javascript var a = obj.__proto__; var a = obj['__proto__']; obj.__proto__ = b; obj['__proto__'] = b; ``` Examples of **correct** code for this rule: ```javascript var a = Object.getPrototypeOf(obj); Object.setPrototypeOf(obj, b); var c = { __proto__: a }; ``` ## Original Documentation - [ESLint: no-proto](https://eslint.org/docs/latest/rules/no-proto) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-proto.js) --- url: /rules/eslint/no-prototype-builtins.md --- # no-prototype-builtins [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-prototype-builtins': 'error', }, }, ]); ``` ## Rule Details This rule disallows calling `Object.prototype` methods directly on object instances. In particular, it flags calls to `hasOwnProperty`, `isPrototypeOf`, and `propertyIsEnumerable` invoked as members of a target object. Such calls can break on objects created with `Object.create(null)` (which do not inherit from `Object.prototype`) or on objects that define shadowing properties with the same names. Examples of **incorrect** code for this rule: ```javascript var hasBarProperty = foo.hasOwnProperty('bar'); var isPrototypeOfBar = foo.isPrototypeOf(bar); var barIsEnumerable = foo.propertyIsEnumerable('bar'); ``` Examples of **correct** code for this rule: ```javascript var hasBarProperty = Object.prototype.hasOwnProperty.call(foo, 'bar'); var isPrototypeOfBar = Object.prototype.isPrototypeOf.call(foo, bar); var barIsEnumerable = {}.propertyIsEnumerable.call(foo, 'bar'); ``` ## Options This rule has no options. ## Original Documentation - [ESLint: no-prototype-builtins](https://eslint.org/docs/latest/rules/no-prototype-builtins) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-prototype-builtins.js) --- url: /rules/eslint/no-redeclare.md --- # no-redeclare [Added in v0.7.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-redeclare': 'error', }, }, ]); ``` ## Rule Details This rule disallows declaring the same variable more than once in the same scope. Examples of **incorrect** code for this rule: ```javascript var a = 3; var a = 10; ``` ```javascript function a() {} function a() {} ``` Examples of **correct** code for this rule: ```javascript var a = 3; var b = function () { var a = 10; }; ``` ```javascript if (foo) { let a = 1; } else { let a = 2; } ``` ## Options ### `builtinGlobals` (default: `true`) When `true`, this rule reports redeclarations of ECMAScript built-in globals. Configured [`languageOptions.globals`](/config/language-options.md#languageoptionsglobals) also participate as built-ins. Select host environments with the `globals` catalog exported by `@rslint/core`. Active `/* global */` directives participate as declarations in either mode; a final `:off` setting removes that inline global. ```json { "no-redeclare": ["error", { "builtinGlobals": true }] } ``` ```javascript var Object = 0; ``` Set `builtinGlobals` to `false` to allow redeclaring built-in global names. ```json { "no-redeclare": ["error", { "builtinGlobals": false }] } ``` ```javascript var Object = 0; ``` ## Original Documentation - [ESLint: no-redeclare](https://eslint.org/docs/latest/rules/no-redeclare) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-redeclare.js) --- url: /rules/eslint/no-regex-spaces.md --- # no-regex-spaces [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-regex-spaces': 'error', }, }, ]); ``` ## Rule Details Disallow multiple spaces in regular expressions. Two or more consecutive space characters are hard to count by eye; an explicit `{n}` quantifier expresses the same pattern unambiguously. The rule applies to both regex literals and the `RegExp` / `new RegExp` constructors (skipped when `RegExp` is shadowed in the enclosing scope or when the flags argument cannot be statically determined). Consecutive spaces inside character classes (`[...]`) are intentionally allowed and not reported. Examples of **incorrect** code for this rule: ```javascript var re = /foo bar/; var re = new RegExp('foo bar'); ``` Examples of **correct** code for this rule: ```javascript var re = /foo {3}bar/; var re = new RegExp('foo {3}bar'); var re = /[ ]/; ``` ## Autofix When the parsed pattern and the raw source text agree (typically any regex literal, and `RegExp` / `new RegExp` calls whose pattern string contains no escape sequences), the rule rewrites ` ` into ` {n}`. When the pattern contains escape sequences that differ from the raw source (e.g. `new RegExp('\\d ')`), the rule reports but does not autofix — the index into the parsed pattern would not map cleanly back to source positions. ## Differences from ESLint - Constructor patterns using capture names or Unicode properties newer than the bundled TypeScript parser's Unicode data can be skipped. - For a constructor pattern with a negated `v` class where a range is followed by a string-valued operand, rslint skips a report that ESLint may emit because JavaScript rejects the pattern. ## Original Documentation - [ESLint: no-regex-spaces](https://eslint.org/docs/latest/rules/no-regex-spaces) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-regex-spaces.js) --- url: /rules/eslint/no-restricted-exports.md --- # no-restricted-exports [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-restricted-exports': 'error', }, }, ]); ``` ## Rule Details In a project, certain names may be disallowed from being used as exported names for various reasons. This rule disallows specified names from being used as exported names. ## Options By default, this rule doesn't disallow any names. Only the names you specify in the configuration will be disallowed. This rule has an object option: - `"restrictedNamedExports"` is an array of strings, where each string is a name to be restricted. - `"restrictedNamedExportsPattern"` is a string representing a regular expression pattern. Named exports matching this pattern will be restricted. This option does not apply to `default` named exports. - `"restrictDefaultExports"` is an object option with boolean properties to restrict certain default export declarations. The option works only if the `restrictedNamedExports` option does not contain the `"default"` value. The following properties are allowed: - `direct`: restricts `export default` declarations. - `named`: restricts `export { foo as default };` declarations. - `defaultFrom`: restricts `export { default } from 'foo';` declarations. - `namedFrom`: restricts `export { foo as default } from 'foo';` declarations. - `namespaceFrom`: restricts `export * as default from 'foo';` declarations. ### restrictedNamedExports Examples of **incorrect** code for the `"restrictedNamedExports"` option: ```json { "no-restricted-exports": ["error", { "restrictedNamedExports": ["foo", "bar", "Baz", "a", "b", "c", "d", "e", "👍"] }] } ``` ```javascript export const foo = 1; export function bar() {} export class Baz {} const a = {}; export { a }; function someFunction() {} export { someFunction as b }; export { c } from "some_module"; export { "d" } from "some_module"; export { something as e } from "some_module"; export { "👍" } from "some_module"; ``` Examples of **correct** code for the `"restrictedNamedExports"` option: ```json { "no-restricted-exports": ["error", { "restrictedNamedExports": ["foo", "bar", "Baz", "a", "b", "c", "d", "e", "👍"] }] } ``` ```javascript export const quux = 1; export function myFunction() {} export class MyClass {} const a = {}; export { a as myObject }; function someFunction() {} export { someFunction }; export { c as someName } from "some_module"; export { "d" as " d " } from "some_module"; export { something } from "some_module"; export { "👍" as thumbsUp } from "some_module"; ``` #### Default exports By design, the `"restrictedNamedExports"` option doesn't disallow `export default` declarations. If you configure `"default"` as a restricted name, that restriction will apply only to named export declarations. Examples of additional **incorrect** code for the `"restrictedNamedExports": ["default"]` option: ```json { "no-restricted-exports": ["error", { "restrictedNamedExports": ["default"] }] } ``` ```javascript function foo() {} export { foo as default }; ``` ```json { "no-restricted-exports": ["error", { "restrictedNamedExports": ["default"] }] } ``` ```javascript export { default } from "some_module"; ``` Examples of additional **correct** code for the `"restrictedNamedExports": ["default"]` option: ```json { "no-restricted-exports": ["error", { "restrictedNamedExports": ["default", "foo"] }] } ``` ```javascript export default function foo() {} ``` ### restrictedNamedExportsPattern Example of **incorrect** code for the `"restrictedNamedExportsPattern"` option: ```json { "no-restricted-exports": ["error", { "restrictedNamedExportsPattern": "bar$" }] } ``` ```javascript export const foobar = 1; ``` Example of **correct** code for the `"restrictedNamedExportsPattern"` option: ```json { "no-restricted-exports": ["error", { "restrictedNamedExportsPattern": "bar$" }] } ``` ```javascript export const abc = 1; ``` Note that this option does not apply to `export default` or any `default` named exports. If you want to also restrict `default` exports, use the `restrictDefaultExports` option. ### restrictDefaultExports This option allows you to restrict certain `default` declarations. The option works only if the `restrictedNamedExports` option does not contain the `"default"` value. This option accepts the following properties: #### direct Examples of **incorrect** code for the `"restrictDefaultExports": { "direct": true }` option: ```json { "no-restricted-exports": ["error", { "restrictDefaultExports": { "direct": true } }] } ``` ```javascript export default foo; ``` ```javascript export default 42; ``` ```javascript export default function foo() {} ``` #### named Examples of **incorrect** code for the `"restrictDefaultExports": { "named": true }` option: ```json { "no-restricted-exports": ["error", { "restrictDefaultExports": { "named": true } }] } ``` ```javascript const foo = 123; export { foo as default }; ``` #### defaultFrom Examples of **incorrect** code for the `"restrictDefaultExports": { "defaultFrom": true }` option: ```json { "no-restricted-exports": ["error", { "restrictDefaultExports": { "defaultFrom": true } }] } ``` ```javascript export { default } from "foo"; ``` ```javascript export { default as default } from "foo"; ``` #### namedFrom Examples of **incorrect** code for the `"restrictDefaultExports": { "namedFrom": true }` option: ```json { "no-restricted-exports": ["error", { "restrictDefaultExports": { "namedFrom": true } }] } ``` ```javascript export { foo as default } from "foo"; ``` #### namespaceFrom Examples of **incorrect** code for the `"restrictDefaultExports": { "namespaceFrom": true }` option: ```json { "no-restricted-exports": ["error", { "restrictDefaultExports": { "namespaceFrom": true } }] } ``` ```javascript export * as default from "foo"; ``` ## Known Limitations This rule doesn't inspect the content of source modules in re-export declarations. In particular, if you are re-exporting everything from another module's export, that export may include a restricted name. This rule cannot detect such cases. ```javascript //----- some_module.js ----- export function foo() {} //----- my_module.js ----- // { "restrictedNamedExports": ["foo"] } export * from "some_module"; // allowed, although this declaration exports "foo" from my_module ``` This rule inspects named export declarations purely syntactically, matching ESLint's behavior: named exports of TypeScript-only declarations (`interface`, `type`, `enum`) are not checked, but `export type { name }` re-export specifiers are checked the same as value exports. A named export of a function declaration with no body is treated the same way, so overload signatures, `export declare function`, and the function declarations of a `.d.ts` are left to the implementation signature that carries the body. `export default interface Foo {}` is a default export, and so is governed by `restrictDefaultExports.direct` rather than by `restrictedNamedExports`. ## Original Documentation - [ESLint: no-restricted-exports](https://eslint.org/docs/latest/rules/no-restricted-exports) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-restricted-exports.js) --- url: /rules/eslint/no-restricted-globals.md --- # no-restricted-globals [Added in v0.7.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-restricted-globals': 'error', }, }, ]); ``` ## Rule Details Disallows specified global variable names. This is useful when a project wants to allow globals in general but forbid specific ones — for example, banning the deprecated global `event` in favor of an explicit handler parameter, or banning ambiguous DOM globals like `name` or `length`. Examples of **incorrect** code for this rule with `["error", "event", "fdescribe"]`: ```javascript function onClick() { console.log(event); } fdescribe("foo", function () {}); ``` Examples of **correct** code for this rule with `["error", "event"]`: ```javascript import event from "event-module"; const event2 = 1; ``` A direct restricted name does not need to be declared through [`languageOptions.globals`](/config/language-options.md#languageoptionsglobals): an unshadowed `event` reference is still reported, while a local declaration or import is not. With `checkGlobalObject`, the receiver must be an active global for the file. For example, select `globals.browser` from `@rslint/core` to check `window.foo`, or `globals.worker` to check `self.foo`; no host environment is enabled by default. The rule also accepts an object form so a custom message can be attached to each restricted name: ```json { "no-restricted-globals": ["error", { "name": "event", "message": "Use the local event parameter instead." }] } ``` ```javascript function onClick() { console.log(event); } ``` ## Options The rule accepts either an array of names/objects, or a single object with the following properties: - `globals` — array of restricted names; each entry is either a string or `{ name, message? }`. - `checkGlobalObject` — when `true`, also flags access through a global object (`window.foo`, `self.foo`, `globalThis.foo`, and any names configured via `globalObjects`). Defaults to `false`. - `globalObjects` — additional global object names to check when `checkGlobalObject` is enabled. `globalThis`, `self`, and `window` are always included. Examples of **incorrect** code for this rule with `{ "globals": ["Promise"], "checkGlobalObject": true }`: ```json { "no-restricted-globals": ["error", { "globals": ["Promise"], "checkGlobalObject": true }] } ``` ```javascript globalThis.Promise; self.Promise; window.Promise; ``` Examples of **incorrect** code for this rule with a custom `globalObjects` entry: ```json { "no-restricted-globals": [ "error", { "globals": ["Promise"], "checkGlobalObject": true, "globalObjects": ["myGlobal"] } ] } ``` ```javascript myGlobal.Promise; ``` ## Original Documentation - [ESLint: no-restricted-globals](https://eslint.org/docs/latest/rules/no-restricted-globals) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-restricted-globals.js) --- url: /rules/eslint/no-restricted-imports.md --- # no-restricted-imports [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-restricted-imports': 'error', }, }, ]); ``` ## Rule Details Disallow specified modules when loaded by `import`. This rule allows you to specify imports that you don't want to use in your application. This can be useful if you want to restrict usage of certain modules, enforce alternatives, or prevent accidental use of deprecated APIs. Examples of **incorrect** code for this rule with `["error", "fs"]`: ```javascript import fs from 'fs'; export * from 'fs'; ``` Examples of **correct** code for this rule with `["error", "fs"]`: ```javascript import crypto from 'crypto'; ``` ## Options The rule accepts either an array of strings/objects or an object with `paths` and `patterns` properties. ### String format ```json { "no-restricted-imports": ["error", "fs", "path"] } ``` ### Object format with paths and patterns ```json { "no-restricted-imports": [ "error", { "paths": [ { "name": "import-foo", "importNames": ["Bar"], "message": "Please use Bar from /import-bar/ instead." } ], "patterns": [ { "group": ["import1/private/*"], "message": "usage of import1 private modules not allowed." } ] } ] } ``` ### Path options - `name` (required): The module name to restrict - `message`: Custom message to display - `importNames`: Restrict specific named exports - `allowImportNames`: Allow only specified named exports - `allowTypeImports`: Allow type-only imports (TypeScript) ### Pattern options - `group`: Gitignore-style patterns - `regex`: Regular expression pattern - `message`: Custom message to display - `caseSensitive`: Case-sensitive matching (default: false) - `importNames`: Restrict specific named imports - `importNamePattern`: Regex pattern for import names - `allowImportNames`: Allow only specified named imports - `allowImportNamePattern`: Regex pattern for allowed import names - `allowTypeImports`: Allow type-only imports (TypeScript) ## Original Documentation - [ESLint: no-restricted-imports](https://eslint.org/docs/latest/rules/no-restricted-imports) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-restricted-imports.js) --- url: /rules/eslint/no-restricted-properties.md --- # no-restricted-properties [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-restricted-properties': 'error', }, }, ]); ``` ## Rule Details Certain properties on objects may be disallowed in a codebase. This is useful for deprecating an API or restricting usage of a module's methods — for example, disallowing `describe.only` when using Mocha, or steering people toward `Object.assign` instead of `_.extend`. This rule looks for accessing a given property key on a given object name, either when reading the property's value or invoking it as a function. It applies to both dot/bracket property access and destructuring. The rule takes a list of objects, where the object name and property name are specified: ```json { "no-restricted-properties": ["error", { "object": "disallowedObjectName", "property": "disallowedPropertyName" }] } ``` Multiple object/property pairs can be disallowed, and each can specify an optional custom message: ```json { "no-restricted-properties": [ "error", { "object": "disallowedObjectName", "property": "disallowedPropertyName" }, { "object": "disallowedObjectName", "property": "anotherDisallowedPropertyName", "message": "Please use allowedObjectName.allowedPropertyName." } ] } ``` Examples of **incorrect** code for this rule: ```javascript const example = disallowedObjectName.disallowedPropertyName; disallowedObjectName.disallowedPropertyName(); ``` Examples of **correct** code for this rule: ```javascript const example = disallowedObjectName.somePropertyName; allowedObjectName.disallowedPropertyName(); ``` If the object name is omitted, the property is disallowed on every object: ```json { "no-restricted-properties": ["error", { "property": "__defineGetter__", "message": "Please use Object.defineProperty instead." }] } ``` If the property name is omitted, every property access on the given object is disallowed: ```json { "no-restricted-properties": ["error", { "object": "require", "message": "Please call require() directly." }] } ``` Examples of **incorrect** code for this rule with `{ "object": "require" }`: ```javascript require.resolve("foo"); ``` Examples of **correct** code for this rule with `{ "object": "require" }`: ```javascript require("foo"); ``` To restrict a property globally but allow specific objects to use it, add `allowObjects` (mutually exclusive with `object`): ```json { "no-restricted-properties": ["error", { "property": "push", "allowObjects": ["router", "history"], "message": "Prefer [...array, newValue]." }] } ``` Examples of **incorrect** code for this rule with `{ "property": "push", "allowObjects": ["router", "history"] }`: ```javascript myArray.push(5); ``` Examples of **correct** code for this rule with `{ "property": "push", "allowObjects": ["router", "history"] }`: ```javascript router.push("/home"); history.push("/about"); ``` To restrict every property on an object except a chosen few, add `allowProperties` (mutually exclusive with `property`): ```json { "no-restricted-properties": ["error", { "object": "config", "allowProperties": ["settings", "version"] }] } ``` Examples of **incorrect** code for this rule with `{ "object": "config", "allowProperties": ["settings", "version"] }`: ```javascript config.apiKey = "12345"; ``` Examples of **correct** code for this rule with `{ "object": "config", "allowProperties": ["settings", "version"] }`: ```javascript config.settings = { theme: "dark" }; config.version = "1.0.0"; ``` ## When Not To Use It If you don't have any object/property combinations to restrict, you should not use this rule. ## Original Documentation - [ESLint: no-restricted-properties](https://eslint.org/docs/latest/rules/no-restricted-properties) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-restricted-properties.js) --- url: /rules/eslint/no-restricted-syntax.md --- # no-restricted-syntax [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-restricted-syntax': 'error', }, }, ]); ``` ## Rule Details Disallows specified syntax. The rule accepts a list of [esquery] selectors; any AST node matching one of the listed selectors triggers a diagnostic with either a default or user-supplied message. This is the catch-all rule for restricting language constructs (e.g. banning `with`, banning `for-in`, requiring named function declarations) without having to write a dedicated rule. The core selector grammar follows ESLint's esquery-based implementation. Examples of **incorrect** code for this rule: ```json { "no-restricted-syntax": [ "error", "FunctionExpression", "WithStatement" ] } ``` ```javascript with (me) { dontMess(); } const doSomething = function () {}; ``` Examples of **correct** code for the same configuration: ```javascript me.dontMess(); function doSomething() {} foo instanceof bar; ``` ## Options The rule accepts an array of restriction entries. Each entry is either: - A bare string — the esquery selector. The diagnostic message is `Using '' is not allowed.`. - An object `{ "selector": , "message"?: }`. When `message` is provided it replaces the default text verbatim. ```json { "no-restricted-syntax": [ "error", { "selector": "CallExpression[callee.name='setTimeout']", "message": "Use the timer service instead of raw setTimeout." }, "WithStatement" ] } ``` ### Supported selector forms The implementation follows the esquery 1.7 selector forms used by ESLint 10.10.0, including the complete upstream `no-restricted-syntax` test suite. Malformed selectors are a deliberate compatibility divergence: rslint drops the malformed entry so one bad selector does not disable the rest of the configuration, while ESLint rejects the whole rule configuration: - ESTree node names (e.g. `Identifier`, `FunctionDeclaration`, `BinaryExpression`) and supported TS-ESTree names such as `TSEnumDeclaration`. ESTree-only wrapper shapes such as `ClassBody`, `JSXEmptyExpression`, `ChainExpression`, and `MethodDefinition.value` are exposed as virtual facades over the tsgo AST. Bodyless class methods expose `TSEmptyBodyFunctionExpression` as their value. - Wildcard `*`. - Field selectors, including nested fields (e.g. `Literal.key` and `.body.declarations.init`). - Attribute selectors with presence (`[label]`), equality (`[name="x"]`, `[kind='using']`), inequality (`!=`), numeric comparisons (`[params.length>2]`), numeric path segments (`[arguments.0.type='Literal']`), `type(...)`, and regex matching (`[regex.flags=/i/]`). Attribute paths may inspect ESLint's `parent` link. BigInt values retain their JavaScript type: `Literal[value=type(bigint)]` selects them, while a string regex equality selector does not. Class-method function fields are available through selectors such as `MethodDefinition[value.body.body.length=0]`. - Combinators `>` (direct child), descendant whitespace, `+` (adjacent sibling), `~` (general sibling), including decorator selectors such as `Decorator > CallExpression[callee.name='sealed']`. - The `!` subject marker, including its reverse sibling/adjacent matching behavior, and ESLint's `:exit` event suffix. - Pseudo-classes `:is()`, `:matches()`, `:not()`, `:has()`, `:first-child`, `:last-child`, `:nth-child(N)`, `:nth-last-child(N)`, and the semantic classes `:statement`, `:expression`, `:declaration`, `:function`, and `:pattern`. ## AST representation note tsgo does not allocate separate nodes for every ESTree wrapper. Direct selectors and structural relationships for those wrappers are modeled, with ESLint-compatible ranges. The bare `*` selector retains the engine's physical tsgo traversal, which starts at the program's children and does not emit additional diagnostics for virtual wrappers. Other broad selectors evaluate each supported ESTree identity separately. `Program` and `Program:exit` can select the program itself. TS-ESTree coverage is limited to the supported node mappings; the rule does not materialize every TypeScript type annotation or type-parameter wrapper. Broad selectors on type-only syntax can therefore differ from the TypeScript ESLint parser. Runtime receiver attribute paths retain their existing behavior of looking through TypeScript assertions, such as `(console as any).log()`. ## Original Documentation - [ESLint: no-restricted-syntax](https://eslint.org/docs/latest/rules/no-restricted-syntax) - [Source code](https://github.com/eslint/eslint/blob/v10.10.0/lib/rules/no-restricted-syntax.js) [esquery]: https://github.com/estools/esquery --- url: /rules/eslint/no-return-assign.md --- # no-return-assign [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-return-assign': 'error', }, }, ]); ``` ## Rule Details This rule aims to eliminate assignments from `return` statements, because it is difficult to tell whether the author intended an assignment or a mistyped comparison. Examples of **incorrect** code for this rule: ```javascript function doSomething() { return foo = bar + 2; } function doSomethingElse() { return foo += 2; } const foo = (a, b) => a = b; const bar = (a, b, c) => (a = b, c == b); function doSomethingMore() { return foo = bar && foo > 0; } ``` Examples of **correct** code for this rule: ```javascript function doSomething() { return foo == bar + 2; } function doSomethingMore() { return (foo = bar + 2); } const foo = (a, b) => (a = b); const bar = (a, b, c) => ((a = b), c == b); function doAnotherThing() { return (foo = bar) && foo > 0; } ``` ## Options This rule takes a single string option: - `"except-parens"` (default) — disallow assignments in `return` statements unless they are enclosed in parentheses. - `"always"` — disallow all assignments in `return` statements, even when parenthesised. Examples of **incorrect** code for this rule with `"always"`: ```json { "no-return-assign": ["error", "always"] } ``` ```javascript function doSomething() { return foo = bar + 2; } function doSomethingMore() { return (foo = bar + 2); } ``` Examples of **correct** code for this rule with `"always"`: ```json { "no-return-assign": ["error", "always"] } ``` ```javascript function doSomething() { return foo == bar + 2; } ``` ## Original Documentation - [ESLint: no-return-assign](https://eslint.org/docs/latest/rules/no-return-assign) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-return-assign.js) --- url: /rules/eslint/no-script-url.md --- # no-script-url [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-script-url': 'error', }, }, ]); ``` ## Rule Details Disallow `javascript:` URLs. Using `javascript:` URLs is considered by some as a form of `eval`. Code passed in `javascript:` URLs has to be parsed and evaluated by the browser in the same way that `eval` is processed. Examples of **incorrect** code for this rule: ```javascript location.href = 'javascript:void(0)'; location.href = `javascript:void(0)`; ``` Examples of **correct** code for this rule: ```javascript location.href = 'https://example.com'; ``` ## Original Documentation - [ESLint: no-script-url](https://eslint.org/docs/latest/rules/no-script-url) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-script-url.js) --- url: /rules/eslint/no-self-assign.md --- # no-self-assign [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-self-assign': 'error', }, }, ]); ``` ## Rule Details Disallow assignments where both sides are exactly the same. Self-assignments have no effect, so they are probably errors due to incomplete refactoring. Examples of **incorrect** code for this rule: ```javascript a = a; [a, b] = [a, b]; [a, ...b] = [a, ...b]; ({ a } = { a }); ({ a: b } = { a: b }); a.b = a.b; a.b.c = a.b.c; a[0] = a[0]; a.b = a['b']; a &&= a; a ||= a; a ??= a; ``` Examples of **correct** code for this rule: ```javascript a = b; [a, b] = [b, a]; a.b = a.c; a.b = c.b; a += a; a = +a; a.b = a?.b; // considered self-assignment ``` ## Options This rule has an object option: - `props` (boolean, default: `true`): When `true`, checks member expression (property access and element access) self-assignments such as `a.b = a.b` and `a[0] = a[0]`. Set to `false` to disable property checks. Examples of **correct** code with `{ "props": false }`: ```javascript a.b = a.b; a[0] = a[0]; this.x = this.x; ``` ## Differences from ESLint - A TypeScript non-null assertion (`!`) has no runtime effect, so it is treated the same as a bare reference. For example, `a!.b = a.b;` is flagged as a self-assignment. ## Original Documentation - [ESLint: no-self-assign](https://eslint.org/docs/latest/rules/no-self-assign) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-self-assign.js) --- url: /rules/eslint/no-self-compare.md --- # no-self-compare [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-self-compare': 'error', }, }, ]); ``` ## Rule Details Disallows comparing a value to itself using any of the equality or relational operators (`===`, `==`, `!==`, `!=`, `>`, `<`, `>=`, `<=`). Such a comparison is typically a typo (the programmer likely meant a different operand) and is either always true, always false, or always `NaN`-sensitive, so the check is pointless. Examples of **incorrect** code for this rule: ```javascript var x = 10; if (x === x) { } if (x !== x) { } if (foo.bar().baz.qux >= foo.bar().baz.qux) { } ``` Examples of **correct** code for this rule: ```javascript var x = 10; var y = 10; if (x === y) { } if (foo.bar.baz === foo.bar.qux) { } class C { #field; foo() { // Property access via private identifier and bracket string literal // are structurally distinct and allowed. return this.#field === this["#field"]; } } ``` ## Original Documentation - [ESLint: no-self-compare](https://eslint.org/docs/latest/rules/no-self-compare) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-self-compare.js) --- url: /rules/eslint/no-sequences.md --- # no-sequences [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-sequences': 'error', }, }, ]); ``` ## Rule Details This rule forbids the use of the comma operator, with the following exceptions: - In the initialization or update portions of a `for` statement. - By default, if the expression sequence is explicitly wrapped in parentheses. This exception can be removed with the `"allowInParentheses": false` option. Examples of **incorrect** code for this rule: ```javascript foo = doSomething(), val; 0, eval("doSomething();"); do {} while (doSomething(), !!test); for (; doSomething(), !!test; ); if (doSomething(), !!test); switch (val = foo(), val) {} while (val = foo(), val < 42); with (doSomething(), val) {} const foo = (val) => (console.log('bar'), val); ``` Examples of **correct** code for this rule: ```javascript foo = (doSomething(), val); (0, eval)("doSomething();"); do {} while ((doSomething(), !!test)); for (i = 0, j = 10; i < j; i++, j--); if ((doSomething(), !!test)); switch ((val = foo(), val)) {} while ((val = foo(), val < 42)); with ((doSomething(), val)) {} const foo = (val) => ((console.log('bar'), val)); ``` ## Options This rule takes one optional object argument: - `allowInParentheses` — when set to `false`, disallows expression sequences even when explicitly wrapped in parentheses. Default `true`. Examples of **incorrect** code for this rule with `{ "allowInParentheses": false }`: ```json { "no-sequences": ["error", { "allowInParentheses": false }] } ``` ```javascript var foo = (1, 2); (0, eval)("doSomething();"); foo(a, (b, c), d); ``` ## Original Documentation - [ESLint: no-sequences](https://eslint.org/docs/latest/rules/no-sequences) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-sequences.js) --- url: /rules/eslint/no-setter-return.md --- # no-setter-return [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-setter-return': 'error', }, }, ]); ``` ## Rule Details Disallows returning a value from a setter. Setters cannot meaningfully return values since any return value is silently ignored by the JavaScript engine. A bare `return;` (without a value) is allowed for control flow purposes. Examples of **incorrect** code for this rule: ```javascript var foo = { set a(val) { return 1; }, }; class A { set a(val) { return val; } } var bar = { set a(val) { return undefined; }, }; ``` Examples of **correct** code for this rule: ```javascript var foo = { set a(val) { val = 1; }, }; class A { set a(val) { if (!val) { return; // bare return for flow control is fine } this._a = val; } } class B { get a() { return this._a; // getters can return values } } ``` ## Original Documentation - [ESLint: no-setter-return](https://eslint.org/docs/latest/rules/no-setter-return) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-setter-return.js) --- url: /rules/eslint/no-shadow.md --- # no-shadow [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-shadow': 'error', }, }, ]); ``` Disallow variable declarations from shadowing variables declared in the outer scope. ## Rule Details Shadowing occurs when a local variable shares the same name as a variable in its containing scope. Inside the inner scope, the outer variable becomes inaccessible, which can be a source of confusion. Examples of **incorrect** code for this rule: ```javascript var a = 3; function b() { var a = 10; } ``` Examples of **correct** code for this rule: ```javascript var a = 3; function b() { var c = 10; } ``` ## Options ### `builtinGlobals` Shadowing a built-in global (for example `Object`, `Array`) is reported when this option is `true`. Default: `false`. Configured [`languageOptions.globals`](/config/language-options.md#languageoptionsglobals) and active `/* global */` directives participate as built-in globals; an explicit `"off"` setting un-declares the name, so shadowing it is no longer reported. Use the `globals` catalog exported by `@rslint/core` to add browser, Node.js, worker, or other environment names. ```json { "no-shadow": ["error", { "builtinGlobals": true }] } ``` ```javascript function foo() { var Object = 0; } ``` ### `hoist` Controls whether shadowing is reported before the outer declaration. Default: `"functions"`. - `"functions"`: report only before function declarations. - `"all"`: always report, even when the outer declaration appears after the inner one. - `"never"`: never report before the outer declaration. - `"types"`: report when the outer declaration is a type (`type` or `interface`). - `"functions-and-types"`: report for both outer function declarations and type declarations. ### `allow` Array of names for which shadowing is allowed. Default: `[]`. ```json { "no-shadow": ["error", { "allow": ["done"] }] } ``` ### `ignoreOnInitialization` Ignores shadowing inside the initializer of the outer declaration when it is called as a callback or IIFE. Default: `false`. ```json { "no-shadow": ["error", { "ignoreOnInitialization": true }] } ``` ### `ignoreTypeValueShadow` Ignores shadowing between a value and a type of the same name (TypeScript). Default: `true`. ### `ignoreFunctionTypeParameterNameValueShadow` Ignores shadowing for parameters declared inside a function type. Default: `true`. ## Original Documentation - [ESLint: no-shadow](https://eslint.org/docs/latest/rules/no-shadow) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-shadow.js) --- url: /rules/eslint/no-shadow-restricted-names.md --- # no-shadow-restricted-names [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-shadow-restricted-names': 'error', }, }, ]); ``` ## Rule Details ECMAScript defines several special names that should not be redefined by user code: `NaN`, `Infinity`, `undefined`, `eval`, `arguments`, and `globalThis`. Shadowing these restricted names obscures runtime globals and makes programs harder to reason about. This rule disallows shadowing of these restricted names by variable declarations, function names, function parameters, catch clause parameters, imported bindings, and class names. Examples of **incorrect** code for this rule: ```javascript function NaN() {} !function (Infinity) {}; var undefined = 5; try {} catch (eval) {} class globalThis {} import undefined from "foo"; ``` Examples of **correct** code for this rule: ```javascript var Object; function f(a, b) {} // A declaration that doesn't assign a value to `undefined` is safe: var undefined; ``` ### Options This rule has an object option: - `"reportGlobalThis": true` (default) — report shadowing of `globalThis`. - `"reportGlobalThis": false` — allow shadowing `globalThis`. Examples of **correct** code for this rule with `{ "reportGlobalThis": false }`: ```json { "no-shadow-restricted-names": ["error", { "reportGlobalThis": false }] } ``` ```javascript let globalThis; class globalThis {} import { baz as globalThis } from "foo"; ``` ## Original Documentation - [ESLint: no-shadow-restricted-names](https://eslint.org/docs/latest/rules/no-shadow-restricted-names) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-shadow-restricted-names.js) --- url: /rules/eslint/no-sparse-arrays.md --- # no-sparse-arrays [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-sparse-arrays': 'error', }, }, ]); ``` ## Rule Details Disallows sparse arrays, which are array literals that contain empty slots created by extra commas. Sparse arrays can be confusing because the empty slots are `undefined` but behave differently from explicitly setting an element to `undefined` (for example, `Array.prototype.forEach` skips sparse entries). Extra commas are usually a typo. Examples of **incorrect** code for this rule: ```javascript var items = [1, , 3]; var colors = ['red', , 'blue']; ``` Examples of **correct** code for this rule: ```javascript var items = [1, 2, 3]; var colors = ['red', 'blue']; var arr = [1, undefined, 3]; // explicit undefined is fine ``` ## Original Documentation - [ESLint: no-sparse-arrays](https://eslint.org/docs/latest/rules/no-sparse-arrays) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-sparse-arrays.js) --- url: /rules/eslint/no-template-curly-in-string.md --- # no-template-curly-in-string [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-template-curly-in-string': 'error', }, }, ]); ``` ## Rule Details Disallows template literal placeholder syntax (`${expression}`) inside regular strings. This is almost always a mistake where the developer intended to use a template literal (backtick-delimited string) but accidentally used single or double quotes instead, so the placeholder is treated as a literal string rather than being interpolated. Examples of **incorrect** code for this rule: ```javascript var greeting = 'Hello, ${name}!'; var query = 'SELECT * FROM ${table}'; var msg = 'The value is ${a + b}'; ``` Examples of **correct** code for this rule: ```javascript var greeting = `Hello, ${name}!`; var query = `SELECT * FROM ${table}`; var literal = 'This is a dollar sign: ${}'; // intentional ``` ## Original Documentation - [ESLint: no-template-curly-in-string](https://eslint.org/docs/latest/rules/no-template-curly-in-string) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-template-curly-in-string.js) --- url: /rules/eslint/no-ternary.md --- # no-ternary [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-ternary': 'error', }, }, ]); ``` ## Rule Details This rule disallows ternary operators. Examples of **incorrect** code for this rule: ```javascript const foo = isBar ? baz : qux; function quux() { return foo ? bar() : baz(); } ``` Examples of **correct** code for this rule: ```javascript let foo; if (isBar) { foo = baz; } else { foo = qux; } function quux() { if (foo) { return bar(); } else { return baz(); } } ``` ## Original Documentation - [ESLint: no-ternary](https://eslint.org/docs/latest/rules/no-ternary) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-ternary.js) --- url: /rules/eslint/no-this-before-super.md --- # no-this-before-super [Added in v0.3.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.3) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-this-before-super': 'error', }, }, ]); ``` ## Rule Details Disallows use of `this` or `super` (for property access like `super.foo`) before calling `super()` in constructors of derived classes. In a derived class (a class that extends another class), the constructor must call `super()` before accessing `this` or `super` for property access. Accessing `this` or `super` before `super()` has been called will throw a `ReferenceError` at runtime. Examples of **incorrect** code for this rule: ```javascript class A extends B { constructor() { this.a = 0; // "this" before "super()" super(); } } class A extends B { constructor() { super.foo(); // "super" property access before "super()" super(); } } class A extends B { constructor() { super(this.a); // "this" in super() arguments } } ``` Examples of **correct** code for this rule: ```javascript class A extends B { constructor() { super(); this.a = 0; } } class A { constructor() { this.a = 0; // OK - not a derived class } } class A extends B { constructor() { super(); super.foo(); } } ``` ## Original Documentation - [ESLint: no-this-before-super](https://eslint.org/docs/latest/rules/no-this-before-super) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-this-before-super.js) --- url: /rules/eslint/no-throw-literal.md --- # no-throw-literal [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-throw-literal': 'error', }, }, ]); ``` ## Rule Details This rule restricts what can be thrown as an exception. When ESLint was originally written, only literals were forbidden, but the rule has since been expanded to disallow any expression which cannot possibly be an `Error` object. Examples of **incorrect** code for this rule: ```javascript throw "error"; throw 0; throw undefined; throw null; const err = new Error(); throw "an " + err; const err2 = new Error(); throw `${err2}`; ``` Examples of **correct** code for this rule: ```javascript throw new Error(); throw new Error("error"); const e = new Error("error"); throw e; try { throw new Error("error"); } catch (e) { throw e; } ``` ## Original Documentation - [ESLint: no-throw-literal](https://eslint.org/docs/latest/rules/no-throw-literal) - [Source code](https://github.com/eslint/eslint/blob/v10.2.1/lib/rules/no-throw-literal.js) --- url: /rules/eslint/no-unassigned-vars.md --- # no-unassigned-vars [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-unassigned-vars': 'error', }, }, ]); ``` ## Rule Details This rule reports `let` and `var` variables that are read but never assigned a value. These variables are always `undefined`, so reading them is usually a programming mistake. Examples of **incorrect** code for this rule: ```javascript let status; if (status === "ready") { console.log("Ready!"); } let user; greet(user); function test() { let error; return error || "Unknown error"; } ``` Examples of **correct** code for this rule: ```javascript let message = "hello"; console.log(message); let user; user = getUser(); console.log(user.name); let temp; ``` Examples of **correct** TypeScript code for this rule: ```typescript declare let value: number | undefined; console.log(value); declare module "my-module" { let value: string; export = value; } ``` ## Options This rule has no options. ## Original Documentation - [ESLint: no-unassigned-vars](https://eslint.org/docs/latest/rules/no-unassigned-vars) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-unassigned-vars.js) --- url: /rules/eslint/no-undef.md --- # no-undef [Added in v0.3.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.3) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-undef': 'error', }, }, ]); ``` Disallow the use of undeclared variables. This rule reports identifiers that reference variables which have not been declared via `var`, `let`, `const`, `function`, `class`, `import`, or as a parameter. Resolution follows ESLint scope semantics: bindings declared or imported in the current file, the standard language globals selected by `languageOptions.ecmaVersion`, and names declared through [`languageOptions.globals`](/config/language-options.md#languageoptionsglobals) or a `/* global */` comment. `ecmaVersion` defaults to `"latest"`. TypeScript's TypeChecker does not alter the result. DOM, Node, cross-file, and ambient `.d.ts` names are not implicit ESLint globals, even when TypeScript can resolve them. Declare host globals such as `console`, `window`, `process`, and `setTimeout` through `languageOptions.globals` or a `/* global */` comment. TypeScript projects normally leave this core rule disabled because `tsc` already reports undeclared names. For browser, Node.js, worker, and other runtime names, use the `globals` catalog exported by `@rslint/core` instead of listing every name manually. Scope each environment to the files where it exists; no runtime environment is enabled by default. See [Configuring runtime globals](/config/language-options.md#languageoptionsglobals) for examples. ## Options ### `typeof` Type: `boolean` Default: `false` When set to `true`, `typeof` expressions will be checked for undeclared variables. By default, `typeof` of an undeclared variable does not trigger a warning, since `typeof` returns `"undefined"` for undeclared variables without throwing a ReferenceError. ## Examples ### Invalid ```js a = 1; // 'a' is not defined. var x = b; // 'b' is not defined. undeclaredFunc(); // 'undeclaredFunc' is not defined. ``` With `{ "typeof": true }`: ```js typeof x === 'string'; // 'x' is not defined. ``` ### Valid ```js var a = 1; a; function f() {} f(); typeof maybeUndefined === 'string'; ``` ## Differences from ESLint - In TypeScript files, rslint applies `languageOptions.ecmaVersion` to runtime ECMAScript globals. ESLint with `@typescript-eslint/parser` uses that parser's default ESNext library instead. For example, with `ecmaVersion: 2019`, rslint reports `BigInt(1)` unless `BigInt` is configured as a global, while ESLint does not. With the default parser library, type-only ESNext names such as `Record` remain available in both. ## Original Documentation - [ESLint: no-undef](https://eslint.org/docs/latest/rules/no-undef) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/no-undef.js) --- url: /rules/eslint/no-undef-init.md --- # no-undef-init [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-undef-init': 'error', }, }, ]); ``` ## Rule Details Disallow initializing variables to `undefined`. In JavaScript, a variable that is declared and not initialized to any value automatically gets the value of `undefined`. It's therefore unnecessary to initialize a variable to `undefined`. This rule aims to eliminate `var` and `let` variable declarations that initialize to `undefined`. Examples of **incorrect** code for this rule: ```javascript var foo = undefined; let bar = undefined; ``` Examples of **correct** code for this rule: ```javascript var foo; let bar; const baz = undefined; ``` ## Differences from ESLint The autofix preserves TypeScript type annotations and definite assignment tokens. ESLint's fix removes from the end of the variable name to the end of the declarator, which in TypeScript would also remove any type annotation: ```typescript // ESLint autofix: let a: string = undefined; → let a; (type annotation lost) // rslint autofix: let a: string = undefined; → let a: string; (type annotation preserved) ``` ## Original Documentation - [ESLint: no-undef-init](https://eslint.org/docs/latest/rules/no-undef-init) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-undef-init.js) --- url: /rules/eslint/no-undefined.md --- # no-undefined [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-undefined': 'error', }, }, ]); ``` ## Rule Details Disallow the use of `undefined` as an identifier. The `undefined` variable in JavaScript is actually a property of the global object. As such, in ECMAScript 3 it was possible to overwrite the value of `undefined`. While ECMAScript 5 disallows overwriting `undefined`, it's still possible to shadow `undefined`, such as: ```javascript function doSomething(data) { const undefined = "hi"; // doesn't do what you think it does if (data === undefined) { // ... } } ``` Because `undefined` can be overwritten or shadowed, reading `undefined` can give an unexpected value. (This is not the case for `null`, which is a keyword that always produces the same value.) To guard against this, you can avoid all uses of `undefined`, which is what some style guides recommend and what this rule enforces. Those style guides then also recommend: - Variables that should be `undefined` are simply left uninitialized. (All uninitialized variables automatically get the value of `undefined` in JavaScript.) - Checking if a value is `undefined` should be done with `typeof`. - Using the `void` operator to generate the value of `undefined` if necessary. Examples of **incorrect** code for this rule: ```javascript const foo = undefined; const undefined = "foo"; if (foo === undefined) { // ... } function baz(undefined) { // ... } bar(undefined, "lorem"); ``` Examples of **correct** code for this rule: ```javascript const foo = void 0; const Undefined = "foo"; if (typeof foo === "undefined") { // ... } global.undefined = "foo"; bar(void 0, "lorem"); ``` ## Options This rule has no options. ## Differences from ESLint - A named class declaration whose name is `undefined` (`class undefined {}`) is reported once. ESLint reports the same position twice. - An assignment-destructuring pattern with a shorthand default whose name is `undefined` (e.g. `({ undefined = 1 } = target)`) is reported once. ESLint reports the same position twice. ## Original Documentation - [ESLint: no-undefined](https://eslint.org/docs/latest/rules/no-undefined) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-undefined.js) --- url: /rules/eslint/no-underscore-dangle.md --- # no-underscore-dangle [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-underscore-dangle': 'error', }, }, ]); ``` ## Rule Details This rule disallows dangling underscores in identifiers — an underscore at the beginning or the end of a name, such as `_foo` or `foo_`. A name that is exactly `_` is always allowed. By default the rule checks variable declarations, function declaration names, and member access. Function parameters, destructured names, method names, and class field names are each governed by an option. Examples of **incorrect** code for this rule: ```javascript let foo_; const __proto__ = {}; foo._bar(); ``` Examples of **correct** code for this rule: ```javascript const _ = require('underscore'); const obj = _.contains(items, item); obj.__proto__ = {}; const file = __filename; function foo(_bar) {} const bar = { onClick(_bar) {} }; const baz = (_bar) => {}; ``` ## Options This rule has an object option: - `"allow"` — a list of identifiers that may have dangling underscores - `"allowAfterThis": false` (default) — disallows dangling underscores in members of the `this` object - `"allowAfterSuper": false` (default) — disallows dangling underscores in members of the `super` object - `"allowAfterThisConstructor": false` (default) — disallows dangling underscores in members of the `this.constructor` object - `"enforceInMethodNames": false` (default) — allows dangling underscores in method names - `"enforceInClassFields": false` (default) — allows dangling underscores in class field names - `"allowInArrayDestructuring": true` (default) — allows dangling underscores in names bound by array destructuring - `"allowInObjectDestructuring": true` (default) — allows dangling underscores in names bound by object destructuring - `"allowFunctionParams": true` (default) — allows dangling underscores in function parameter names ### allow Examples of additional **correct** code for this rule with the `{ "allow": ["foo_", "_bar"] }` option: ```json { "no-underscore-dangle": ["error", { "allow": ["foo_", "_bar"] }] } ``` ```javascript let foo_; foo._bar(); ``` ### allowAfterThis Examples of **correct** code for this rule with the `{ "allowAfterThis": true }` option: ```json { "no-underscore-dangle": ["error", { "allowAfterThis": true }] } ``` ```javascript const a = this.foo_; this._bar(); ``` ### allowAfterSuper Examples of **correct** code for this rule with the `{ "allowAfterSuper": true }` option: ```json { "no-underscore-dangle": ["error", { "allowAfterSuper": true }] } ``` ```javascript class Foo extends Bar { doSomething() { const a = super.foo_; super._bar(); } } ``` ### allowAfterThisConstructor Examples of **correct** code for this rule with the `{ "allowAfterThisConstructor": true }` option: ```json { "no-underscore-dangle": ["error", { "allowAfterThisConstructor": true }] } ``` ```javascript const a = this.constructor.foo_; this.constructor._bar(); ``` ### enforceInMethodNames Examples of **incorrect** code for this rule with the `{ "enforceInMethodNames": true }` option: ```json { "no-underscore-dangle": ["error", { "enforceInMethodNames": true }] } ``` ```javascript class Foo { _bar() {} } class Bar { bar_() {} } const o1 = { _bar() {}, }; const o2 = { bar_() {}, }; ``` ### enforceInClassFields Examples of **incorrect** code for this rule with the `{ "enforceInClassFields": true }` option: ```json { "no-underscore-dangle": ["error", { "enforceInClassFields": true }] } ``` ```javascript class Foo { _bar; } class Bar { _bar = () => {}; } class Baz { bar_; } class Qux { #_bar; } class FooBar { #bar_; } ``` ### allowInArrayDestructuring Examples of **incorrect** code for this rule with the `{ "allowInArrayDestructuring": false }` option: ```json { "no-underscore-dangle": ["error", { "allowInArrayDestructuring": false }] } ``` ```javascript const [_foo, _bar] = list; const [foo_, ..._qux] = list; const [foo, [bar, _baz]] = list; ``` ### allowInObjectDestructuring Examples of **incorrect** code for this rule with the `{ "allowInObjectDestructuring": false }` option: ```json { "no-underscore-dangle": ["error", { "allowInObjectDestructuring": false }] } ``` ```javascript const { foo, bar: _bar } = collection; const { qux, xyz, _baz } = collection; ``` Examples of **correct** code for this rule with the `{ "allowInObjectDestructuring": false }` option: ```json { "no-underscore-dangle": ["error", { "allowInObjectDestructuring": false }] } ``` ```javascript const { foo, bar, _baz: { a, b }, } = collection; const { qux, xyz, _baz: baz } = collection; ``` ### allowFunctionParams Examples of **incorrect** code for this rule with the `{ "allowFunctionParams": false }` option: ```json { "no-underscore-dangle": ["error", { "allowFunctionParams": false }] } ``` ```javascript function foo1(_bar) {} function foo2(_bar = 0) {} function foo3(..._bar) {} const foo4 = function onClick(_bar) {}; const foo5 = function onClick(_bar = 0) {}; const foo6 = function onClick(..._bar) {}; const foo7 = (_bar) => {}; const foo8 = (_bar = 0) => {}; const foo9 = (..._bar) => {}; ``` ## TypeScript A member that only declares a signature has no implementation to name, so it is never reported: overload signatures, `declare function`, and `abstract` class members. The implementation that follows is checked as usual. ```json { "no-underscore-dangle": [ "error", { "enforceInMethodNames": true, "enforceInClassFields": true } ] } ``` ```typescript declare function _read(): void; abstract class Store { abstract _load(): void; abstract _cache: Map; } ``` A constructor parameter that also declares a property — one marked `private`, `protected`, `public`, `readonly`, or `override` — is exempt from `allowFunctionParams`. ```json { "no-underscore-dangle": ["error", { "allowFunctionParams": false }] } ``` ```typescript class Service { constructor(private readonly _http: Http) {} } ``` ## When Not To Use It If you want to allow dangling underscores in identifiers, then you can safely turn this rule off. ## Original Documentation - [ESLint: no-underscore-dangle](https://eslint.org/docs/latest/rules/no-underscore-dangle) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-underscore-dangle.js) --- url: /rules/eslint/no-unexpected-multiline.md --- # no-unexpected-multiline [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-unexpected-multiline': 'error', }, }, ]); ``` ## Rule Details JavaScript inserts semicolons automatically (ASI), but only at certain positions. When a line break appears between an expression and tokens like `(`, `[`, `` ` ``, or `/`, the parser treats the next line as a continuation rather than a new statement, which often surprises the author. This rule reports four cases where a newline produces an unintended continuation: - A function call where `(` opens on the next line. - A computed property access where `[` opens on the next line. - A tagged template where the `` ` `` opens on the next line. - A division by a value that visually resembles a regular-expression literal (e.g. `foo / bar /gym`), where what looks like a regex is actually parsed as two divisions. Examples of **incorrect** code for this rule: ```javascript var a = b (x || y).doSomething() var a = b [a, b, c].forEach(doSomething) let x = function() {} `hello` foo / bar /gym ``` Examples of **correct** code for this rule: ```javascript var a = b; (x || y).doSomething() var a = b; [a, b, c].forEach(doSomething) let x = function() {}; `hello` foo / bar / gym ``` ## Original Documentation - [ESLint: no-unexpected-multiline](https://eslint.org/docs/latest/rules/no-unexpected-multiline) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-unexpected-multiline.js) --- url: /rules/eslint/no-unmodified-loop-condition.md --- # no-unmodified-loop-condition [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-unmodified-loop-condition': 'error', }, }, ]); ``` ## Rule Details Disallows variables in loop conditions that are not modified by the loop. A modification may occur while evaluating the condition, in the loop body, or in a `for` loop's increment expression. If a variable used in a loop's test condition is never assigned to, incremented, or decremented in any of those places, it is likely a bug that leads to an infinite loop or incorrect termination. References nested inside function calls, member access expressions, `new` expressions, or `yield` expressions are skipped, since those may have side effects that modify the condition indirectly. Binary expression groups, and by default ternary expression groups, are also skipped when they contain one of those dynamic expressions or a tagged template. Examples of **incorrect** code for this rule: ```javascript var foo = 0; while (foo) { // foo is never modified doSomething(); } var bar = 0; do { doSomething(); } while (bar); for (var i = 0; i < 10; ) { // i is never modified, no incrementor doSomething(); } ``` Examples of **correct** code for this rule: ```javascript var foo = 0; while (foo) { foo++; } var bar = 0; do { bar = getNextValue(); } while (bar); var remaining = 10; while (remaining--) { processNext(); } for (var i = 0; i < 10; i++) { doSomething(); } // Function calls in condition are allowed (side effects possible) while (hasNext()) { process(); } // Member access in condition is allowed while (obj.ready) { process(); } ``` ## Options This rule accepts an object option with `checkConditionalExpressions`, which defaults to `false`. When `checkConditionalExpressions` is `true`, references in the test and branches of a ternary expression are checked independently instead of treating the whole ternary as one group. For example, this reports `done` because only `chunk` is modified: ```javascript /* rslint no-unmodified-loop-condition: ["error", { "checkConditionalExpressions": true }] */ let chunk = getInitialChunk(); let done = false; while (chunk ? !done : false) { chunk = nextOrNull(); } ``` ## Original Documentation - [ESLint: no-unmodified-loop-condition](https://eslint.org/docs/latest/rules/no-unmodified-loop-condition) - [Source code](https://github.com/eslint/eslint/blob/9ef407a3b051e74f50dc7fb8914e2bd89b3e5e53/lib/rules/no-unmodified-loop-condition.js) --- url: /rules/eslint/no-unneeded-ternary.md --- # no-unneeded-ternary [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-unneeded-ternary': 'error', }, }, ]); ``` ## Rule Details Disallows ternary expressions when a simpler alternative exists. Two patterns are flagged: - **Boolean-literal selection** — `cond ? true : false` (or any combination of boolean literals on both arms) collapses to `cond`, `!cond`, `!!cond`, or the boolean literal itself. Always reported. - **Default assignment** — `a ? a : b` is equivalent to `a || b`. Reported only when the `defaultAssignment` option is set to `false`. Examples of **incorrect** code for this rule: ```javascript var a = x === 2 ? true : false; var b = x ? true : false; ``` Examples of **correct** code for this rule: ```javascript var a = x === 2 ? "Yes" : "No"; var b = x !== false; var c = x ? "Yes" : "No"; var d = x ? y : x; ``` Examples of **incorrect** code for this rule with `{ "defaultAssignment": false }`: ```json { "no-unneeded-ternary": ["error", { "defaultAssignment": false }] } ``` ```javascript var a = x ? x : 1; f(x ? x : 1); ``` ## Options | Option | Type | Default | Description | | ------------------- | ------- | ------- | ---------------------------------------------------------------------------------------------- | | `defaultAssignment` | boolean | `true` | When `false`, also flag the `a ? a : b` default-assignment pattern (auto-fixed to `a \|\| b`). | ## Original Documentation - [ESLint: no-unneeded-ternary](https://eslint.org/docs/latest/rules/no-unneeded-ternary) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-unneeded-ternary.js) --- url: /rules/eslint/no-unreachable.md --- # no-unreachable [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-unreachable': 'error', }, }, ]); ``` ## Rule Details Disallows unreachable code after `return`, `throw`, `break`, and `continue` statements. Because these statements unconditionally exit a block of code, any statements after them cannot be executed and are therefore unreachable. Function declarations are allowed after terminal statements because they are hoisted. Similarly, `var` declarations without initializers are allowed because the declaration itself is hoisted, even though the assignment would be unreachable. Examples of **incorrect** code for this rule: ```javascript function foo() { return true; console.log('done'); } function bar() { throw new Error('oops'); console.log('done'); } while (value) { break; console.log('done'); } while (value) { continue; console.log('done'); } function baz() { return; var x = 1; } ``` Examples of **correct** code for this rule: ```javascript function foo() { return bar(); function bar() { return 1; } } function baz() { return; var x; } function qux() { if (condition) { return; } doSomething(); } ``` ## Original Documentation - [ESLint: no-unreachable](https://eslint.org/docs/latest/rules/no-unreachable) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-unreachable.js) --- url: /rules/eslint/no-unreachable-loop.md --- # no-unreachable-loop [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-unreachable-loop': 'error', }, }, ]); ``` ## Rule Details Disallows a loop whose body can never run a second time. Every path through the body leaves the loop — by `break`, `return`, or `throw` — so the loop is a conditional block written as a loop, and the extra iterations it looks like it performs never happen. That is usually a mistake: a `break` that belongs inside an `if`, a `return` that should collect results instead of leaving on the first element, or a condition that was never finished. A loop iterates again as soon as one path flows back into it, so a `break` or `return` guarded by an `if` is fine. A loop the surrounding code can never reach is left alone. Examples of **incorrect** code for this rule: ```javascript for (let i = 0; i < arr.length; i++) { console.log(arr[i]); break; } while (foo) { doSomething(foo); foo = foo.parent; return; } function find(arr, target) { for (const item of arr) { return item === target; } } ``` Examples of **correct** code for this rule: ```javascript for (let i = 0; i < arr.length; i++) { console.log(arr[i]); } while (foo) { if (bar) { break; } foo = foo.parent; } function find(arr, target) { for (const item of arr) { if (item === target) { return item; } } } ``` ## Options This rule accepts an options object with one property: ### `ignore` An array of loop types to leave unchecked. Each entry is one of `"WhileStatement"`, `"DoWhileStatement"`, `"ForStatement"`, `"ForInStatement"`, or `"ForOfStatement"`. It defaults to an empty array. The following configuration allows the idiom that reads only the first entry of a collection: ```json { "no-unreachable-loop": [ "error", { "ignore": ["ForInStatement", "ForOfStatement"] } ] } ``` ```javascript function firstKey(obj) { for (const key in obj) { return key; } return null; } ``` ## Differences from ESLint - rslint accepts double-labelled `while` and `do-while` loops when `continue` targets the outer label. ESLint 10.8.0 reports those two forms even though the jump starts another iteration. - rslint accepts an enclosing loop when `continue` in a `finally` block overrides a pending `return` or `throw`. ESLint 10.8.0 reports some of these code paths even though control starts another iteration. ## Original Documentation - [ESLint: no-unreachable-loop](https://eslint.org/docs/latest/rules/no-unreachable-loop) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-unreachable-loop.js) --- url: /rules/eslint/no-unsafe-finally.md --- # no-unsafe-finally [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-unsafe-finally': 'error', }, }, ]); ``` ## Rule Details Disallows control flow statements (`return`, `throw`, `break`, `continue`) inside `finally` blocks. When control flow statements are used inside `finally` blocks, they override the control flow of `try` and `catch` blocks, which can lead to unexpected behavior and make code harder to understand. Examples of **incorrect** code for this rule: ```javascript function foo() { try { return 1; } catch (err) { return 2; } finally { return 3; // overrides the return in try/catch } } function bar() { try { doSomething(); } finally { throw new Error(); // overrides any error thrown in try } } label: try { return 0; } finally { break label; // overrides the return in try } ``` Examples of **correct** code for this rule: ```javascript function foo() { try { return 1; } catch (err) { return 2; } finally { console.log('done'); } } function bar() { try { doSomething(); } finally { // control flow inside nested functions is fine function cleanup(x) { return x; } cleanup(); } } function baz() { try { doSomething(); } finally { // break/continue inside loops within finally is fine while (condition) { break; } } } ``` ## Original Documentation - [ESLint: no-unsafe-finally](https://eslint.org/docs/latest/rules/no-unsafe-finally) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-unsafe-finally.js) --- url: /rules/eslint/no-unsafe-negation.md --- # no-unsafe-negation [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-unsafe-negation': 'error', }, }, ]); ``` ## Rule Details Disallows negating the left operand of relational operators. The code `!a in b` is parsed as `(!a) in b`, not `!(a in b)`, which is usually not the intended behavior. The same applies to `instanceof`. With the `enforceForOrderingRelations` option enabled, this rule also checks `<`, `>`, `<=`, and `>=` operators. Examples of **incorrect** code for this rule: ```javascript if ((!key) in object) { } if ((!obj) instanceof Ctor) { } ``` Examples of **correct** code for this rule: ```javascript if (!(key in object)) { } if (!(obj instanceof Ctor)) { } if ((!key) in object) { } ``` ## Options ### `enforceForOrderingRelations` When set to `true`, also disallows negating the left operand of `<`, `>`, `<=`, and `>=` operators. Default is `false`. Examples of **incorrect** code with `{ "enforceForOrderingRelations": true }`: ```javascript if (!a < b) { } if (!a >= b) { } ``` ## Original Documentation - [ESLint: no-unsafe-negation](https://eslint.org/docs/latest/rules/no-unsafe-negation) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-unsafe-negation.js) --- url: /rules/eslint/no-unsafe-optional-chaining.md --- # no-unsafe-optional-chaining [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-unsafe-optional-chaining': 'error', }, }, ]); ``` ## Rule Details Disallows using optional chaining in contexts where the `undefined` value is not allowed. Optional chaining (`?.`) can short-circuit to `undefined`. When the result is used in a position where `undefined` causes a TypeError or unexpected behavior, this rule reports it. Examples of **incorrect** code for this rule: ```javascript (obj?.foo)(); // TypeError if obj?.foo is undefined (obj?.foo).bar; // TypeError new (obj?.foo)(); // TypeError const { a } = obj?.foo; // TypeError (destructuring undefined) [...obj?.foo]; // TypeError (spreading undefined) for (const x of obj?.foo) { } // TypeError (iterating undefined) 'foo' in obj?.bar; // TypeError foo instanceof obj?.bar; // TypeError class Foo extends obj?.bar {} // TypeError ``` Examples of **correct** code for this rule: ```javascript obj?.foo; // standalone is fine obj?.foo(); // optional call is fine (obj?.foo ?? bar)(); // fallback via ?? (obj?.foo || bar).baz; // fallback via || obj?.foo?.bar; // chaining is fine ``` ## Options ### `disallowArithmeticOperators` When set to `true`, also reports arithmetic operations on optional chaining results, which can produce `NaN`. Default is `false`. Examples of **incorrect** code with `{ "disallowArithmeticOperators": true }`: ```javascript obj?.foo + bar; // may be NaN +obj?.foo; // may be NaN -obj?.foo; // may be NaN obj?.foo * bar; // may be NaN ``` ## Original Documentation - [ESLint: no-unsafe-optional-chaining](https://eslint.org/docs/latest/rules/no-unsafe-optional-chaining) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-unsafe-optional-chaining.js) --- url: /rules/eslint/no-unused-expressions.md --- # no-unused-expressions [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-unused-expressions': 'error', }, }, ]); ``` ## Rule Details Disallow expression statements that do not affect program state. Examples of **incorrect** code for this rule: ```javascript 0; a; foo.bar; a ? b() : c; tag`template`; ``` Examples of **correct** code for this rule: ```javascript a = b; new Foo(); foo(); delete foo.bar; void foo(); ``` ## Options This rule has an object option: - `allowShortCircuit` (default: `false`): allow short-circuit expressions when the right-hand side has an accepted side effect. - `allowTernary` (default: `false`): allow ternary expressions when both branches have accepted side effects. - `allowTaggedTemplates` (default: `false`): allow tagged template expression statements. - `enforceForJSX` (default: `false`): report unused JSX expression statements. - `ignoreDirectives` (default: `false`): accepted for ESLint config compatibility; directive prologues are always allowed in rslint. Examples of **correct** code for this rule with `{ "allowShortCircuit": true }`: ```json { "no-unused-expressions": ["error", { "allowShortCircuit": true }] } ``` ```javascript condition && doSomething(); ``` Examples of **correct** code for this rule with `{ "allowTernary": true }`: ```json { "no-unused-expressions": ["error", { "allowTernary": true }] } ``` ```javascript condition ? doSomething() : doSomethingElse(); ``` Examples of **correct** code for this rule with `{ "allowTaggedTemplates": true }`: ```json { "no-unused-expressions": ["error", { "allowTaggedTemplates": true }] } ``` ```javascript tag`template`; ``` Examples of **incorrect** code for this rule with `{ "enforceForJSX": true }`: ```json { "no-unused-expressions": ["error", { "enforceForJSX": true }] } ``` ```jsx
; ``` ## Original Documentation - [ESLint: no-unused-expressions](https://eslint.org/docs/latest/rules/no-unused-expressions) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-unused-expressions.js) --- url: /rules/eslint/no-unused-labels.md --- # no-unused-labels [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-unused-labels': 'error', }, }, ]); ``` ## Rule Details This rule disallows labels that are declared but never used by a labeled `break` or `continue` statement. Examples of **incorrect** code for this rule: ```javascript A: var foo = 0; B: { foo(); } C: for (let i = 0; i < 10; ++i) { foo(); } ``` Examples of **correct** code for this rule: ```javascript A: { if (foo()) { break A; } bar(); } B: for (let i = 0; i < 10; ++i) { if (foo()) { continue B; } bar(); } ``` ## Options This rule has no options. ## Original Documentation - [ESLint: no-unused-labels](https://eslint.org/docs/latest/rules/no-unused-labels) - [Source code](https://github.com/eslint/eslint/blob/v10.6.0/lib/rules/no-unused-labels.js) --- url: /rules/eslint/no-unused-private-class-members.md --- # no-unused-private-class-members [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-unused-private-class-members': 'error', }, }, ]); ``` ## Rule Details This rule reports private class members that are declared but never used. A private field or method is considered unused if its value is never read. A private accessor is considered unused if it is never accessed, either for a read or a write. Examples of **incorrect** code for this rule: ```javascript class A { #unusedMember = 5; } class B { #usedOnlyInWrite = 5; method() { this.#usedOnlyInWrite = 42; } } class C { #usedOnlyToUpdateItself = 5; method() { this.#usedOnlyToUpdateItself++; } } class D { #unusedMethod() {} } ``` Examples of **correct** code for this rule: ```javascript class A { #usedMember = 42; method() { return this.#usedMember; } } class B { #usedMethod() { return 42; } anotherMethod() { return this.#usedMethod(); } } class C { get #usedAccessor() {} set #usedAccessor(value) {} method() { this.#usedAccessor = 42; } } ``` ## Options This rule has no options. ## Original Documentation - [ESLint: no-unused-private-class-members](https://eslint.org/docs/latest/rules/no-unused-private-class-members) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-unused-private-class-members.js) --- url: /rules/eslint/no-unused-vars.md --- # no-unused-vars [Added in v0.7.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.1) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-unused-vars': 'error', }, }, ]); ``` ## Rule Details Disallow variables that are declared or assigned but never read. Removing unused bindings keeps scope intent clear and catches misspellings, incomplete refactors, and discarded assignments. Examples of **incorrect** code for this rule: ```javascript const unused = 1; function greet(name, punctuation) { return `Hello, ${name}`; } let result; result = calculate(); ``` Examples of **correct** code for this rule: ```javascript const value = calculate(); consume(value); function greet(name) { return `Hello, ${name}`; } export const publicValue = 1; ``` The rule reports a discarded binding at its last write in the binding's variable scope. When it is safe to do so, the diagnostic includes a suggestion that removes the unused declaration, parameter, destructuring element, class, function, or import. ## Options The rule accepts either `"all"` or `"local"` as a shorthand for `vars`, or one options object: ```json { "no-unused-vars": [ "error", { "vars": "all", "args": "after-used", "caughtErrors": "all", "ignoreRestSiblings": false, "ignoreClassWithStaticInitBlock": false, "ignoreUsingDeclarations": false, "reportUsedIgnorePattern": false } ] } ``` - `vars`: Check all variables (`"all"`, the default) or only variables in non-global scopes (`"local"`). Top-level ES module bindings are local and remain checked. - `varsIgnorePattern`: Ignore variable names matching this JavaScript regular expression. - `args`: Check all parameters (`"all"`), only parameters after the last used parameter (`"after-used"`, the default), or no parameters (`"none"`). - `argsIgnorePattern`: Ignore parameter names matching this JavaScript regular expression. - `caughtErrors`: Check catch-clause bindings (`"all"`, the default) or ignore them (`"none"`). - `caughtErrorsIgnorePattern`: Ignore catch-clause binding names matching this JavaScript regular expression. - `destructuredArrayIgnorePattern`: Ignore direct array-destructuring elements that match this JavaScript regular expression. Defaulted and rest elements continue to use their ordinary variable, parameter, or catch-clause option. - `ignoreRestSiblings`: Ignore direct object-destructuring properties that have a rest sibling. Bindings nested inside those properties are still checked. - `ignoreClassWithStaticInitBlock`: Ignore classes containing a static initialization block. - `ignoreUsingDeclarations`: Ignore `using` and `await using` declarations. - `reportUsedIgnorePattern`: Report a binding when its name matches an ignore pattern but the binding is actually used. For example, this configuration allows underscore-prefixed parameters: ```json { "no-unused-vars": ["error", { "args": "all", "argsIgnorePattern": "^_" }] } ``` ## The `/* exported */` comment A script shares its globals with the other scripts loaded alongside it, where this rule cannot see them being read. An `/* exported name */` block comment declares that such a global is consumed elsewhere, and the rule counts the comment itself as a use: ```javascript /* exported publicValue */ var publicValue = 1; ``` The comment resolves each name only against the outer global scope. Whether a file has that scope is determined by its effective `languageOptions.sourceType`, not by the presence of `import` or `export` syntax. With flat config, omitting `sourceType` makes `.js` and `.ts` files modules even when they contain no module syntax, so the comment has no effect. Set `sourceType: "script"` for a shared script. Module bindings, bindings in a JavaScript CommonJS wrapper, block bindings, and function locals are still reported. An exact, case-sensitive `.cjs` extension defaults to the CommonJS wrapper. TypeScript-flavoured files configured as `commonjs` retain a global program scope, so their top-level bindings can be marked by the comment. ## Original Documentation - [ESLint: no-unused-vars](https://eslint.org/docs/latest/rules/no-unused-vars) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/no-unused-vars.js) --- url: /rules/eslint/no-use-before-define.md --- # no-use-before-define [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-use-before-define': 'error', }, }, ]); ``` Disallow the use of variables before they are defined. ## Rule Details In JavaScript, `var` declarations and function declarations are hoisted, so using them before their declaration is legal but confusing. `let`, `const`, and `class` declarations are not: reading them before the declaration throws at runtime (the temporal dead zone). This rule reports a reference that appears before the declaration it resolves to, and a reference that runs while that declaration is still being initialized. References to names that are not declared in the file — globals, ambient declarations, imports from other modules — are not reported. Examples of **incorrect** code for this rule: ```javascript alert(a); var a = 10; f(); function f() {} new C(); class C {} var b = b; ``` Examples of **correct** code for this rule: ```javascript var a = 10; alert(a); function f() {} f(); class C {} new C(); var b = 1; ``` Note that a reference from a different execution context still counts as "before" when the declaration comes later in the file — the forward call in a pair of mutually recursive functions is reported unless `functions` is turned off: ```javascript function isEven(n) { return isOdd(n - 1); } function isOdd(n) { return isEven(n - 1); } ``` ## Options This rule takes one option, either the string `"nofunc"` or an object. The string form `"nofunc"` is shorthand for `{ "functions": false }`. The object form supports the following properties. ### `functions` Whether references to function declarations are checked. Default: `true`. Because function declarations are hoisted, calling one before its declaration is safe, so turning this off is common in codebases that define helpers at the bottom of a file. Examples of **correct** code with `{ "functions": false }`: ```json { "no-use-before-define": ["error", { "functions": false }] } ``` ```javascript f(); function f() {} ``` ### `classes` Whether references to class declarations are checked. Default: `true`. Turning it off only exempts references from a _different_ execution context — a function body, a method, a non-static field initializer. A reference in the same context as the class definition is a temporal dead zone error and is still reported. Examples of **correct** code with `{ "classes": false }`: ```json { "no-use-before-define": ["error", { "classes": false }] } ``` ```javascript function make() { return new C(); } class C {} ``` Examples of **incorrect** code with `{ "classes": false }`: ```json { "no-use-before-define": ["error", { "classes": false }] } ``` ```javascript new C(); class C {} ``` ### `variables` Whether references to `var`, `let`, and `const` declarations are checked. Default: `true`. As with `classes`, turning it off only exempts references from a different execution context. Examples of **correct** code with `{ "variables": false }`: ```json { "no-use-before-define": ["error", { "variables": false }] } ``` ```javascript function read() { return value; } let value = 1; ``` ### `allowNamedExports` Whether the local names in `export { ... }` are exempt. Default: `false`. Examples of **correct** code with `{ "allowNamedExports": true }`: ```json { "no-use-before-define": ["error", { "allowNamedExports": true }] } ``` ```javascript export { a }; const a = 1; ``` ### `enums` Whether references to TypeScript `enum` declarations are checked. Default: `true`. Examples of **correct** code with `{ "enums": false }`: ```json { "no-use-before-define": ["error", { "enums": false }] } ``` ```typescript const value = Level.Low; enum Level { Low, } ``` ### `typedefs` Whether references to TypeScript `type` aliases, `interface` declarations, and generic type parameters are checked. Default: `true`. Examples of **correct** code with `{ "typedefs": false }`: ```json { "no-use-before-define": [ "error", { "typedefs": false, "ignoreTypeReferences": false } ] } ``` ```typescript let value: Later; type Later = string; ``` ### `ignoreTypeReferences` Whether direct type references such as `let x: Foo`, and `typeof Foo` type queries, are exempt. Default: `true`. As in ESLint core, this exemption does not cover heritage names (`implements Foo`), qualified-name roots (`NS.Foo`), export assignments, or type-predicate parameter names. Examples of **incorrect** code with `{ "ignoreTypeReferences": false }`: ```json { "no-use-before-define": ["error", { "ignoreTypeReferences": false }] } ``` ```typescript interface Bar { type: typeof Foo; } const Foo = 2; ``` ## Original Documentation - [ESLint: no-use-before-define](https://eslint.org/docs/latest/rules/no-use-before-define) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-use-before-define.js) --- url: /rules/eslint/no-useless-assignment.md --- # no-useless-assignment [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-useless-assignment': 'error', }, }, ]); ``` ## Rule Details Disallows assignments whose value is never read. A variable that is written and then overwritten — or written on a path that ends without reading it again — carries a value nothing observes, which usually means a mistake: a typo in the variable name, a missing `return`, or leftover code from a refactor. The rule only looks at variables it can follow end to end. It stays silent when the variable is never read at all (that is `no-unused-vars`' job), when it is read from another function, when it leaves the file — through an `export`, or through an `/* exported name */` comment naming a global — and when the assignment sits inside a `try` block, where the block may be abandoned before the value is used. Examples of **incorrect** code for this rule: ```javascript function fn() { let v = 'used'; console.log(v); v = 'unused'; } function fn() { let v = 'unused'; if (condition) { v = 'used'; console.log(v); return; } } function fn() { let v = 'used'; console.log(v); v = 'unused'; v = 'used'; console.log(v); } ``` Examples of **correct** code for this rule: ```javascript function fn() { let v = 'used'; console.log(v); v = 'used-2'; console.log(v); } function fn() { let v = 'used'; if (condition) { v = 'used-2'; console.log(v); return; } console.log(v); } function fn() { let v = 'used'; console.log(v); setTimeout(() => console.log(v), 1); v = 'used in another scope'; } ``` ## Differences from ESLint - Destructuring follows the run-time evaluation order: the initializer or right-hand side produces its value first, then each element evaluates its computed key and default. So `let { a = x } = (x = 1, obj)` is clean here — the default may read `x = 1` — while ESLint reports it based on source positions; and in `({ [a = 1]: x } = (a = 2, obj)); console.log(a)` this rule reports the genuinely dead `a = 2` where ESLint reports the `a = 1` the log actually observes. - Every label wrapped around a loop resolves its `break`/`continue`: `outer: inner: while (cond) { … continue outer; }` keeps its back edge, so values the next iteration reads are counted as used. ESLint attaches only the innermost label and falsely reports such assignments. - A variable read from inside a parameter decorator's arguments is treated as used, so assignments to it are never reported: `const pipe = {}; class C { handler(@Body(pipe) body) {} }`. ESLint reports `const pipe = {}` here — a known false positive ([eslint/eslint#20947](https://github.com/eslint/eslint/issues/20947)). - For deeply nested `try`/`catch`/`switch` combinations, this rule's control flow modeling can occasionally diverge from ESLint's own, which has open, accepted-but-unfixed bugs in the same area ([eslint/eslint#17579](https://github.com/eslint/eslint/issues/17579)) and its own false negatives on some such shapes. Matching it exactly there is hard to pin down, so it is left as a known gap. These shapes are rare in practice; in the large majority of real code this rule reports the same findings as ESLint. ## Original Documentation - [ESLint: no-useless-assignment](https://eslint.org/docs/latest/rules/no-useless-assignment) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-useless-assignment.js) --- url: /rules/eslint/no-useless-backreference.md --- # no-useless-backreference [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-useless-backreference': 'error', }, }, ]); ``` ## Rule Details This rule disallows useless backreferences in regular expressions — backreferences that can only ever match the empty string regardless of input. The rule recognizes five problematic patterns: - A backreference to a group that contains the backreference itself (the group hasn't matched yet when the backreference starts). - A backreference that appears before the group it refers to (forward reference). - A backreference inside a lookbehind that refers to a group appearing before it in the same lookbehind (lookbehind matches right-to-left). - A backreference and its referenced group are in different alternatives of the same disjunction. - A backreference to a group inside a negative lookaround when the backreference itself is outside that lookaround (the group's match was discarded). Examples of **incorrect** code for this rule: ```javascript /^(?:(a)|\1b)$/; // reference to a group in another alternative /(?:(a)|b(?:c|\1))$/; // reference to a group in another alternative /\1(a)/; // forward reference RegExp('(a)\\2(b)'); // forward reference /\k(?a)/; // forward reference (named) /(?<=(a)\1)b/; // backward reference in lookbehind new RegExp('(\\1)'); // nested reference /^((a)\1)$/; // nested reference /a(?!(b)).\1/; // reference into a negative lookahead /(?a)\k/; /(?<=\1(a))b/; /^(?:(a)\1)$/; /a(?!(b|c)\1)./; ``` ## Options This rule has no options. ## Original Documentation - [ESLint: no-useless-backreference](https://eslint.org/docs/latest/rules/no-useless-backreference) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-useless-backreference.js) --- url: /rules/eslint/no-useless-call.md --- # no-useless-call [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-useless-call': 'error', }, }, ]); ``` ## Rule Details `Function.prototype.call()` and `Function.prototype.apply()` are slower than the normal function invocation. This rule reports cases where `.call()` / `.apply()` does not change `this` (so the call could be a normal invocation). A call is reported when its `thisArg` matches the receiver implied by the applied expression: - `foo.call(undefined, …)` / `foo.apply(null, …)` — the applied expression has no implied `this`, so `null`/`undefined`/`void 0` are equivalent to a plain call. - `obj.foo.call(obj, …)` / `obj.foo.apply(obj, …)` — the `thisArg` is the same expression (token-for-token) as the receiver of the applied member access. `.apply()` is only flagged when the second argument is an array literal — the variadic / spread case is the responsibility of `prefer-spread`. Examples of **incorrect** code for this rule: ```javascript foo.call(undefined, 1, 2, 3); foo.apply(undefined, [1, 2, 3]); foo.call(null, 1, 2, 3); foo.apply(null, [1, 2, 3]); obj.foo.call(obj, 1, 2, 3); obj.foo.apply(obj, [1, 2, 3]); ``` Examples of **correct** code for this rule: ```javascript // The `this` binding actually changes. foo.call(obj, 1, 2, 3); foo.apply(obj, [1, 2, 3]); obj.foo.call(null, 1, 2, 3); obj.foo.apply(null, [1, 2, 3]); obj.foo.call(otherObj, 1, 2, 3); obj.foo.apply(otherObj, [1, 2, 3]); // Variadic is delegated to `prefer-spread`. foo.apply(undefined, args); foo.apply(null, args); obj.foo.apply(obj, args); ``` ## Original Documentation - [ESLint: no-useless-call](https://eslint.org/docs/latest/rules/no-useless-call) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-useless-call.js) --- url: /rules/eslint/no-useless-catch.md --- # no-useless-catch [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-useless-catch': 'error', }, }, ]); ``` ## Rule Details Disallows catch clauses that only rethrow the caught error. A catch clause that only rethrows the original error is redundant, and has no effect on the runtime behavior of the program. These redundant clauses can be a source of confusion and code bloat, so it is better to disallow them. Examples of **incorrect** code for this rule: ```javascript try { doSomethingThatMightThrow(); } catch (e) { throw e; } try { doSomethingThatMightThrow(); } catch (e) { throw e; } finally { cleanUp(); } ``` Examples of **correct** code for this rule: ```javascript try { doSomethingThatMightThrow(); } catch (e) { doSomethingBeforeRethrow(); throw e; } try { doSomethingThatMightThrow(); } catch (e) { handleError(e); } try { doSomethingThatMightThrow(); } catch ({ message }) { throw message; } ``` ## Original Documentation - [ESLint: no-useless-catch](https://eslint.org/docs/latest/rules/no-useless-catch) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-useless-catch.js) --- url: /rules/eslint/no-useless-computed-key.md --- # no-useless-computed-key [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-useless-computed-key': 'error', }, }, ]); ``` ## Rule Details Disallow computed property keys when their use is unnecessary. For example, `{ ["a"]: 1 }` can be rewritten as `{ a: 1 }` with the same behavior. The rule applies to object literals, destructuring patterns, and (by default) class members. A few keys retain distinct semantics in computed form and are therefore exempt: - `{ ["__proto__"]: v }` defines a regular property, whereas `{ __proto__: v }` sets the object's prototype. - In a class, `["constructor"]()` is a regular method whereas `constructor()` is the constructor. - In a class, `static ["prototype"]` / `static ["prototype"]()` produce only a runtime error, whereas the unbracketed form is a parse error that breaks the whole script. Examples of **incorrect** code for this rule: ```javascript ({ ['0']: 0 }); ({ ['x']: 0 }); ({ [0]: 0 }); ({ ['x']() {} }); ({ get ['foo']() {} }); var { ['x']: a } = obj; class Foo { ['x']() {} } class Foo { ['0']; } ``` Examples of **correct** code for this rule: ```javascript ({ a: 0, b() {} }); ({ [x]: 0 }); ({ ['__proto__']: [] }); class Foo { [x]() {} } class Foo { ['constructor']() {} } class Foo { static ['prototype']() {} } ``` ## Options This rule has one option, an object with a single key: - `enforceForClassMembers` (default `true`): when `false`, the rule only flags object literals and destructuring patterns and leaves class members alone. Examples of **correct** code for this rule with `{ "enforceForClassMembers": false }`: ```json { "no-useless-computed-key": ["error", { "enforceForClassMembers": false }] } ``` ```javascript class Foo { ['x']() {} } ``` ## Original Documentation - [ESLint: no-useless-computed-key](https://eslint.org/docs/latest/rules/no-useless-computed-key) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-useless-computed-key.js) --- url: /rules/eslint/no-useless-concat.md --- # no-useless-concat [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-useless-concat': 'error', }, }, ]); ``` ## Rule Details Disallow unnecessary concatenation of literals or template literals. This rule flags a `+` that joins two string literals or template literals on the same line, since they could be written as a single literal. Concatenation that spans multiple source lines is intentionally not reported. Examples of **incorrect** code for this rule: ```javascript var a = `some` + `string`; var b = '1' + '0'; var c = '1' + `0`; var d = `1` + '0'; var e = `1` + `0`; ``` Examples of **correct** code for this rule: ```javascript // When the variables could hold non-strings var a = 1 + 1; var b = 1 + '1'; var c = foo + bar; var d = 'foo' + bar; ``` ## Original Documentation - [ESLint: no-useless-concat](https://eslint.org/docs/latest/rules/no-useless-concat) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-useless-concat.js) --- url: /rules/eslint/no-useless-constructor.md --- # no-useless-constructor [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-useless-constructor': 'error', }, }, ]); ``` ## Rule Details Disallow unnecessary constructors. ES2015 provides a default class constructor if one is not specified. As such, it is unnecessary to provide an empty constructor or one that simply delegates into its parent class. Examples of **incorrect** code for this rule: ```javascript class A { constructor() {} } class B extends A { constructor(...args) { super(...args); } } ``` Examples of **correct** code for this rule: ```javascript class A {} class B { constructor() { doSomething(); } } class C extends A { constructor() { super('foo'); } } class D extends A { constructor() { super(); doSomething(); } } ``` ## Original Documentation - [ESLint: no-useless-constructor](https://eslint.org/docs/latest/rules/no-useless-constructor) - [Source code](https://github.com/eslint/eslint/blob/v10.2.1/lib/rules/no-useless-constructor.js) --- url: /rules/eslint/no-useless-escape.md --- # no-useless-escape [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-useless-escape': 'error', }, }, ]); ``` Disallow unnecessary escape characters. Escaping non-special characters in strings, template literals, and regular expressions does not change behavior. Removing the redundant `\` keeps the code simpler and avoids confusion. ```js let foo = "hol\a"; // > foo = "hola" let bar = `${foo}\!`; // > bar = "hola!" let baz = /\:/; // same as /:/ ``` ## Rule Details This rule flags escapes that can be safely removed without changing behavior. Examples of **incorrect** code for this rule: ```javascript "\'"; '\"'; "\#"; "\e"; `\"`; `\"${foo}\"`; `\#{foo}`; /\!/; /\@/; /[\[]/; /[a-z\-]/; ``` Examples of **correct** code for this rule: ```javascript "\""; '\''; "\x12"; "©"; "\371"; "xsℑ"; `\``; `\${${foo}}`; `$\{${foo}}`; /\\/g; /\t/g; /\w\$\*\^\./; /[[]/; /[\]]/; /[a-z-]/; ``` ## Options This rule has an object option: - `allowRegexCharacters` — array of characters whose `\X` form is always allowed inside regular expressions, even when the `\` would otherwise be flagged. Useful for characters like `-` where the explicit escape can prevent the pattern from drifting into a range as the class grows. ### allowRegexCharacters Examples of **incorrect** code for the `{ "allowRegexCharacters": ["-"] }` option: ```json { "no-useless-escape": ["error", { "allowRegexCharacters": ["-"] }] } ``` ```javascript /\!/; /\@/; /[a-z\^]/; ``` Examples of **correct** code for the `{ "allowRegexCharacters": ["-"] }` option: ```json { "no-useless-escape": ["error", { "allowRegexCharacters": ["-"] }] } ``` ```javascript /[0\-]/; /[\-9]/; /a\-b/; ``` ## When Not To Use It If you do not want to be notified about unnecessary escapes, you can safely disable this rule. ## Original Documentation - [ESLint: no-useless-escape](https://eslint.org/docs/latest/rules/no-useless-escape) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-useless-escape.js) --- url: /rules/eslint/no-useless-rename.md --- # no-useless-rename [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-useless-rename': 'error', }, }, ]); ``` Disallow renaming import, export, and destructured assignments to the same name. ## Rule Details ES2015 allows for the renaming of references in import statements, export statements, and destructuring assignments. This gives programmers a concise syntax for performing these operations while renaming these references: ```javascript import { foo as bar } from "baz"; export { foo as bar }; let { foo: bar } = baz; ``` With this syntax, it is possible to rename a reference to the same name. This is a completely redundant operation, as this is the same as not renaming at all. Examples of **incorrect** code for this rule: ```javascript import { foo as foo } from "bar"; export { foo as foo }; export { foo as foo } from "bar"; let { foo: foo } = bar; let { 'foo': foo } = bar; function foo({ bar: bar }) {} ({ foo: foo }) => {}; ({ foo: foo } = bar); ``` Examples of **correct** code for this rule: ```javascript import * as foo from "foo"; import { foo } from "bar"; import { foo as bar } from "baz"; export { foo }; export { foo as bar }; export { foo as bar } from "foo"; let { foo } = bar; let { foo: bar } = baz; let { [foo]: foo } = bar; function foo({ bar }) {} function foo({ bar: baz }) {} ({ foo }) => {}; ({ foo: bar }) => {}; ``` ## Options This rule has an object option: - `"ignoreDestructuring": false` (default) — disallow useless renaming in destructuring patterns. - `"ignoreImport": false` (default) — disallow useless renaming in import statements. - `"ignoreExport": false` (default) — disallow useless renaming in export statements. ### ignoreDestructuring Examples of **correct** code for this rule with `{ "ignoreDestructuring": true }`: ```json { "no-useless-rename": ["error", { "ignoreDestructuring": true }] } ``` ```javascript let { foo: foo } = bar; function foo({ bar: bar }) {} ``` ### ignoreImport Examples of **correct** code for this rule with `{ "ignoreImport": true }`: ```json { "no-useless-rename": ["error", { "ignoreImport": true }] } ``` ```javascript import { foo as foo } from "bar"; ``` ### ignoreExport Examples of **correct** code for this rule with `{ "ignoreExport": true }`: ```json { "no-useless-rename": ["error", { "ignoreExport": true }] } ``` ```javascript export { foo as foo }; export { foo as foo } from "bar"; ``` ## Original Documentation - [ESLint: no-useless-rename](https://eslint.org/docs/latest/rules/no-useless-rename) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-useless-rename.js) --- url: /rules/eslint/no-useless-return.md --- # no-useless-return [Added in v0.8.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-useless-return': 'error', }, }, ]); ``` ## Rule Details A `return;` at the end of a function does the same thing as reaching the end of the function, so it can be dropped. This rule reports every `return` with no value that nothing runs after. A `return` that carries a value is left alone, and so is one inside a loop — which leaves the loop early — or inside a `finally` block, which replaces the value the statement was leaving with. Examples of **incorrect** code for this rule: ```javascript function foo() { return; } function bar() { doSomething(); return; } function baz() { if (condition) { doSomething(); return; } else { doSomethingElse(); } } function qux() { switch (value) { case 1: doSomething(); return; } } ``` Examples of **correct** code for this rule: ```javascript function foo() { return 5; } function bar() { if (condition) { return; } doSomething(); } function baz() { for (const item of items) { if (item.done) { return; } process(item); } } function qux() { try { return computeValue(); } finally { return fallback; } } ``` ## Original Documentation - [ESLint: no-useless-return](https://eslint.org/docs/latest/rules/no-useless-return) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-useless-return.js) --- url: /rules/eslint/no-var.md --- # no-var [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-var': 'error', }, }, ]); ``` ## Rule Details Requires `let` or `const` instead of `var`. ECMAScript 6 introduced `let` and `const` as alternatives to `var` for variable declarations. `let` and `const` provide block scoping, which helps avoid common issues caused by the function scoping of `var`. Examples of **incorrect** code for this rule: ```javascript var x = 'y'; var CONFIG = {}; ``` Examples of **correct** code for this rule: ```javascript let x = 'y'; const CONFIG = {}; ``` ## Original Documentation - [ESLint: no-var](https://eslint.org/docs/latest/rules/no-var) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/no-var.js) ## Differences from ESLint Rslint leaves some declarations unfixed when replacing `var` with `let` would introduce a temporal dead zone, even if ESLint offers a fix. This includes a function called during the variable's initialization that reads that variable: ```javascript var value = read(); function read() { return value; } ``` The same protection applies to immediately invoked callbacks, constructors, getters and loop binding defaults that read an uninitialized variable. Stored callbacks and methods that run after initialization can still be fixed. --- url: /rules/eslint/no-void.md --- # no-void [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-void': 'error', }, }, ]); ``` ## Rule Details Disallow use of the `void` operator. Examples of **incorrect** code for this rule: ```javascript void foo; void someFunction(); const foo = void bar(); function baz() { return void 0; } ``` ## Options ### `allowAsStatement` When `true`, permits `void` as a standalone statement but still prohibits its use in expression contexts such as variable assignments or return statements. Default: `false`. Examples of **incorrect** code for this rule with `{ "allowAsStatement": true }`: ```json { "no-void": ["error", { "allowAsStatement": true }] } ``` ```javascript const foo = void bar(); function baz() { return void 0; } ``` Examples of **correct** code for this rule with `{ "allowAsStatement": true }`: ```json { "no-void": ["error", { "allowAsStatement": true }] } ``` ```javascript void foo; void someFunction(); ``` ## Original Documentation - [ESLint: no-void](https://eslint.org/docs/latest/rules/no-void) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-void.js) --- url: /rules/eslint/no-warning-comments.md --- # no-warning-comments [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-warning-comments': 'error', }, }, ]); ``` ## Rule Details This rule reports comments that include any of the predefined terms specified in its configuration. ```javascript // TODO: do something // FIXME: this is not a good idea ``` ## Options This rule has an options object literal: - `"terms"`: optional array of terms to match. Defaults to `["todo", "fixme", "xxx"]`. Terms are matched case-insensitively and as whole words: `fix` would match `FIX` but not `fixing`. Terms can consist of multiple words: `really bad idea`. - `"location"`: optional string that configures where in your comments to check for matches. Defaults to `"start"`. The start is from the first non-decorative character, ignoring whitespace, new lines and characters specified in `decoration`. The other value is match `anywhere` in comments. - `"decoration"`: optional array of characters that are ignored at the start of a comment, when location is `"start"`. Defaults to `[]`. Any sequence of whitespace or the characters from this property are ignored. This option is ignored when location is `"anywhere"`. Examples of **incorrect** code for this rule with the default `{ "terms": ["todo", "fixme", "xxx"], "location": "start" }` options: ```javascript /* FIXME */ function callback(err, results) { if (err) { console.error(err); return; } // TODO } ``` Examples of **correct** code for this rule with the default `{ "terms": ["todo", "fixme", "xxx"], "location": "start" }` options: ```javascript function callback(err, results) { if (err) { console.error(err); return; } // NOT READY FOR PRIME TIME // but too bad, it is not a predefined warning term } ``` ### terms and location Examples of **incorrect** code for the `{ "terms": ["todo", "fixme", "any other term"], "location": "anywhere" }` options: ```json { "no-warning-comments": [ "error", { "terms": ["todo", "fixme", "any other term"], "location": "anywhere" } ] } ``` ```javascript // TODO: this // todo: this too // Even this: TODO /* * The same goes for this TODO comment * Or a fixme * as well as any other term */ ``` Examples of **correct** code for the `{ "terms": ["todo", "fixme", "any other term"], "location": "anywhere" }` options: ```javascript // This is to do // even not any other term // any other terminal /* * The same goes for block comments * with any other interesting term * or fix me this */ ``` ### Decoration Characters Examples of **incorrect** code for the `{ "decoration": ["*"] }` options: ```json { "no-warning-comments": ["error", { "decoration": ["*"] }] } ``` ```javascript //***** todo decorative asterisks are ignored *****// /** * TODO new lines and asterisks are also ignored in block comments. */ ``` Examples of **incorrect** code for the `{ "decoration": ["/", "*"] }` options: ```json { "no-warning-comments": ["error", { "decoration": ["/", "*"] }] } ``` ```javascript ////// TODO decorative slashes and whitespace are ignored ////// //***** todo decorative asterisks are also ignored *****// /** * TODO new lines are also ignored in block comments. */ ``` Examples of **correct** code for the `{ "decoration": ["/", "*"] }` options: ```javascript //!TODO preceded by non-decoration character /** *!TODO preceded by non-decoration character in a block comment */ ``` ## Original Documentation - [ESLint: no-warning-comments](https://eslint.org/docs/latest/rules/no-warning-comments) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-warning-comments.js) --- url: /rules/eslint/no-with.md --- # no-with [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'no-with': 'error', }, }, ]); ``` ## Rule Details Disallow `with` statements. The `with` statement is potentially problematic because it adds members of an object to the current scope, making it impossible to tell what a variable inside the block actually refers to. In strict mode, `with` statements are not allowed at all. Examples of **incorrect** code for this rule: ```javascript with (point) { r = Math.sqrt(x * x + y * y); // is r a member of point? } ``` Examples of **correct** code for this rule: ```javascript const r = Math.sqrt(point.x * point.x + point.y * point.y); ``` ## Original Documentation - [ESLint: no-with](https://eslint.org/docs/latest/rules/no-with) - [Source code](https://github.com/eslint/eslint/blob/v9.39.1/lib/rules/no-with.js) --- url: /rules/eslint/object-shorthand.md --- # object-shorthand [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'object-shorthand': 'error', }, }, ]); ``` Require or disallow method and property shorthand syntax for object literals. ## Rule Details ECMAScript 6 provides shorthand syntax for defining object literal methods and properties. It is useful when an object property shares the name of a local variable and lets you define methods using concise syntax. This rule enforces usage of that shorthand whenever possible (the default `"always"` mode) and can be configured to enforce the opposite (`"never"`) or to cover only one of the two shorthand forms. Examples of **incorrect** code for this rule (default): ```javascript const foo = { w: function () {}, x: function* () {}, z: z, }; ``` Examples of **correct** code for this rule (default): ```javascript const foo = { w() {}, *x() {}, z, }; ``` ## Options The first option is a string: - `"always"` (default) — always use shorthand where possible. - `"methods"` — enforce only method shorthand. - `"properties"` — enforce only property shorthand. - `"never"` — never use shorthand. - `"consistent"` — properties within an object must be all shorthand or all longform. - `"consistent-as-needed"` — all properties must be shorthand when they can be, otherwise all must be longform. The second option is an object with additional flags (valid with `"always"`, `"methods"`, or `"properties"` as noted on each): - `avoidQuotes` — prefer longform for string literal keys (all modes above). - `ignoreConstructors` — skip constructor-style names (only `"always"` or `"methods"`). - `methodsIgnorePattern` — regular expression of method names to skip (only `"always"` or `"methods"`). - `avoidExplicitReturnArrows` — report arrow functions with block bodies (`() => { … }`) as preferring the method shorthand (only `"always"` or `"methods"`). Arrows that reference `this`, `super`, `arguments`, or `new.target` are left alone because the conversion would change their binding. ## Original Documentation - [ESLint: object-shorthand](https://eslint.org/docs/latest/rules/object-shorthand) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/object-shorthand.js) --- url: /rules/eslint/one-var.md --- # one-var [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'one-var': 'error', }, }, ]); ``` Enforce variables to be declared either together or separately in functions. > **Upstream status:** This rule is **frozen** in ESLint — it is no longer accepting new features and is not part of the recommended config. Bug-fix-only. ## Rule Details This rule enforces a single variable declaration style in a scope. Variables can be declared together in a single statement or each in a separate statement, depending on the configured mode. The rule supports `var`, `let`, `const`, `using`, and `await using` declarations. Examples of **incorrect** code for this rule: ```javascript function foo() { var bar; var baz; } function foo() { let bar; let baz; } function foo() { const bar = 1; const baz = 2; } ``` Examples of **correct** code for this rule: ```javascript function foo() { var bar, baz; } function foo() { let bar, baz; } function foo() { const bar = 1, baz = 2; } ``` ## Options This rule accepts a string or an object as its only option. ### String option The string option configures the same mode for every declaration kind: - `"always"` (default) — requires one variable declaration per scope. - `"never"` — requires multiple separate variable declarations per scope. - `"consecutive"` — requires consecutive declarations of the same kind to be combined into a single statement. ```json { "one-var": ["error", "never"] } ``` ```javascript function foo() { var bar; var baz; } ``` ```json { "one-var": ["error", "consecutive"] } ``` ```javascript function foo() { var bar, baz; qux(); var quux; } ``` ### Object option (per kind) The object form lets you choose a different mode for each declaration kind: - `"var"`, `"let"`, `"const"`, `"using"`, `"awaitUsing"` — each accepts `"always"`, `"never"`, or `"consecutive"`. - `"separateRequires"` — when `true`, treats `require()` calls as a separate group from other initialized declarations of the same kind. ```json { "one-var": ["error", { "var": "always", "let": "never", "const": "never" }] } ``` ```javascript function foo() { var bar, baz; let qux; let norf; const a = 1; const b = 2; } ``` ```json { "one-var": ["error", { "separateRequires": true, "var": "always" }] } ``` ```javascript var foo = require('foo'); var bar = require('bar'); var baz = 'baz', qux = 'qux'; ``` ### Object option (initialized / uninitialized) The alternative object form discriminates by initialization status across all kinds: - `"initialized"` — applies to declarations that have an initializer. - `"uninitialized"` — applies to declarations without an initializer. Both accept `"always"`, `"never"`, or `"consecutive"`. ```json { "one-var": ["error", { "initialized": "never", "uninitialized": "always" }] } ``` ```javascript function foo() { var bar, baz; var a = 1; var b = 2; } ``` ## Differences from ESLint - **`declare`-modified declarations are reported but not auto-fixed.** ESLint v10 emits fixes that produce TypeScript parse errors on this input shape: splitting `declare var a, b;` yields `declare var a; var b;` (the second statement silently loses ambient semantics), and combining `declare var a; declare var b;` yields `declare var a, var b;` (two `var` keywords, syntactically invalid). rslint deliberately suppresses the fix in these cases to avoid producing broken code; the diagnostic itself is still reported with identical position and message. ## Original Documentation - [ESLint: one-var](https://eslint.org/docs/latest/rules/one-var) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/one-var.js) --- url: /rules/eslint/operator-assignment.md --- # operator-assignment [Added in v0.8.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'operator-assignment': 'error', }, }, ]); ``` ## Rule Details This rule requires or disallows assignment operator shorthand where possible. This rule applies to the following 12 operators: `+=`, `-=`, `*=`, `/=`, `%=`, `**=`, `<<=`, `>>=`, `>>>=`, `&=`, `^=`, `|=`. Logical assignment operators (`&&=`, `||=`, `??=`) are not checked, since they short-circuit differently from a plain assignment. Examples of **incorrect** code for this rule, in the default `"always"` mode: ```javascript x = x + y; x = y * x; x[0] = x[0] / y; x.y = x.y << z; ``` Examples of **correct** code for this rule, in the default `"always"` mode: ```javascript x = y; x += y; x = y * z; x = (x * y) * z; x[0] /= y; x[foo()] = x[foo()] % 2; x = y + x; // `+` is not always commutative ``` Examples of **incorrect** code for this rule with `"never"`: ```json { "operator-assignment": ["error", "never"] } ``` ```javascript x *= y; x ^= (y + z) / foo(); ``` Examples of **correct** code for this rule with `"never"`: ```json { "operator-assignment": ["error", "never"] } ``` ```javascript x = x + y; x.y = x.y / a.b; ``` ## Differences from ESLint - Autofix is skipped when the assignment target is (or contains) an optional-chain access — for example, `obj.a = obj?.a + b`. ESLint also reports the diagnostic without a fix in this case. - TypeScript-only wrappers with no runtime effect — `x!`, `x as T`, `x satisfies T` — are treated the same as a bare receiver when deciding whether the two sides name the same value. For example, `x!.y = x!.y + z` is autofixed to `x!.y += z`. - The shorthand form drops the right-hand copy of the target, so a fix is offered only when both copies carry the same assertions. `x = (x as number) * 2` and `x = x! + 1` are reported without a fix, since `x *= 2` would type-check `x` against its declared type again. - In `"never"` mode, a right side whose leftmost operand is a bare `as` or `satisfies` expression is parenthesized as a whole: `x += a as number * b` becomes `x = x + (a as number * b)`, which keeps the original grouping. Without the parentheses TypeScript would read the result as `((x + a) as number) * b`. - In `"never"` mode, `<<=` is reported without a fix when the expansion would put a `(` right after the `<<` and the right side writes TypeScript type syntax of its own — a type argument list such as `x <<= foo` or `x <<= (foo)`, or a type parameter list such as `x <<= (v: X) => v`. TypeScript re-scans the `<` of `<<` as the start of a type argument list, and the right side's own `>` closes it, so `x = x << (foo)` would not parse. Angle brackets that are not type syntax — `x <<= a < b`, a `<` inside a string, template, or comment — are parenthesized and fixed as usual. ## Original Documentation - [ESLint: operator-assignment](https://eslint.org/docs/latest/rules/operator-assignment) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/operator-assignment.js) --- url: /rules/eslint/prefer-arrow-callback.md --- # prefer-arrow-callback [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'prefer-arrow-callback': 'error', }, }, ]); ``` ## Rule Details Requires using arrow functions for callbacks when the function expression can be replaced without changing `this`, `super`, `arguments`, or `new.target` semantics. Examples of **incorrect** code for this rule: ```javascript foo(function (value) { return value; }); foo(function () { return this.value; }.bind(this)); ``` Examples of **correct** code for this rule: ```javascript foo((value) => { return value; }); foo(() => { return this.value; }); foo(function () { return this.value; }); ``` ## Options This rule accepts an options object with the following properties: - `allowNamedFunctions` defaults to `false`. When `true`, named function expressions are allowed. - `allowUnboundThis` defaults to `true`. When `false`, callbacks that reference their own `this` are still reported, but they are not automatically fixed. Examples of **correct** code for this rule with `{ "allowNamedFunctions": true }`: ```json { "prefer-arrow-callback": ["error", { "allowNamedFunctions": true }] } ``` ```javascript foo(function namedCallback() {}); ``` Examples of **incorrect** code for this rule with `{ "allowUnboundThis": false }`: ```json { "prefer-arrow-callback": ["error", { "allowUnboundThis": false }] } ``` ```javascript foo(function () { return this.value; }); ``` ## Original Documentation - [ESLint: prefer-arrow-callback](https://eslint.org/docs/latest/rules/prefer-arrow-callback) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/prefer-arrow-callback.js) --- url: /rules/eslint/prefer-const.md --- # prefer-const [Added in v0.3.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.3) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'prefer-const': 'error', }, }, ]); ``` ## Rule Details Requires `const` declarations for variables that are never reassigned after declared. If a variable is never reassigned, using the `const` declaration is better because it makes the intent clear that the value is not intended to be changed. Examples of **incorrect** code for this rule: ```javascript let x = 1; let obj = { key: 0 }; for (let x in obj) { console.log(x); } for (let x of [1, 2, 3]) { console.log(x); } ``` Examples of **correct** code for this rule: ```javascript const x = 1; const obj = { key: 0 }; let y = 1; y = 2; let z; z = 1; for (const x in obj) { console.log(x); } for (const x of [1, 2, 3]) { console.log(x); } ``` A global named by an `/* exported name */` block comment is shared with the other scripts loaded alongside this one, any of which may reassign it, so the rule leaves such a declaration alone: ```javascript /* exported sharedValue */ let sharedValue = 1; ``` ## Original Documentation - [ESLint: prefer-const](https://eslint.org/docs/latest/rules/prefer-const) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/prefer-const.js) --- url: /rules/eslint/prefer-destructuring.md --- # prefer-destructuring [Added in v0.7.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'prefer-destructuring': 'error', }, }, ]); ``` ## Rule Details Requires destructuring when extracting values from array indexes or object properties in variable declarations and assignment expressions. Examples of **incorrect** code for this rule: ```javascript const foo = array[0]; const bar = object.bar; bar = object.bar; ``` Examples of **correct** code for this rule: ```javascript const [foo] = array; const { bar } = object; ({ bar } = object); ``` Integer literal keys are treated as array access. Other computed keys are treated as object access, regardless of the receiver's runtime type. Without `enforceForRenamedProperties`, object access is reported only when an identifier or string-literal property matches the target name. For a nested member chain, the final property is destructured from its immediate receiver: ```javascript const bar = object.foo.bar; ``` This is fixed to: ```javascript const { bar } = object.foo; ``` Direct optional-chain access, direct `super` access, and private properties are not reported because they cannot be replaced safely with equivalent destructuring. ## Options This rule accepts up to two option objects. ### Array and object checks Without options, both array and object checks are enabled for variable declarations and assignment expressions. The first option controls which access types are checked. The flat form applies the same settings to declarations and assignments: ```json { "prefer-destructuring": ["error", { "array": false, "object": true }] } ``` Supplying this object replaces the defaults, so an omitted or `false` property is disabled. Checks can also be configured separately with `VariableDeclarator` and `AssignmentExpression`. An omitted context is disabled: ```json { "prefer-destructuring": [ "error", { "VariableDeclarator": { "array": true, "object": true }, "AssignmentExpression": { "array": false, "object": true } } ] } ``` ### Renamed properties The optional second object accepts `enforceForRenamedProperties`, which defaults to `false`. When it is `true`, object access is reported even when the target name differs from the accessed property. Examples of **incorrect** code for this rule with `{ "enforceForRenamedProperties": true }`: ```json { "prefer-destructuring": [ "error", { "object": true }, { "enforceForRenamedProperties": true } ] } ``` ```javascript const foo = object.bar; ``` ## Autofix The autofix is limited to same-name, non-computed object property declarations such as `const foo = object.foo`. Array access, assignments, renamed or computed properties, and rewrites that would remove comments are reported without a fix. For TypeScript projects that need type-aware numeric-index handling or special handling of declaration type annotations, use `@typescript-eslint/prefer-destructuring`. The core rule follows ESLint's autofix behavior and may remove an inline type annotation while converting a declaration. ## Original Documentation - [ESLint: prefer-destructuring](https://eslint.org/docs/latest/rules/prefer-destructuring) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/prefer-destructuring.js) --- url: /rules/eslint/prefer-exponentiation-operator.md --- # prefer-exponentiation-operator [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'prefer-exponentiation-operator': 'error', }, }, ]); ``` ## Rule Details This rule disallows calls to `Math.pow` and suggests using the `**` operator instead. Examples of **incorrect** code for this rule: ```javascript const foo = Math.pow(2, 8); const bar = Math.pow(a, b); let baz = Math.pow(a + b, c + d); let quux = Math.pow(-1, n); ``` Examples of **correct** code for this rule: ```javascript const foo = 2 ** 8; const bar = a ** b; let baz = (a + b) ** (c + d); let quux = (-1) ** n; ``` ## When Not To Use It Do not enable this rule if your runtime target does not support the exponentiation operator (`**`). ## Original Documentation - [ESLint: prefer-exponentiation-operator](https://eslint.org/docs/latest/rules/prefer-exponentiation-operator) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/prefer-exponentiation-operator.js) --- url: /rules/eslint/prefer-named-capture-group.md --- # prefer-named-capture-group [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'prefer-named-capture-group': 'error', }, }, ]); ``` ## Rule Details This rule enforces using named capture groups instead of numbered capture groups in regular expressions. Named capture groups make a regular expression's intent easier to read, and make the captured values easier to retrieve (`match.groups.name` instead of a numbered index that shifts if the pattern changes). This rule checks regex literals as well as string patterns passed to the `RegExp` constructor, including stable local aliases initialized from `RegExp` or `globalThis`/`window`/`self`/`global`, when the pattern is statically determinable. Examples of **incorrect** code for this rule: ```javascript const foo = /(ba[rz])/; const bar = new RegExp("(ba[rz])"); const baz = RegExp("(ba[rz])"); foo.exec("bar")[1]; // Retrieve the group result. ``` Examples of **correct** code for this rule: ```javascript const foo = /(?ba[rz])/; const bar = new RegExp("(?ba[rz])"); const baz = RegExp("(?ba[rz])"); const xyz = /xyz(?:zy|abc)/; foo.exec("bar").groups.id; // Retrieve the group result. ``` ## Options This rule has no configurable options. ## Differences from ESLint - ESLint reports some indirect constructor calls that rslint currently skips. This includes aliases created by destructuring, a parameter default, or a separate assignment, as well as an alias assigned again anywhere in the file. - If a single call can resolve to the global `RegExp` through more than 128 logical or conditional branches, rslint reports at most 128 warnings for each unnamed capture group. - A pattern that uses a Unicode property added after rslint's bundled Unicode version may be accepted by the target runtime but not reported by this rule. - Suggested edits can differ from ESLint: rslint omits an edit that would make the pattern invalid and may choose a different temporary group name to avoid reusing one already present in the pattern. ## When Not To Use It If you are targeting ECMAScript 2017 or older environments, you should disable this rule, because named capture groups are only supported in ECMAScript 2018 and newer environments. ## Original Documentation - [ESLint: prefer-named-capture-group](https://eslint.org/docs/latest/rules/prefer-named-capture-group) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/prefer-named-capture-group.js) --- url: /rules/eslint/prefer-numeric-literals.md --- # prefer-numeric-literals [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'prefer-numeric-literals': 'error', }, }, ]); ``` ## Rule Details This rule disallows `parseInt()` and `Number.parseInt()` when binary, octal, or hexadecimal numeric literals can be used instead. Examples of **incorrect** code for this rule: ```javascript parseInt("111110111", 2) === 503; parseInt(`767`, 8) === 503; Number.parseInt("1F7", 16) === 255; ``` Examples of **correct** code for this rule: ```javascript 0b111110111 === 503; 0o767 === 503; 0x1F7 === 503; parseInt(foo, 2); parseInt("11", 10); Number.parseInt("11", 36); ``` ## Original Documentation - [ESLint: prefer-numeric-literals](https://eslint.org/docs/latest/rules/prefer-numeric-literals) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/prefer-numeric-literals.js) --- url: /rules/eslint/prefer-object-has-own.md --- # prefer-object-has-own [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'prefer-object-has-own': 'error', }, }, ]); ``` ## Rule Details `Object.prototype.hasOwnProperty.call(object, property)` is the long-standing way to ask whether an object has a property of its own without going through the object's own `hasOwnProperty`, which may be missing or redefined. `Object.hasOwn()`, introduced in ES2022, asks the same question directly. This rule reports a call to `hasOwnProperty` reached through the global `Object`, `Object.prototype`, or an empty object literal, and offers `Object.hasOwn()` in its place. Examples of **incorrect** code for this rule: ```javascript Object.prototype.hasOwnProperty.call(object, 'foo'); Object.hasOwnProperty.call(object, 'foo'); ({}).hasOwnProperty.call(object, 'foo'); const hasProperty = Object.prototype.hasOwnProperty.call(object, property); ``` Examples of **correct** code for this rule: ```javascript Object.hasOwn(object, 'foo'); const hasProperty = Object.hasOwn(object, property); object.hasOwnProperty('foo'); foo.hasOwnProperty.call(object, 'foo'); function check(Object) { return Object.prototype.hasOwnProperty.call(object, 'foo'); } ``` ## Options This rule has no options. ## When Not To Use It Use this rule only where ES2022 is available: `Object.hasOwn()` does not exist in older runtimes. ## Differences from ESLint - A TypeScript declaration that binds the name `Object` as a type only — a `type` alias, an `interface`, or a type parameter — leaves the call reported; ESLint stays silent on the whole file. A value declaration (`const Object`, `class Object`, `import Object from …`, `declare const Object`) silences the report in both. ## Original Documentation - [ESLint: prefer-object-has-own](https://eslint.org/docs/latest/rules/prefer-object-has-own) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/prefer-object-has-own.js) --- url: /rules/eslint/prefer-object-spread.md --- # prefer-object-spread [Added in v0.7.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'prefer-object-spread': 'error', }, }, ]); ``` ## Rule Details When `Object.assign` is called using an object literal as the first argument, this rule requires using the object spread syntax instead. This rule also warns on cases where an `Object.assign` call is made using a single argument that is an object literal, in this case, the `Object.assign` call is not needed. Object spread is a declarative alternative which may perform better than the more dynamic, imperative `Object.assign`. Examples of **incorrect** code for this rule: ```javascript Object.assign({}, foo); Object.assign({}, { foo: 'bar' }); Object.assign({ foo: 'bar' }, baz); Object.assign({}, baz, { foo: 'bar' }); Object.assign({}, { ...baz }); // Object.assign with a single argument that is an object literal Object.assign({}); Object.assign({ foo: bar }); ``` Examples of **correct** code for this rule: ```javascript ({ ...foo }); ({ ...baz, foo: 'bar' }); // Any Object.assign call without an object literal as the first argument Object.assign(foo, { bar: baz }); Object.assign(foo, bar); Object.assign(foo, { bar, baz }); Object.assign(foo, { ...baz }); ``` ## Options This rule has no options. ## Differences from ESLint - ESLint stops tracking the global `Object` variable for the whole file once it is reassigned anywhere without a new declaration (e.g. `Object = {};`), including calls textually before the reassignment. rslint tracks this flow-sensitively: calls before the first bare write to `Object` (and aliases captured before it) are still reported; only references after the write are untracked. - rslint follows aliases flow-sensitively and reports calls that ESLint's ReferenceTracker misses: aliases established by a plain assignment (`let o; o = Object; o.assign({}, x)`), nested destructuring (`const { Object: { assign } } = globalThis; assign({}, x)`), and alias chains of any length. Conversely, an alias that has been reassigned to something else by the time of the call (`let o = Object; o = foo; o.assign({}, x)`) is not reported. - When a source argument is an object literal with a prototype-setting `__proto__:` property, the autofix keeps that literal whole behind a spread (`Object.assign({}, { __proto__: p })` → `({ ...{ __proto__: p } })`) instead of merging its properties into the result literal, where `__proto__:` would change the result's prototype. ESLint's fixer merges it and changes behavior. - The autofix parenthesizes the resulting object literal when the call is the callee of another call (`Object.assign({}, foo)()` → `({ ...foo})()`); ESLint's fixer produces unparsable output there. ## Original Documentation - [ESLint: prefer-object-spread](https://eslint.org/docs/latest/rules/prefer-object-spread) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/prefer-object-spread.js) --- url: /rules/eslint/prefer-promise-reject-errors.md --- # prefer-promise-reject-errors [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'prefer-promise-reject-errors': 'error', }, }, ]); ``` ## Rule Details This rule requires that Promises are rejected with `Error` objects only. Rejecting with non-`Error` values (such as strings or numbers) makes debugging harder because the rejection reason does not carry a stack trace. The rule flags two patterns: - `Promise.reject(value)` calls where `value` cannot be an `Error`. - `new Promise((resolve, reject) => { ... })` executors where the second parameter is invoked with a value that cannot be an `Error`. Examples of **incorrect** code for this rule: ```javascript Promise.reject("something bad happened"); Promise.reject(5); Promise.reject(); new Promise(function (resolve, reject) { reject("something bad happened"); }); new Promise(function (resolve, reject) { reject(); }); ``` Examples of **correct** code for this rule: ```javascript Promise.reject(new Error("something bad happened")); Promise.reject(new TypeError("something bad happened")); new Promise(function (resolve, reject) { reject(new Error("something bad happened")); }); const foo = getUnknownValue(); Promise.reject(foo); ``` ## Options This rule accepts an options object with the following property: - `allowEmptyReject` (`boolean`, default `false`) — when `true`, allows calls to `Promise.reject()` and the executor's reject callback with no arguments. Examples of **correct** code for this rule with `{ "allowEmptyReject": true }`: ```json { "prefer-promise-reject-errors": ["error", { "allowEmptyReject": true }] } ``` ```javascript Promise.reject(); new Promise(function (resolve, reject) { reject(); }); ``` ## Original Documentation - [ESLint: prefer-promise-reject-errors](https://eslint.org/docs/latest/rules/prefer-promise-reject-errors) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/prefer-promise-reject-errors.js) --- url: /rules/eslint/prefer-regex-literals.md --- # prefer-regex-literals [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'prefer-regex-literals': 'error', }, }, ]); ``` ## Rule Details This rule disallows `RegExp` constructor calls when the same regular expression can be written as a literal. Examples of **incorrect** code for this rule: ```javascript new RegExp("abc"); RegExp("abc", "u"); new RegExp(String.raw`^\d\.$`); ``` Examples of **correct** code for this rule: ```javascript /abc/; /abc/u; new RegExp(pattern); RegExp("abc", flags); new RegExp(prefix + "abc"); ``` ## Options This rule accepts an options object with the following property: - `disallowRedundantWrapping` (`boolean`, default `false`) — when `true`, additionally reports regex literals that are unnecessarily wrapped in a `RegExp` constructor. To enable this option: ```json { "prefer-regex-literals": ["error", { "disallowRedundantWrapping": true }] } ``` Examples of **incorrect** code for this rule with `{ "disallowRedundantWrapping": true }`: ```javascript new RegExp(/abc/); new RegExp(/abc/, "u"); ``` Examples of **correct** code for this rule with `{ "disallowRedundantWrapping": true }`: ```javascript /abc/; /abc/u; new RegExp(/abc/, flags); ``` ## Differences from ESLint - rslint does not vary suggestions by configured ECMAScript version; a diagnostic is still reported when the pattern arguments are static. ## Original Documentation - [ESLint: prefer-regex-literals](https://eslint.org/docs/latest/rules/prefer-regex-literals) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/prefer-regex-literals.js) --- url: /rules/eslint/prefer-rest-params.md --- # prefer-rest-params [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'prefer-rest-params': 'error', }, }, ]); ``` ## Rule Details Requires rest parameters instead of `arguments`. There are rest parameters in ES2015. We can use that feature for variadic functions instead of the `arguments` variable. `arguments` does not have methods of `Array.prototype`, so it's a bit inconvenient. Examples of **incorrect** code for this rule: ```javascript function foo() { console.log(arguments); } function foo(action) { var args = Array.prototype.slice.call(arguments, 1); action.apply(null, args); } function foo(action) { var args = [].slice.call(arguments, 1); action.apply(null, args); } ``` Examples of **correct** code for this rule: ```javascript function foo(...args) { console.log(args); } function foo(action, ...args) { action.apply(null, args); } // This is not a use of `arguments` itself function foo() { arguments.length; arguments.callee; } ``` ## Original Documentation - [ESLint: prefer-rest-params](https://eslint.org/docs/latest/rules/prefer-rest-params) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/prefer-rest-params.js) --- url: /rules/eslint/prefer-spread.md --- # prefer-spread [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'prefer-spread': 'error', }, }, ]); ``` ## Rule Details Suggest using the spread operator instead of `.apply()`. Before ES2015, `Function.prototype.apply()` was the only way to call a variadic function with an array of arguments. With the spread operator (`...`), `function(...args)` achieves the same effect more concisely and also works in `new` expressions, which `.apply()` does not support. This rule flags `.apply()` calls that are interchangeable with a spread call: - The second argument of `.apply()` is neither an array literal nor a spread element (those forms already behave like a spread call). - The first argument preserves the `this` binding of the applied function: - When the function is not a member expression, only `null` / `undefined` / `void 0` pass (otherwise the `this` binding may change on migration). - When the function is a member expression (e.g. `obj.foo.apply(obj, args)`), the first argument must produce the same token stream as the member's object (e.g. `obj` on both sides). Examples of **incorrect** code for this rule: ```javascript foo.apply(undefined, args); foo.apply(null, args); obj.foo.apply(obj, args); ``` Examples of **correct** code for this rule: ```javascript // The `this` binding is changed deliberately foo.apply(obj, args); obj.foo.apply(null, args); obj.foo.apply(otherObj, args); // The second argument is not variadic foo.apply(undefined, [1, 2, 3]); obj.foo.apply(obj, [1, 2, 3]); // Already using a spread call obj.foo(...args); ``` ## Original Documentation - [ESLint: prefer-spread](https://eslint.org/docs/latest/rules/prefer-spread) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/prefer-spread.js) --- url: /rules/eslint/prefer-template.md --- # prefer-template [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'prefer-template': 'error', }, }, ]); ``` ## Rule Details This rule is aimed to flag usage of `+` operators with strings. It encourages the use of template literals instead of string concatenation. Examples of **incorrect** code for this rule: ```javascript var str = 'Hello, ' + name + '!'; var str = 'Time: ' + 12 * 60 * 60 * 1000; ``` Examples of **correct** code for this rule: ```javascript var str = 'Hello World!'; var str = `Hello, ${name}!`; var str = `Time: ${12 * 60 * 60 * 1000}`; ``` This rule does not report two string literals concatenated together (for example, `"Hello, " + "World!"`), which is reported by the [`no-useless-concat`](https://eslint.org/docs/latest/rules/no-useless-concat) rule instead. The rule provides an autofix that rewrites the concatenation as a single template literal, preserving comments around the `+` operators. Autofix is skipped when any operand contains an octal or non-octal-decimal escape sequence, because those cannot be represented in a template literal. ## Original Documentation - [ESLint: prefer-template](https://eslint.org/docs/latest/rules/prefer-template) - [Source code](https://github.com/eslint/eslint/blob/v10.2.1/lib/rules/prefer-template.js) --- url: /rules/eslint/preserve-caught-error.md --- # preserve-caught-error [Added in v0.7.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.3) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'preserve-caught-error': 'error', }, }, ]); ``` ## Rule Details When a `catch` block reacts to a failure by throwing a new, more descriptive error, the original error should travel along with it as the new error's `cause`. This rule requires every error constructed and thrown inside a `catch` block to receive the caught error as its `cause`, so the underlying failure stays visible in stack traces and error reports. The rule checks the global error constructors — `Error`, `EvalError`, `RangeError`, `ReferenceError`, `SyntaxError`, `TypeError`, `URIError`, and `AggregateError` — and reports both a missing `cause` and a `cause` set to anything other than the caught error. Each report comes with a suggestion that attaches the caught error. Examples of **incorrect** code for this rule: ```javascript try { doSomething(); } catch (error) { throw new Error('Failed to perform error prone operations'); } try { doSomething(); } catch (error) { throw new Error('Failed to perform error prone operations', { cause: error.message, }); } try { doSomething(); } catch (error) { if (whatever) { const error = anotherError; throw new Error('Something went wrong', { cause: error }); } } try { doSomething(); } catch ({ message }) { throw new Error(message); } ``` Examples of **correct** code for this rule: ```javascript try { doSomething(); } catch (error) { throw new Error('Failed to perform error prone operations', { cause: error }); } try { doSomething(); } catch (error) { throw new Error('Failed to perform error prone operations', { cause: error, retryable: true, }); } try { doSomething(); } catch (error) { console.error(error); } try { doSomething(); } catch (error) { foo = { bar() { throw new Error('Unrelated to the caught error'); }, }; } ``` ## Options ### `requireCatchParameter` By default a `catch` block may omit the parameter entirely, which discards the caught error before the rule can ask for it. Set `requireCatchParameter` to `true` to require the parameter so the caught error stays available. Examples of **incorrect** code for this rule with `{ "requireCatchParameter": true }`: ```json { "preserve-caught-error": ["error", { "requireCatchParameter": true }] } ``` ```javascript try { doSomething(); } catch { throw new Error('Something went wrong'); } ``` Examples of **correct** code for this rule with `{ "requireCatchParameter": true }`: ```json { "preserve-caught-error": ["error", { "requireCatchParameter": true }] } ``` ```javascript try { doSomething(); } catch (error) { throw new Error('Something went wrong', { cause: error }); } ``` ### `errorClassNames` Custom error classes are checked when their name is listed in `errorClassNames`. A bare string means the class takes its error options as the second argument, matching the built-in error signature. To describe a different signature, use an object with `name` and the 1-based `argumentPosition` of the options argument. The name is matched against the constructor identifier, including the property name of a namespaced constructor such as `new errors.AppError()`. Examples of **incorrect** code for this rule with `{ "errorClassNames": ["AppError"] }`: ```json { "preserve-caught-error": ["error", { "errorClassNames": ["AppError"] }] } ``` ```javascript class AppError extends Error {} try { doSomething(); } catch (error) { throw new AppError('Something went wrong'); } ``` Examples of **correct** code for this rule with `{ "errorClassNames": [{ "name": "AppError", "argumentPosition": 3 }] }`: ```json { "preserve-caught-error": [ "error", { "errorClassNames": [{ "name": "AppError", "argumentPosition": 3 }] } ] } ``` ```javascript class AppError extends Error {} try { doSomething(); } catch (error) { throw new AppError('Something went wrong', context, { cause: error }); } ``` ## Differences from ESLint - For a constructor written without an argument list, the suggestion adds the arguments after the whole expression — `new AppError` becomes `new AppError({ cause: error })` and `new (AppError)` becomes `new (AppError)({ cause: error })`. ESLint puts them directly after the callee name, which lands inside the type arguments or the parentheses. ## Original Documentation - [ESLint: preserve-caught-error](https://eslint.org/docs/latest/rules/preserve-caught-error) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/preserve-caught-error.js) --- url: /rules/eslint/radix.md --- # radix [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'radix': 'error', }, }, ]); ``` ## Rule Details This rule enforces that `parseInt()` and `Number.parseInt()` are called with an explicit radix argument. Without a radix, `parseInt` defaults to decimal for most inputs but previously inferred `16` for strings starting with `0x` (and some implementations inferred `8` for strings starting with `0`), which made the behavior hard to predict. Passing an explicit radix eliminates the ambiguity. The rule reports three kinds of problems: - **No arguments** — `parseInt()` is called with no arguments at all. - **Missing radix** — `parseInt(s)` is called with only the string argument. A suggestion fix is offered that inserts `, 10` (or ` 10,` when a trailing comma is present) to pass the decimal radix explicitly. - **Invalid radix** — the second argument is a literal (or the identifier `undefined`) that cannot be an integer between `2` and `36`. Examples of **incorrect** code for this rule: ```javascript parseInt(); parseInt("071"); parseInt("071", "abc"); parseInt("071", 37); parseInt("071", 10.5); Number.parseInt(); Number.parseInt("071"); ``` Examples of **correct** code for this rule: ```javascript parseInt("071", 10); parseInt("071", 8); parseInt("071", foo); Number.parseInt("071", 10); parseFloat(someValue); ``` ## Options The rule accepts a deprecated string option (`"always"` or `"as-needed"`). It is preserved for backward compatibility and does not change the rule's behavior — a radix argument is always required regardless of the option. ## Original Documentation - [ESLint: radix](https://eslint.org/docs/latest/rules/radix) - [Source code](https://github.com/eslint/eslint/blob/v10.2.1/lib/rules/radix.js) --- url: /rules/eslint/require-atomic-updates.md --- # require-atomic-updates [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'require-atomic-updates': 'error', }, }, ]); ``` ## Rule Details Disallow assignments that can lead to race conditions due to usage of `await` or `yield`. This rule reports assignments to variables or properties in cases where the assignments may be based on outdated values. When a variable is read, then an `await` or `yield` pauses execution, the variable might be modified by another concurrent operation before the assignment completes. Examples of **incorrect** code for this rule: ```javascript let result; async function foo() { result += await something; } async function bar() { result = result + (await something); } function* baz() { result += yield; } ``` Examples of **correct** code for this rule: ```javascript let result; async function foo() { result = (await something) + result; } async function bar() { const tmp = await something; result += tmp; } async function baz() { let localVar = 0; localVar += await something; } ``` ## Options ### `allowProperties` When set to `true`, the rule does not report assignments to properties (only variables). ```json { "require-atomic-updates": ["error", { "allowProperties": true }] } ``` ```javascript async function foo(obj) { if (!obj.done) { obj.something = await getSomething(); // OK with allowProperties } } ``` ## Original Documentation - [ESLint: require-atomic-updates](https://eslint.org/docs/latest/rules/require-atomic-updates) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/require-atomic-updates.js) --- url: /rules/eslint/require-await.md --- # require-await [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'require-await': 'error', }, }, ]); ``` ## Rule Details This rule warns on async functions that have no `await` expression. Examples of **incorrect** code for this rule: ```javascript async function foo() { doSomething(); } bar(async () => { doSomething(); }); ``` Examples of **correct** code for this rule: ```javascript async function foo() { await doSomething(); } bar(async () => { await doSomething(); }); function baz() { doSomething(); } bar(() => { doSomething(); }); async function noop() {} ``` Async generator functions are ignored by this rule. ## When Not To Use It If you don't want to warn on async functions that have no `await` expression, then it's safe to disable this rule. ## Original Documentation - [ESLint: require-await](https://eslint.org/docs/latest/rules/require-await) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/require-await.js) --- url: /rules/eslint/require-unicode-regexp.md --- # require-unicode-regexp [Added in v0.9.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'require-unicode-regexp': 'error', }, }, ]); ``` ## Rule Details Enforces the use of the `u` or `v` flag on regular expressions. Examples of **incorrect** code for this rule: ```javascript const a = /aaa/; const b = /bbb/gi; const c = new RegExp("ccc"); const d = new RegExp("ddd", "gi"); ``` Examples of **correct** code for this rule: ```javascript const a = /aaa/u; const b = /bbb/giu; const c = new RegExp("ccc", "u"); const d = new RegExp("ddd", "giu"); const e = /aaa/v; const f = /bbb/giv; const g = new RegExp("ccc", "v"); const h = new RegExp("ddd", "giv"); // This rule ignores RegExp calls if the flags could not be evaluated to a static value. function i(flags) { return new RegExp("eee", flags); } ``` ## Options This rule has one object option: - `requireFlag`: `"u"` or `"v"` — requires that particular flag instead of accepting either. Examples of **incorrect** code for this rule with `{ "requireFlag": "u" }`: ```json { "require-unicode-regexp": ["error", { "requireFlag": "u" }] } ``` ```javascript const foo = /foo/; const fooRegexp = new RegExp("foo"); const bar = /bar/v; const barRegexp = new RegExp("bar", "v"); ``` Examples of **correct** code for this rule with `{ "requireFlag": "u" }`: ```json { "require-unicode-regexp": ["error", { "requireFlag": "u" }] } ``` ```javascript const foo = /foo/u; const fooRegexp = new RegExp("foo", "u"); ``` Examples of **incorrect** code for this rule with `{ "requireFlag": "v" }`: ```json { "require-unicode-regexp": ["error", { "requireFlag": "v" }] } ``` ```javascript const foo = /foo/; const fooRegexp = new RegExp("foo"); const bar = /bar/u; const barRegexp = new RegExp("bar", "u"); ``` Examples of **correct** code for this rule with `{ "requireFlag": "v" }`: ```json { "require-unicode-regexp": ["error", { "requireFlag": "v" }] } ``` ```javascript const foo = /foo/v; const fooRegexp = new RegExp("foo", "v"); ``` ## Differences from ESLint - When flags come from a newly constructed RegExp object's property, such as `RegExp("g", "u").source`, rslint may skip a call that ESLint reports. - With computed `['__proto__']` properties in constant objects, rslint follows own-property semantics and can report a constructor call that ESLint skips. - Capture names or Unicode properties newer than the bundled TypeScript parser's Unicode data can receive a diagnostic without a flag suggestion. - For a negated `v` class where a range is followed by a string-valued operand, rslint omits ESLint's suggestion because JavaScript would reject the result. ## Original Documentation - [ESLint: require-unicode-regexp](https://eslint.org/docs/latest/rules/require-unicode-regexp) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/require-unicode-regexp.js) --- url: /rules/eslint/require-yield.md --- # require-yield [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'require-yield': 'error', }, }, ]); ``` ## Rule Details This rule generates warnings for generator functions that do not have the `yield` keyword. Examples of **incorrect** code for this rule: ```javascript function* foo() { return 10; } ``` Examples of **correct** code for this rule: ```javascript function* foo() { yield 5; return 10; } function foo() { return 10; } // This rule does not warn on empty generator functions. function* foo() {} ``` ## When Not To Use It If you don't want to notify generator functions that have no `yield` expression, then it's safe to disable this rule. ## Original Documentation - [ESLint: require-yield](https://eslint.org/docs/latest/rules/require-yield) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/require-yield.js) --- url: /rules/eslint/sort-imports.md --- # sort-imports [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'sort-imports': 'error', }, }, ]); ``` ## Rule Details This rule enforces a consistent order for import declarations and for named members within an import declaration. Examples of **incorrect** code for this rule: ```javascript import b from "b"; import a from "a"; import { z, a } from "values"; ``` Examples of **correct** code for this rule: ```javascript import "setup"; import * as namespace from "namespace"; import { a, z } from "values"; import value from "value"; ``` The declaration order can be customized with `memberSyntaxSortOrder`. `ignoreCase`, `ignoreDeclarationSort`, `ignoreMemberSort`, and `allowSeparatedGroups` provide the same controls as ESLint. ## Original Documentation - [ESLint: sort-imports](https://eslint.org/docs/latest/rules/sort-imports) - [Source code](https://github.com/eslint/eslint/blob/v10.9.0/lib/rules/sort-imports.js) --- url: /rules/eslint/sort-keys.md --- # sort-keys [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'sort-keys': 'error', }, }, ]); ``` ## Rule Details This rule checks all property definitions of object literal expressions and verifies that all keys are sorted alphabetically. Examples of **incorrect** code for this rule: ```javascript var obj1 = { a: 1, c: 3, b: 2 }; var obj2 = { a: 1, "c": 3, b: 2 }; // Case-sensitive by default. var obj3 = { a: 1, b: 2, C: 3 }; // Non-natural order by default. var obj4 = { 1: a, 2: c, 10: b }; // This rule checks computed properties which have a simple name as well. var obj5 = { a: 1, ["c"]: 3, b: 2 }; ``` Examples of **correct** code for this rule: ```javascript var obj1 = { a: 1, b: 2, c: 3 }; var obj2 = { a: 1, "b": 2, c: 3 }; // Case-sensitive by default. var obj3 = { C: 3, a: 1, b: 2 }; // Non-natural order by default. var obj4 = { 1: a, 10: b, 2: c }; // This rule ignores computed properties which have a non-simple name. var obj5 = { a: 1, [c + d]: 3, b: 2 }; // This rule does not report unsorted properties that are separated by a spread property. var obj6 = { b: 1, ...c, a: 2 }; ``` Examples of **incorrect** code for this rule with `{ "caseSensitive": false }`: ```json { "sort-keys": ["error", "asc", { "caseSensitive": false }] } ``` ```javascript var obj = { a: 1, C: 3, b: 2 }; ``` Examples of **incorrect** code for this rule with `{ "natural": true }`: ```json { "sort-keys": ["error", "asc", { "natural": true }] } ``` ```javascript var obj = { 1: a, 10: c, 2: b }; ``` Examples of **incorrect** code for this rule with `{ "minKeys": 4 }`: ```json { "sort-keys": ["error", "asc", { "minKeys": 4 }] } ``` ```javascript var obj = { a: 1, c: 2, b: 3, d: 4 }; ``` Examples of **correct** code for this rule with `{ "allowLineSeparatedGroups": true }`: ```json { "sort-keys": ["error", "asc", { "allowLineSeparatedGroups": true }] } ``` ```javascript var obj = { e: 1, f: 2, g: 3, a: 4, b: 5, c: 6, }; ``` Examples of **correct** code for this rule with `{ "ignoreComputedKeys": true }`: ```json { "sort-keys": ["error", "asc", { "ignoreComputedKeys": true }] } ``` ```javascript var obj = { a: 1, [c]: 2, b: 3 }; ``` ## Options The 1st option is `"asc"` or `"desc"`. - `"asc"` (default) enforces properties to be in ascending order. - `"desc"` enforces properties to be in descending order. The 2nd option is an object with the following properties. - `caseSensitive` — if `true`, enforces properties to be in case-sensitive order. Default is `true`. - `natural` — if `true`, enforces properties to be in natural order: strings that mix letters and numbers are compared the way a human would, so `10` sorts after `2` instead of before it. Default is `false`. - `minKeys` — the minimum number of keys an object must have for its sort order to be checked. Default is `2`. - `allowLineSeparatedGroups` — if `true`, a blank line after a property resets sorting: the properties that follow only need to be sorted relative to each other, not to the properties before the blank line. Default is `false`. - `ignoreComputedKeys` — if `true`, computed keys are ignored entirely and reset the sorting of the keys that follow them. Default is `false`. ## Original Documentation - [ESLint: sort-keys](https://eslint.org/docs/latest/rules/sort-keys) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/sort-keys.js) --- url: /rules/eslint/sort-vars.md --- # sort-vars [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'sort-vars': 'error', }, }, ]); ``` ## Rule Details This rule requires identifier variables within the same declaration block to be sorted alphabetically. Destructuring declarations are ignored. By default, ordering is case-sensitive. Examples of **incorrect** code for this rule: ```javascript let b, a; let c, D, e; ``` Examples of **correct** code for this rule: ```javascript let a, b, c; let G, f, h; let { b, a } = value; ``` With `{ "ignoreCase": true }`, names are compared without case sensitivity: ```json { "sort-vars": ["error", { "ignoreCase": true }] } ``` ```javascript let a, A; let c, D, e; ``` The rule can automatically reorder declarations when every participating initializer is a literal. It reports without a fix when reordering might change evaluation order. ## Original Documentation - [ESLint: sort-vars](https://eslint.org/docs/latest/rules/sort-vars) - [Source code](https://github.com/eslint/eslint/blob/v10.9.0/lib/rules/sort-vars.js) --- url: /rules/eslint/strict.md --- # strict [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'strict': 'error', }, }, ]); ``` ## Rule Details Require or disallow strict mode directives (`"use strict"`). The rule supports four options: - `"safe"` (default) — uses `"function"` semantics for scripts and `"global"` semantics for CommonJS files; module files always use `"module"` semantics. - `"never"` — disallows all strict mode directives. - `"global"` — requires exactly one strict directive in global scope and disallows all other directives. - `"function"` — requires one strict directive in each top-level function and disallows directives in the global scope or in nested functions / class bodies. When `languageOptions.sourceType` is `"module"`, the rule always uses module semantics: every `"use strict"` directive is reported as unnecessary and removed by autofix. ## Differences from ESLint The `parserOptions.ecmaFeatures.impliedStrict` and `globalReturn` options are not supported. ## Examples ### `"never"` ```json { "strict": ["error", "never"] } ``` Examples of **incorrect** code: ```javascript "use strict"; function foo() {} ``` ```javascript function foo() { "use strict"; } ``` Examples of **correct** code: ```javascript function foo() {} ``` ### `"global"` ```json { "strict": ["error", "global"] } ``` Examples of **incorrect** code: ```javascript function foo() {} ``` ```javascript function foo() { "use strict"; } ``` ```javascript "use strict"; function foo() { "use strict"; } ``` Examples of **correct** code: ```javascript "use strict"; function foo() {} ``` ### `"function"` ```json { "strict": ["error", "function"] } ``` Examples of **incorrect** code: ```javascript "use strict"; function foo() {} ``` ```javascript function foo() {} (function() { function bar() { "use strict"; } }()); ``` Examples of **correct** code: ```javascript function foo() { "use strict"; } (function() { "use strict"; function bar() {} function baz(a = 1) {} }()); const foo2 = (function() { "use strict"; return function foo(a = 1) {}; }()); ``` ## Original Documentation - [ESLint: strict](https://eslint.org/docs/latest/rules/strict) - [Source code](https://github.com/eslint/eslint/blob/v10.9.1/lib/rules/strict.js) --- url: /rules/eslint/symbol-description.md --- # symbol-description [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'symbol-description': 'error', }, }, ]); ``` ## Rule Details Requires a description when creating a `Symbol`. A description makes logged and debugged symbols easier to identify. Examples of **incorrect** code for this rule: ```javascript var foo = Symbol(); ``` Examples of **correct** code for this rule: ```javascript var foo = Symbol("some description"); var someString = "some description"; var bar = Symbol(someString); ``` ## Original Documentation - [ESLint: symbol-description](https://eslint.org/docs/latest/rules/symbol-description) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/symbol-description.js) --- url: /rules/eslint/unicode-bom.md --- # unicode-bom [Added in v0.8.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'unicode-bom': 'error', }, }, ]); ``` ## Rule Details The Unicode byte order mark (BOM, U+FEFF) marks whether code units are big endian or little endian. UTF-8 does not need one, because byte ordering does not matter when a character is a single byte, and UTF-8 dominates the web. This rule controls whether a file begins with a BOM. Only the first position counts: a U+FEFF character anywhere else in the file is ordinary text and is left alone. The mark lives in a file's bytes rather than in its text, so this rule reads the file itself. It runs wherever rslint reads files — the CLI and the API — and `rslint --fix` adds or removes the mark, rewriting the rest of the file unchanged. Editors work from decoded text: VS Code turns a leading mark into the document's encoding, shown in the status bar as "UTF-8 with BOM". The language server therefore leaves this rule to the CLI and the API, where the file's own bytes are in reach. ## Options This rule takes one string option. ### `"never"` (default) A file must not begin with a byte order mark. ```json { "unicode-bom": ["error", "never"] } ``` Example of **correct** code: ```javascript let abc; ``` Example of **incorrect** code: ```javascript // U+FEFF at the beginning let abc; ``` ### `"always"` A file must begin with a byte order mark. ```json { "unicode-bom": ["error", "always"] } ``` Example of **correct** code: ```javascript // U+FEFF at the beginning let abc; ``` Example of **incorrect** code: ```javascript let abc; ``` The mark itself is invisible, so the comment stands in for it: the file's first three bytes are `EF BB BF`. A UTF-16 file, whose mark is `FF FE` or `FE FF`, counts as carrying one for the same reason. ## When Not To Use It If you do not care about the presence of a byte order mark in your files, you can turn this rule off. ## Original Documentation - [ESLint: unicode-bom](https://eslint.org/docs/latest/rules/unicode-bom) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/unicode-bom.js) --- url: /rules/eslint/use-isnan.md --- # use-isnan [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'use-isnan': 'error', }, }, ]); ``` ## Rule Details Requires calls to `isNaN()` when checking for `NaN`. Because `NaN` is unique in JavaScript in that it is not equal to anything, including itself, the results of comparisons to `NaN` are confusing: `NaN === NaN` is `false`. Therefore, use `Number.isNaN()` or the global `isNaN()` function to test whether a value is `NaN`. ## Options - `enforceForSwitchCase` (default: `true`): Disallows `switch(NaN)` and `case NaN:` in switch statements. - `enforceForIndexOf` (default: `false`): Disallows calling `indexOf` and `lastIndexOf` with `NaN` as an argument. Examples of **incorrect** code for this rule: ```javascript if (foo == NaN) { } if (foo === NaN) { } if (foo !== NaN) { } switch (NaN) { case foo: break; } switch (foo) { case NaN: break; } ``` Examples of **correct** code for this rule: ```javascript if (isNaN(foo)) { } if (Number.isNaN(foo)) { } if (!isNaN(foo)) { } ``` ## Original Documentation - [ESLint: use-isnan](https://eslint.org/docs/latest/rules/use-isnan) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/use-isnan.js) --- url: /rules/eslint/valid-typeof.md --- # valid-typeof [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration | Preset | Configured Value | | ------------------------ | ---------------- | | ✅ js.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'valid-typeof': 'error', }, }, ]); ``` ## Rule Details Enforces comparing `typeof` expressions against valid string literals. The `typeof` operator can only return one of the following strings: `"undefined"`, `"object"`, `"boolean"`, `"number"`, `"string"`, `"function"`, `"symbol"`, `"bigint"`. Comparing a `typeof` expression against any other value is almost certainly a bug. Examples of **incorrect** code for this rule: ```javascript typeof foo === 'strnig'; typeof foo == 'undefned'; typeof bar != 'nunber'; typeof bar !== 'fucntion'; typeof foo === undefined; ``` Examples of **correct** code for this rule: ```javascript typeof foo === 'string'; typeof bar == 'undefined'; typeof baz === 'object'; typeof qux !== 'function'; typeof foo === typeof bar; ``` ## Options ### `requireStringLiterals` When set to `true`, requires that `typeof` expressions are only compared to string literals or other `typeof` expressions, and disallows comparisons to any other value. Examples of additional **incorrect** code with `{ "requireStringLiterals": true }`: ```javascript typeof foo === undefined; typeof foo === Object; typeof foo === someVariable; ``` ## Original Documentation - [ESLint: valid-typeof](https://eslint.org/docs/latest/rules/valid-typeof) - [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/valid-typeof.js) --- url: /rules/eslint/vars-on-top.md --- # Require `var` declarations at the top of their scope (`vars-on-top`) [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'vars-on-top': 'error', }, }, ]); ``` The `vars-on-top` rule requires `var` declarations to appear before executable statements in the program or in a function body. Directive strings and imports may appear before the declarations. Declarations inside nested blocks and loop headers are reported; declarations at the start of a class static block are also allowed. ## Rule Details Examples of **incorrect** code: ```js function example() { doSomething(); var value = 1; } ``` Examples of **correct** code: ```js function example() { "use strict"; var value = 1; doSomething(value); } ``` ## Differences from ESLint rslint applies the same rule behavior to JavaScript and TypeScript syntax. As with ESLint, the rule has no options and reports the complete declaration. --- url: /rules/eslint/yoda.md --- # yoda [Added in v0.9.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, js } from '@rslint/core'; export default defineConfig([ js.configs.recommended, { rules: { 'yoda': 'error', }, }, ]); ``` ## Rule Details Yoda conditions are so named because the literal value of the condition comes first while the variable comes second, e.g. `if ("red" === color)`. This rule enforces a consistent style of conditions which compare a variable to a literal value. Examples of **incorrect** code for this rule, with the default `"never"` option: ```javascript if ("red" === color) { } if (true == flag) { } if (5 > count) { } if (-1 < str.indexOf(substr)) { } if (0 <= x && x < 1) { } ``` Examples of **correct** code for this rule, with the default `"never"` option: ```javascript if (value === "red") { } if (flag == true) { } if (count < 5) { } ``` ## Options This rule takes a string option: - `"never"` (default): comparisons must never be Yoda conditions. - `"always"`: the literal value must always come first. The `"never"` option can take exception options in an object literal: - `exceptRange`: when `true`, allows Yoda conditions in range comparisons that are wrapped directly in parentheses, including the parentheses of an `if` or `while` condition. A range comparison tests whether a variable is inside or outside the range between two literal values. Default `false`. - `onlyEquality`: when `true`, only reports Yoda conditions for the equality operators `==` and `===`. Default `false`. `onlyEquality` allows a superset of the exceptions `exceptRange` allows, so combining both options together isn't useful. Examples of **correct** code for this rule with `{ "exceptRange": true }`: ```json { "yoda": ["error", "never", { "exceptRange": true }] } ``` ```javascript function isReddish(color) { return (color.hue < 60 || 300 < color.hue); } if (x < -1 || 1 < x) { } if ((0 <= rand && rand < 1) && count < 10) { } ``` Each parenthesized pair of comparisons forms one range comparison, so a range comparison combined with a further condition needs its own parentheses. Examples of **correct** code for this rule with `{ "onlyEquality": true }`: ```json { "yoda": ["error", "never", { "onlyEquality": true }] } ``` ```javascript if (x < -1 || 9 < x) { } if (x !== "foo" && "bar" != x) { } ``` Examples of **incorrect** code for this rule with the `"always"` option: ```json { "yoda": ["error", "always"] } ``` ```javascript if (color == "blue") { } ``` Examples of **correct** code for this rule with the `"always"` option: ```json { "yoda": ["error", "always"] } ``` ```javascript if ("blue" == color) { } ``` ## Differences from ESLint - TypeScript-only wrappers with no runtime effect — `x!`, `x as T`, `x satisfies T` — are read through when deciding whether the two comparisons of a range test hold the same operand. With `{ "exceptRange": true }`, `if (0 <= x! && x! < 1) {}` reads as one range comparison and stays exempt. ## Original Documentation - [ESLint: yoda](https://eslint.org/docs/latest/rules/yoda) - [Source code](https://github.com/eslint/eslint/blob/v10.8.0/lib/rules/yoda.js) --- url: /rules/typescript-eslint/adjacent-overload-signatures.md --- # adjacent-overload-signatures [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/adjacent-overload-signatures': 'error', }, }, ]); ``` ## Rule Details Require that function overload signatures be consecutive. When function overload signatures are not adjacent to each other, it can be difficult to read and understand the complete set of overloads for a given function. Examples of **incorrect** code for this rule: ```typescript declare function foo(s: string): void; declare function bar(): void; declare function foo(n: number): void; class MyClass { foo(s: string): void; bar(): void; foo(n: number): void; } ``` Examples of **correct** code for this rule: ```typescript declare function foo(s: string): void; declare function foo(n: number): void; declare function bar(): void; class MyClass { foo(s: string): void; foo(n: number): void; bar(): void; } ``` ## Original Documentation - [typescript-eslint: adjacent-overload-signatures](https://typescript-eslint.io/rules/adjacent-overload-signatures) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts) --- url: /rules/typescript-eslint/array-type.md --- # array-type [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/array-type': 'error', }, }, ]); ``` ## Rule Details Require consistently using either `T[]` or `Array` for arrays. TypeScript provides two equivalent ways to define array types. This rule enforces a consistent style across the codebase. The rule supports three modes via the `default` option: `"array"` (prefer `T[]`), `"generic"` (prefer `Array`), and `"array-simple"` (prefer `T[]` for simple types, `Array` for complex types). A separate `readonly` option controls readonly array syntax. Examples of **incorrect** code for this rule (with default `"array"` option): ```typescript const a: Array = []; const b: ReadonlyArray = [1, 2]; const c: Array = []; ``` Examples of **correct** code for this rule (with default `"array"` option): ```typescript const a: string[] = []; const b: readonly number[] = [1, 2]; const c: (string | number)[] = []; ``` ## Original Documentation - [typescript-eslint: array-type](https://typescript-eslint.io/rules/array-type) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.39.0/packages/eslint-plugin/src/rules/array-type.ts) --- url: /rules/typescript-eslint/await-thenable.md --- # await-thenable [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/await-thenable': 'error', }, }, ]); ``` ## Rule Details Disallow awaiting a value that is not a Thenable (Promise-like). Using `await` on a non-Promise value is almost always a programmer error and has no effect at runtime, since `await` on a non-Thenable value simply returns it immediately. This rule also checks `for await...of` loops for non-async iterables and `await using` declarations for non-async disposable values. Examples of **incorrect** code for this rule: ```typescript async function foo() { await 42; } async function bar(x: number) { await x; } async function baz(arr: number[]) { for await (const item of arr) { } } ``` Examples of **correct** code for this rule: ```typescript async function foo() { await Promise.resolve(42); } async function bar(x: Promise) { await x; } async function baz(iter: AsyncIterable) { for await (const item of iter) { } } ``` ## Original Documentation - [typescript-eslint: await-thenable](https://typescript-eslint.io/rules/await-thenable) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.28.0/packages/eslint-plugin/src/rules/await-thenable.ts) --- url: /rules/typescript-eslint/ban-ts-comment.md --- # ban-ts-comment [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ----------------------------------- | ------------------------------------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `["error",{"minimumDescriptionLength":10}]` | | ✅ ts.configs.strictTypeChecked | `["error",{"minimumDescriptionLength":10}]` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/ban-ts-comment': 'error', }, }, ]); ``` ## Rule Details Disallow `@ts-` comments or require descriptions after directives. TypeScript provides several directive comments (`@ts-expect-error`, `@ts-ignore`, `@ts-nocheck`, `@ts-check`) that alter how the compiler processes code. Overusing these directives can hide real errors and reduce type safety. By default, `@ts-expect-error`, `@ts-ignore`, and `@ts-nocheck` are banned. Directives can optionally be allowed if accompanied by a description meeting a minimum length requirement. Examples of **incorrect** code for this rule: ```typescript // @ts-ignore const x: number = 'hello'; // @ts-nocheck /* @ts-ignore */ const y = undefined; ``` Examples of **correct** code for this rule: ```typescript // @ts-expect-error: this is intentional for testing const x: number = 'hello'; // @ts-check // Regular comments that mention @ts-ignore in passing are fine ``` ## Original Documentation - [typescript-eslint: ban-ts-comment](https://typescript-eslint.io/rules/ban-ts-comment) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.46.3/packages/eslint-plugin/src/rules/ban-ts-comment.ts) --- url: /rules/typescript-eslint/ban-tslint-comment.md --- # ban-tslint-comment [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/ban-tslint-comment': 'error', }, }, ]); ``` ## Rule Details Disallow TSLint directive comments such as `// tslint:disable` and `// tslint:disable-next-line`. These directives are not used by ESLint and are typically left behind when migrating from TSLint. Examples of **incorrect** code for this rule: ```javascript /* tslint:disable */ /* tslint:enable */ // tslint:disable-next-line someCode(); // tslint:disable-line ``` Examples of **correct** code for this rule: ```javascript // some other comment /* another comment that mentions tslint */ ``` ## Original Documentation - [typescript-eslint: ban-tslint-comment](https://typescript-eslint.io/rules/ban-tslint-comment) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/ban-tslint-comment.ts) --- url: /rules/typescript-eslint/class-literal-property-style.md --- # class-literal-property-style [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/class-literal-property-style': 'error', }, }, ]); ``` ## Rule Details Enforce that literals on classes are exposed in a consistent style, either as readonly fields or as getter methods. When a class has a property that always returns a literal value, there are two ways to expose it: a `readonly` field or a `get` accessor. This rule enforces one style for consistency. The rule supports two modes: `"fields"` (default) prefers `readonly` fields, and `"getters"` prefers getter methods. Examples of **incorrect** code for this rule (with default `"fields"` option): ```typescript class Foo { get name() { return 'foo'; } } class Bar { get count() { return 42; } } ``` Examples of **correct** code for this rule (with default `"fields"` option): ```typescript class Foo { readonly name = 'foo'; } class Bar { readonly count = 42; } ``` ## Original Documentation - [typescript-eslint: class-literal-property-style](https://typescript-eslint.io/rules/class-literal-property-style) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.39.0/packages/eslint-plugin/src/rules/class-literal-property-style.ts) --- url: /rules/typescript-eslint/class-methods-use-this.md --- # class-methods-use-this [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/class-methods-use-this': 'error', }, }, ]); ``` ## Rule Details Enforce that class methods utilize `this`. If a class method does not use `this`, it can sometimes be made into a static function. If you do convert the method into a static function, instances of the class that call that particular method will have to be converted to a static call (i.e., `MyClass.callStaticMethod()`). This rule extends the base ESLint `class-methods-use-this` rule with two TypeScript-specific options: `ignoreOverrideMethods` (skip members marked with the `override` modifier) and `ignoreClassesThatImplementAnInterface` (skip members of classes that `implements` an interface). Examples of **incorrect** code for this rule: ```javascript class A { foo() { console.log('Hello World'); } } ``` Examples of **correct** code for this rule: ```javascript class A { foo() { this.bar = 'Hello World'; } } class A { constructor() { // OK. constructor is exempt. } } class A { static foo() { // OK. static methods are exempt. } } ``` ## Options ### `enforceForClassFields` **Type:** `boolean` — **Default:** `true` Enforces that functions used as instance field initializers utilize `this`. Examples of **incorrect** code with `{ "enforceForClassFields": true }` (default): ```json { "@typescript-eslint/class-methods-use-this": ["error", { "enforceForClassFields": true }] } ``` ```javascript class A { foo = () => {}; } ``` Examples of **correct** code with `{ "enforceForClassFields": false }`: ```json { "@typescript-eslint/class-methods-use-this": ["error", { "enforceForClassFields": false }] } ``` ```javascript class A { foo = () => {}; } ``` ### `exceptMethods` **Type:** `string[]` — **Default:** `[]` Allows specified method names to be ignored by this rule. Private class members can be referenced via their `#`-prefixed name (`#foo`). Examples of **correct** code with `{ "exceptMethods": ["foo", "#bar"] }`: ```json { "@typescript-eslint/class-methods-use-this": ["error", { "exceptMethods": ["foo", "#bar"] }] } ``` ```javascript class A { foo() {} #bar() {} } ``` ### `ignoreOverrideMethods` **Type:** `boolean` — **Default:** `false` Whether to ignore class members marked with the `override` modifier. Examples of **correct** code with `{ "ignoreOverrideMethods": true }`: ```json { "@typescript-eslint/class-methods-use-this": ["error", { "ignoreOverrideMethods": true }] } ``` ```typescript class Base { method() {} } class Derived extends Base { override method() {} } ``` ### `ignoreClassesThatImplementAnInterface` **Type:** `boolean | 'public-fields'` — **Default:** `false` Whether to ignore class members that are defined within a class that `implements` an interface. - `true` — ignore every member of any class that implements an interface. - `'public-fields'` — only ignore public members (those without a `private` or `protected` modifier). Examples of **correct** code with `{ "ignoreClassesThatImplementAnInterface": true }`: ```json { "@typescript-eslint/class-methods-use-this": ["error", { "ignoreClassesThatImplementAnInterface": true }] } ``` ```typescript class Foo implements Bar { method() {} property = () => {}; } ``` Examples of **correct** code with `{ "ignoreClassesThatImplementAnInterface": "public-fields" }`: ```json { "@typescript-eslint/class-methods-use-this": ["error", { "ignoreClassesThatImplementAnInterface": "public-fields" }] } ``` ```typescript class Foo implements Bar { method() {} } ``` Examples of **incorrect** code with `{ "ignoreClassesThatImplementAnInterface": "public-fields" }` (`private`/`protected` members are still checked): ```typescript class Foo implements Bar { private method() {} protected property = () => {}; } ``` ## Original Documentation - [typescript-eslint: class-methods-use-this](https://typescript-eslint.io/rules/class-methods-use-this) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/class-methods-use-this.ts) --- url: /rules/typescript-eslint/consistent-generic-constructors.md --- # consistent-generic-constructors [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/consistent-generic-constructors': 'error', }, }, ]); ``` ## Rule Details Enforce specifying generic type arguments on the type annotation or the constructor of a variable declaration. When constructing a generic class, the type arguments can be placed either on the left-hand side (type annotation) or the right-hand side (constructor call). This rule enforces consistency. The rule supports two modes: `"constructor"` (default) prefers type arguments on the constructor call, and `"type-annotation"` prefers them on the type annotation. Examples of **incorrect** code for this rule (with default `"constructor"` option): ```typescript const map: Map = new Map(); const set: Set = new Set(); ``` Examples of **correct** code for this rule (with default `"constructor"` option): ```typescript const map = new Map(); const set = new Set(); const map2: Map = new Map(); ``` ## Original Documentation - [typescript-eslint: consistent-generic-constructors](https://typescript-eslint.io/rules/consistent-generic-constructors) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.46.3/packages/eslint-plugin/src/rules/consistent-generic-constructors.ts) --- url: /rules/typescript-eslint/consistent-indexed-object-style.md --- # consistent-indexed-object-style [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/consistent-indexed-object-style': 'error', }, }, ]); ``` ## Rule Details Require or disallow the `Record` type. TypeScript supports defining object types with an index signature or using the built-in `Record` utility type. This rule enforces a consistent style. The rule supports two modes: `"record"` (default) prefers `Record` over index signatures, and `"index-signature"` prefers index signatures over `Record`. Examples of **incorrect** code for this rule (with default `"record"` option): ```typescript interface Foo { [key: string]: unknown; } type Bar = { [key: number]: string; }; ``` Examples of **correct** code for this rule (with default `"record"` option): ```typescript type Foo = Record; type Bar = Record; interface Baz { [key: string]: unknown; name: string; // has other members, so it's fine } ``` ## Original Documentation - [typescript-eslint: consistent-indexed-object-style](https://typescript-eslint.io/rules/consistent-indexed-object-style) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/consistent-indexed-object-style.ts) --- url: /rules/typescript-eslint/consistent-return.md --- # consistent-return [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/consistent-return': 'error', }, }, ]); ``` ## Rule Details Require `return` statements to either always or never specify values. This is the TypeScript-enhanced version of the ESLint `consistent-return` rule. It uses type information to allow valid return patterns for functions with `void`, `undefined`, or `Promise` return types. A function with inconsistent return statements (some returning a value and some not) is typically a mistake. Examples of **incorrect** code for this rule: ```typescript function foo(flag: boolean): string | undefined { if (flag) { return 'hello'; } return; } function bar(x: number) { if (x > 0) { return x; } return; } ``` Examples of **correct** code for this rule: ```typescript function foo(flag: boolean): string | undefined { if (flag) { return 'hello'; } return undefined; } function bar(): void { if (Math.random() > 0.5) { return; } console.log('done'); } ``` ## Original Documentation - [typescript-eslint: consistent-return](https://typescript-eslint.io/rules/consistent-return) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/consistent-return.ts) --- url: /rules/typescript-eslint/consistent-type-assertions.md --- # consistent-type-assertions [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/consistent-type-assertions': 'error', }, }, ]); ``` ## Rule Details Enforce consistent usage of type assertions. TypeScript provides two syntaxes for type assertions: `as` expressions (`value as Type`) and angle-bracket syntax (`value`). This rule enforces a consistent style and can also restrict type assertions on object and array literals. The `assertionStyle` option supports `"as"` (default), `"angle-bracket"`, and `"never"`. Additional options `objectLiteralTypeAssertions` and `arrayLiteralTypeAssertions` control whether assertions on literals are allowed. Examples of **incorrect** code for this rule (with default `"as"` option): ```typescript const x = value; const y = 42; ``` Examples of **correct** code for this rule (with default `"as"` option): ```typescript const x = value as string; const y = 42 as number; const z = value as const; ``` ## Compatibility Notes The rule is aligned with `typescript-eslint` v8.69.0 for diagnostic selection, message IDs, ranges, suggestions, and autofixes. Literal-assertion diagnostics use context-aware descriptions: an untyped variable initializer recommends a type annotation or the `satisfies` operator, while other expressions recommend only `satisfies`. Upstream always recommends `const x: T = ...`, including in return expressions, class fields, and other positions where that replacement cannot be applied. ## Original Documentation - [typescript-eslint: consistent-type-assertions](https://typescript-eslint.io/rules/consistent-type-assertions) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.69.0/packages/eslint-plugin/src/rules/consistent-type-assertions.ts) --- url: /rules/typescript-eslint/consistent-type-definitions.md --- # consistent-type-definitions [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/consistent-type-definitions': 'error', }, }, ]); ``` ## Rule Details Enforce type definitions to consistently use either `interface` or `type`. TypeScript provides two ways to define object types: `interface` declarations and `type` alias declarations with object literal types. This rule enforces one style for consistency. The rule supports two modes: `"interface"` (default) prefers interfaces over type literals, and `"type"` prefers type aliases over interfaces. This rule is auto-fixable. Examples of **incorrect** code for this rule (with default `"interface"` option): ```typescript // type alias with object literal -> should be interface type Foo = { name: string; age: number; }; // including index signatures type Bar = { [key: string]: number; }; // including parenthesized types type Baz = { x: number; }; ``` Examples of **correct** code for this rule (with default `"interface"` option): ```typescript interface Foo { name: string; age: number; } // Type aliases for non-object types are always allowed type ID = string | number; type Callback = () => void; type Union = { x: number } | { y: string }; type Intersection = { x: number } & { y: string }; type Mapped = { [K in T]: U }; ``` Examples of **incorrect** code for this rule (with `"type"` option): ```typescript interface Foo { name: string; } ``` Examples of **correct** code for this rule (with `"type"` option): ```typescript type Foo = { name: string; }; ``` ## Autofix The rule provides automatic fixes: - **`interface` mode**: Converts `type T = { ... }` to `interface T { ... }`, handling `export`, `declare`, type parameters, parenthesized types, and trailing semicolons. - **`type` mode**: Converts `interface T { ... }` to `type T = { ... }`, converting `extends` clauses to intersection types (`& B & C`). Handles `export default interface` by splitting into a type declaration and a separate default export. Note: Interfaces inside `declare global` blocks report an error but are not auto-fixed to avoid breaking global type augmentation patterns. ## Original Documentation - [typescript-eslint: consistent-type-definitions](https://typescript-eslint.io/rules/consistent-type-definitions) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/consistent-type-definitions.ts) --- url: /rules/typescript-eslint/consistent-type-exports.md --- # consistent-type-exports [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/consistent-type-exports': 'error', }, }, ]); ``` ## Rule Details Enforce consistent usage of type exports. TypeScript allows marking exports as type-only using `export type`, which is erased at compile time and results in no runtime code. This rule enforces that type-only exports use the `export type` syntax. When all exports in a declaration are types, the entire declaration should use `export type`. When a declaration contains a mix of type and value exports, the rule can suggest using inline `type` specifiers. Examples of **incorrect** code for this rule: ```typescript interface Foo {} type Bar = string; export { Foo, Bar }; export { SomeType } from './types'; ``` Examples of **correct** code for this rule: ```typescript interface Foo {} type Bar = string; export type { Foo, Bar }; export type { SomeType } from './types'; export { value, type MyType } from './mixed'; ``` ## Original Documentation - [typescript-eslint: consistent-type-exports](https://typescript-eslint.io/rules/consistent-type-exports) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.46.3/packages/eslint-plugin/src/rules/consistent-type-exports.ts) --- url: /rules/typescript-eslint/consistent-type-imports.md --- # consistent-type-imports [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/consistent-type-imports': 'error', }, }, ]); ``` ## Rule Details Enforce consistent use of type-only imports. TypeScript erases imports marked with `type`, which makes their runtime behavior explicit and works with module settings that preserve value imports. Examples of **incorrect** code for this rule with the default options: ```typescript import { Model, createModel } from './models'; export function create(): Model { return createModel(); } type External = import('./external').External; ``` Examples of **correct** code for this rule with the default options: ```typescript import type { Model } from './models'; import { createModel } from './models'; export function create(): Model { return createModel(); } ``` ### `prefer` The default, `"type-imports"`, requires imports used only in type positions to be marked as type-only. `"no-type-imports"` instead forbids both top-level and inline `type` modifiers. ```json { "consistent-type-imports": ["error", { "prefer": "no-type-imports" }] } ``` ```typescript import { Model } from './models'; type LocalModel = Model; ``` ### `fixStyle` When `prefer` is `"type-imports"`, `"separate-type-imports"` (the default) moves type-only names into a separate declaration. `"inline-type-imports"` keeps named type imports in the value declaration when possible. ```json { "consistent-type-imports": [ "error", { "fixStyle": "inline-type-imports" } ] } ``` ```typescript import { type Model, createModel } from './models'; ``` ### `disallowTypeAnnotations` `disallowTypeAnnotations` defaults to `true` and reports `import()` type annotations. Set it to `false` to allow them. ```json { "consistent-type-imports": [ "error", { "disallowTypeAnnotations": false } ] } ``` ```typescript type Model = import('./models').Model; ``` ## Differences from ESLint The pinned upstream implementation stores module sources in a plain JavaScript object, so imports from `"constructor"`, `"toString"`, `"__proto__"`, or `"hasOwnProperty"` throw while linting. The Go map intentionally handles these names normally and still reports and fixes the import. With `"inline-type-imports"`, rslint also emits a valid inline fix when an earlier default-only or default-plus-namespace value import from the same module causes the pinned upstream implementation to suppress its fix. ## Original Documentation - [typescript-eslint: consistent-type-imports](https://typescript-eslint.io/rules/consistent-type-imports) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/consistent-type-imports.ts) --- url: /rules/typescript-eslint/default-param-last.md --- # default-param-last [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/default-param-last': 'error', }, }, ]); ``` ## Rule Details Enforce default parameters to be last. This is the TypeScript-enhanced version of the ESLint `default-param-last` rule. It also handles TypeScript-specific optional parameters (those with a `?` modifier), enforcing that they come after required parameters. Putting default and optional parameters last makes function calls clearer, since callers do not need to pass `undefined` to skip optional arguments. Examples of **incorrect** code for this rule: ```typescript function foo(a = 1, b: number) {} function bar(a?: string, b: number) {} class MyClass { method(a = 0, b: string) {} } ``` Examples of **correct** code for this rule: ```typescript function foo(a: number, b = 1) {} function bar(a: number, b?: string) {} function baz(a: number, b = 1, ...rest: number[]) {} ``` ## Original Documentation - [typescript-eslint: default-param-last](https://typescript-eslint.io/rules/default-param-last) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/default-param-last.ts) --- url: /rules/typescript-eslint/dot-notation.md --- # dot-notation [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/dot-notation': 'error', }, }, ]); ``` ## Rule Details Enforce dot notation whenever possible. This is the TypeScript-enhanced version of the ESLint `dot-notation` rule. Dot notation is generally preferred over bracket notation for readability. The TypeScript version adds options to allow bracket notation for private/protected class members and index signature properties. The rule provides autofixes to convert bracket notation (`obj["prop"]`) to dot notation (`obj.prop`) when safe. Examples of **incorrect** code for this rule: ```typescript const x = obj['foo']; const y = obj['bar']; ``` Examples of **correct** code for this rule: ```typescript const x = obj.foo; const y = obj.bar; const z = obj['some-kebab-case']; // not a valid identifier const w = obj[dynamicKey]; // computed access ``` ## Original Documentation - [typescript-eslint: dot-notation](https://typescript-eslint.io/rules/dot-notation) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/dot-notation.ts) --- url: /rules/typescript-eslint/explicit-function-return-type.md --- # explicit-function-return-type [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/explicit-function-return-type': 'error', }, }, ]); ``` ## Rule Details Require explicit return types on functions and class methods. Functions in TypeScript often don't need to be given an explicit return type annotation. Leaving off the return type is less code to read or write and allows the compiler to infer it from the contents of the function. However, explicit return types do make it visually more clear what type is returned by a function and can speed up TypeScript type checking performance in large codebases. Examples of **incorrect** code for this rule: ```typescript function test() { return; } var fn = function () { return 1; }; var arrowFn = () => 'test'; class Test { method() { return; } } ``` Examples of **correct** code for this rule: ```typescript function test(): void { return; } var fn = function (): number { return 1; }; var arrowFn = (): string => 'test'; class Test { method(): void { return; } } ``` ## Original Documentation - [typescript-eslint: explicit-function-return-type](https://typescript-eslint.io/rules/explicit-function-return-type) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/explicit-function-return-type.ts) --- url: /rules/typescript-eslint/explicit-member-accessibility.md --- # explicit-member-accessibility [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/explicit-member-accessibility': 'error', }, }, ]); ``` ## Rule Details This rule reports class members and parameter properties whose accessibility declarations don't match the configured policy. With the default `explicit` mode, every class member and parameter property must be declared `public`, `private`, or `protected`. Switching the policy to `no-public` flips the rule: any redundant `public` modifier is reported (and removed by the autofix). Set the policy to `off` to disable the check for that member kind. Examples of **incorrect** code for this rule: ```typescript class Animal { constructor(name: string) {} getName(): string { return this.name; } get legs(): number { return 4; } } ``` Examples of **correct** code for this rule: ```typescript class Animal { public constructor(public readonly name: string) {} public getName(): string { return this.name; } public get legs(): number { return 4; } } ``` ## Options This rule accepts an options object with the following properties: - `accessibility`: top-level policy applied to every member kind unless overridden. One of `'explicit'` (default), `'no-public'`, `'off'`. - `ignoredMethodNames`: list of method names to skip entirely. Method name matching uses the same name normalization as the diagnostic message (identifier text, `#name` for private fields, the literal value for string / numeric literal keys). - `overrides`: per-kind overrides. Each entry overrides `accessibility` for that member kind: - `accessors` — getters and setters. - `constructors` — constructors. - `methods` — regular methods (not getters/setters/constructors). - `parameterProperties` — `public`/`private`/`protected`/`readonly` parameters of a constructor. - `properties` — class fields, including auto-accessor (`accessor x`) and abstract properties. ### `accessibility: 'no-public'` ```json { "@typescript-eslint/explicit-member-accessibility": ["error", { "accessibility": "no-public" }] } ``` Examples of **incorrect** code with this option: ```typescript class Animal { public name: string; public getName(): string { return this.name; } } ``` Examples of **correct** code with this option: ```typescript class Animal { name: string; getName(): string { return this.name; } } ``` ### `overrides` Examples of **correct** code with mixed overrides: ```json { "@typescript-eslint/explicit-member-accessibility": [ "error", { "accessibility": "explicit", "overrides": { "constructors": "no-public", "accessors": "off" } } ] } ``` ```typescript class Animal { constructor(private readonly name: string) {} public bark(): void {} get legs(): number { return 4; } } ``` ### `ignoredMethodNames` Examples of **correct** code with `{ "ignoredMethodNames": ["getX"] }`: ```json { "@typescript-eslint/explicit-member-accessibility": ["error", { "ignoredMethodNames": ["getX"] }] } ``` ```typescript class Test { getX() { return 1; } } ``` ## Original Documentation - [typescript-eslint: explicit-member-accessibility](https://typescript-eslint.io/rules/explicit-member-accessibility) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/explicit-member-accessibility.ts) --- url: /rules/typescript-eslint/explicit-module-boundary-types.md --- # explicit-module-boundary-types [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/explicit-module-boundary-types': 'error', }, }, ]); ``` Require explicit return and argument types on exported functions' and classes' public class methods. ## Rule Details Code that is part of a module's public surface — exported functions, exported class methods, default-exported expressions — is consumed by other modules whose authors can't see your implementation. Annotating the parameter and return types at that boundary documents the contract, lets editors offer accurate help, and prevents downstream callers from accidentally relying on the inferred type of an internal helper. This rule reports any exported function, exported class method, or value reachable via an export reference that omits its parameter types or return type. Examples of **incorrect** code for this rule: ```typescript export function test(a: number, b: number) { return; } export var arrowFn = () => 'test'; export function fn(test): string { return '123'; } export class Test { method() { return; } } ``` Examples of **correct** code for this rule: ```typescript export function test(a: number, b: number): void { return; } export var arrowFn = (): string => 'test'; export function fn(test: string): string { return '123'; } export class Test { method(): void { return; } } ``` ## Options This rule accepts an options object with the following properties: - `allowArgumentsExplicitlyTypedAsAny` (default `false`): permit parameters explicitly annotated as `any`. - `allowDirectConstAssertionInArrowFunctions` (default `true`): skip the return-type check on body-less arrow functions whose result is `as const` (optionally followed by `satisfies T`). Parameters still must be typed. - `allowedNames` (default `[]`): list of function or method names to skip entirely (both return type and parameters). - `allowHigherOrderFunctions` (default `true`): skip the return-type check on functions that immediately return another function expression, as long as the inner function has a return type. - `allowOverloadFunctions` (default `false`): skip the return-type check on the implementation of an overloaded function/method. - `allowTypedFunctionExpressions` (default `true`): skip the return-type check on function expressions whose surrounding context already supplies a type (variable annotation, type assertion, typed property, JSX attribute, function argument, …). ### `allowArgumentsExplicitlyTypedAsAny` Examples of **incorrect** code with `{ "allowArgumentsExplicitlyTypedAsAny": false }` (the default): ```json { "@typescript-eslint/explicit-module-boundary-types": ["error", { "allowArgumentsExplicitlyTypedAsAny": false }] } ``` ```typescript export function foo(foo: any): void {} ``` Examples of **correct** code with `{ "allowArgumentsExplicitlyTypedAsAny": true }`: ```json { "@typescript-eslint/explicit-module-boundary-types": ["error", { "allowArgumentsExplicitlyTypedAsAny": true }] } ``` ```typescript export function foo(foo: any): void {} ``` ### `allowDirectConstAssertionInArrowFunctions` Examples of **correct** code with the default `{ "allowDirectConstAssertionInArrowFunctions": true }`: ```typescript export const func1 = (value: number) => ({ type: 'X', value }) as const; ``` ### `allowedNames` Examples of **correct** code with `{ "allowedNames": ["func1"] }`: ```json { "@typescript-eslint/explicit-module-boundary-types": ["error", { "allowedNames": ["func1"] }] } ``` ```typescript export const func1 = (value: number) => value; ``` ### `allowHigherOrderFunctions` Examples of **correct** code with the default `{ "allowHigherOrderFunctions": true }`: ```typescript export const fn = () => (n: number): string => String(n); ``` ### `allowOverloadFunctions` Examples of **correct** code with `{ "allowOverloadFunctions": true }`: ```json { "@typescript-eslint/explicit-module-boundary-types": ["error", { "allowOverloadFunctions": true }] } ``` ```typescript export function test(a: string): string; export function test(a: number): number; export function test(a: unknown) { return a; } ``` ### `allowTypedFunctionExpressions` Examples of **correct** code with the default `{ "allowTypedFunctionExpressions": true }`: ```typescript export var arrowFn: Foo = () => 'test'; const x = (() => {}) as Foo; ``` ## Original Documentation - [typescript-eslint: explicit-module-boundary-types](https://typescript-eslint.io/rules/explicit-module-boundary-types) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts) --- url: /rules/typescript-eslint/init-declarations.md --- # init-declarations [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/init-declarations': 'error', }, }, ]); ``` ## Rule Details Require or disallow initialization in variable declarations. This is the TypeScript-aware version of the ESLint `init-declarations` rule: bindings introduced by `declare` (either on the declaration itself or on an enclosing `declare namespace` / `declare module 'm'` / `declare global`) are skipped. Examples of **incorrect** code for this rule: ```typescript var foo; var bar: string; let baz; namespace myLib { let count: number; } ``` Examples of **correct** code for this rule: ```typescript var foo = null; let bar: string = 'hi'; const baz = 0; declare const x: number; declare namespace myLib { let count: number; } ``` ## Options ### `mode` **Type:** `"always" | "never"` — **Default:** `"always"` When set to `"always"`, every variable declaration must include an initializer. When set to `"never"`, declarators that include an initializer are reported. `const`, `using`, and `await using` bindings are exempt from `"never"` because they require an initializer at parse time. Examples of **incorrect** code with `"never"`: ```json { "@typescript-eslint/init-declarations": ["error", "never"] } ``` ```typescript var foo = 1; let bar: string = 'hi'; for (var i = 0; i < 1; i++) {} ``` Examples of **correct** code with `"never"`: ```json { "@typescript-eslint/init-declarations": ["error", "never"] } ``` ```typescript var foo; let bar: string; const baz = 1; ``` ### `ignoreForLoopInit` **Type:** `boolean` — **Default:** `false` Only meaningful when `mode` is `"never"`. When `true`, declarators in the initializer / left slot of `for`, `for-in`, and `for-of` statements are not reported. Examples of **correct** code with `["never", { "ignoreForLoopInit": true }]`: ```json { "@typescript-eslint/init-declarations": ["error", "never", { "ignoreForLoopInit": true }] } ``` ```typescript for (var i = 0; i < 1; i++) {} for (var key in obj) { } for (var item of items) { } ``` ## Original Documentation - [typescript-eslint: init-declarations](https://typescript-eslint.io/rules/init-declarations) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/init-declarations.ts) --- url: /rules/typescript-eslint/max-params.md --- # max-params [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/max-params': 'error', }, }, ]); ``` Enforce a maximum number of parameters in function definitions. ## Rule Details Functions that take many parameters are usually harder to read and maintain than functions that take fewer. This rule reports any function whose parameter list exceeds the configured maximum (default 3). The typescript-eslint variant adds the `countVoidThis` option for the TypeScript `this: void` parameter, which is a type annotation rather than a real argument. By default, `this: void` is excluded from the parameter count. Examples of **incorrect** code for this rule: ```javascript function foo(a, b, c, d) {} const bar = (a, b, c, d) => {}; class Foo { method(this: Foo, a, b, c) {} } ``` Examples of **correct** code for this rule: ```javascript function foo(a, b, c) {} const bar = (a, b, c) => {}; class Foo { method(this: void, a, b, c) {} } ``` ## Options The rule accepts an options object: ```json { "@typescript-eslint/max-params": ["error", { "max": 3 }] } ``` - `max` (default `3`): the maximum number of parameters allowed. - `maximum`: deprecated alias for `max`. - `countVoidThis` (default `false`): if `true`, count a `this: void` parameter toward the limit. Examples of **incorrect** code with `{ "max": 2 }`: ```json { "@typescript-eslint/max-params": ["error", { "max": 2 }] } ``` ```javascript function foo(a, b, c) {} ``` Examples of **correct** code with `{ "max": 2 }`: ```json { "@typescript-eslint/max-params": ["error", { "max": 2 }] } ``` ```javascript function foo(a, b) {} ``` Examples of **incorrect** code with `{ "countVoidThis": true, "max": 2 }`: ```json { "@typescript-eslint/max-params": ["error", { "countVoidThis": true, "max": 2 }] } ``` ```javascript class Foo { method(this: void, a, b) {} } ``` ## Original Documentation - [typescript-eslint: max-params](https://typescript-eslint.io/rules/max-params) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/max-params.ts) --- url: /rules/typescript-eslint/member-ordering.md --- # member-ordering [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/member-ordering': 'error', }, }, ]); ``` ## Rule Details Require a consistent member declaration order. A consistent ordering of fields, methods and constructors can make interfaces, type literals, classes and class expressions easier to read, navigate and edit. This rule accepts an order configuration for each of the following AST node types: - `default` — default ordering for all node types - `classes` — ordering for class declarations - `classExpressions` — ordering for class expressions - `interfaces` — ordering for interface declarations - `typeLiterals` — ordering for type literal declarations Examples of **incorrect** code for this rule with the default configuration: ```typescript interface Foo { B(): void; new (): Foo; A: string; [Z: string]: any; } ``` Examples of **correct** code for this rule with the default configuration: ```typescript interface Foo { [Z: string]: any; A: string; new (): Foo; B(): void; } ``` ## Original Documentation - [typescript-eslint: member-ordering](https://typescript-eslint.io/rules/member-ordering) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/member-ordering.ts) --- url: /rules/typescript-eslint/method-signature-style.md --- # method-signature-style [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/method-signature-style': 'error', }, }, ]); ``` ## Rule Details Enforces using a particular method signature syntax in interfaces and type literals. There are two styles for declaring method signatures in TypeScript: - **Method shorthand**: `func(arg: string): number;` - **Property**: `func: (arg: string) => number;` The key difference: with `strictFunctionTypes` enabled, method parameters are checked less strictly, while function property parameters are checked more strictly. This makes function properties more type-safe. ### Options - `"property"` (default): Enforces function property signature syntax. - `"method"`: Enforces method shorthand signature syntax. ### `"property"` (default) Examples of **incorrect** code: ```typescript interface T1 { func(arg: string): number; } ``` Examples of **correct** code: ```typescript interface T1 { func: (arg: string) => number; } ``` ### `"method"` Examples of **incorrect** code: ```typescript interface T1 { func: (arg: string) => number; } ``` Examples of **correct** code: ```typescript interface T1 { func(arg: string): number; } ``` ## Original Documentation - [typescript-eslint: method-signature-style](https://typescript-eslint.io/rules/method-signature-style) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.58.2/packages/eslint-plugin/src/rules/method-signature-style.ts) --- url: /rules/typescript-eslint/naming-convention.md --- # naming-convention [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/naming-convention': 'error', }, }, ]); ``` ## Rule Details Enforces naming conventions for everything across a codebase. This rule allows you to enforce conventions for any identifier, using granular selectors to create a fine-grained style guide. It supports a wide variety of selectors, modifiers, formats, and custom patterns. Each selector can be configured independently, and more specific selectors take precedence over less specific ones. Examples of **incorrect** code for this rule (with default config): ```typescript const my_variable = 1; function my_function() {} class my_class {} interface my_interface {} type my_type = string; enum my_enum { my_member, } ``` Examples of **correct** code for this rule (with default config): ```typescript const myVariable = 1; function myFunction() {} class MyClass {} interface MyInterface {} type MyType = string; enum MyEnum { MyMember, } ``` ## Options This rule accepts an array of objects, where each object describes a naming convention to enforce. Each object can have the following properties: ### `selector` **(Required)** The selector(s) to apply the convention to. Can be a string or an array of strings. **Individual selectors:** `variable`, `function`, `parameter`, `property`, `parameterProperty`, `accessor`, `enumMember`, `classMethod`, `objectLiteralMethod`, `typeMethod`, `classProperty`, `objectLiteralProperty`, `typeProperty`, `class`, `interface`, `typeAlias`, `enum`, `typeParameter`, `import` **Group selectors:** `default` (matches all), `variableLike` (variable, function, parameter), `memberLike` (property, parameterProperty, enumMember, classMethod, objectLiteralMethod, typeMethod, classProperty, objectLiteralProperty, typeProperty, accessor), `typeLike` (class, interface, typeAlias, enum), `method` (classMethod, objectLiteralMethod, typeMethod), `objectLiteralMember` (objectLiteralProperty, objectLiteralMethod) ### `format` The format(s) that the identifier must match. Set to `null` to skip format checking (useful for names that require quotes). Can be an array to allow multiple formats. **Allowed values:** `camelCase`, `strictCamelCase`, `PascalCase`, `StrictPascalCase`, `snake_case`, `UPPER_CASE` ```json { "@typescript-eslint/naming-convention": [ "warn", { "selector": "variable", "format": ["camelCase", "UPPER_CASE"] } ] } ``` ### `leadingUnderscore` / `trailingUnderscore` Controls whether leading/trailing underscores are allowed, required, or forbidden. **Allowed values:** `forbid`, `require`, `requireDouble`, `allow`, `allowDouble`, `allowSingleOrDouble` ```json { "@typescript-eslint/naming-convention": [ "warn", { "selector": "variable", "format": ["camelCase"], "leadingUnderscore": "allow" } ] } ``` ### `prefix` / `suffix` Requires identifiers to start/end with one of the given strings. The prefix/suffix is stripped before format checking. ```json { "@typescript-eslint/naming-convention": [ "warn", { "selector": "interface", "format": ["PascalCase"], "prefix": ["I"] } ] } ``` ### `custom` A custom regex pattern that the identifier must match (or not match). Requires a `regex` string and a `match` boolean. ```json { "@typescript-eslint/naming-convention": [ "warn", { "selector": "variable", "format": ["camelCase"], "custom": { "regex": "^I[A-Z]", "match": false } } ] } ``` ### `filter` A regex filter to limit which identifiers are checked by this selector. Identifiers matching the filter are skipped (`match: false`) or exclusively checked (`match: true`). ```json { "@typescript-eslint/naming-convention": [ "warn", { "selector": "property", "format": null, "filter": { "regex": "^(Property-Name-One|Property-Name-Two)$", "match": true } } ] } ``` ### `modifiers` Limits the selector to only match identifiers with the specified modifiers. All specified modifiers must be present for the selector to match. **Allowed values:** `const`, `readonly`, `static`, `public`, `protected`, `private`, `#private`, `abstract`, `destructured`, `global`, `exported`, `unused`, `requiresQuotes`, `override`, `async`, `default`, `namespace` ```json { "@typescript-eslint/naming-convention": [ "warn", { "selector": "variable", "modifiers": ["const"], "format": ["UPPER_CASE"] } ] } ``` ### `types` Limits the selector to only match identifiers whose type matches. Only available for: `variable`, `parameter`, `classProperty`, `objectLiteralProperty`, `typeProperty`, `accessor`, `property`, `parameterProperty`. **Allowed values:** `boolean`, `string`, `number`, `function`, `array` ```json { "@typescript-eslint/naming-convention": [ "warn", { "selector": "variable", "types": ["boolean"], "format": ["PascalCase"], "prefix": ["is", "has"] } ] } ``` ## Default Configuration When no options are provided, the rule uses the following defaults: ```json [ { "selector": "default", "format": ["camelCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }, { "selector": "import", "format": ["camelCase", "PascalCase"] }, { "selector": "variable", "format": ["camelCase", "UPPER_CASE"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" }, { "selector": "typeLike", "format": ["PascalCase"] } ] ``` ## Original Documentation - [typescript-eslint: naming-convention](https://typescript-eslint.io/rules/naming-convention) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/naming-convention.ts) --- url: /rules/typescript-eslint/no-array-constructor.md --- # no-array-constructor [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-array-constructor': 'error', }, }, ]); ``` ## Rule Details Disallow generic `Array` constructors. Use of the `Array` constructor to create arrays is generally discouraged in favor of array literal notation because of the single-argument pitfall and because the `Array` global may be redefined. The rule allows single-argument calls since they are commonly used to create arrays with a specific size. Examples of **incorrect** code for this rule: ```javascript new Array(); Array(); new Array(x, y); Array(x, y); new Array(0, 1, 2); Array(0, 1, 2); ``` Examples of **correct** code for this rule: ```typescript []; [x, y]; [0, 1, 2]; new Array(500); // single argument creates array with size Array(someOtherArray.length); new Array(); // TypeScript generic syntax new Array(1, 2, 3); ``` ## Original Documentation - [typescript-eslint: no-array-constructor](https://typescript-eslint.io/rules/no-array-constructor) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-array-constructor.ts) --- url: /rules/typescript-eslint/no-array-delete.md --- # no-array-delete [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-array-delete': 'error', }, }, ]); ``` ## Rule Details Disallow using the `delete` operator on array values. Using `delete` on an array element sets it to `undefined` and leaves a hole in the array without changing its length. This is almost always a mistake -- `Array.prototype.splice()` should be used instead to remove elements. The rule uses type information to detect when the `delete` target is an array or tuple type. Examples of **incorrect** code for this rule: ```typescript const arr = [1, 2, 3]; delete arr[1]; // arr is now [1, undefined, 3] const tuple: [string, number] = ['a', 1]; delete tuple[0]; ``` Examples of **correct** code for this rule: ```typescript const arr = [1, 2, 3]; arr.splice(1, 1); // arr is now [1, 3] const obj: Record = { a: 1 }; delete obj['a']; // objects are fine ``` ## Original Documentation - [typescript-eslint: no-array-delete](https://typescript-eslint.io/rules/no-array-delete) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-array-delete.ts) --- url: /rules/typescript-eslint/no-base-to-string.md --- # no-base-to-string [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-base-to-string': 'error', }, }, ]); ``` ## Rule Details Require `.toString()` and `.toLocaleString()` to only be called on objects which provide useful information when stringified. JavaScript calls `toString()` implicitly in string contexts such as template literals and string concatenation. The default `Object.prototype.toString()` returns `"[object Object]"`, which is rarely useful. This rule uses type information to detect when a value will use the base `Object.prototype.toString()` and flags string concatenation, template literals, explicit `.toString()`/`.toLocaleString()` calls, `String()` calls, and `.join()` on arrays containing such types. Examples of **incorrect** code for this rule: ```typescript class MyClass {} const obj = new MyClass(); `Value: ${obj}`; '' + obj; obj.toString(); [obj].join(','); ``` Examples of **correct** code for this rule: ```typescript `Value: ${'str'}`; '' + 42; class MyClass { toString() { return 'MyClass'; } } `Value: ${new MyClass()}`; ``` ## Original Documentation - [typescript-eslint: no-base-to-string](https://typescript-eslint.io/rules/no-base-to-string) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.28.0/packages/eslint-plugin/src/rules/no-base-to-string.ts) --- url: /rules/typescript-eslint/no-confusing-non-null-assertion.md --- # no-confusing-non-null-assertion [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-confusing-non-null-assertion': 'error', }, }, ]); ``` ## Rule Details Disallow non-null assertion in locations that may be confusing. A non-null assertion (`!`) placed immediately before `=`, `==`, `===`, `in`, or `instanceof` is visually almost indistinguishable from the operators `!=`, `!==`, `!(... in ...)`, or `!(... instanceof ...)`. This rule flags those combinations and offers suggestions to either remove the assertion or wrap the left-hand side in parentheses to disambiguate. Examples of **incorrect** code for this rule: ```typescript a! == b; a! === b; a! in b; a! instanceof b; ``` Examples of **correct** code for this rule: ```typescript a == b; (1 + foo.num!) == 2; foo.bar == 'hello'; !(a in b); ``` ## Original Documentation - [typescript-eslint: no-confusing-non-null-assertion](https://typescript-eslint.io/rules/no-confusing-non-null-assertion) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-confusing-non-null-assertion.ts) --- url: /rules/typescript-eslint/no-confusing-void-expression.md --- # no-confusing-void-expression [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-confusing-void-expression': 'error', }, }, ]); ``` ## Rule Details Disallows void type expressions from being used in misleading locations such as being assigned to a variable, returned from a function, or used inside other expressions. The `void` type in TypeScript indicates a function returns nothing, and using void-returning expressions in value positions can lead to confusing code. Examples of **incorrect** code for this rule: ```typescript // Assigning a void expression to a variable const result = console.log('hello'); // Returning a void expression from a function function foo() { return console.log('hello'); } // Using a void expression in an arrow function shorthand const fn = () => console.log('hello'); ``` Examples of **correct** code for this rule: ```typescript // Void expression as a standalone statement console.log('hello'); // Arrow function with braces const fn = () => { console.log('hello'); }; // Explicit void operator (with ignoreVoidOperator option) const fn = () => void console.log('hello'); ``` ## Original Documentation - [typescript-eslint: no-confusing-void-expression](https://typescript-eslint.io/rules/no-confusing-void-expression) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-confusing-void-expression.ts) --- url: /rules/typescript-eslint/no-deprecated.md --- # no-deprecated [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-deprecated': 'error', }, }, ]); ``` ## Rule Details Disallow usage of declarations marked with `@deprecated`. ## Original Documentation - [typescript-eslint: no-deprecated](https://typescript-eslint.io/rules/no-deprecated) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-deprecated.ts) --- url: /rules/typescript-eslint/no-dupe-class-members.md --- # no-dupe-class-members [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-dupe-class-members': 'error', }, }, ]); ``` ## Rule Details Disallow duplicate class members. If there are declarations of the same name in class members, the last declaration overwrites other declarations silently. It can cause unexpected behaviors. This rule extends the base ESLint `no-dupe-class-members` rule to support TypeScript method overload signatures, which should not be flagged as duplicates. Examples of **incorrect** code for this rule: ```typescript class A { foo() {} foo() {} } class B { foo; foo() {} } class C { static bar() {} static bar() {} } ``` Examples of **correct** code for this rule: ```typescript class A { foo() {} bar() {} } class B { get foo() {} set foo(value) {} } class C { static foo() {} foo() {} } // TypeScript method overloads are allowed class D { foo(a: string): string; foo(a: number): number; foo(a: any): any {} } ``` ## Original Documentation - [typescript-eslint: no-dupe-class-members](https://typescript-eslint.io/rules/no-dupe-class-members) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-dupe-class-members.ts) --- url: /rules/typescript-eslint/no-duplicate-enum-values.md --- # no-duplicate-enum-values [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-duplicate-enum-values': 'error', }, }, ]); ``` ## Rule Details Disallows duplicate enum member values. Enum members that share the same literal value (number, string, or template literal) are almost always a mistake. This rule checks for duplicate initializer values within a single enum declaration. Examples of **incorrect** code for this rule: ```typescript enum Direction { Up = 0, Down = 0, } enum Color { Red = 'red', Blue = 'red', } enum Num { A = 1, B = -1, C = 1, } ``` Examples of **correct** code for this rule: ```typescript enum Direction { Up = 0, Down = 1, Left = 2, Right = 3, } enum Color { Red = 'red', Blue = 'blue', Green = 'green', } ``` ## Original Documentation - [typescript-eslint: no-duplicate-enum-values](https://typescript-eslint.io/rules/no-duplicate-enum-values) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-duplicate-enum-values.ts) --- url: /rules/typescript-eslint/no-duplicate-type-constituents.md --- # no-duplicate-type-constituents [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-duplicate-type-constituents': 'error', }, }, ]); ``` ## Rule Details Disallows duplicate constituents in union or intersection types. Having the same type more than once in a union (`|`) or intersection (`&`) is redundant and can be removed without changing the type. This rule also flags explicit `undefined` on optional parameters, since the `?` modifier already implies `undefined`. Examples of **incorrect** code for this rule: ```typescript type Foo = string | string; type Bar = number & number; type Baz = 'a' | 'b' | 'a'; function fn(x?: string | undefined) {} ``` Examples of **correct** code for this rule: ```typescript type Foo = string | number; type Bar = { a: string } & { b: number }; type Baz = 'a' | 'b' | 'c'; function fn(x?: string) {} ``` ## Original Documentation - [typescript-eslint: no-duplicate-type-constituents](https://typescript-eslint.io/rules/no-duplicate-type-constituents) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-duplicate-type-constituents.ts) --- url: /rules/typescript-eslint/no-dynamic-delete.md --- # no-dynamic-delete [Added in v0.3.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.2) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-dynamic-delete': 'error', }, }, ]); ``` ## Rule Details Disallow the `delete` operator on computed property keys unless the key is a literal. Examples of **incorrect** code for this rule: ```typescript const container: { [i: string]: 0 } = {}; delete container[name]; delete container['aa' + 'b']; delete container[`name`]; ``` Examples of **correct** code for this rule: ```typescript const container: { [i: string]: 0 } = {}; delete container['name']; delete container[7]; ``` ## Original Documentation - [typescript-eslint: no-dynamic-delete](https://typescript-eslint.io/rules/no-dynamic-delete) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-dynamic-delete.ts) --- url: /rules/typescript-eslint/no-empty-function.md --- # no-empty-function [Added in v0.1.6](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.6) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-empty-function': 'error', }, }, ]); ``` ## Rule Details Disallows empty functions. Empty functions can reduce readability because readers need to guess whether the empty body is intentional. This rule extends the base ESLint `no-empty-function` rule with TypeScript-specific support, including constructors with parameter properties, decorated functions, override methods, and various function types like async functions and generators. Examples of **incorrect** code for this rule: ```typescript function foo() {} const bar = () => {}; class MyClass { method() {} constructor() {} } ``` Examples of **correct** code for this rule: ```typescript function foo() { // intentionally empty } const bar = () => { return; }; class MyClass { constructor(private name: string) {} } ``` ## Original Documentation - [typescript-eslint: no-empty-function](https://typescript-eslint.io/rules/no-empty-function) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-empty-function.ts) --- url: /rules/typescript-eslint/no-empty-interface.md --- # no-empty-interface [Added in v0.1.6](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.6) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-empty-interface': 'error', }, }, ]); ``` ## Rule Details Disallows empty interface declarations. An empty interface with no members is equivalent to the empty object type `{}`. An empty interface that extends a single interface is equivalent to a type alias of that interface. In both cases, the interface declaration adds unnecessary indirection and can be replaced with a simpler construct. Examples of **incorrect** code for this rule: ```typescript // Empty interface is equivalent to {} interface Foo {} // Equivalent to: type Bar = Baz interface Bar extends Baz {} ``` Examples of **correct** code for this rule: ```typescript // Interface with members interface Foo { name: string; } // Interface extending multiple interfaces interface Bar extends Baz, Qux {} // Type alias instead of empty extending interface type Bar = Baz; ``` ## Original Documentation - [typescript-eslint: no-empty-interface](https://typescript-eslint.io/rules/no-empty-interface) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.69.0/packages/eslint-plugin/src/rules/no-empty-interface.ts) --- url: /rules/typescript-eslint/no-empty-object-type.md --- # no-empty-object-type [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-empty-object-type': 'error', }, }, ]); ``` ## Rule Details Disallows accidental uses of the `{}` ("empty object") type. In TypeScript `{}` is the type of any non-nullish value, which is rarely what authors intend — typically they want `object` (any non-primitive value) or `unknown` (any value at all). The same problem applies to empty `interface` declarations: an empty interface with no members is equivalent to `{}`, and an empty interface that extends a single supertype is equivalent to a type alias of that supertype. This rule reports both shapes and offers `object` / `unknown` suggestions. Examples of **incorrect** code for this rule: ```typescript let anyObject: {}; let anyValue: {}; interface AnyObject {} interface AnyValue {} type AnyObjectAlias = {}; type AnyValueAlias = {}; ``` Examples of **correct** code for this rule: ```typescript let anyObject: object; let anyValue: unknown; type AnyObjectAlias = object; type AnyValueAlias = unknown; let objectWith: { property: boolean; }; interface InterfaceWith { property: boolean; } type TypeWith = { property: boolean; }; ``` ### Options - `allowInterfaces` (default `"never"`): how empty interfaces are treated. - `"never"`: empty interfaces are disallowed. - `"always"`: empty interfaces are always allowed. - `"with-single-extends"`: empty interfaces are allowed only when they extend exactly one supertype. - `allowObjectTypes` (default `"never"`): how empty `{}` type literals are treated. - `"never"`: empty `{}` is disallowed. - `"always"`: empty `{}` is always allowed. - `allowWithName`: a regular expression source string. When set, interfaces and `type` aliases whose name matches the pattern are exempted. ### `allowInterfaces: "with-single-extends"` Examples of **correct** code: ```typescript interface Base { value: boolean; } interface Derived extends Base {} ``` ### `allowObjectTypes: "always"` Examples of **correct** code: ```typescript type AnyObject = {}; let value: {}; ``` ### `allowWithName: "Props$"` Examples of **correct** code: ```typescript interface ComponentProps {} type DialogProps = {}; ``` ## Original Documentation - [typescript-eslint: no-empty-object-type](https://typescript-eslint.io/rules/no-empty-object-type) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.69.0/packages/eslint-plugin/src/rules/no-empty-object-type.ts) --- url: /rules/typescript-eslint/no-explicit-any.md --- # no-explicit-any [Added in v0.1.13](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.13) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-explicit-any': 'error', }, }, ]); ``` ## Rule Details Disallows the `any` type. Using the `any` type defeats the purpose of TypeScript's type system. When `any` is used, all compiler type checks around that value are ignored. This rule reports on explicit uses of the `any` keyword as a type annotation. It suggests using `unknown` for safe type assertions, `never` for generic type parameters that should not be used, and `PropertyKey` instead of `keyof any`. Examples of **incorrect** code for this rule: ```typescript const age: any = 'seventeen'; function greet(): any {} function foo(arg: any): void {} const key: keyof any = 'name'; ``` Examples of **correct** code for this rule: ```typescript const age: number = 17; function greet(): string { return 'hello'; } function foo(arg: unknown): void {} const key: PropertyKey = 'name'; ``` ## Original Documentation - [typescript-eslint: no-explicit-any](https://typescript-eslint.io/rules/no-explicit-any) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-explicit-any.ts) --- url: /rules/typescript-eslint/no-extra-non-null-assertion.md --- # no-extra-non-null-assertion [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-extra-non-null-assertion': 'error', }, }, ]); ``` ## Rule Details Disallow extra non-null assertions. The `!` non-null assertion operator in TypeScript is used to assert that a value's type does not include `null` or `undefined`. Using the operator any more than once on a single value does nothing. Examples of **incorrect** code for this rule: ```typescript const bar = foo!!.bar; function foo(bar?: { n: number }) { return bar!?.n; } ``` Examples of **correct** code for this rule: ```typescript const bar = foo!.bar; function foo(bar?: { n: number }) { return bar?.n; } ``` ## Original Documentation - [typescript-eslint: no-extra-non-null-assertion](https://typescript-eslint.io/rules/no-extra-non-null-assertion) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-extra-non-null-assertion.ts) --- url: /rules/typescript-eslint/no-extraneous-class.md --- # no-extraneous-class [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-extraneous-class': 'error', }, }, ]); ``` ## Rule Details Disallows classes used as namespaces or that serve no purpose beyond wrapping static members, constructors, or being empty. In JavaScript and TypeScript, classes that contain only static members, only a constructor, or no members at all can typically be replaced with standalone functions, plain objects, or modules. This rule reports on classes that do not benefit from the class structure. Examples of **incorrect** code for this rule: ```typescript class Empty {} class OnlyConstructor { constructor() { doSomething(); } } class StaticOnly { static utility() {} static helper() {} } ``` Examples of **correct** code for this rule: ```typescript class MyClass { value: string; constructor(value: string) { this.value = value; } greet() { return this.value; } } // Use module-level functions instead export function utility() {} export function helper() {} ``` ## Original Documentation - [typescript-eslint: no-extraneous-class](https://typescript-eslint.io/rules/no-extraneous-class) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.46.3/packages/eslint-plugin/src/rules/no-extraneous-class.ts) --- url: /rules/typescript-eslint/no-floating-promises.md --- # no-floating-promises [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-floating-promises': 'error', }, }, ]); ``` ## Rule Details Requires Promise-like statements to be handled appropriately. A "floating" promise is one that is created without any code to handle potential errors. Floating promises can cause unexpected behavior because errors in them will be silently ignored. This rule reports on promises in expression statements that are not awaited, not chained with `.catch()` or `.then()` with a rejection handler, and not explicitly ignored with the `void` operator. Examples of **incorrect** code for this rule: ```typescript async function fetchData() { fetch('https://example.com'); } const promise = new Promise(resolve => resolve('value')); promise; async function run() { doAsyncWork(); } ``` Examples of **correct** code for this rule: ```typescript async function fetchData() { await fetch('https://example.com'); } const promise = new Promise(resolve => resolve('value')); await promise; promise.catch(handleError); void promise; ``` ## Original Documentation - [typescript-eslint: no-floating-promises](https://typescript-eslint.io/rules/no-floating-promises) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-floating-promises.ts) --- url: /rules/typescript-eslint/no-for-in-array.md --- # no-for-in-array [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-for-in-array': 'error', }, }, ]); ``` ## Rule Details Disallows iterating over arrays with a `for-in` loop. Using `for-in` on arrays is problematic because it skips holes, returns indices as strings rather than numbers, and may visit inherited enumerable properties from the prototype chain. Use `for-of`, `Array.prototype.forEach`, or a standard `for` loop instead. Examples of **incorrect** code for this rule: ```typescript const arr = [1, 2, 3]; for (const index in arr) { console.log(index); // "0", "1", "2" (strings, not numbers) } for (const key in ['a', 'b', 'c']) { console.log(key); } ``` Examples of **correct** code for this rule: ```typescript const arr = [1, 2, 3]; for (const value of arr) { console.log(value); } arr.forEach((value, index) => { console.log(index, value); }); for (let i = 0; i < arr.length; i++) { console.log(arr[i]); } ``` ## Original Documentation - [typescript-eslint: no-for-in-array](https://typescript-eslint.io/rules/no-for-in-array) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-for-in-array.ts) --- url: /rules/typescript-eslint/no-implied-eval.md --- # no-implied-eval [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-implied-eval': 'error', }, }, ]); ``` ## Rule Details Disallows the use of `eval()`-like methods. Functions such as `setTimeout`, `setInterval`, `setImmediate`, and `execScript` can accept a string argument that is evaluated as code, similar to `eval()`. This is dangerous because it can execute arbitrary code and makes the application vulnerable to injection attacks. This rule also disallows using the `Function` constructor to dynamically create functions from strings. Examples of **incorrect** code for this rule: ```typescript setTimeout("alert('hello')", 100); setInterval('doWork()', 1000); const fn = new Function('a', 'b', 'return a + b'); window.setTimeout('doSomething()', 100); ``` Examples of **correct** code for this rule: ```typescript setTimeout(() => alert('hello'), 100); setInterval(doWork, 1000); const fn = (a: number, b: number) => a + b; window.setTimeout(() => doSomething(), 100); ``` ## Original Documentation - [typescript-eslint: no-implied-eval](https://typescript-eslint.io/rules/no-implied-eval) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-implied-eval.ts) --- url: /rules/typescript-eslint/no-import-type-side-effects.md --- # no-import-type-side-effects [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-import-type-side-effects': 'error', }, }, ]); ``` ## Rule Details Enforce the use of a top-level `import type` qualifier when an import only has specifiers with inline `type` qualifiers. Under TypeScript's `--verbatimModuleSyntax`, inline `type` specifiers are stripped one by one, which leaves behind an empty `import {} from 'mod'` — a runtime side-effect import. Hoisting the qualifier to the top level removes the whole statement instead. The rule is auto-fixable. Examples of **incorrect** code for this rule: ```typescript import { type A } from 'mod'; import { type A as AA } from 'mod'; import { type A, type B } from 'mod'; import { type A as AA, type B as BB } from 'mod'; ``` Examples of **correct** code for this rule: ```typescript import T from 'mod'; import * as T from 'mod'; import { T } from 'mod'; import type { T } from 'mod'; import type { T, U } from 'mod'; import { type T, U } from 'mod'; import { T, type U } from 'mod'; import type T from 'mod'; import T, { type U } from 'mod'; import type * as T from 'mod'; import 'mod'; ``` ## Original Documentation - [typescript-eslint: no-import-type-side-effects](https://typescript-eslint.io/rules/no-import-type-side-effects) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-import-type-side-effects.ts) --- url: /rules/typescript-eslint/no-inferrable-types.md --- # no-inferrable-types [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-inferrable-types': 'error', }, }, ]); ``` ## Rule Details Disallows explicit type declarations for variables or parameters initialized to a number, string, or boolean. TypeScript is able to infer the types of parameters, properties, and variables from their default or initial values. There is no need to use an explicit type annotation for trivially inferred types (boolean, bigint, number, null, RegExp, string, symbol, undefined). Examples of **incorrect** code for this rule: ```typescript const a: bigint = 10n; const a: bigint = -10n; const a: bigint = BigInt(10); const a: boolean = true; const a: boolean = false; const a: boolean = Boolean(null); const a: boolean = !0; const a: number = 10; const a: number = +10; const a: number = -10; const a: number = Number('1'); const a: number = Infinity; const a: number = NaN; const a: null = null; const a: RegExp = /a/; const a: RegExp = RegExp('a'); const a: RegExp = new RegExp('a'); const a: string = 'str'; const a: string = `str`; const a: string = String(1); const a: symbol = Symbol('a'); const a: undefined = undefined; const a: undefined = void 0; function fn(a: number = 5) {} const fn = (a: boolean = true) => {}; class Foo { prop: number = 5; } ``` Examples of **correct** code for this rule: ```typescript const a = 10n; const a = true; const a = 'str'; const a = null; const a = /a/; const a = undefined; const a = Symbol('a'); function fn(a = 5) {} const fn = (a = true) => {}; class Foo { prop = 5; } // Readonly properties are allowed class Bar { readonly prop: number = 5; } ``` ## Options ### `ignoreParameters` When set to `true`, ignores explicit type annotations on function parameters with default values. ```json { "@typescript-eslint/no-inferrable-types": [ "warn", { "ignoreParameters": true } ] } ``` ### `ignoreProperties` When set to `true`, ignores explicit type annotations on class properties with initializers. ```json { "@typescript-eslint/no-inferrable-types": [ "warn", { "ignoreProperties": true } ] } ``` ## Original Documentation - [typescript-eslint: no-inferrable-types](https://typescript-eslint.io/rules/no-inferrable-types) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-inferrable-types.ts) --- url: /rules/typescript-eslint/no-invalid-this.md --- # no-invalid-this [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-invalid-this': 'error', }, }, ]); ``` Disallow `this` keywords outside of classes or class-like objects. ## Rule Details Under strict mode, `this` keywords outside of classes or class-like objects might be `undefined` and raise a `TypeError`. This rule judges from the following conditions whether or not the function is a constructor: - The name of the function starts with uppercase. - The function is assigned to a variable which starts with an uppercase letter. - The function is a constructor of ES2015 Classes. This rule judges from the following conditions whether or not the function is a method: - The function is on an object literal. - The function is assigned to a property. - The function is a method / getter / setter of ES2015 Classes. And this rule allows `this` keywords in functions below: - The `call` / `apply` / `bind` method of the function is called directly. - The function is a callback of array methods (such as `.forEach()`) if `thisArg` is given. - The function has an `@this` tag in its JSDoc comment. - The function declares an explicit `this` parameter (`function foo(this: SomeType)`). Otherwise, this rule warns on `this` keywords. It also reports `this` at the top level. Examples of **incorrect** code for this rule: ```typescript this.a = 0; baz(() => this); (function () { this.a = 0; baz(() => this); })(); function foo() { this.a = 0; baz(() => this); } var foo = function () { this.a = 0; baz(() => this); }; foo(function () { this.a = 0; baz(() => this); }); obj.foo = () => { // `this` of arrow functions is the outer scope's. this.a = 0; }; var obj = { aaa: function () { return function foo() { // There is a method `aaa`, but `foo` is not a method. this.a = 0; baz(() => this); }; }, }; foo.forEach(function () { this.a = 0; baz(() => this); }); ``` Examples of **correct** code for this rule: ```typescript function Foo() { // OK, legacy-style constructor. this.a = 0; baz(() => this); } class Foo { constructor() { this.a = 0; baz(() => this); } } var obj = { foo() { this.a = 0; }, }; var obj = { get foo() { return this.a; }, }; Object.defineProperty(obj, 'foo', { value: function foo() { this.a = 0; }, }); obj.foo = function foo() { this.a = 0; }; class Foo { foo() { this.a = 0; baz(() => this); } static foo() { this.a = 0; baz(() => this); } } var foo = function foo() { this.a = 0; }.bind(obj); foo.forEach(function () { this.a = 0; baz(() => this); }, thisArg); /** @this Foo */ function foo() { this.a = 0; } function foo(this: SomeType) { this.a = 0; } ``` ## Options ### `capIsConstructor` **Type:** `boolean` — **Default:** `true` When `true`, the rule treats a function whose name starts with an uppercase letter (or which is assigned to such a variable) as an ES5 constructor — `this` inside is allowed. Set this option to `false` to treat capitalized-name functions as regular functions. Examples of **incorrect** code with `{ "capIsConstructor": false }`: ```json { "@typescript-eslint/no-invalid-this": ["error", { "capIsConstructor": false }] } ``` ```typescript function Foo() { this.a = 0; } var Bar = function () { this.a = 0; }; Baz = function () { this.a = 0; }; ``` Examples of **correct** code with `{ "capIsConstructor": false }`: ```json { "@typescript-eslint/no-invalid-this": ["error", { "capIsConstructor": false }] } ``` ```typescript obj.Foo = function () { // OK, assigned to a property. this.a = 0; }; class Foo { constructor() { this.a = 0; } } ``` ## Differences from ESLint The `parserOptions.ecmaFeatures.globalReturn` option is not supported. Unlike `@typescript-eslint/no-invalid-this` 8.67.0, rslint does not preserve the core rule's accessor-initializer validity frame after an initialized auto-accessor has finished. Upstream accidentally leaves that frame active and can suppress diagnostics in later code, such as the top-level `this` in `class C { accessor x = 1; } this;`; rslint reports the later `this` normally. ## When Not To Use It If you do not want to be notified about usage of the `this` keyword outside of classes or class-like objects, you can safely disable this rule. ## Original Documentation - [typescript-eslint: no-invalid-this](https://typescript-eslint.io/rules/no-invalid-this) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-invalid-this.ts) --- url: /rules/typescript-eslint/no-invalid-void-type.md --- # no-invalid-void-type [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-invalid-void-type': 'error', }, }, ]); ``` ## Rule Details Disallows `void` type outside of generic or return types. The `void` type in TypeScript means a function returns nothing, and is only meaningful as a return type of functions, methods, callable signatures, construct signatures, or as a generic type argument (e.g., `Promise`). Using `void` in other positions such as variable types, parameter types, or union types is typically a mistake and can lead to confusing behavior. Examples of **incorrect** code for this rule: ```typescript let value: void; function foo(arg: void) {} type Union = string | void; type KeyofVoid = keyof void; let arr: void[]; let value = undefined as void; ``` Examples of **correct** code for this rule: ```typescript function foo(): void {} type Callback = () => void; async function bar(): Promise {} type Result = void | never; // Callable and construct signatures interface Callable { (...args: string[]): void; } interface Constructable { new (...args: string[]): void; } // Function overloads - void in implementation return type is valid function f(): void; function f(x: string): string; function f(x?: string): string | void { if (x !== undefined) { return x; } } ``` ## Options ### `allowInGenericTypeArguments` - Type: `boolean | string[]` - Default: `true` When `true` (default), allows `void` as a type argument in any generic type (e.g., `Promise`, `Map`). When set to an array of strings, only allows `void` as a type argument in the listed generic types. Supports dotted names (e.g., `['Promise', 'Ex.Mx.Tx']`). When `false`, `void` is only valid as a direct return type. ### `allowAsThisParameter` - Type: `boolean` - Default: `false` When `true`, allows `void` as the type of a `this` parameter in functions and methods. ```typescript // Valid when allowAsThisParameter is true function f(this: void) {} class Test { method(this: void) {} } ``` ## Original Documentation - [typescript-eslint: no-invalid-void-type](https://typescript-eslint.io/rules/no-invalid-void-type) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-invalid-void-type.ts) --- url: /rules/typescript-eslint/no-loop-func.md --- # no-loop-func [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-loop-func': 'error', }, }, ]); ``` Disallow function declarations that contain unsafe references inside loop statements. ## Rule Details This is the TypeScript-aware version of the ESLint [`no-loop-func`](https://eslint.org/docs/latest/rules/no-loop-func) rule. It reports any function created inside a loop body that closes over a variable that may be modified across iterations, which typically indicates a mistake — every closure ends up reading the final value of the variable instead of the value at the time the closure was created. Type-only references (used as TypeScript type annotations) are not flagged, because they have no runtime impact. Examples of **incorrect** code for this rule: ```javascript for (var i = 0; i < 10; i++) { function foo() { console.log(i); } } ``` ```typescript for (var i = 0; i < 10; i++) { const handler = (event: Event) => { console.log(i); }; } ``` Examples of **correct** code for this rule: ```javascript for (let i = 0; i < 10; i++) { function foo() { console.log(i); } } ``` ```typescript let someArray: MyType[] = []; for (let i = 0; i < 10; i += 1) { someArray = someArray.filter((item: MyType) => !!item); } ``` ```typescript type MyType = 1; let someArray: MyType[] = []; for (let i = 0; i < 10; i += 1) { someArray = someArray.filter((item: MyType) => !!item); } ``` ## When Not To Use It If you do not want to be notified about functions defined inside loops, you can safely disable this rule. ## Original Documentation - [typescript-eslint: no-loop-func](https://typescript-eslint.io/rules/no-loop-func) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.59.1/packages/eslint-plugin/src/rules/no-loop-func.ts) --- url: /rules/typescript-eslint/no-magic-numbers.md --- # no-magic-numbers [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-magic-numbers': 'error', }, }, ]); ``` ## Rule Details Disallow magic numbers. A "magic number" is a numeric literal that is used in the code without explanation or assignment to a named constant. Magic numbers make code less readable and harder to maintain. Examples of **incorrect** code for this rule: ```javascript var total = 500; if (foo === 10) {} var data = ['foo', 'bar', 'baz']; var dataLast = data[2]; ``` Examples of **correct** code for this rule: ```javascript var TAX = 0.25; var total = 500; if (foo === TAX) {} const data = ['foo', 'bar', 'baz']; const LAST = 2; var dataLast = data[LAST]; ``` Examples of **correct** code for this rule with `{ "ignoreEnums": true }`: ```json { "@typescript-eslint/no-magic-numbers": ["error", { "ignoreEnums": true }] } ``` ```javascript enum foo { SECOND = 1000, NEG = -1, } ``` Examples of **correct** code for this rule with `{ "ignoreNumericLiteralTypes": true }`: ```json { "@typescript-eslint/no-magic-numbers": ["error", { "ignoreNumericLiteralTypes": true }] } ``` ```javascript type Foo = 1; type Foo = 1 | 2 | 3; ``` Examples of **correct** code for this rule with `{ "ignoreReadonlyClassProperties": true }`: ```json { "@typescript-eslint/no-magic-numbers": ["error", { "ignoreReadonlyClassProperties": true }] } ``` ```javascript class Foo { readonly A = 1; readonly B = 2; public static readonly C = 1; } ``` Examples of **correct** code for this rule with `{ "ignoreTypeIndexes": true }`: ```json { "@typescript-eslint/no-magic-numbers": ["error", { "ignoreTypeIndexes": true }] } ``` ```javascript type Foo = Bar[0]; type Foo = Bar[1 | -2]; type Foo = Parameters[2]; ``` ## Original Documentation - [typescript-eslint: no-magic-numbers](https://typescript-eslint.io/rules/no-magic-numbers) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-magic-numbers.ts) --- url: /rules/typescript-eslint/no-meaningless-void-operator.md --- # no-meaningless-void-operator [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-meaningless-void-operator': 'error', }, }, ]); ``` ## Rule Details Disallows the `void` operator when its argument is already of type `void` or `undefined`. The `void` operator is intended to convey that a return value is deliberately being ignored. Using it on an expression that already evaluates to `void` or `undefined` is redundant and misleading. Optionally, the rule can also check for `void` on `never`-typed expressions. Examples of **incorrect** code for this rule: ```typescript void undefined; void console.log('hello'); function foo(): void {} void foo(); ``` Examples of **correct** code for this rule: ```typescript void Promise.resolve(); void someAsyncFunction(); console.log('hello'); foo(); ``` ## Original Documentation - [typescript-eslint: no-meaningless-void-operator](https://typescript-eslint.io/rules/no-meaningless-void-operator) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-meaningless-void-operator.ts) --- url: /rules/typescript-eslint/no-misused-new.md --- # no-misused-new [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-misused-new': 'error', }, }, ]); ``` ## Rule Details Disallows incorrect usage of `new` and `constructor` in interfaces and classes. Interfaces define the shape of objects but cannot be constructed directly; defining a `new()` construct signature in an interface that returns the interface type or a `constructor` method signature is almost always a mistake. Similarly, classes should not have a method literally named `new` that returns the class type, as the `constructor` keyword should be used instead. Examples of **incorrect** code for this rule: ```typescript interface Foo { new (): Foo; } interface Bar { constructor(): Bar; } class Baz { new(): Baz; } ``` Examples of **correct** code for this rule: ```typescript class Foo { constructor() {} } interface Bar { new (): SomeOtherClass; } interface Baz { method(): void; } ``` ## Original Documentation - [typescript-eslint: no-misused-new](https://typescript-eslint.io/rules/no-misused-new) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-misused-new.ts) --- url: /rules/typescript-eslint/no-misused-promises.md --- # no-misused-promises [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-misused-promises': 'error', }, }, ]); ``` ## Rule Details Disallows Promises in places that are not designed to handle them. This rule catches common mistakes such as using a Promise in a conditional check (where it always evaluates to truthy), passing an async function as a callback where a void return is expected, spreading a Promise in an object, or returning a Promise-returning function where a void return is expected. The rule checks conditionals, void returns (arguments, properties, variables, inherited methods, attributes, and return statements), and object spreads. Examples of **incorrect** code for this rule: ```typescript // Promise used in conditional (always truthy) if (fetchData()) { } // Async function passed where void callback expected [1, 2, 3].forEach(async n => { await doSomething(n); }); // Spreading a Promise in an object const obj = { ...fetchData() }; // Returning async function where void expected const listeners = { onClick: async () => await handleClick(), }; ``` Examples of **correct** code for this rule: ```typescript if (await fetchData()) { } for (const n of [1, 2, 3]) { await doSomething(n); } const data = await fetchData(); const obj = { ...data }; const listeners = { onClick: () => { void handleClick(); }, }; ``` ## Original Documentation - [typescript-eslint: no-misused-promises](https://typescript-eslint.io/rules/no-misused-promises) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.28.0/packages/eslint-plugin/src/rules/no-misused-promises.ts) --- url: /rules/typescript-eslint/no-misused-spread.md --- # no-misused-spread [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-misused-spread': 'error', }, }, ]); ``` ## Rule Details Disallows spread syntax (`...`) in places where the type being spread would produce unexpected behavior. This includes spreading strings in arrays (which can mishandle special characters and emojis), spreading arrays in object literals (producing a list of indices rather than values), spreading Promises in objects (which yields an empty object), spreading Maps in objects (also producing an empty object), spreading functions without properties, spreading class instances (losing the prototype), and spreading class declarations (only copying static properties). Examples of **incorrect** code for this rule: ```typescript // Spreading a string in an array const chars = [...'hello']; // Spreading an array in an object const obj = { ...[1, 2, 3] }; // Spreading a Promise in an object const data = { ...fetchData() }; // Spreading a Map in an object const map = new Map([['a', 1]]); const obj = { ...map }; // Spreading a class instance in an object const instance = new MyClass(); const copy = { ...instance }; ``` Examples of **correct** code for this rule: ```typescript const arr = [...otherArray]; const obj = { ...otherObject }; const data = { ...(await fetchData()) }; const obj = Object.fromEntries(map); const chars = Array.from(new Intl.Segmenter().segment('hello')); ``` ## Original Documentation - [typescript-eslint: no-misused-spread](https://typescript-eslint.io/rules/no-misused-spread) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-misused-spread.ts) --- url: /rules/typescript-eslint/no-mixed-enums.md --- # no-mixed-enums [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-mixed-enums': 'error', }, }, ]); ``` ## Rule Details Disallows enums that mix string and number member values. TypeScript enums can contain either string values or number values, but mixing both types in a single enum declaration can lead to confusing behavior. For example, number enum members have reverse mappings while string enum members do not. This rule ensures all members in an enum use the same type of initializer. Examples of **incorrect** code for this rule: ```typescript enum Status { Active = 0, Inactive = 'inactive', } enum Mixed { A = 0, B = 1, C = 'c', } ``` Examples of **correct** code for this rule: ```typescript enum Status { Active = 0, Inactive = 1, } enum Color { Red = 'red', Blue = 'blue', Green = 'green', } enum Direction { Up, Down, Left, Right, } ``` ## Original Documentation - [typescript-eslint: no-mixed-enums](https://typescript-eslint.io/rules/no-mixed-enums) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-mixed-enums.ts) --- url: /rules/typescript-eslint/no-namespace.md --- # no-namespace [Added in v0.1.6](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.6) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-namespace': 'error', }, }, ]); ``` ## Rule Details Disallows the use of TypeScript `namespace` declarations. TypeScript historically allowed organizing code with custom `namespace` blocks, but ES2015 modules (using `import`/`export`) are the modern standard for code organization. Namespaces are generally considered outdated and should be replaced with modules. By default, this rule allows namespaces in `.d.ts` definition files, since they are commonly used there. Examples of **incorrect** code for this rule: ```typescript namespace MyNamespace { export const value = 1; } namespace Nested { export namespace Inner { export type Foo = string; } } ``` Examples of **correct** code for this rule: ```typescript // Use ES modules instead export const value = 1; // Declare namespaces are allowed with allowDeclarations option declare namespace ExternalLib { function doWork(): void; } // Namespaces in .d.ts files are allowed by default // (in file.d.ts) declare namespace MyLib { interface Options {} } ``` ## Original Documentation - [typescript-eslint: no-namespace](https://typescript-eslint.io/rules/no-namespace) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-namespace.ts) --- url: /rules/typescript-eslint/no-non-null-asserted-nullish-coalescing.md --- # no-non-null-asserted-nullish-coalescing [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error', }, }, ]); ``` ## Rule Details Disallow non-null assertions in the left operand of a nullish coalescing operator. The `??` nullish coalescing operator is designed to provide a default value when dealing with `null` or `undefined`. Using a non-null assertion `!` in the left operand is contradictory and likely a mistake. Examples of **incorrect** code for this rule: ```typescript foo! ?? bar; foo.bazz! ?? bar; foo()! ?? bar; ``` Examples of **correct** code for this rule: ```typescript foo ?? bar; foo ?? bar!; foo.bazz ?? bar; ``` ## Original Documentation - [typescript-eslint: no-non-null-asserted-nullish-coalescing](https://typescript-eslint.io/rules/no-non-null-asserted-nullish-coalescing) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-non-null-asserted-nullish-coalescing.ts) --- url: /rules/typescript-eslint/no-non-null-asserted-optional-chain.md --- # no-non-null-asserted-optional-chain [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', }, }, ]); ``` ## Rule Details Disallow non-null assertions after an optional chain expression. Optional chain expressions (`?.`) are designed to return `undefined` if the value is nullish. Using a non-null assertion (`!`) after an optional chain expression is unsafe, as it defeats the purpose of the optional chain. Examples of **incorrect** code for this rule: ```typescript foo?.bar!; foo?.bar()!; ``` Examples of **correct** code for this rule: ```typescript foo?.bar; foo?.bar(); ``` ## Original Documentation - [typescript-eslint: no-non-null-asserted-optional-chain](https://typescript-eslint.io/rules/no-non-null-asserted-optional-chain) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-non-null-asserted-optional-chain.ts) --- url: /rules/typescript-eslint/no-non-null-assertion.md --- # no-non-null-assertion [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-non-null-assertion': 'error', }, }, ]); ``` ## Rule Details Disallows non-null assertions using the `!` postfix operator. TypeScript's `!` non-null assertion operator asserts to the type system that an expression is non-nullable. Using assertions to tell the type system new information is often a sign that code is not fully type-safe. It's generally better to structure program logic so that TypeScript understands when values may be nullable. Examples of **incorrect** code for this rule: ```typescript interface Example { property?: string; } declare const example: Example; const includesBaz = example.property!.includes('baz'); ``` Examples of **correct** code for this rule: ```typescript interface Example { property?: string; } declare const example: Example; const includesBaz = example.property?.includes('baz') ?? false; ``` ## Original Documentation - [typescript-eslint: no-non-null-assertion](https://typescript-eslint.io/rules/no-non-null-assertion) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.68.0/packages/eslint-plugin/src/rules/no-non-null-assertion.ts) --- url: /rules/typescript-eslint/no-redeclare.md --- # no-redeclare [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-redeclare': 'error', }, }, ]); ``` ## Rule Details This rule disallows redeclaring variables. It extends ESLint's base `no-redeclare` to understand TypeScript constructs such as type aliases, interfaces, namespaces, and declaration merging. Examples of **incorrect** code for this rule: ```javascript var a = 3; var a = 10; ``` ```javascript function a() {} function a() {} ``` ```typescript type T = 1; type T = 2; ``` Examples of **correct** code for this rule: ```javascript var a = 3; var b = function () { var a = 10; }; ``` ```typescript interface A { prop1: 1; } interface A { prop2: 2; } ``` ```typescript class Foo {} namespace Foo {} ``` ## Options ### `builtinGlobals` (default: `true`) When `true`, the rule reports redeclaring ECMAScript built-in globals and names provided by TypeScript's active lib type definitions, such as `Object`, `Promise`, or `HTMLElement`. Configured [`languageOptions.globals`](/config/language-options.md#languageoptionsglobals) also participate as built-ins; use the `globals` catalog exported by `@rslint/core` to select a runtime environment. Active `/* global */` directives participate as declarations in either mode; a final `:off` setting removes that inline global. Turning off a value global does not remove a same-named TypeScript type global. ```json { "@typescript-eslint/no-redeclare": ["error", { "builtinGlobals": true }] } ``` ```javascript var Object = 0; ``` ### `ignoreDeclarationMerge` (default: `true`) When `true`, the rule ignores redeclarations that are legal TypeScript declaration merges: - `interface` + `interface` - `namespace` + `namespace` - `class` + `interface` / `class` + `namespace` / `class` + `interface` + `namespace` (at most one class) - `function` + `namespace` (at most one function) - `enum` + `namespace` (at most one enum) ```json { "@typescript-eslint/no-redeclare": ["error", { "ignoreDeclarationMerge": true }] } ``` ```typescript function A() {} namespace A {} ``` ## Original Documentation - [typescript-eslint: no-redeclare](https://typescript-eslint.io/rules/no-redeclare) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-redeclare.ts) --- url: /rules/typescript-eslint/no-redundant-type-constituents.md --- # no-redundant-type-constituents [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-redundant-type-constituents': 'error', }, }, ]); ``` ## Rule Details Disallow members of unions and intersections that do nothing or override other members. Some types can override other types in a union or intersection, rendering them redundant. For example, `any` in a union type overrides all other members, and `never` in an intersection type overrides all other members. These redundant constituents can be misleading and should be removed. Examples of **incorrect** code for this rule: ```typescript type Union = any | string; type Intersection = string & any; type PrimitiveOverride = string | 'hello'; type NeverUnion = string | never; ``` Examples of **correct** code for this rule: ```typescript type Union = string | number; type Intersection = string & { foo: string }; type ValidUnion = string | number | boolean; type ReturnType = string | never; // allowed in return type position ``` ## Original Documentation - [typescript-eslint: no-redundant-type-constituents](https://typescript-eslint.io/rules/no-redundant-type-constituents) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-redundant-type-constituents.ts) --- url: /rules/typescript-eslint/no-require-imports.md --- # no-require-imports [Added in v0.1.6](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.6) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-require-imports': 'error', }, }, ]); ``` ## Rule Details Disallow invocation of `require()`. Prefer the newer ES6-style imports over `require()`. TypeScript projects should use `import` statements which provide better type safety and editor tooling support. Examples of **incorrect** code for this rule: ```typescript const fs = require('fs'); const path = require?.('path'); import foo = require('foo'); ``` Examples of **correct** code for this rule: ```typescript import fs from 'fs'; import * as path from 'path'; import { readFile } from 'fs'; ``` ## Original Documentation - [typescript-eslint: no-require-imports](https://typescript-eslint.io/rules/no-require-imports) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-require-imports.ts) --- url: /rules/typescript-eslint/no-restricted-imports.md --- # no-restricted-imports [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-restricted-imports': 'error', }, }, ]); ``` Disallow specified modules when loaded by `import`. ## Rule Details This rule extends the base [`no-restricted-imports`](https://eslint.org/docs/latest/rules/no-restricted-imports) rule. It adds first-class support for TypeScript-only forms: - Type-only imports: `import type Foo from 'foo'` - Inline type specifiers: `import { type Foo } from 'foo'` - CommonJS `import = require(...)` (including `import type x = require(...)`) - Type-only re-exports: `export type { Foo } from 'foo'` The schema, message ids, and reporting positions are all identical to the base rule. The only addition is the `allowTypeImports` option on each `paths` entry and `patterns` entry — when set, type-only imports/exports of the matching source are exempted from the restriction. ## Options The rule accepts the same option shapes as the base `no-restricted-imports` rule. Each entry in `paths` (object form) and `patterns` (object form) may also set: - `allowTypeImports: boolean` — when `true`, do not report a type-only import or export of this path/pattern. Default `false`. Examples of **incorrect** code with `["error", { "paths": [{ "name": "import-foo", "message": "Use import-bar instead.", "allowTypeImports": true }] }]`: ```json { "@typescript-eslint/no-restricted-imports": [ "error", { "paths": [ { "name": "import-foo", "message": "Use import-bar instead.", "allowTypeImports": true } ] } ] } ``` ```ts import foo from 'import-foo'; export { foo } from 'import-foo'; ``` Examples of **correct** code with the same options: ```ts import type foo from 'import-foo'; import type _ = require('import-foo'); export type { foo } from 'import-foo'; ``` Examples of **incorrect** code with `["error", { "patterns": [{ "group": ["import1/private/*"], "message": "private modules are not allowed.", "allowTypeImports": true }] }]`: ```json { "@typescript-eslint/no-restricted-imports": [ "error", { "patterns": [ { "group": ["import1/private/*"], "message": "private modules are not allowed.", "allowTypeImports": true } ] } ] } ``` ```ts import foo from 'import1/private/bar'; ``` Examples of **correct** code with the same options: ```ts import type foo from 'import1/private/bar'; export type { foo } from 'import1/private/bar'; ``` ## When Not To Use It If you do not need to restrict imports of any modules, do not enable this rule. ## Original Documentation - [typescript-eslint: no-restricted-imports](https://typescript-eslint.io/rules/no-restricted-imports) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-restricted-imports.ts) --- url: /rules/typescript-eslint/no-restricted-types.md --- # no-restricted-types [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-restricted-types': 'error', }, }, ]); ``` ## Rule Details Disallow specified types. The rule reports any usage of a type whose name matches a key in the configured `types` map. Names are compared after stripping all whitespace, so a source-side `Banned` matches a configured key of `Banned` (and a configured key of ` NS.Banned ` matches a source-side `NS.Banned`). The rule recognizes these type-syntax forms: - Primitive type keywords (`bigint`, `boolean`, `never`, `null`, `number`, `object`, `string`, `symbol`, `undefined`, `unknown`, `void`). - Type references — both bare (`Banned`, `NS.Banned`) and parameterized (`Banned`, `NS.Banned`). - The empty tuple type `[]`. - The empty type literal `{}`. - Heritage references — `class X implements Banned` and `interface X extends Banned`. Each entry in `types` pairs a type name with one of: - `true` — ban with the default message. - `false` or `null` — explicitly do not ban this name. - A `string` — ban with the string appended to the default message. - An object `{ message?: string, fixWith?: string, suggest?: string[] }` — ban with an extra message, an optional auto-fix replacement, and/or one or more editor suggestions. Examples of **incorrect** code for this rule with `{ "types": { "Banned": "Use Ok instead." } }`: ```json { "@typescript-eslint/no-restricted-types": ["error", { "types": { "Banned": "Use Ok instead." } }] } ``` ```typescript let value: Banned; ``` Examples of **correct** code for this rule with `{ "types": { "Banned": "Use Ok instead." } }`: ```json { "@typescript-eslint/no-restricted-types": ["error", { "types": { "Banned": "Use Ok instead." } }] } ``` ```typescript let value: Ok; ``` Examples of **incorrect** code for this rule with `{ "types": { "Banned": { "fixWith": "Ok", "message": "Use Ok instead." } } }`: ```json { "@typescript-eslint/no-restricted-types": ["error", { "types": { "Banned": { "fixWith": "Ok", "message": "Use Ok instead." } } }] } ``` ```typescript let value: Banned; ``` The auto-fix rewrites the type reference to `Ok`. Examples of **incorrect** code for this rule with `{ "types": { "[]": "Use unknown[] instead." } }`: ```json { "@typescript-eslint/no-restricted-types": ["error", { "types": { "[]": "Use unknown[] instead." } }] } ``` ```typescript let value: []; ``` ## Original Documentation - [typescript-eslint: no-restricted-types](https://typescript-eslint.io/rules/no-restricted-types) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-restricted-types.ts) --- url: /rules/typescript-eslint/no-shadow.md --- # no-shadow [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-shadow': 'error', }, }, ]); ``` Disallow variable declarations from shadowing variables declared in the outer scope. Extends the ESLint core [`no-shadow`](https://eslint.org/docs/latest/rules/no-shadow) rule with TypeScript-aware behavior. ## Rule Details Shadowing occurs when a local variable shares the same name as a variable in its containing scope. The TypeScript variant additionally understands type-only declarations and the related `typeof` interplay between values and types. Examples of **incorrect** code for this rule: ```ts type Foo = number; function b() { type Foo = string; } ``` Examples of **correct** code for this rule: ```ts type Foo = number; function b() { type Bar = string; } ``` ## Options This rule accepts the same options as the ESLint core `no-shadow` rule with these additions and default differences: ### `hoist` In addition to the core values (`"functions"`, `"all"`, `"never"`), this rule supports: - `"types"`: report shadowing of an outer type or interface that appears later. - `"functions-and-types"`: report shadowing of outer function or type declarations that appear later. **Default**: `"functions-and-types"` (the core ESLint default is `"functions"`). ### `ignoreTypeValueShadow` When `true`, a value declaration and a type declaration that share a name are not considered shadowing (the two live in different namespaces and a `typeof` is required to bridge them). **Default**: `true`. ```json { "@typescript-eslint/no-shadow": ["error", { "ignoreTypeValueShadow": false }] } ``` ```ts type Foo = number; function f() { const Foo = 1; } ``` ### `ignoreFunctionTypeParameterNameValueShadow` When `true`, parameters declared inside a function type (for example `(x: string) => void`) do not report when they shadow an outer value binding. **Default**: `true`. ```json { "@typescript-eslint/no-shadow": ["error", { "ignoreFunctionTypeParameterNameValueShadow": false }] } ``` ```ts const test = 1; type Func = (test: string) => typeof test; ``` ### `allow`, `builtinGlobals`, `ignoreOnInitialization` Same semantics and defaults as the ESLint core rule. When `builtinGlobals` is enabled, names from [`languageOptions.globals`](/config/language-options.md#languageoptionsglobals) participate too; the `globals` catalog exported by `@rslint/core` provides runtime environment maps. ## Original Documentation - [typescript-eslint: no-shadow](https://typescript-eslint.io/rules/no-shadow) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.59.1/packages/eslint-plugin/src/rules/no-shadow.ts) --- url: /rules/typescript-eslint/no-this-alias.md --- # no-this-alias [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-this-alias': 'error', }, }, ]); ``` ## Rule Details Disallow aliasing `this`. Assigning `this` to a variable (commonly named `self` or `that`) is a legacy pattern that predates arrow functions. Arrow functions automatically capture the surrounding `this`, making `this` aliasing unnecessary. Examples of **incorrect** code for this rule: ```typescript const self = this; let that = this; const foo = this; ``` Examples of **correct** code for this rule: ```typescript const { foo } = this; // destructuring is allowed by default setTimeout(() => { this.doSomething(); // use arrow function instead of aliasing }); ``` ## Original Documentation - [typescript-eslint: no-this-alias](https://typescript-eslint.io/rules/no-this-alias) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-this-alias.ts) --- url: /rules/typescript-eslint/no-type-alias.md --- # no-type-alias [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-type-alias': 'error', }, }, ]); ``` ## Rule Details Disallow type aliases. Examples of **incorrect** code for this rule: ```ts type Name = string; ``` Examples of **correct** code: ```ts interface Name { value: string; } ``` ## Original Documentation - [typescript-eslint: no-type-alias](https://typescript-eslint.io/rules/no-type-alias) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-type-alias.ts) --- url: /rules/typescript-eslint/no-unnecessary-boolean-literal-compare.md --- # no-unnecessary-boolean-literal-compare [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error', }, }, ]); ``` ## Rule Details Disallow unnecessary equality comparisons against boolean literals. Comparing a boolean value to `true` or `false` is redundant. The value can be used directly or negated instead. This rule flags such comparisons and provides auto-fixes. ### Options - `allowComparingNullableBooleansToTrue` (default: `true`): When set to `true`, allows `nullableVar === true` or `nullableVar !== true` comparisons for nullable boolean types (`boolean | null | undefined`). Set to `false` to flag these comparisons. - `allowComparingNullableBooleansToFalse` (default: `true`): When set to `true`, allows `nullableVar === false` or `nullableVar !== false` comparisons for nullable boolean types. Set to `false` to flag these comparisons and suggest using the `??` operator instead. - `allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing` (default: `false`): When set to `true`, allows the rule to run even when `strictNullChecks` is not enabled. By default, the rule reports an error if `strictNullChecks` is off. Examples of **incorrect** code for this rule: ```typescript declare const someCondition: boolean; if (someCondition === true) { } if (someCondition !== true) { } if (someCondition === false) { } ``` Examples of **incorrect** code with `{ allowComparingNullableBooleansToTrue: false }`: ```typescript declare const nullableFlag: boolean | undefined; if (nullableFlag === true) { } ``` Examples of **incorrect** code with `{ allowComparingNullableBooleansToFalse: false }`: ```typescript declare const nullableFlag: boolean | null; if (nullableFlag === false) { } ``` Examples of **correct** code for this rule: ```typescript declare const someCondition: boolean; if (someCondition) { } if (!someCondition) { } declare const nullableFlag: boolean | null; if (nullableFlag === true) { } // allowed by default for nullable booleans ``` ## Original Documentation - [typescript-eslint: no-unnecessary-boolean-literal-compare](https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.29.0/packages/eslint-plugin/src/rules/no-unnecessary-boolean-literal-compare.ts) --- url: /rules/typescript-eslint/no-unnecessary-condition.md --- # no-unnecessary-condition [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unnecessary-condition': 'error', }, }, ]); ``` ## Rule Details Disallow conditionals where the type is always truthy or always falsy. Any expression being used as a condition must be able to evaluate as truthy or falsy in order to be considered necessary. Conversely, any expression that always evaluates to truthy or always evaluates to falsy is considered unnecessary and will be flagged by this rule. Examples of **incorrect** code for this rule: ```typescript function head(items: T[]) { // items is always truthy (arrays are objects) if (items) { return items[0].toUpperCase(); } } function foo(arg: 'bar' | 'baz') { // arg is always truthy (non-empty string literals) if (arg) { } } ``` Examples of **correct** code for this rule: ```typescript function head(items: T[]) { // items.length can be zero if (items.length) { return items[0].toUpperCase(); } } function foo(arg: string) { // string can be empty if (arg) { } } ``` ## Original Documentation - [typescript-eslint: no-unnecessary-condition](https://typescript-eslint.io/rules/no-unnecessary-condition) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.69.0/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts) --- url: /rules/typescript-eslint/no-unnecessary-parameter-property-assignment.md --- # no-unnecessary-parameter-property-assignment [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unnecessary-parameter-property-assignment': 'error', }, }, ]); ``` ## Rule Details Disallow unnecessary assignment of constructor property parameter. TypeScript's parameter property syntax (`constructor(public foo: string)`) both declares a class member and assigns the constructor argument to it. Writing an explicit `this.foo = foo` inside the constructor body therefore performs the exact same assignment a second time and adds nothing. This rule reports `this.X = X` — and the `||=`, `&&=`, `??=` variants that have the same effect on a freshly-bound member — when the constructor's parameter list declares a parameter property named `X`. Examples of **incorrect** code for this rule: ```typescript class Foo { constructor(public foo: string) { this.foo = foo; } } class Foo { constructor(public foo: string) { this.foo ||= foo; } } class Foo { constructor(public foo: string) { this.foo ??= foo; } } class Foo { constructor(public foo: string) { this.foo &&= foo; } } class Foo { constructor(private foo: string) { this['foo'] = foo; } } class Foo { constructor(public foo?: string) { this.foo = foo!; } } class Foo { constructor(public foo?: string) { this.foo = foo as any; } } ``` Examples of **correct** code for this rule: ```typescript class Foo { constructor(public foo: string) {} } class Foo { constructor(private foo: string) { this.foo = bar; } } class Foo { foo: string; constructor(foo: string) { this.foo = foo; } } class Foo { constructor(public foo: number) { this.foo += foo; this.foo -= foo; } } class Foo { constructor(public foo: number) { this.foo += 1; this.foo = foo; } } class Foo { constructor(public foo: number) { { const foo = 1; this.foo = foo; } } } ``` ## Original Documentation - [typescript-eslint: no-unnecessary-parameter-property-assignment](https://typescript-eslint.io/rules/no-unnecessary-parameter-property-assignment) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.59.3/packages/eslint-plugin/src/rules/no-unnecessary-parameter-property-assignment.ts) --- url: /rules/typescript-eslint/no-unnecessary-qualifier.md --- # no-unnecessary-qualifier [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unnecessary-qualifier': 'error', }, }, ]); ``` ## Rule Details Disallow unnecessary namespace qualifiers. Accessing an enum member or a namespace export by its qualified name when the right-hand identifier is already directly in scope is redundant. The rule flags those qualifiers and offers an autofix that removes them. Examples of **incorrect** code for this rule: ```typescript enum A { B, C = A.B, } namespace A { export type B = number; const x: A.B = 3; } namespace A { export namespace B { export type T = number; const x: A.B.T = 3; } } ``` Examples of **correct** code for this rule: ```typescript enum A { B, C = B, } namespace A { export type B = number; const x: B = 3; } namespace X { export type T = number; } namespace Y { export const x: X.T = 3; } ``` ## Original Documentation - [typescript-eslint: no-unnecessary-qualifier](https://typescript-eslint.io/rules/no-unnecessary-qualifier) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts) --- url: /rules/typescript-eslint/no-unnecessary-template-expression.md --- # no-unnecessary-template-expression [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unnecessary-template-expression': 'error', }, }, ]); ``` ## Rule Details Disallow unnecessary expressions inside template literals and template literal types. Literal interpolations can be written directly into the surrounding template. When a template contains only one string-typed expression, the template wrapper can be removed entirely. The rule provides an autofix for both forms while preserving template escapes. Examples of **incorrect** code for this rule: ```typescript const ab = `${'a'}`; const greeting = `${name}`; // when name is typed as string const value = `${true}`; const num = `${100}`; type EventName = `on${'Click'}`; ``` Examples of **correct** code for this rule: ```typescript const ab = 'a'; const greeting = name; const combined = `Hello, ${name}!`; const tagged = tag`${value}`; type EventName = 'onClick'; ``` ## Original Documentation - [typescript-eslint: no-unnecessary-template-expression](https://typescript-eslint.io/rules/no-unnecessary-template-expression) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.29.1/packages/eslint-plugin/src/rules/no-unnecessary-template-expression.ts) --- url: /rules/typescript-eslint/no-unnecessary-type-arguments.md --- # no-unnecessary-type-arguments [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unnecessary-type-arguments': 'error', }, }, ]); ``` ## Rule Details Disallow type arguments that are equal to the default. If a type parameter has a default value and an explicit type argument provides the same type, the argument is redundant and can be omitted for cleaner code. Examples of **incorrect** code for this rule: ```typescript function f() {} f(); // number is the default, can be omitted type Foo = T[]; const x: Foo = []; // string is the default class Bar {} new Bar(); // boolean is the default ``` Examples of **correct** code for this rule: ```typescript function f() {} f(); // uses default f(); // overrides default type Foo = T[]; const x: Foo = []; const y: Foo = []; ``` ## Original Documentation - [typescript-eslint: no-unnecessary-type-arguments](https://typescript-eslint.io/rules/no-unnecessary-type-arguments) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.29.0/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts) --- url: /rules/typescript-eslint/no-unnecessary-type-assertion.md --- # no-unnecessary-type-assertion [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unnecessary-type-assertion': 'error', }, }, ]); ``` ## Rule Details Disallow type assertions that do not change the type of an expression. Type assertions (`as` expressions, angle-bracket syntax, and non-null assertions `!`) that don't actually change the type of an expression are unnecessary and add noise to the code. This includes non-null assertions on values that are already non-nullable. Examples of **incorrect** code for this rule: ```typescript const foo = 3; const bar = foo!; // foo is already non-nullable const str = 'hello' as string; // already a string declare const value: number; const num = value as number; // already a number ``` Examples of **correct** code for this rule: ```typescript const foo: number | undefined = getValue(); const bar = foo!; // non-null assertion is meaningful const value = someUnknown as string; // type narrowing const x = 3 as const; // const assertions are allowed ``` ## Original Documentation - [typescript-eslint: no-unnecessary-type-assertion](https://typescript-eslint.io/rules/no-unnecessary-type-assertion) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.68.0/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts) --- url: /rules/typescript-eslint/no-unnecessary-type-constraint.md --- # no-unnecessary-type-constraint [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unnecessary-type-constraint': 'error', }, }, ]); ``` ## Rule Details This rule disallows unnecessary constraints on generic types. Type parameters (``) default to `unknown`, so constraining a generic type parameter to `any` or `unknown` has no effect. Examples of **incorrect** code for this rule: ```typescript interface FooAny {} class BarAny {} function BazAny() {} const QuuxAny = () => {}; interface FooUnknown {} class BarUnknown {} function BazUnknown() {} const QuuxUnknown = () => {}; ``` Examples of **correct** code for this rule: ```typescript interface Foo {} class Bar {} function Baz() {} const Quux = () => {}; ``` ## Original Documentation - [typescript-eslint: no-unnecessary-type-constraint](https://typescript-eslint.io/rules/no-unnecessary-type-constraint) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-unnecessary-type-constraint.ts) --- url: /rules/typescript-eslint/no-unnecessary-type-conversion.md --- # no-unnecessary-type-conversion [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unnecessary-type-conversion': 'error', }, }, ]); ``` ## Rule Details Disallow conversion idioms when they do not change the type or value of the expression. TypeScript already tracks the type of every expression, so calling `String(x)`, `Number(x)`, `Boolean(x)`, `BigInt(x)`, `.toString()`, `+x`, `!!x`, `~~x`, or concatenating with `''` when the source expression already has the target type is a no-op — it adds noise without changing the value or the type. The rule never reports on `new String(...)`, `new Number(...)`, `new Boolean(...)`, or `new BigInt(...)`; those construct wrapper objects whose runtime type is `object`, not the primitive, so the call is not a no-op. It also opts out of the `.toString()` check when the receiver is an enum or enum member, since `.toString()` there is the documented way to read the enum's underlying string or number. A locally declared `String` / `Number` / `Boolean` / `BigInt` shadows the global and suppresses the call-form report. Examples of **incorrect** code for this rule: ```typescript String('asdf'); 'asdf'.toString(); 'asdf' + ''; '' + 'asdf'; let str = 'asdf'; str += ''; Number(123); +123; ~~123; Boolean(true); !!true; BigInt(3n); ``` Examples of **correct** code for this rule: ```typescript String(1); (1).toString(); `${1}`; '' + 1; 1 + ''; let str = 1; str += ''; Number('2'); +'2'; ~~'2'; ~~1.1; ~~(1 / 3); Boolean(0); !!0; BigInt(3); new String('asdf'); new Number(2); new Boolean(true); ``` ## Original Documentation - [typescript-eslint: no-unnecessary-type-conversion](https://typescript-eslint.io/rules/no-unnecessary-type-conversion) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.59.3/packages/eslint-plugin/src/rules/no-unnecessary-type-conversion.ts) --- url: /rules/typescript-eslint/no-unnecessary-type-parameters.md --- # no-unnecessary-type-parameters [Added in v0.8.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.0) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unnecessary-type-parameters': 'error', }, }, ]); ``` ## Rule Details Disallows type parameters that aren't used multiple times in a function, method, or class signature. A type parameter relates two or more positions in a signature; if it only appears once, it isn't relating anything, and the concrete type it stands for can be written directly instead. Examples of **incorrect** code for this rule: ```typescript function second(a: A, b: B): B { return b; } function parseJSON(input: string): T { return JSON.parse(input); } function printProperty(obj: T, key: K) { console.log(obj[key]); } ``` Examples of **correct** code for this rule: ```typescript function second(a: unknown, b: B): B { return b; } function parseJSON(input: string): unknown { return JSON.parse(input); } // T appears twice: once as the parameter type, once as the return type. function identity(arg: T): T { return arg; } // T appears twice: `keyof T` and the inferred return type (`T[K]`). // K appears twice: `key: K` and the inferred return type (`T[K]`). function getProperty(obj: T, key: K) { return obj[key]; } ``` ## Differences from ESLint rslint resolves a few signature positions that the TypeScript public API keeps out of reach of upstream `@typescript-eslint/no-unnecessary-type-parameters`, and counts a type parameter appearing there as used. That makes for slightly fewer reports, all of them ones upstream raises in error. The `replaceUsagesWithConstraint` suggestion parenthesizes the constraint wherever the type grammar calls for it, so applying it always leaves you with the same type the code had before. ## Original Documentation - [typescript-eslint: no-unnecessary-type-parameters](https://typescript-eslint.io/rules/no-unnecessary-type-parameters) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-unnecessary-type-parameters.ts) --- url: /rules/typescript-eslint/no-unsafe-argument.md --- # no-unsafe-argument [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unsafe-argument': 'error', }, }, ]); ``` ## Rule Details Disallow calling a function with a value with type `any`. The `any` type in TypeScript is a dangerous escape hatch from the type system. Passing an `any`-typed value as an argument to a function defeats the purpose of the parameter's type safety. This rule flags cases where `any`-typed values are passed as arguments, including spread arguments. Examples of **incorrect** code for this rule: ```typescript declare function foo(arg: string): void; const anyVal: any = 'hello'; foo(anyVal); declare function bar(...args: string[]): void; const anyArray: any[] = []; bar(...anyArray); ``` Examples of **correct** code for this rule: ```typescript declare function foo(arg: string): void; foo('hello'); declare function bar(arg: any): void; bar(value); // parameter already typed as any declare function baz(...args: string[]): void; const strArray: string[] = []; baz(...strArray); ``` ## Differences from typescript-eslint rslint also checks the element type of non-tuple iterable spreads, including ordinary arrays and type parameters constrained to `Iterable` or an array type. typescript-eslint currently ignores these spread arguments. ## Original Documentation - [typescript-eslint: no-unsafe-argument](https://typescript-eslint.io/rules/no-unsafe-argument) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.68.0/packages/eslint-plugin/src/rules/no-unsafe-argument.ts) --- url: /rules/typescript-eslint/no-unsafe-assignment.md --- # no-unsafe-assignment [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unsafe-assignment': 'error', }, }, ]); ``` ## Rule Details Disallow assigning a value with type `any` to variables and properties. Assigning an `any`-typed value to a variable or property circumvents TypeScript's type checking. This rule flags unsafe assignments including direct assignments, variable declarations, array destructuring with `any` elements, object destructuring with `any` properties, and array spreads of `any`-typed values. Examples of **incorrect** code for this rule: ```typescript const x = 1 as any; const [y] = [1] as any; const [z] = [1 as any]; function fn(arg: any) { const val: string = arg; } ``` Examples of **correct** code for this rule: ```typescript const x = 1; const [y] = [1]; const val: unknown = someAnyValue; function fn(arg: string) { const val: string = arg; } ``` ## Original Documentation - [typescript-eslint: no-unsafe-assignment](https://typescript-eslint.io/rules/no-unsafe-assignment) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.65.0/packages/eslint-plugin/src/rules/no-unsafe-assignment.ts) --- url: /rules/typescript-eslint/no-unsafe-call.md --- # no-unsafe-call [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unsafe-call': 'error', }, }, ]); ``` ## Rule Details Disallow calling a value with type `any`. Calling an `any`-typed value as a function or constructor is unsafe since there is no guarantee that the value is actually callable. This rule also flags tagged template expressions and `new` expressions with `any`-typed callee values, as well as calling values typed as the `Function` type. Examples of **incorrect** code for this rule: ```typescript declare const anyVal: any; anyVal(); anyVal.foo(); new anyVal(); declare const fn: Function; fn(); ``` Examples of **correct** code for this rule: ```typescript declare const greet: (name: string) => void; greet('world'); declare const Cls: new () => object; new Cls(); declare const tag: (strings: TemplateStringsArray) => string; tag`hello`; ``` ## Original Documentation - [typescript-eslint: no-unsafe-call](https://typescript-eslint.io/rules/no-unsafe-call) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.28.0/packages/eslint-plugin/src/rules/no-unsafe-call.ts) --- url: /rules/typescript-eslint/no-unsafe-declaration-merging.md --- # no-unsafe-declaration-merging [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unsafe-declaration-merging': 'error', }, }, ]); ``` ## Rule Details Disallows unsafe declaration merging between a class and an interface. TypeScript allows a class and an interface that share the same name in the same scope to merge into a single declaration. Properties declared on the interface are added to the resulting type without forcing the class to actually initialize them, so accessing such a property on a class instance type-checks but throws `Cannot read properties of undefined` at runtime. Examples of **incorrect** code for this rule: ```typescript interface Foo {} class Foo {} ``` ```typescript class Foo {} interface Foo {} ``` ```typescript declare global { interface Foo {} class Foo {} } ``` Examples of **correct** code for this rule: ```typescript interface Foo {} class Bar implements Foo {} ``` ```typescript namespace Foo {} namespace Foo {} ``` ```typescript enum Foo {} namespace Foo {} ``` ```typescript namespace Qux {} function Qux() {} ``` ```typescript const Foo = class {}; ``` ```typescript interface Foo { props: string; } function bar() { return class Foo {}; } ``` ```typescript declare global { interface Foo {} } class Foo {} ``` ## Original Documentation - [typescript-eslint: no-unsafe-declaration-merging](https://typescript-eslint.io/rules/no-unsafe-declaration-merging) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-unsafe-declaration-merging.ts) --- url: /rules/typescript-eslint/no-unsafe-enum-comparison.md --- # no-unsafe-enum-comparison [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unsafe-enum-comparison': 'error', }, }, ]); ``` ## Rule Details Disallow comparing an enum value with a non-enum value. TypeScript enums are a special type that represent a set of named constants. Comparing enum values against raw literals or values of a different enum type is often a mistake and can lead to subtle bugs, since enums in TypeScript have their own type identity. Examples of **incorrect** code for this rule: ```typescript enum Fruit { Apple, Banana, } declare const fruit: Fruit; fruit === 0; fruit === 'Apple'; enum Vegetable { Carrot, } fruit === Vegetable.Carrot; ``` Examples of **correct** code for this rule: ```typescript enum Fruit { Apple, Banana, } declare const fruit: Fruit; fruit === Fruit.Apple; fruit === Fruit.Banana; ``` ## Original Documentation - [typescript-eslint: no-unsafe-enum-comparison](https://typescript-eslint.io/rules/no-unsafe-enum-comparison) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.68.0/packages/eslint-plugin/src/rules/no-unsafe-enum-comparison.ts) --- url: /rules/typescript-eslint/no-unsafe-function-type.md --- # no-unsafe-function-type [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unsafe-function-type': 'error', }, }, ]); ``` ## Rule Details Disallow using the built-in `Function` type. `Function` describes any callable value: it accepts any number of arguments, returns `any`, and includes class declarations, which throw at runtime when invoked without `new`. A concrete signature — including parameters and return type — should be used instead. A local declaration named `Function` (a `type` alias, `interface`, or `class`) shadows the global one, in which case the reference is no longer the unsafe built-in and is not reported. Examples of **incorrect** code for this rule: ```typescript let value: Function; let values: Function[]; let valueOrNumber: Function | number; class Weird implements Function { // ... } interface AlsoWeird extends Function { // ... } ``` Examples of **correct** code for this rule: ```typescript let value: () => void; let value: (t: T) => T; { type Function = () => void; let value: Function; } ``` ## Original Documentation - [typescript-eslint: no-unsafe-function-type](https://typescript-eslint.io/rules/no-unsafe-function-type) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-unsafe-function-type.ts) --- url: /rules/typescript-eslint/no-unsafe-member-access.md --- # no-unsafe-member-access [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unsafe-member-access': 'error', }, }, ]); ``` ## Rule Details Disallow member access on a value with type `any`. Accessing a member (property or element) on an `any`-typed value is unsafe because the result will also be typed as `any`, propagating the lack of type safety. This rule flags both dot-notation property access and bracket-notation element access on `any`-typed values, as well as computed member access where the index expression is typed as `any`. Examples of **incorrect** code for this rule: ```typescript declare const anyVal: any; anyVal.foo; anyVal['bar']; anyVal[0]; declare const key: any; declare const obj: { [k: string]: number }; obj[key]; ``` Examples of **correct** code for this rule: ```typescript declare const obj: { foo: string }; obj.foo; declare const arr: string[]; arr[0]; declare const key: string; declare const map: { [k: string]: number }; map[key]; ``` Optional chaining on `any` remains unsafe by default. Set `allowOptionalChaining` to `true` to allow only the access link containing `?.`: ```json { "@typescript-eslint/no-unsafe-member-access": [ "error", { "allowOptionalChaining": true } ] } ``` ```typescript declare const value: any; const result: unknown = value?.property; ``` ## Original Documentation - [typescript-eslint: no-unsafe-member-access](https://typescript-eslint.io/rules/no-unsafe-member-access) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-unsafe-member-access.ts) --- url: /rules/typescript-eslint/no-unsafe-return.md --- # no-unsafe-return [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unsafe-return': 'error', }, }, ]); ``` ## Rule Details Disallow returning a value with type `any` from a function. Returning an `any`-typed value from a function that has a typed return type undermines type safety, since the caller will trust the return type but the actual value has no type guarantees. This rule also flags returning `any[]` and `Promise` where the function expects more specific types. Examples of **incorrect** code for this rule: ```typescript function foo(): string { return 1 as any; } function bar(): string[] { return [] as any[]; } const fn = (): Set => new Set(); ``` Examples of **correct** code for this rule: ```typescript function foo(): string { return 'hello'; } function bar(): unknown { return 1 as any; // returning any to unknown is allowed } function baz(): any { return 1 as any; // explicit any return type is allowed } ``` ## Original Documentation - [typescript-eslint: no-unsafe-return](https://typescript-eslint.io/rules/no-unsafe-return) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-unsafe-return.ts) --- url: /rules/typescript-eslint/no-unsafe-type-assertion.md --- # no-unsafe-type-assertion [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unsafe-type-assertion': 'error', }, }, ]); ``` ## Rule Details Disallow type assertions that narrow a type. Type assertions (`as` or angle-bracket syntax) that narrow the type of an expression are unsafe because they tell TypeScript to trust the developer rather than the type system. This rule flags assertions from `any` types, assertions to `any` types, assertions to unconstrained type parameters, and assertions that narrow a type to a more specific one. Examples of **incorrect** code for this rule: ```typescript const x = {} as string; const y = value as any; const z = 1 as any as string; function fn(x: string) { return x as T; // T is unconstrained } ``` Examples of **correct** code for this rule: ```typescript const x = 'hello' as string; // same type, no narrowing const y = someValue as unknown; // widening is safe function fn(x: string | number) { if (typeof x === 'string') { const str: string = x; // use type guards instead } } ``` ## Original Documentation - [typescript-eslint: no-unsafe-type-assertion](https://typescript-eslint.io/rules/no-unsafe-type-assertion) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.29.0/packages/eslint-plugin/src/rules/no-unsafe-type-assertion.ts) --- url: /rules/typescript-eslint/no-unsafe-unary-minus.md --- # no-unsafe-unary-minus [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unsafe-unary-minus': 'error', }, }, ]); ``` ## Rule Details Disallow unary negation of a value that is not a `number` or `bigint`. Applying the unary minus operator (`-`) to a value that is not a number or bigint type is a likely mistake. JavaScript will coerce the value to a number, often resulting in `NaN`. This rule ensures the operand of unary negation is always `number` or `bigint`. Examples of **incorrect** code for this rule: ```typescript declare const str: string; -str; declare const bool: boolean; -bool; declare const obj: object; -obj; ``` Examples of **correct** code for this rule: ```typescript -42; -someNumber; declare const big: bigint; -big; declare const val: number | bigint; -val; ``` ## Original Documentation - [typescript-eslint: no-unsafe-unary-minus](https://typescript-eslint.io/rules/no-unsafe-unary-minus) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-unsafe-unary-minus.ts) --- url: /rules/typescript-eslint/no-unused-expressions.md --- # no-unused-expressions [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unused-expressions': 'error', }, }, ]); ``` ## Rule Details Disallow unused expressions. An unused expression is an expression that is evaluated but whose result is not used. This can indicate a mistake or a misunderstanding of the code. Examples of **incorrect** code for this rule: ```typescript 0; a; f(), {}; a && b(); foo.bar; foo as any; foo; foo!; Foo; ``` Examples of **correct** code for this rule: ```typescript a = b; a(); new Foo(); delete foo.bar; void 0; 'use strict'; import('./foo'); foo?.(); ``` ## Options - `allowShortCircuit` (default: `false`): Allow short-circuit evaluations (e.g., `a && a()`). - `allowTernary` (default: `false`): Allow ternary expressions (e.g., `a ? b() : c()`). - `allowTaggedTemplates` (default: `false`): Allow tagged template literals. - `enforceForJSX` (default: `false`): Enforce the rule for JSX elements. - `ignoreDirectives` (default: `false`): Ignore directive prologues. ## Original Documentation - [typescript-eslint: no-unused-expressions](https://typescript-eslint.io/rules/no-unused-expressions) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-unused-expressions.ts) --- url: /rules/typescript-eslint/no-unused-private-class-members.md --- # no-unused-private-class-members [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unused-private-class-members': 'error', }, }, ]); ``` ## Rule Details Disallow unused private class members. This rule extends the base ESLint [`no-unused-private-class-members`](https://eslint.org/docs/latest/rules/no-unused-private-class-members) rule by recognizing members declared with TypeScript's `private` accessibility modifier and parameter properties (`constructor(private x: T)`), in addition to JavaScript's `#`-prefixed private fields. A private class member is considered _used_ when its value is read at least once. Pure writes do not count — a field that is only assigned but never read can be removed with no observable effect. Getter and setter accessors are the exception: any access keeps them alive, since they can have side effects. Examples of **incorrect** code for this rule: ```typescript class A { #foo = 123; } ``` ```typescript class A { private foo = 123; } ``` ```typescript class A { private foo = 123; bar() { this.foo = 1; this.foo += 2; this.foo++; } } ``` ```typescript class A { constructor(private foo: number) {} } ``` Examples of **correct** code for this rule: ```typescript class A { #foo = 123; bar() { return this.#foo; } } ``` ```typescript class A { private foo = 123; constructor() { console.log(this.foo); } } ``` ```typescript class A { private foo: number = 0; bar(other: A) { return other.foo; } } ``` ```typescript class A { private accessor foo = 123; bar() { this.foo = 0; } } ``` ## Options This rule has no options. ## Known Limitations Detection is shape-based, so the rule cannot see uses that reach the member through these indirect patterns: - Access through a variable whose type annotation is more complex than a single `T` or `typeof T` (unions, intersections, generic constraints). - External access via bracket notation with a dynamic key (`instance[someVar]`). - Usages reached through multi-step `this`-aliasing (`let X = this; let Y = X; Y.foo`). ## Original Documentation - [typescript-eslint: no-unused-private-class-members](https://typescript-eslint.io/rules/no-unused-private-class-members) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-unused-private-class-members.ts) --- url: /rules/typescript-eslint/no-unused-vars.md --- # no-unused-vars [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | --------------------------------------------------------------- | | ✅ ts.configs.recommended | `["error",{"varsIgnorePattern":"^_","argsIgnorePattern":"^_"}]` | | ✅ ts.configs.recommendedTypeChecked | `["error",{"varsIgnorePattern":"^_","argsIgnorePattern":"^_"}]` | | ✅ ts.configs.strict | `["error",{"varsIgnorePattern":"^_","argsIgnorePattern":"^_"}]` | | ✅ ts.configs.strictTypeChecked | `["error",{"varsIgnorePattern":"^_","argsIgnorePattern":"^_"}]` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-unused-vars': 'error', }, }, ]); ``` ## Rule Details Disallow unused variables. Variables, functions, and function parameters that are declared but never used anywhere in the code are most likely an error due to incomplete refactoring. This rule extends the base ESLint `no-unused-vars` rule with TypeScript-specific awareness: - Detects variables that are only used in type contexts (e.g., type annotations) and not in runtime code, reporting them as "defined but only used as a type" - Recognizes type-level declarations (interfaces, type aliases, enums) and imports as validly used when referenced in type positions - Handles declaration merging (e.g., interface + const with the same name) - Respects ambient declarations (`declare module`, `.d.ts` files) - Marks JSX factory and fragment factory imports as used when JSX elements are present (for `jsx: "preserve"` / `"react-native"` modes) ## Options ```jsonc { "@typescript-eslint/no-unused-vars": ["error", { "vars": "all", // "all" | "local" "varsIgnorePattern": "", // regex pattern for vars to ignore "args": "after-used", // "after-used" | "all" | "none" "argsIgnorePattern": "", // regex pattern for args to ignore "caughtErrors": "all", // "all" | "none" "caughtErrorsIgnorePattern": "", // regex pattern for caught errors to ignore "destructuredArrayIgnorePattern": "", // regex pattern for destructured array elements "ignoreRestSiblings": false, // ignore siblings of rest properties "ignoreClassWithStaticInitBlock": false, // ignore classes with static init blocks "ignoreUsingDeclarations": false, // ignore `using` / `await using` declarations "reportUsedIgnorePattern": false, // report used vars that match ignore patterns "enableAutofixRemoval": { "imports": false // auto-fix to remove unused imports } }] } ``` Examples of **incorrect** code for this rule: ```typescript const unused = 42; function foo(unusedParam: string) { return 'hello'; } import { SomeValue } from './values'; const x: number = getSomething(); // SomeValue is never used ``` Examples of **correct** code for this rule: ```typescript const used = 42; console.log(used); export function foo() {} function bar(_unused: string, used: number) { return used; } // Type-only usage of imports is valid import { SomeType } from './types'; const x: SomeType = getValue(); // Ignore pattern: variables starting with _ are ignored function baz(_unused: string) {} ``` ## The `/* exported */` comment A script shares its globals with the other scripts loaded alongside it, where this rule cannot see them being read. An `/* exported name */` block comment declares that such a global is consumed elsewhere, and the rule counts the comment itself as a use. TypeScript's scope manager puts type-only declarations in the same global scope as value ones, so the comment reaches an `interface`, `type`, `enum`, or `namespace` as well: ```typescript /* exported PublicValue, PublicType */ var PublicValue = 1; type PublicType = string; ``` The comment resolves each name only against the outer global scope. Whether a file has that scope is determined by its effective `languageOptions.sourceType`, not by the presence of `import` or `export` syntax. With flat config, omitting `sourceType` makes `.js` and `.ts` files modules even when they contain no module syntax, so the comment has no effect. Set `sourceType: "script"` for a shared script. Module bindings, bindings in a JavaScript CommonJS wrapper, block bindings, function parameters, and nested type bindings are still reported. An exact, case-sensitive `.cjs` extension defaults to the CommonJS wrapper. TypeScript-flavoured files configured as `commonjs` retain a global program scope, so their top-level bindings can be marked by the comment. ## Original Documentation - [typescript-eslint: no-unused-vars](https://typescript-eslint.io/rules/no-unused-vars) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.69.0/packages/eslint-plugin/src/rules/no-unused-vars.ts) --- url: /rules/typescript-eslint/no-use-before-define.md --- # no-use-before-define [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-use-before-define': 'error', }, }, ]); ``` ## Rule Details Disallow the use of variables before they are defined. This rule extends the base ESLint `no-use-before-define` rule to add support for TypeScript-specific constructs like `type`, `interface`, and `enum` declarations. Examples of **incorrect** code for this rule: ```typescript alert(a); var a = 10; f(); function f() {} new A(); class A {} const foo = Foo.FOO; enum Foo { FOO } ``` Examples of **correct** code for this rule: ```typescript var a = 10; alert(a); type Foo = string; const x: Foo = "hello"; function f() {} f(); ``` ## Options - `functions` (boolean, default `true`) - Whether to check function declarations - `classes` (boolean, default `true`) - Whether to check class declarations - `variables` (boolean, default `true`) - Whether to check variable declarations - `enums` (boolean, default `true`) - Whether to check enum declarations - `typedefs` (boolean, default `true`) - Whether to check type/interface declarations - `ignoreTypeReferences` (boolean, default `true`) - Whether to ignore references in type annotations - `allowNamedExports` (boolean, default `false`) - Whether to allow references in named exports Also accepts `"nofunc"` as a shorthand for `{ functions: false }`. ## Differences from ESLint rslint also ships the core `no-use-before-define` rule, which gained TypeScript support in ESLint 10 and takes the same options. Enable one or the other — the two disagree in a few places, because this rule extends an older version of the core rule: - Code that reads a class binding while the class itself is still being defined — `class C extends C {}`, `class C { [C](){} }`, `const C = class { static x = C }` — is reported by the core rule and not by this one. - A class field initializer or static block is an ordinary separate scope here, so `classes`, `variables`, and `enums` exempt references from inside one. The core rule treats static initializers as part of the surrounding code, and still reports them. - `ignoreTypeReferences` covers every type position here — including `implements` clauses, qualified type names, and the exported name of `export = X` / `export default X`. The core rule only exempts direct type references and `typeof` queries. - References from a function/constructor type or call/construct/method signature are never reported here, including its parameter and return types. - A reference that resolves to a string-literal enum member (`enum E { b = a, "a" = 1 }`) is not reported here, because such a member declares no identifier. The core rule measures it from the literal and reports it. ## Original Documentation - [typescript-eslint: no-use-before-define](https://typescript-eslint.io/rules/no-use-before-define) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-use-before-define.ts) --- url: /rules/typescript-eslint/no-useless-constructor.md --- # no-useless-constructor [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-useless-constructor': 'error', }, }, ]); ``` ## Rule Details Disallow unnecessary constructors. ES2015 provides a default class constructor if one is not specified. As such, it is unnecessary to provide an empty constructor or one that simply delegates into its parent class, as in the following examples: This rule extends ESLint's `no-useless-constructor` with TypeScript-specific support for: - Access modifiers (`private`, `protected`, `public`) - Parameter properties - Parameter decorators Examples of **incorrect** code for this rule: ```typescript class A { constructor() {} } class B extends A { constructor(foo) { super(foo); } } class C { public constructor() {} } ``` Examples of **correct** code for this rule: ```typescript class A { constructor(private name: string) {} } class B { private constructor() {} } class C extends D { public constructor(foo) { super(foo); } } ``` ## Original Documentation - [typescript-eslint: no-useless-constructor](https://typescript-eslint.io/rules/no-useless-constructor) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-useless-constructor.ts) --- url: /rules/typescript-eslint/no-useless-default-assignment.md --- # no-useless-default-assignment [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-useless-default-assignment': 'error', }, }, ]); ``` ## Rule Details Disallow default values that will never be used. [Default parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) and [destructuring default values](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value) are only used when the parameter or property is `undefined`. If the source type guarantees a non-`undefined` value, the default is unreachable — at best dead code, at worst a misleading signal about the value's nullability. Examples of **incorrect** code for this rule: ```typescript function Bar({ foo = '' }: { foo: string }) { return foo; } const { foo = '' } = { foo: 'bar' }; const [foo = ''] = ['bar']; [1, 2, 3].map((a = 42) => a + 1); function f(a = undefined) {} const { a = undefined } = {}; function g(p: number | undefined = undefined) {} ``` Examples of **correct** code for this rule: ```typescript function Bar({ foo = '' }: { foo?: string }) { return foo; } const { foo = '' } = { foo: undefined }; const [foo = ''] = [undefined]; [1, 2, 3, undefined].map((a = 42) => a + 1); function f(a?: number) {} function g(p?: number | undefined) {} ``` ## Options ### `allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing` Defaults to `false`. While `false`, the rule emits a top-of-file diagnostic on every file whose `tsconfig.json` does **not** enable `strictNullChecks` (or `strict`). Without `strictNullChecks`, TypeScript erases `undefined` and `null` from types — which makes this rule unable to tell whether a value can be `undefined`, so any per-site report would be unreliable. Set this option to `true` to opt out of that file-level diagnostic and let the rule continue to run anyway. Examples of code for this rule with `{ "allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing": true }`: ```json { "@typescript-eslint/no-useless-default-assignment": ["error", { "allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing": true }] } ``` ## When Not To Use It If you use default values defensively against runtime values that bypass type checking, or for documentation purposes, you may want to disable this rule. ## Differences from ESLint rslint reports a strict superset of what upstream `@typescript-eslint/no-useless-default-assignment` reports — every upstream diagnostic is still emitted, plus the following: - `const`/`let`/`var` destructuring whose source is a variable reference and whose property is non-optional. Example: `declare const obj: { foo: string }; const { foo = 'd' } = obj;` — rslint reports `foo = 'd'`; upstream is silent on most property names. - Numeric-key destructuring whose source is a variable reference. Example: `declare const obj: { 1: string }; const { 1: x = 'd' } = obj;` — rslint reports; upstream is silent. If you only want to match upstream's behavior exactly, ignore these additional reports with an inline disable comment. ## Original Documentation - [typescript-eslint: no-useless-default-assignment](https://typescript-eslint.io/rules/no-useless-default-assignment) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.59.4/packages/eslint-plugin/src/rules/no-useless-default-assignment.ts) --- url: /rules/typescript-eslint/no-useless-empty-export.md --- # no-useless-empty-export [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-useless-empty-export': 'error', }, }, ]); ``` ## Rule Details Disallow empty exports (`export {}`) that don't affect the module's exports. An empty `export {}` is used to turn a script file into a module, but if the file already has other imports or exports, this empty export is unnecessary and can be removed. This rule does not flag empty exports in `.d.ts` definition files, where they may be needed for module encapsulation. Examples of **incorrect** code for this rule: ```typescript export const value = 'Hello'; export {}; import { foo } from 'bar'; export {}; ``` Examples of **correct** code for this rule: ```typescript export const value = 'Hello'; export {}; // (when no other imports/exports exist, this is the only module indicator) ``` ## Original Documentation - [typescript-eslint: no-useless-empty-export](https://typescript-eslint.io/rules/no-useless-empty-export) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-useless-empty-export.ts) --- url: /rules/typescript-eslint/no-var-requires.md --- # no-var-requires [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-var-requires': 'error', }, }, ]); ``` ## Rule Details Disallow `require` statements except in import statements. In other words, the use of forms such as `var foo = require("foo")` is banned. Instead, use ES6-style imports or TypeScript's `import foo = require("foo")` syntax. Standalone `require()` calls (as expression statements) and TypeScript `import ... = require(...)` declarations are allowed. Examples of **incorrect** code for this rule: ```typescript var foo = require('foo'); const foo = require('foo'); let foo = require('foo'); ``` Examples of **correct** code for this rule: ```typescript import foo from 'foo'; import foo = require('foo'); require('foo'); import { foo } from 'foo'; ``` ## Original Documentation - [typescript-eslint: no-var-requires](https://typescript-eslint.io/rules/no-var-requires) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-var-requires.ts) --- url: /rules/typescript-eslint/no-wrapper-object-types.md --- # no-wrapper-object-types [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/no-wrapper-object-types': 'error', }, }, ]); ``` ## Rule Details Disallow using the upper-cased built-in primitive class wrappers — `BigInt`, `Boolean`, `Number`, `Object`, `String`, and `Symbol` — as type names. The lower-cased primitive forms (`bigint`, `boolean`, `number`, `object`, `string`, `symbol`) are the safe choice in every case: primitives are compared by value and have predictable truthiness, while the wrapper objects are compared by reference and are always truthy. A local declaration with the same name (a `type` alias, `interface`, or `class`) shadows the global wrapper, in which case the reference is no longer the unsafe built-in and is not reported. Examples of **incorrect** code for this rule: ```typescript let myBigInt: BigInt; let myBoolean: Boolean; let myNumber: Number; let myString: String; let mySymbol: Symbol; let myObject: Object; class MyClass implements Number {} interface MyInterface extends Number {} ``` Examples of **correct** code for this rule: ```typescript let myBigint: bigint; let myBoolean: boolean; let myNumber: number; let myString: string; let mySymbol: symbol; let myObject: object; type Number = 0 | 1; let value: Number; ``` ## Original Documentation - [typescript-eslint: no-wrapper-object-types](https://typescript-eslint.io/rules/no-wrapper-object-types) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/no-wrapper-object-types.ts) --- url: /rules/typescript-eslint/non-nullable-type-assertion-style.md --- # non-nullable-type-assertion-style [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/non-nullable-type-assertion-style': 'error', }, }, ]); ``` ## Rule Details Enforce non-null assertions over explicit type assertions when the asserted type is the same as the original type minus `null` and `undefined`. A non-null assertion (`!`) is a more concise way to remove `null` and `undefined` from a type than using an `as` type assertion. Examples of **incorrect** code for this rule: ```typescript const foo = bar as string; // when bar is string | null const baz = bar as string; // when bar is string | undefined const qux = bar as string; // when bar is string | null | undefined ``` Examples of **correct** code for this rule: ```typescript const foo = bar!; const baz = bar as string | null; const qux = bar as SomeDifferentType; ``` ## Original Documentation - [typescript-eslint: non-nullable-type-assertion-style](https://typescript-eslint.io/rules/non-nullable-type-assertion-style) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/non-nullable-type-assertion-style.ts) --- url: /rules/typescript-eslint/only-throw-error.md --- # only-throw-error [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/only-throw-error': 'error', }, }, ]); ``` ## Rule Details Disallow throwing non-Error values as exceptions. It is considered good practice to only `throw` `Error` objects, because they automatically capture a stack trace which can be used to debug the error. Throwing non-Error values such as strings, numbers, or `undefined` does not provide this benefit and makes debugging harder. Examples of **incorrect** code for this rule: ```typescript throw 'error'; throw 0; throw undefined; throw { message: 'error' }; ``` Examples of **correct** code for this rule: ```typescript throw new Error('error'); throw new RangeError('error'); class CustomError extends Error {} throw new CustomError('error'); ``` ## Original Documentation - [typescript-eslint: only-throw-error](https://typescript-eslint.io/rules/only-throw-error) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/only-throw-error.ts) --- url: /rules/typescript-eslint/parameter-properties.md --- # parameter-properties [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/parameter-properties': 'error', }, }, ]); ``` ## Rule Details Require or disallow parameter properties in class constructors. TypeScript includes a shorthand for declaring and initializing class members from constructor parameters called parameter properties. This rule can be used to enforce consistent usage of this feature. ## Options - `prefer` (`"class-property"` | `"parameter-property"`): Whether to prefer class properties or parameter properties. Default: `"class-property"`. - `allow` (array of modifiers): Which parameter property modifiers to allow. Valid values: `"readonly"`, `"private"`, `"protected"`, `"public"`, `"private readonly"`, `"protected readonly"`, `"public readonly"`. Default: `[]`. ### `prefer: "class-property"` (default) Examples of **incorrect** code: ```typescript class Foo { constructor(readonly name: string) {} } class Bar { constructor(private age: number) {} } ``` Examples of **correct** code: ```typescript class Foo { constructor(name: string) {} } ``` ### `prefer: "parameter-property"` Examples of **incorrect** code: ```typescript class Foo { member: string; constructor(member: string) { this.member = member; } } ``` Examples of **correct** code: ```typescript class Foo { constructor(private member: string) {} } ``` ## Original Documentation - [typescript-eslint: parameter-properties](https://typescript-eslint.io/rules/parameter-properties) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/parameter-properties.ts) --- url: /rules/typescript-eslint/prefer-as-const.md --- # prefer-as-const [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-as-const': 'error', }, }, ]); ``` ## Rule Details Enforce the use of `as const` over literal type assertions. Using `as const` is preferred because it more clearly expresses intent, consistently applies to all literal values, and enables deeper immutability for objects and arrays. This rule flags type assertions (`as` or angle-bracket style) and type annotations on variable or property declarations where the asserted/annotated type is a literal type that matches the literal value. Examples of **incorrect** code for this rule: ```typescript let foo = 'bar' as 'bar'; let baz = 1 as 1; let qux = <'bar'>'bar'; let x: 10 = 10; ``` Examples of **correct** code for this rule: ```typescript let foo = 'bar' as const; let baz = 1 as const; let arr = [1, 2, 3] as const; ``` ## Original Documentation - [typescript-eslint: prefer-as-const](https://typescript-eslint.io/rules/prefer-as-const) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-as-const.ts) --- url: /rules/typescript-eslint/prefer-destructuring.md --- # prefer-destructuring [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-destructuring': 'error', }, }, ]); ``` ## Rule Details Require destructuring from arrays and/or objects. This rule extends the base ESLint `prefer-destructuring` rule with TypeScript-specific type awareness. Examples of **incorrect** code for this rule: ```javascript var foo = object.foo; var bar = array[0]; ``` Examples of **correct** code for this rule: ```javascript var { foo } = object; var [bar] = array; ``` ### Type Annotation Handling By default, the rule does not report on variable declarations with type annotations, because the auto-fix would remove them: ```typescript // This is correct by default (has type annotation) const x: string = obj.x; ``` ### Type-Aware Array Detection The rule uses the TypeScript type checker to determine whether numeric index access (`x[0]`) should be treated as array destructuring or object destructuring: - If the object type is iterable (has `[Symbol.iterator]`) or `any`, it is treated as array access - If the object type is a plain object with numeric keys (e.g., `{ 0: unknown }`), it is treated as object access ```json { "@typescript-eslint/prefer-destructuring": ["error", { "object": true }, { "enforceForRenamedProperties": true }] } ``` ```typescript // Correct: x is not iterable, so numeric index is treated as object access let x: { 0: unknown }; let y = x[0]; ``` ```typescript // Incorrect: x is iterable (array), so numeric index triggers array destructuring let x: number[]; let y = x[0]; // Use array destructuring ``` ### `enforceForDeclarationWithTypeAnnotation` ```json { "@typescript-eslint/prefer-destructuring": ["error", { "object": true }, { "enforceForDeclarationWithTypeAnnotation": true }] } ``` Examples of **incorrect** code with `{ "enforceForDeclarationWithTypeAnnotation": true }`: ```typescript const x: string = obj.x; ``` Examples of **correct** code with `{ "enforceForDeclarationWithTypeAnnotation": true }`: ```typescript const { x }: { x: string } = obj; ``` ## Original Documentation - [typescript-eslint: prefer-destructuring](https://typescript-eslint.io/rules/prefer-destructuring) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-destructuring.ts) --- url: /rules/typescript-eslint/prefer-enum-initializers.md --- # prefer-enum-initializers [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-enum-initializers': 'error', }, }, ]); ``` ## Rule Details Require each enum member to have an explicitly initialized value. TypeScript enum members default to a sequential numeric value when no initializer is provided. Relying on that implicit numbering makes the enum fragile — inserting, deleting, or reordering members silently shifts the numeric value of every later member, which can break code that persisted those numbers (in storage, in a network protocol, in serialized output). Explicit initializers make the value of each member a documented, stable choice. For each uninitialized member, this rule reports a diagnostic and offers three suggestions: initialize to the member's current index, to the index plus one, or to a string matching the member's name. Examples of **incorrect** code for this rule: ```typescript enum Direction { Up, Down, } enum Status { Open = 1, Close, } ``` Examples of **correct** code for this rule: ```typescript enum Direction { Up = 1, Down = 2, } enum Status { Open = 'Open', Close = 'Close', } enum Empty {} ``` ## Original Documentation - [typescript-eslint: prefer-enum-initializers](https://typescript-eslint.io/rules/prefer-enum-initializers) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-enum-initializers.ts) --- url: /rules/typescript-eslint/prefer-find.md --- # prefer-find [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-find': 'error', }, }, ]); ``` Enforce the use of `Array.prototype.find()` over `Array.prototype.filter()` followed by `[0]` when looking for a single result. ## Rule Details When searching for the first item in an array matching a condition, it may be tempting to use code like `arr.filter(x => x > 0)[0]`. However, it is simpler to use [`Array.prototype.find()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) instead, `arr.find(x => x > 0)`, which also returns the first entry matching a condition. Because `.find()` only executes the callback until it finds a match, it is also more efficient. The rule triggers on these patterns when the receiver's type is an array or tuple: - `arr.filter(p)[0]` - `arr.filter(p).at(0)` - `arr.filter(p)['0']` and ``arr.filter(p)[`0`]`` - `arr['filter'](p)[0]` and ``arr[`filter`](p)[0]`` - Sequence and ternary wrappers: `(a, b, arr.filter(p))[0]`, `(cond ? arr1.filter(p) : arr2.filter(p))[0]` - Optional-chain receivers: `arr?.filter(p)[0]` It does not trigger when: - The receiver type is not an array or tuple (e.g. a custom `Filter` interface, `null`, `undefined`). - The subscript or `.at(...)` argument does not statically resolve to zero. - The `[0]` access is itself optional (`?.[0]`), the `.at(0)` callee is optional (`?.at(0)`), or the `.filter(...)` call is optional (`.filter?.(...)`) — rewriting these would change short-circuiting semantics. The rewrite is offered as a **suggestion** that you must explicitly apply — it is not auto-applied. `.find()` stops at the first match, but `.filter()` always visits every element, so if your `.filter()` callback has side effects, applying the suggestion will change behavior. Examples of **incorrect** code for this rule: ```typescript declare const arr: string[]; arr.filter(item => item === 'aha')[0]; ``` ```typescript declare const arr: string[]; arr.filter(item => item === 'aha').at(0); ``` ```typescript declare const arr: string[]; arr.filter(item => item === 'aha')['0']; ``` ```typescript declare const arr: string[]; const zero = 0; arr.filter(item => item === 'aha').at(zero); ``` ```typescript declare const arr: { a: 1 }[] & { b: 2 }[]; arr.filter(f)[0]; ``` Examples of **correct** code for this rule: ```typescript [1, 2, 3].find(x => x > 1); ``` ```typescript declare const arr: string[]; arr.filter(item => item === 'aha')[1]; ``` ```typescript declare const arr: string[]; arr.filter(item => item === 'aha').at(1); ``` ```typescript [].filter(() => true)?.[0]; ``` ```typescript [].filter(() => true)?.at?.(0); ``` ```typescript [].filter?.(() => true)[0]; ``` ```typescript interface Filter { filter(predicate: (item: T) => boolean): Filter; } declare const f: Filter; f.filter(x => x.length > 0)[0]; ``` ## When Not To Use It If you intentionally use patterns like `.filter(callback)[0]` to execute side effects in `callback` on all array elements, you will want to avoid this rule. ## Original Documentation - [typescript-eslint: prefer-find](https://typescript-eslint.io/rules/prefer-find) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-find.ts) --- url: /rules/typescript-eslint/prefer-for-of.md --- # prefer-for-of [Added in v0.5.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.1) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-for-of': 'error', }, }, ]); ``` ## Rule Details Enforce the use of `for-of` loop over the standard `for` loop where possible. Many developers default to writing `for (let i = 0; i < ...; i++)` loops to iterate over arrays. However, in many cases the loop iterator variable is only used to access the respective element of the array. In such cases, a `for-of` loop is simpler and more readable. This rule will report when a `for` loop can be replaced with a `for-of` loop. Examples of **incorrect** code for this rule: ```javascript declare const array: string[]; for (let i = 0; i < array.length; i++) { console.log(array[i]); } ``` Examples of **correct** code for this rule: ```javascript // for-of loop for (const x of array) { console.log(x); } // Index variable is used for more than just array access for (let i = 0; i < array.length; i++) { console.log(i, array[i]); } // Array element is being assigned for (let i = 0; i < array.length; i++) { array[i] = 0; } ``` ## Original Documentation - [typescript-eslint: prefer-for-of](https://typescript-eslint.io/rules/prefer-for-of) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-for-of.ts) --- url: /rules/typescript-eslint/prefer-function-type.md --- # prefer-function-type [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylistic | `"error"` | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-function-type': 'error', }, }, ]); ``` ## Rule Details Enforce using function types instead of interfaces with call signatures. TypeScript allows declaring a function type in two ways: as a function type (`() => string`) or as an object type with a single call signature (`{ (): string }`). The former is more concise, so this rule reports the latter on interfaces and type literals whose only member is a single call signature (or construct signature) and offers an autofix to rewrite them. Examples of **incorrect** code for this rule: ```typescript interface Example { (): string; } function foo(example: { (): number }): number { return example(); } interface ReturnsSelf { // returns `this` directly, not a `this` type parameter (arg: string): this; } ``` Examples of **correct** code for this rule: ```typescript type Example = () => string; function foo(example: () => number): number { return example(); } // `this` parameter via a generic to avoid the // `unexpectedThisOnFunctionOnlyInterface` warning: type ReturnsSelf = (this: Self, arg: string) => Self; // Has additional properties besides the call signature: function foo(bar: { (): string; baz: number }): string { return bar(); } // Multiple call signatures (overloads): interface Overloaded { (data: string): number; (id: number): string; } // `extends` something other than `Function`: interface Foo { bar: string; } interface Bar extends Foo { (): void; } ``` ## Options This rule has no options. ## When Not To Use It Disable this rule if you prefer interfaces or object type literals for stylistic consistency, or if you rely on declaration merging (e.g. augmenting the global `Function` interface) — those cases occasionally produce false positives that can be silenced with an inline disable comment. ## Original Documentation - [typescript-eslint: prefer-function-type](https://typescript-eslint.io/rules/prefer-function-type) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-function-type.ts) --- url: /rules/typescript-eslint/prefer-includes.md --- # prefer-includes [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-includes': 'error', }, }, ]); ``` ## Rule Details Disallow `indexOf(...) !== -1` / `indexOf(...) === -1` style checks when `includes(...)` expresses intent more clearly. Examples of **incorrect** code for this rule: ```ts if (arr.indexOf(value) !== -1) { doSomething(); } ``` Examples of **correct** code for this rule: ```ts if (arr.includes(value)) { doSomething(); } ``` ## Original Documentation - [typescript-eslint: prefer-includes](https://typescript-eslint.io/rules/prefer-includes) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-includes.ts) --- url: /rules/typescript-eslint/prefer-literal-enum-member.md --- # prefer-literal-enum-member [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-literal-enum-member': 'error', }, }, ]); ``` ## Rule Details Require that all enum members are literal values to prevent unintended enum member values. TypeScript allows the value of an enum member to be many different kinds of valid JavaScript expressions. However, because enums create their own scope whereby each enum member becomes a variable in that scope, developers are often surprised at the result of using non-literal values. Explicit enum values should only be literals (string or number). Examples of **incorrect** code for this rule: ```typescript const impliedValueIsString = 'a'; enum Foo { ReadWrite = 2 | 4, Read = getMask(), Write = impliedValueIsString, Shift = 1 << 1, } ``` Examples of **correct** code for this rule: ```typescript enum Foo { Read, Write, Shift = 1, Name = 'hello', Combined = 1 | 2, // only with allowBitwiseExpressions } ``` ## Options ### `allowBitwiseExpressions` When set to `true`, allows using bitwise expressions in enum initializers, which is common in flag-style enums. ```json { "@typescript-eslint/prefer-literal-enum-member": [ "warn", { "allowBitwiseExpressions": true } ] } ``` ## Original Documentation - [typescript-eslint: prefer-literal-enum-member](https://typescript-eslint.io/rules/prefer-literal-enum-member) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-literal-enum-member.ts) --- url: /rules/typescript-eslint/prefer-namespace-keyword.md --- # prefer-namespace-keyword [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-namespace-keyword': 'error', }, }, ]); ``` ## Rule Details Require using `namespace` keyword over `module` keyword to declare custom TypeScript modules. TypeScript historically allowed `module` keyword as a way to group related code. The newer `namespace` keyword was added in TypeScript 1.5 to distinguish between built-in modules and user-defined modules. While the two keywords are functionally identical, using `namespace` is recommended as `module` may cause confusion with ECMAScript modules. Examples of **incorrect** code for this rule: ```typescript module Foo {} declare module Foo {} ``` Examples of **correct** code for this rule: ```typescript namespace Foo {} declare namespace Foo {} declare module 'foo' {} ``` ## Original Documentation - [typescript-eslint: prefer-namespace-keyword](https://typescript-eslint.io/rules/prefer-namespace-keyword) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-namespace-keyword.ts) --- url: /rules/typescript-eslint/prefer-nullish-coalescing.md --- # prefer-nullish-coalescing [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-nullish-coalescing': 'error', }, }, ]); ``` Enforce using the nullish coalescing operator instead of logical assignments or chaining. ## Rule Details The `??` nullish coalescing runtime operator allows providing a default value when dealing with `null` or `undefined`. Because the nullish coalescing operator only coalesces when the original value is `null` or `undefined`, it is much safer than relying upon logical OR operator chaining `||`, which coalesces on any falsy value. This rule reports when `||`, `||=`, conditional expressions, and `if`-statement assignments could be replaced with the nullish-coalescing operator. This rule requires `strictNullChecks` to be enabled in `tsconfig.json` to function correctly. Examples of **incorrect** code for this rule: ```typescript declare const a: string | null; declare const b: string | null; a || b; a || 'fallback'; a ||= b; a !== undefined && a !== null ? a : 'a string'; a === undefined || a === null ? 'a string' : a; declare let foo: { a: string } | null; declare function makeFoo(): { a: string }; if (!foo) { foo = makeFoo(); } ``` Examples of **correct** code for this rule: ```typescript declare const a: string | null; declare const b: string | null; a ?? b; a ?? 'fallback'; a ??= b; declare let foo: { a: string } | null; declare function makeFoo(): { a: string }; foo ??= makeFoo(); ``` ## Options ### `ignoreConditionalTests` Default: `true`. When `true`, ignore cases that appear inside the test of `if`/`while`/`do…while`/`for` loops or in the test of a conditional expression. ```json { "@typescript-eslint/prefer-nullish-coalescing": ["error", { "ignoreConditionalTests": false }] } ``` ### `ignoreTernaryTests` Default: `false`. When `true`, ignore ternary expressions that could be replaced with `??`. ### `ignoreIfStatements` Default: `false`. When `true`, ignore `if` statements that could be replaced with `??=`. ### `ignoreMixedLogicalExpressions` Default: `false`. When `true`, ignore `||` expressions that are part of a mixed logical expression (with `&&`). ### `ignoreBooleanCoercion` Default: `false`. When `true`, ignore `||` arguments to the global `Boolean` constructor. ### `ignorePrimitives` Default: `{ bigint: false, boolean: false, number: false, string: false }`. Set to `true` to ignore all listed primitives, or to a partial object to ignore individual primitive types. ```json { "@typescript-eslint/prefer-nullish-coalescing": ["error", { "ignorePrimitives": { "string": true } }] } ``` ### `allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing` Default: `false`. By default the rule errors on every file when `strictNullChecks` is off. Setting this to `true` silences that error and lets the rule run anyway. ## Original Documentation - [typescript-eslint: prefer-nullish-coalescing](https://typescript-eslint.io/rules/prefer-nullish-coalescing) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts) --- url: /rules/typescript-eslint/prefer-optional-chain.md --- # prefer-optional-chain [Added in v0.5.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.0) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-optional-chain': 'error', }, }, ]); ``` ## Rule Details Enforce using concise optional chain expressions instead of chained logical ANDs, negated logical ORs, or empty object coalescing patterns. TypeScript 3.7 introduced optional chaining (`?.`) which provides a more concise and readable way to access deeply nested properties that may be null or undefined. Examples of **incorrect** code for this rule: ```typescript foo && foo.bar; foo && foo.bar && foo.bar.baz; foo && foo.bar(); foo != null && foo.bar; foo !== undefined && foo.bar; typeof foo !== 'undefined' && foo.bar; !foo || !foo.bar; foo === null || foo.bar !== 'baz'; (foo || {}).bar; (foo ?? {}).bar; ``` Examples of **correct** code for this rule: ```typescript foo?.bar; foo?.bar?.baz; foo?.bar(); foo?.bar; foo?.bar; foo?.bar; !foo?.bar; foo?.bar !== 'baz'; foo?.bar; foo?.bar; ``` ## Options ### `allowPotentiallyUnsafeFixesThatModifyTheReturnTypeIKnowWhatImDoing` Type: `boolean`, default: `false` When set to `true`, the rule will provide auto-fixes even when the fix may change the return type of the expression. By default, such cases are reported as suggestions only. ### `checkAny` Type: `boolean`, default: `true` When set to `true`, the rule will check operands typed as `any` when inspecting boolean expressions. ### `checkUnknown` Type: `boolean`, default: `true` When set to `true`, the rule will check operands typed as `unknown` when inspecting boolean expressions. ### `checkString` Type: `boolean`, default: `true` When set to `true`, the rule will check operands typed as `string` when inspecting boolean expressions. ### `checkNumber` Type: `boolean`, default: `true` When set to `true`, the rule will check operands typed as `number` when inspecting boolean expressions. ### `checkBoolean` Type: `boolean`, default: `true` When set to `true`, the rule will check operands typed as `boolean` when inspecting boolean expressions. ### `checkBigInt` Type: `boolean`, default: `true` When set to `true`, the rule will check operands typed as `bigint` when inspecting boolean expressions. ### `requireNullish` Type: `boolean`, default: `false` When set to `true`, the rule will only report on expressions where at least one operand has a type that includes `null` or `undefined`. This prevents false positives when the expression uses truthy checks for non-nullable types like `string` or `number`. ## Original Documentation - [typescript-eslint: prefer-optional-chain](https://typescript-eslint.io/rules/prefer-optional-chain) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.68.0/packages/eslint-plugin/src/rules/prefer-optional-chain.ts) --- url: /rules/typescript-eslint/prefer-promise-reject-errors.md --- # prefer-promise-reject-errors [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-promise-reject-errors': 'error', }, }, ]); ``` ## Rule Details Require using Error objects as Promise rejection reasons. When rejecting a Promise, it is best practice to reject with an `Error` object, because `Error` objects store a stack trace, making it much easier to debug by determining where the error came from. This rule reports calls to `Promise.reject()` and the `reject` parameter in `new Promise((resolve, reject) => ...)` when they are called with a non-Error value. Examples of **incorrect** code for this rule: ```typescript Promise.reject('error'); Promise.reject(0); new Promise((resolve, reject) => reject('error')); ``` Examples of **correct** code for this rule: ```typescript Promise.reject(new Error('error')); new Promise((resolve, reject) => reject(new Error('error'))); Promise.reject(unknownVariable); ``` ## Original Documentation - [typescript-eslint: prefer-promise-reject-errors](https://typescript-eslint.io/rules/prefer-promise-reject-errors) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.28.0/packages/eslint-plugin/src/rules/prefer-promise-reject-errors.ts) --- url: /rules/typescript-eslint/prefer-readonly.md --- # prefer-readonly [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-readonly': 'error', }, }, ]); ``` ## Rule Details Require private members to be marked as `readonly` if they're never modified outside of the constructor. Member variables with the `private` modifier or `#` private fields are only accessible within their declaring class. If that member is never reassigned after initialization (either at declaration or in the constructor), it should be marked as `readonly` to communicate intent and prevent accidental mutation. Examples of **incorrect** code for this rule: ```typescript class Foo { private neverModified = 'unchanged'; } class Bar { #neverModified = 'unchanged'; } class Baz { private neverModified = 'unchanged'; public constructor() { this.neverModified = 'reassigned in constructor only'; } } ``` Examples of **correct** code for this rule: ```typescript class Foo { private readonly neverModified = 'unchanged'; } class Bar { readonly #neverModified = 'unchanged'; } class Baz { private modifiedLater = 'unchanged'; public mutate() { this.modifiedLater = 'changed outside constructor'; } } ``` ## Options ### `onlyInlineLambdas` When set to `true`, only checks members that are assigned an arrow function expression. This can be useful when a project wants to enforce `readonly` only for function-like members. ```json { "@typescript-eslint/prefer-readonly": ["warn", { "onlyInlineLambdas": true }] } ``` ## Original Documentation - [typescript-eslint: prefer-readonly](https://typescript-eslint.io/rules/prefer-readonly) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.54.0/packages/eslint-plugin/src/rules/prefer-readonly.ts) --- url: /rules/typescript-eslint/prefer-readonly-parameter-types.md --- # prefer-readonly-parameter-types [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-readonly-parameter-types': 'error', }, }, ]); ``` Requires function parameters to have deeply readonly types, preventing code from accidentally mutating values supplied by callers. ## Rule Details Examples of **incorrect** code for this rule: ```typescript function consume(items: string[]) {} function update(options: { enabled: boolean }) {} function register(value: Set) {} ``` Examples of **correct** code for this rule: ```typescript function consume(items: readonly string[]) {} function update(options: Readonly<{ enabled: boolean }>) {} function register(value: ReadonlySet) {} function format(value: string) {} ``` The rule checks nested property and element types, so a readonly outer property whose value is mutable is still reported. ## Options - `allow` (default `[]`): type specifiers that the rule should accept without checking their readonlyness. String names and `file`, `lib`, or `package` specifiers are supported. - `checkParameterProperties` (default `true`): check TypeScript constructor parameter properties. - `ignoreInferredTypes` (default `false`): skip parameters without an explicit type annotation. - `treatMethodsAsReadonly` (default `false`): treat method declarations as readonly while checking object types. This is useful for types such as `ReadonlySet` and `ReadonlyMap`. ## Original Documentation - [typescript-eslint: prefer-readonly-parameter-types](https://typescript-eslint.io/rules/prefer-readonly-parameter-types) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.68.0/packages/eslint-plugin/src/rules/prefer-readonly-parameter-types.ts) --- url: /rules/typescript-eslint/prefer-reduce-type-parameter.md --- # prefer-reduce-type-parameter [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-reduce-type-parameter': 'error', }, }, ]); ``` ## Rule Details Enforce using type parameters for `Array#reduce` instead of type assertions on the initial value. When calling `Array#reduce`, it is common to use a type assertion (`as`) on the initial value to specify the result type. However, `Array#reduce` accepts a type parameter that achieves the same result in a cleaner way without requiring a type assertion. Examples of **incorrect** code for this rule: ```typescript [1, 2, 3].reduce( (acc, val) => ({ ...acc, [val]: true }), {} as Record, ); ['a', 'b'].reduce((acc, val) => [...acc, val], [] as string[]); ``` Examples of **correct** code for this rule: ```typescript [1, 2, 3].reduce>( (acc, val) => ({ ...acc, [val]: true }), {}, ); ['a', 'b'].reduce((acc, val) => [...acc, val], []); ``` ## Original Documentation - [typescript-eslint: prefer-reduce-type-parameter](https://typescript-eslint.io/rules/prefer-reduce-type-parameter) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-reduce-type-parameter.ts) --- url: /rules/typescript-eslint/prefer-regexp-exec.md --- # prefer-regexp-exec [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-regexp-exec': 'error', }, }, ]); ``` ## Rule Details Prefer `RegExp#exec` over `String#match` when a non-global regex match is used. Examples of **incorrect** code for this rule: ```ts const value = 'foo'; value.match(/foo/); value.match('foo'); ``` Examples of **correct** code: ```ts const value = 'foo'; /foo/.exec(value); value.match(/foo/g); ``` ## Original Documentation - [typescript-eslint: prefer-regexp-exec](https://typescript-eslint.io/rules/prefer-regexp-exec) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/prefer-regexp-exec.ts) --- url: /rules/typescript-eslint/prefer-return-this-type.md --- # prefer-return-this-type [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-return-this-type': 'error', }, }, ]); ``` ## Rule Details Enforce that `this` is used when only `this` type is returned. If a class method's return type is the class itself and the method only returns `this`, then it is better to use `this` as the return type. Using the `this` return type enables proper type narrowing in subclasses, since `this` refers to the current class type rather than a fixed class name. Examples of **incorrect** code for this rule: ```typescript class Foo { doStuff(): Foo { return this; } chain(): Foo { return this; } } ``` Examples of **correct** code for this rule: ```typescript class Foo { doStuff(): this { return this; } chain(): this { return this; } } ``` ## Original Documentation - [typescript-eslint: prefer-return-this-type](https://typescript-eslint.io/rules/prefer-return-this-type) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.29.0/packages/eslint-plugin/src/rules/prefer-return-this-type.ts) --- url: /rules/typescript-eslint/prefer-string-starts-ends-with.md --- # prefer-string-starts-ends-with [Added in v0.2.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.2.1) ## Configuration | Preset | Configured Value | | --------------------------------- | ---------------- | | ✅ ts.configs.stylisticTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-string-starts-ends-with': 'error', }, }, ]); ``` ## Rule Details Enforce using `String#startsWith` and `String#endsWith` over other equivalent methods of checking substrings. There are multiple ways to verify if a string starts or ends with a specific string, such as `foo.indexOf('bar') === 0`, `foo.charAt(0) === 'b'`, or regex tests like `/^bar/.test(foo)`. Since ES2015 has added `String#startsWith` and `String#endsWith`, this rule reports on other ways of checking, suggesting the use of the built-in methods instead. Examples of **incorrect** code for this rule: ```typescript declare const foo: string; foo[0] === 'b'; foo.charAt(0) === 'b'; foo.indexOf('bar') === 0; foo.slice(0, 3) === 'bar'; foo.substring(0, 3) === 'bar'; foo.match(/^bar/) != null; /^bar/.test(foo); foo[foo.length - 1] === 'b'; foo.charAt(foo.length - 1) === 'b'; foo.lastIndexOf('bar') === foo.length - 3; foo.slice(-3) === 'bar'; foo.substring(foo.length - 3) === 'bar'; foo.match(/bar$/) != null; /bar$/.test(foo); ``` Examples of **correct** code for this rule: ```typescript declare const foo: string; foo.startsWith('bar'); foo.endsWith('bar'); foo.startsWith('a'); foo.endsWith('a'); ``` ## Options ### `allowSingleElementEquality` When set to `"always"`, allows equality checks for a single character (e.g. `foo[0] === 'a'` and `foo.charAt(0) === 'a'`). ```json { "@typescript-eslint/prefer-string-starts-ends-with": [ "warn", { "allowSingleElementEquality": "always" } ] } ``` ## Original Documentation - [typescript-eslint: prefer-string-starts-ends-with](https://typescript-eslint.io/rules/prefer-string-starts-ends-with) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.55.0/packages/eslint-plugin/src/rules/prefer-string-starts-ends-with.ts) --- url: /rules/typescript-eslint/prefer-ts-expect-error.md --- # prefer-ts-expect-error [Added in v0.3.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/prefer-ts-expect-error': 'error', }, }, ]); ``` ## Rule Details Prefer `@ts-expect-error` over `@ts-ignore` in TypeScript directive comments. Examples of **incorrect** code for this rule: ```typescript // @ts-ignore ``` Examples of **correct** code for this rule: ```typescript // @ts-expect-error ``` ## Original Documentation - [typescript-eslint: prefer-ts-expect-error](https://typescript-eslint.io/rules/prefer-ts-expect-error) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.57.0/packages/eslint-plugin/src/rules/prefer-ts-expect-error.ts) --- url: /rules/typescript-eslint/promise-function-async.md --- # promise-function-async [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/promise-function-async': 'error', }, }, ]); ``` ## Rule Details Require any function or method that returns a Promise to be marked async. Ensures that each function is only capable of either returning a rejected promise or throwing an `Error` object. In contrast, non-async Promise-returning functions are technically capable of either. Code that handles both rejected promises and thrown errors simultaneously is often overly complex and hard to maintain. Examples of **incorrect** code for this rule: ```typescript function foo(): Promise { return Promise.resolve('value'); } const bar = (): Promise => Promise.resolve(42); class Baz { method(): Promise { return Promise.resolve(); } } ``` Examples of **correct** code for this rule: ```typescript async function foo(): Promise { return 'value'; } const bar = async (): Promise => 42; class Baz { async method(): Promise {} } ``` ## Original Documentation - [typescript-eslint: promise-function-async](https://typescript-eslint.io/rules/promise-function-async) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.29.1/packages/eslint-plugin/src/rules/promise-function-async.ts) --- url: /rules/typescript-eslint/related-getter-setter-pairs.md --- # related-getter-setter-pairs [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/related-getter-setter-pairs': 'error', }, }, ]); ``` ## Rule Details Enforce that `get()` types are assignable to their equivalent `set()` types. A getter and setter for the same property should have compatible types. The getter's return type should be assignable to the setter's parameter type; otherwise it creates a confusing API where writing a value and then reading it back produces a different type. Examples of **incorrect** code for this rule: ```typescript interface Foo { get value(): string; set value(newValue: number); } class Bar { get prop(): string { return this._prop; } set prop(newValue: number) { this._prop = String(newValue); } } ``` Examples of **correct** code for this rule: ```typescript interface Foo { get value(): string; set value(newValue: string); } class Bar { get prop(): string { return this._prop; } set prop(newValue: string) { this._prop = newValue; } } ``` ## Original Documentation - [typescript-eslint: related-getter-setter-pairs](https://typescript-eslint.io/rules/related-getter-setter-pairs) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/related-getter-setter-pairs.ts) --- url: /rules/typescript-eslint/require-array-sort-compare.md --- # require-array-sort-compare [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/require-array-sort-compare': 'error', }, }, ]); ``` ## Rule Details Require `Array#sort` and `Array#toSorted` calls to always provide a `compareFunction`. When called without a compare function, `Array#sort()` and `Array#toSorted()` convert all non-undefined elements to strings and then compare them using their UTF-16 code unit values. This can lead to surprising sort orders, especially for arrays of numbers (e.g., `[1, 10, 2]` instead of `[1, 2, 10]`). By default, string arrays are ignored since the default sort behavior is appropriate for them. Examples of **incorrect** code for this rule: ```typescript const numbers = [3, 1, 2]; numbers.sort(); const mixed = [1, 'a', 2]; mixed.sort(); ``` Examples of **correct** code for this rule: ```typescript const numbers = [3, 1, 2]; numbers.sort((a, b) => a - b); const strings = ['c', 'a', 'b']; strings.sort(); // OK, string arrays are ignored by default ``` ## Original Documentation - [typescript-eslint: require-array-sort-compare](https://typescript-eslint.io/rules/require-array-sort-compare) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/require-array-sort-compare.ts) --- url: /rules/typescript-eslint/require-await.md --- # require-await [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/require-await': 'error', }, }, ]); ``` ## Rule Details Disallow async functions which have no `await` expression. Asynchronous functions that do not use `await` might not need to be asynchronous, and may be the unintentional result of refactoring. They also cause a performance penalty by wrapping the function return value in an extra `Promise`. This rule extends the base ESLint `require-await` rule with TypeScript-specific support: it considers returning a thenable value from an async function as equivalent to using `await`, and also handles `for-await-of` loops, `yield*` on async iterables, and `using`/`await using` declarations. Examples of **incorrect** code for this rule: ```typescript async function foo() { return 'value'; } async function bar() { doSomethingSync(); } ``` Examples of **correct** code for this rule: ```typescript async function foo() { await doSomethingAsync(); } async function bar() { return await fetchData(); } function baz() { return 'value'; } ``` ## Original Documentation - [typescript-eslint: require-await](https://typescript-eslint.io/rules/require-await) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.68.0/packages/eslint-plugin/src/rules/require-await.ts) --- url: /rules/typescript-eslint/restrict-plus-operands.md --- # restrict-plus-operands [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `["error",{"allowAny":false,"allowBoolean":false,"allowNullish":false,"allowNumberAndString":false,"allowRegExp":false}]` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/restrict-plus-operands': 'error', }, }, ]); ``` ## Rule Details Require both operands of addition to be the same type and be `bigint`, `number`, or `string`. The `+` operator in TypeScript can be used for both addition and string concatenation. This rule ensures that operands of `+` are both numbers, both bigints, or both strings, preventing accidental implicit type coercions that can lead to unexpected results (e.g., `"1" + 2` becoming `"12"` instead of `3`). Examples of **incorrect** code for this rule: ```typescript const result = 1 + '2'; const bad = 1n + 2; const invalid = {} + []; ``` Examples of **correct** code for this rule: ```typescript const sum = 1 + 2; const concat = 'a' + 'b'; const bigSum = 1n + 2n; const explicit = String(1) + '2'; ``` ## Original Documentation - [typescript-eslint: restrict-plus-operands](https://typescript-eslint.io/rules/restrict-plus-operands) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/restrict-plus-operands.ts) --- url: /rules/typescript-eslint/restrict-template-expressions.md --- # restrict-template-expressions [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `["error",{"allowAny":false,"allowBoolean":false,"allowNever":false,"allowNullish":false,"allowNumber":false,"allowRegExp":false}]` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/restrict-template-expressions': 'error', }, }, ]); ``` ## Rule Details Enforce template literal expressions to be of `string` type. When a value is interpolated into a template literal (`${expr}`), it is implicitly converted to a string, which produces results such as `"[object Object]"` for plain objects. This rule restricts which types may be interpolated. By default, primitives that stringify predictably are permitted (`number`, `bigint`, `boolean`, `null`, `undefined`, `any`, `RegExp`), along with `Error`, `URL`, and `URLSearchParams` and their subclasses. Examples of **incorrect** code for this rule: ```typescript declare const obj: object; const msg = `result: ${obj}`; declare const arr: string[]; const msg2 = `items: ${arr}`; declare const sym: symbol; const msg3 = `symbol: ${sym}`; ``` Examples of **correct** code for this rule: ```typescript const name = 'world'; const greeting = `Hello, ${name}`; declare const obj: object; const msg = `result: ${JSON.stringify(obj)}`; declare const arr: string[]; const msg2 = `items: ${arr.join(', ')}`; ``` ## Options | Option | Type | Default | Description | | -------------- | ------------------------------------ | -------------------------------------------------------------- | ------------------------------------------------------------------------------ | | `allow` | `(string \| TypeOrValueSpecifier)[]` | `[{ from: 'lib', name: ['Error', 'URL', 'URLSearchParams'] }]` | Additional types to permit, matched against the type or any of its base types. | | `allowAny` | `boolean` | `true` | Permit `any` typed values. | | `allowArray` | `boolean` | `false` | Permit arrays and tuples whose element type is itself permitted. | | `allowBoolean` | `boolean` | `true` | Permit `boolean` typed values. | | `allowNever` | `boolean` | `false` | Permit `never` typed values. | | `allowNullish` | `boolean` | `true` | Permit `null` and `undefined`. | | `allowNumber` | `boolean` | `true` | Permit `number` and `bigint` typed values. | | `allowRegExp` | `boolean` | `true` | Permit `RegExp` typed values. | To require every interpolated value to be a `string`, empty the `allow` list and turn each `allow*` option off: ```json { "@typescript-eslint/restrict-template-expressions": [ "error", { "allow": [], "allowAny": false, "allowBoolean": false, "allowNever": false, "allowNullish": false, "allowNumber": false, "allowRegExp": false } ] } ``` ## Original Documentation - [typescript-eslint: restrict-template-expressions](https://typescript-eslint.io/rules/restrict-template-expressions) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/restrict-template-expressions.ts) --- url: /rules/typescript-eslint/return-await.md --- # return-await [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ------------------------------ | --------------------------------------------- | | ✅ ts.configs.strictTypeChecked | `["error","error-handling-correctness-only"]` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/return-await': 'error', }, }, ]); ``` ## Rule Details Enforce consistent returning of awaited values. This rule controls whether `return await` should be used in async functions. Depending on the configuration, it enforces one of several strategies: - `in-try-catch` (default): Requires `await` in try/catch/finally blocks (for proper error handling) and disallows it elsewhere (for performance). - `always`: Always requires `return await`. - `never`: Always disallows `return await`. - `error-handling-correctness-only`: Only requires `await` where it affects error handling correctness, with no preference otherwise. Using `return await` inside try/catch ensures the promise rejection is caught in the local catch block. Outside try/catch, the `await` adds unnecessary overhead. Examples of **incorrect** code for this rule (with default `in-try-catch`): ```typescript async function foo() { return await bar(); // unnecessary await outside try/catch } async function baz() { try { return promise; // missing await inside try } catch (e) { handleError(e); } } ``` Examples of **correct** code for this rule (with default `in-try-catch`): ```typescript async function foo() { return bar(); } async function baz() { try { return await promise; } catch (e) { handleError(e); } } ``` ## Original Documentation - [typescript-eslint: return-await](https://typescript-eslint.io/rules/return-await) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/return-await.ts) --- url: /rules/typescript-eslint/strict-boolean-expressions.md --- # strict-boolean-expressions [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/strict-boolean-expressions': 'error', }, }, ]); ``` ## Rule Details Disallow certain types in boolean expressions. Forbids usage of non-boolean types in the following boolean positions: - the argument of the logical-negation operator (`!arg`) - the test expression of a conditional (`cond ? x : y`) - the condition of an `if`, `for`, `while`, or `do-while` statement - the operands of the logical AND/OR operators (`&&`, `||`) - the argument of a truthiness-assertion function (`function f(x): asserts x; f(arg)`) - the return value of an array predicate callback (`arr.filter(cb)`, `arr.some(cb)`, …) The `boolean` and `never` types are always allowed. Every other type reports unless the matching `allow*` option enables it. When a non-boolean value is reported, the rule emits one or more suggestion fixes appropriate to the value's type. For example a `string` value gets `value.length > 0`, `value !== ""`, and `Boolean(value)` suggestions; a nullable number gets `value != null`, `value ?? 0`, and `Boolean(value)`; an array-predicate callback whose return type is non-boolean gets an `: boolean` return-type-annotation suggestion in addition to the standard conversion fixes. Examples of **incorrect** code for this rule: ```typescript declare const num: number | undefined; if (num) { console.log('defined'); } declare const str: string | null; if (!str) { console.log('empty'); } function foo(bool?: boolean) { if (bool) { bar(); } } const foo = (arg: T) => (arg ? 1 : 0); ``` Examples of **correct** code for this rule: ```typescript declare const num: number | undefined; if (num != null) { console.log('defined'); } declare const str: string | null; if (str != null && str !== '') { console.log('non-empty'); } function foo(bool?: boolean) { if (bool ?? false) { bar(); } } const foo = (arg: any) => (Boolean(arg) ? 1 : 0); ``` ## Options ### `allowString` Default: `true`. When `true`, allow `string` values in boolean expressions. Examples of **incorrect** code with `{ "allowString": false }`: ```json { "@typescript-eslint/strict-boolean-expressions": ["error", { "allowString": false }] } ``` ```typescript declare const x: string; if (x) { } ``` ### `allowNumber` Default: `true`. When `true`, allow `number` and `bigint` values in boolean expressions. Examples of **incorrect** code with `{ "allowNumber": false }`: ```json { "@typescript-eslint/strict-boolean-expressions": ["error", { "allowNumber": false }] } ``` ```typescript declare const x: number; if (x) { } ``` ### `allowNullableObject` Default: `true`. When `true`, allow nullable object values — for example `object`, `symbol`, or function types in a union with `null` or `undefined`. ### `allowNullableBoolean` Default: `false`. When `true`, allow nullable boolean values — `boolean` in a union with `null` or `undefined`. Examples of **correct** code with `{ "allowNullableBoolean": true }`: ```json { "@typescript-eslint/strict-boolean-expressions": ["error", { "allowNullableBoolean": true }] } ``` ```typescript declare const x: boolean | null; if (x) { } ``` ### `allowNullableString` Default: `false`. When `true`, allow nullable string values. ### `allowNullableNumber` Default: `false`. When `true`, allow nullable number values. ### `allowNullableEnum` Default: `false`. When `true`, allow nullable enum values. ### `allowAny` Default: `false`. When `true`, allow `any`, `unknown`, and unconstrained generic values. ### `allowRuleToRunWithoutStrictNullChecksIKnowWhatIAmDoing` Default: `false`. By default the rule emits a file-level `noStrictNullCheck` diagnostic when `strictNullChecks` is off because the rule's output is unreliable without it. Set this to `true` to silence the diagnostic and run the rule anyway. ## When Not To Use It If your codebase does not rely on JavaScript truthiness coercion in boolean positions, or you prefer the conciseness of `if (x)` over the strictness of `if (x != null)`, you can disable this rule. ## Original Documentation - [typescript-eslint: strict-boolean-expressions](https://typescript-eslint.io/rules/strict-boolean-expressions) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts) --- url: /rules/typescript-eslint/strict-void-return.md --- # strict-void-return [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/strict-void-return': 'error', }, }, ]); ``` ## Rule Details Disallow passing a value-returning function in a position accepting a void function. TypeScript permits a function returning a value to be used where a `void`-returning function is expected — callbacks can return any value and it is silently discarded — but it hides several common mistakes: forgotten `await`s on promise-returning callbacks, generators or async functions misused as fire-and-forget event handlers, and accidental dead values from arrow shorthands. This rule reports any value-returning function used in a context that expects a function whose return type is `void`. It checks function arguments, JSX attribute values, array elements, assignments, variable initializers, object properties, class members (against extended base classes and implemented interfaces), and `return` statements. Examples of **incorrect** code for this rule: ```typescript const getNothing: () => void = () => 2137; declare function takesCallback(cb: () => void): void; takesCallback(async () => { const response = await fetch('https://api.example.com/'); }); takesCallback(function* () { yield 'Hello'; }); ['Alice', 'Bob'].forEach(name => `Hello, ${name}!`); class Foo { cb() { console.log('foo'); } } class Bar extends Foo { cb() { return 'bar'; } } interface Foo { cb(): void; } class Bar implements Foo { cb() { return 'cb'; } } ``` Examples of **correct** code for this rule: ```typescript const getNothing: () => void = () => {}; declare function takesCallback(cb: () => void): void; takesCallback(() => { void (async () => { const response = await fetch('https://api.example.com/'); })(); }); takesCallback(() => { function* gen() { yield 'Hello'; } for (const _ of gen()); }); ['Alice', 'Bob'].forEach(name => console.log(`Hello, ${name}!`)); class Foo { cb() { console.log('foo'); } } class Bar extends Foo { cb() { super.cb(); console.log('bar'); } } interface Foo { cb(): void; } class Bar implements Foo { cb() { console.log('cb'); } } ``` ## Options ### `allowReturnAny` **Type:** `boolean` — **Default:** `false` When `false` (default), a function returning `any` is treated the same as any other non-void return — for example, `fn(() => JSON.parse('{}'))` is reported. When `true`, functions returning `any` are accepted in void positions. Useful for codebases where untyped values flow through callbacks intentionally. Examples of **correct** code with `{ "allowReturnAny": true }`: ```json { "@typescript-eslint/strict-void-return": ["error", { "allowReturnAny": true }] } ``` ```typescript declare function fn(cb: () => void): void; fn(() => JSON.parse('{}')); fn(() => { return someUntypedApi(); }); ``` ## Original Documentation - [typescript-eslint: strict-void-return](https://typescript-eslint.io/rules/strict-void-return) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/strict-void-return.ts) --- url: /rules/typescript-eslint/switch-exhaustiveness-check.md --- # switch-exhaustiveness-check [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/switch-exhaustiveness-check': 'error', }, }, ]); ``` ## Rule Details Require switch statements over union types to be exhaustive. When switching over a union type (such as a discriminated union or enum), it is easy to forget to handle all possible cases. This rule ensures that every possible value of the union is handled with a `case` clause, either explicitly or via a `default` clause, preventing runtime errors from unhandled values. Examples of **incorrect** code for this rule: ```typescript type Direction = 'north' | 'south' | 'east' | 'west'; function move(dir: Direction) { switch (dir) { case 'north': break; case 'south': break; // 'east' and 'west' are not handled } } ``` Examples of **correct** code for this rule: ```typescript type Direction = 'north' | 'south' | 'east' | 'west'; function move(dir: Direction) { switch (dir) { case 'north': break; case 'south': break; case 'east': break; case 'west': break; } } ``` ## Options ### `allowDefaultCaseForExhaustiveSwitch` If `false`, a `default` clause is reported as unnecessary once every member of the union already has its own `case`. ```json { "switch-exhaustiveness-check": ["error", { "allowDefaultCaseForExhaustiveSwitch": false }] } ``` ```typescript type Direction = 'north' | 'south'; function move(dir: Direction) { switch (dir) { case 'north': break; case 'south': break; default: break; } } ``` ### `requireDefaultForNonUnion` If `true`, also requires a `default` clause for switches over non-union types (such as `number` or `string`), so they are held to the same standard as unions. ```json { "switch-exhaustiveness-check": ["error", { "requireDefaultForNonUnion": true }] } ``` ```typescript declare const value: number; switch (value) { case 0: break; case 1: break; } ``` ### `considerDefaultExhaustiveForUnions` If `true`, a `default` clause on a switch over a union type is itself treated as covering every unhandled member, instead of requiring each member to have an explicit `case`. ```json { "switch-exhaustiveness-check": ["error", { "considerDefaultExhaustiveForUnions": true }] } ``` ```typescript type Direction = 'north' | 'south'; function move(dir: Direction) { switch (dir) { case 'north': break; default: break; } } ``` ### `defaultCaseCommentPattern` Regular expression for a trailing comment that stands in for a missing `default` clause. Defaults to `/^no default$/i`. ```json { "switch-exhaustiveness-check": ["error", { "defaultCaseCommentPattern": "^skip default" }] } ``` ```typescript declare const value: 'a' | 'b'; switch (value) { case 'a': break; // skip default } ``` ## Differences from ESLint - When a switch is missing more than one case, the order of the types listed in the `missingBranches` message and the order the fixer inserts the corresponding `case` clauses follow rslint's internal type ordering rather than the union's declaration order. For example, `type Day = 'Monday' | 'Tuesday' | 'Wednesday'` reports missing cases as `"Monday" | "Tuesday" | "Wednesday"`, alphabetized, even when the type alias declares them in a different order. ## Original Documentation - [typescript-eslint: switch-exhaustiveness-check](https://typescript-eslint.io/rules/switch-exhaustiveness-check) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/switch-exhaustiveness-check.ts) --- url: /rules/typescript-eslint/triple-slash-reference.md --- # triple-slash-reference [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommended | `"error"` | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/triple-slash-reference': 'error', }, }, ]); ``` ## Rule Details Disallow certain triple slash directives in favor of ES6-style import declarations. TypeScript's `/// ` triple-slash directives are an older mechanism for including type information. In most modern codebases, ES6-style `import` statements are preferred. This rule can ban `/// `, `/// `, and `/// ` directives. The default options are: - `lib: "always"`: allow `lib` references. - `path: "never"`: disallow `path` references. - `types: "prefer-import"`: disallow a `types` reference only when the same module is also imported. Examples of **incorrect** code for this rule: ```typescript /// import 'jest'; /// ``` Examples of **correct** code for this rule: ```typescript /// import { foo } from 'bar'; // The "jest" reference is allowed because only "bar" is imported. ``` ## Original Documentation - [typescript-eslint: triple-slash-reference](https://typescript-eslint.io/rules/triple-slash-reference) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/triple-slash-reference.ts) --- url: /rules/typescript-eslint/unbound-method.md --- # unbound-method [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ----------------------------------- | ---------------- | | ✅ ts.configs.recommendedTypeChecked | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/unbound-method': 'error', }, }, ]); ``` ## Rule Details Enforce unbound methods are called with their expected scope. Extracting a class method as a standalone variable or callback without binding it to the class instance causes `this` to be `undefined` at runtime, which is a common source of bugs. This rule reports when a method is referenced without being called, unless it is in a safe context (like a comparison, typeof check, or conditional check). If the method does not access `this`, the rule additionally suggests annotating the method parameter with `this: void` or converting it to an arrow function. Examples of **incorrect** code for this rule: ```typescript class MyClass { method() { return this.value; } } const instance = new MyClass(); const unboundMethod = instance.method; [1, 2, 3].forEach(instance.method); ``` Examples of **correct** code for this rule: ```typescript class MyClass { method() { return this.value; } } const instance = new MyClass(); const boundMethod = instance.method.bind(instance); instance.method(); if (instance.method) { } typeof instance.method; ``` ## Original Documentation - [typescript-eslint: unbound-method](https://typescript-eslint.io/rules/unbound-method) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.28.0/packages/eslint-plugin/src/rules/unbound-method.ts) --- url: /rules/typescript-eslint/unified-signatures.md --- # unified-signatures [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strict | `"error"` | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/unified-signatures': 'error', }, }, ]); ``` Disallow overloads that can be combined into one signature with a union, optional parameter, or rest parameter. ## Rule details Multiple overloads make an API harder to read when they differ only in a single parameter type or in one parameter that can be omitted. This rule reports those signatures and recommends expressing the difference directly. Examples of **incorrect** code for this rule: ```typescript function parse(value: string): void; function parse(value: number): void; interface Factory { create(): Result; create(options?: Options): Result; } ``` Examples of **correct** code for this rule: ```typescript function parse(value: string | number): void; interface Factory { create(options?: Options): Result; } function convert(value: string): string; function convert(value: number): number; ``` The last pair is allowed because its return types differ. ## Options The rule accepts an optional object: ```json { "ignoreDifferentlyNamedParameters": false, "ignoreOverloadsWithDifferentJSDoc": false } ``` ### `ignoreDifferentlyNamedParameters` When `true`, overloads whose corresponding parameters have different names are not combined. ### `ignoreOverloadsWithDifferentJSDoc` When `true`, overloads with different preceding block comments are not combined. ## Original documentation - [typescript-eslint: unified-signatures](https://typescript-eslint.io/rules/unified-signatures) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.69.0/packages/eslint-plugin/src/rules/unified-signatures.ts) - [Tests](https://github.com/typescript-eslint/typescript-eslint/blob/v8.69.0/packages/eslint-plugin/tests/rules/unified-signatures.test.ts) --- url: /rules/typescript-eslint/use-unknown-in-catch-callback-variable.md --- # use-unknown-in-catch-callback-variable [Added in v0.1.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.4) ## Configuration | Preset | Configured Value | | ------------------------------ | ---------------- | | ✅ ts.configs.strictTypeChecked | `"error"` | ```ts title=rslint.config.ts import { defineConfig, ts } from '@rslint/core'; export default defineConfig([ ts.configs.recommended, { rules: { '@typescript-eslint/use-unknown-in-catch-callback-variable': 'error', }, }, ]); ``` ## Rule Details Enforce typing the rejection callback parameter of `.catch()` and `.then()` as `unknown`. Similar to how catch clause variables should be typed as `unknown` (since any value can be thrown), Promise rejection callback parameters should also be typed as `unknown`. This prevents unsafe property accesses and assumptions about the shape of the rejection reason. The rule checks `.catch(callback)` and `.then(onFulfilled, onRejected)` calls on thenable types and flags the rejection callback parameter when it is not typed as `unknown`. Examples of **incorrect** code for this rule: ```typescript promise.catch(err => {}); promise.catch((err: Error) => {}); promise.then(undefined, err => {}); promise.then(undefined, (err: string) => {}); ``` Examples of **correct** code for this rule: ```typescript promise.catch((err: unknown) => {}); promise.then(undefined, (err: unknown) => {}); promise.catch((...args: [unknown]) => {}); ``` ## Original Documentation - [typescript-eslint: use-unknown-in-catch-callback-variable](https://typescript-eslint.io/rules/use-unknown-in-catch-callback-variable) - [Source code](https://github.com/typescript-eslint/typescript-eslint/blob/v8.67.0/packages/eslint-plugin/src/rules/use-unknown-in-catch-callback-variable.ts) --- url: /rules/import/default.md --- # default [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration | Preset | Configured Value | | ---------------------------------- | ---------------- | | ✅ importPlugin.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, importPlugin } from '@rslint/core'; export default defineConfig([ importPlugin.configs.recommended, { rules: { 'import/default': 'error', }, }, ]); ``` ## Rule Details This rule reports a default import when the imported module does not provide a default export. Examples of **incorrect** code for this rule: ```javascript // ./bar.js export const bar = 1; // ./foo.js import bar from "./bar"; ``` Examples of **correct** code for this rule: ```javascript // ./bar.js export default 1; // ./foo.js import bar from "./bar"; ``` Modules that cannot be resolved, are ignored, or are not ES modules are not reported by this rule. ## Original Documentation - [eslint-plugin-import: default](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/default.md) - [Source code](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/src/rules/default.js) --- url: /rules/import/first.md --- # first [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, importPlugin } from '@rslint/core'; export default defineConfig([ importPlugin.configs.recommended, { rules: { 'import/first': 'error', }, }, ]); ``` ## Rule Details Ensures all import statements appear before other statements in a module. Since imports are hoisted, interleaving them with other code can be confusing. Examples of **incorrect** code for this rule: ```javascript import { x } from './foo'; export { x }; import { y } from './bar'; ``` ```javascript var a = 1; import { y } from './bar'; ``` Examples of **correct** code for this rule: ```javascript import { x } from './foo'; import { y } from './bar'; export { x, y }; ``` ## Options ### `absolute-first` When set to `"absolute-first"`, this rule enforces that absolute (package) imports appear before relative imports. Examples of **incorrect** code with `"absolute-first"`: ```javascript import { x } from './foo'; import { y } from 'bar'; ``` Examples of **correct** code with `"absolute-first"`: ```javascript import { y } from 'bar'; import { x } from './foo'; ``` ## Original Documentation - [eslint-plugin-import: first](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/first.md) - [Source code](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/src/rules/first.js) --- url: /rules/import/namespace.md --- # namespace [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration | Preset | Configured Value | | ---------------------------------- | ---------------- | | ✅ importPlugin.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, importPlugin } from '@rslint/core'; export default defineConfig([ importPlugin.configs.recommended, { rules: { 'import/namespace': 'error', }, }, ]); ``` ## Rule Details Enforces that properties read from namespace imports exist in the imported module. Examples of **incorrect** code for this rule: ```javascript import * as names from './named-exports'; names.missing; ``` ```javascript import * as names from './named-exports'; names['dynamic']; ``` ```javascript import * as names from './named-exports'; names.foo = 1; ``` Examples of **correct** code for this rule: ```javascript import * as names from './named-exports'; names.foo; ``` Examples of **correct** code for this rule with `{ "allowComputed": true }`: ```json { "import/namespace": ["error", { "allowComputed": true }] } ``` ```javascript import * as names from './named-exports'; names[key]; ``` ## Options ### `allowComputed` Defaults to `false`. When set to `true`, computed namespace member access is allowed, but the computed property name is not validated. Modules that cannot be resolved, are ignored, or are not ES modules are not reported by this rule. ## Original Documentation - [eslint-plugin-import: namespace](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/namespace.md) - [Source code](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/src/rules/namespace.js) --- url: /rules/import/newline-after-import.md --- # newline-after-import [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, importPlugin } from '@rslint/core'; export default defineConfig([ importPlugin.configs.recommended, { rules: { 'import/newline-after-import': 'error', }, }, ]); ``` ## Rule Details Enforces having one or more empty lines after the last top-level import statement or require call. This rule supports the following options: - `count` which sets the number of newlines that are enforced after the last top-level import statement or require call. This option defaults to `1`. - `exactCount` which enforces the exact number of newlines mentioned in `count`. This option defaults to `false`. - `considerComments` which enforces the rule on comments after the last import statement as well when set to true. This option defaults to `false`. Examples of **incorrect** code for this rule: ```javascript import * as foo from 'foo'; const FOO = 'BAR'; ``` ```javascript const FOO = require('./foo'); const BAZ = 1; ``` Examples of **correct** code for this rule: ```javascript import defaultExport from './foo'; const FOO = 'BAR'; ``` ```javascript const FOO = require('./foo'); const BAR = require('./bar'); const BAZ = 1; ``` ## Original Documentation - [eslint-plugin-import: newline-after-import](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/newline-after-import.md) - [Source code](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/src/rules/newline-after-import.js) --- url: /rules/import/no-cycle.md --- # no-cycle [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration ```ts title=rslint.config.ts import { defineConfig, importPlugin } from '@rslint/core'; export default defineConfig([ importPlugin.configs.recommended, { rules: { 'import/no-cycle': 'error', }, }, ]); ``` ## Rule Details Ensures that an imported module does not have a resolvable dependency path back to the linted module. Examples of **incorrect** code for this rule: ```javascript // dep-b.js import "./dep-a.js"; // dep-a.js import "./dep-b.js"; ``` Examples of **correct** code for this rule: ```javascript // dep-b.js export const value = 1; // dep-a.js import { value } from "./dep-b.js"; ``` This rule does not report direct self imports. Use `import/no-self-import` for that case. Type-only imports are ignored because they have no runtime effect. Named type-only re-exports still participate in the dependency graph, matching `eslint-plugin-import`. ## Options ### `maxDepth` Limits how far the rule traverses the dependency graph. The value must be a positive integer or `"∞"`. ```json { "import/no-cycle": ["error", { "maxDepth": 1 }] } ``` ### `commonjs` Checks `require()` calls in addition to ES module imports. ```json { "import/no-cycle": ["error", { "commonjs": true }] } ``` ### `amd` Checks AMD `require([...])` and `define([...])` dependencies. ```json { "import/no-cycle": ["error", { "amd": true }] } ``` ### `ignoreExternal` Skips modules treated as external, such as modules under `node_modules`. ```json { "import/no-cycle": ["error", { "ignoreExternal": true }] } ``` ### `allowUnsafeDynamicCyclicDependency` Allows a cycle when at least one dependency in the cycle is imported with dynamic `import()`. ```json { "import/no-cycle": [ "error", { "allowUnsafeDynamicCyclicDependency": true } ] } ``` ### `esmodule` Checks ES module `import`/`export` sources. Defaults to `true`; set to `false` to disable them. ```json { "import/no-cycle": ["error", { "esmodule": false }] } ``` ### `disableScc` Accepted for compatibility with upstream configs. Upstream uses this to skip building a strongly-connected-components graph, an internal traversal optimization; this rule does not build one either way, so the option has no observable effect here. ## Original Documentation - [eslint-plugin-import: no-cycle](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-cycle.md) - [Source code](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/src/rules/no-cycle.js) --- url: /rules/import/no-default-export.md --- # no-default-export [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration ```ts title=rslint.config.ts import { defineConfig, importPlugin } from '@rslint/core'; export default defineConfig([ importPlugin.configs.recommended, { rules: { 'import/no-default-export': 'error', }, }, ]); ``` ## Rule Details Forbids default exports and default re-exports. Use named exports instead. Examples of **incorrect** code for this rule: ```javascript export default function foo() {} const foo = "foo"; export { foo as default }; export { default } from "./foo"; ``` Examples of **correct** code for this rule: ```javascript export function foo() {} const foo = "foo"; export { foo }; ``` ## Original Documentation - [eslint-plugin-import: no-default-export](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-default-export.md) - [Source code](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/src/rules/no-default-export.js) --- url: /rules/import/no-duplicates.md --- # no-duplicates [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration | Preset | Configured Value | | ---------------------------------- | --------------------------------------- | | ✅ importPlugin.configs.recommended | `["warn",{"considerQueryString":true}]` | ```ts title=rslint.config.ts import { defineConfig, importPlugin } from '@rslint/core'; export default defineConfig([ importPlugin.configs.recommended, { rules: { 'import/no-duplicates': 'error', }, }, ]); ``` ## Rule Details Reports if a resolved path is imported more than once. This rule is similar to ESLint core's `no-duplicate-imports`, but differs in two key ways: 1. The paths in the source code don't have to exactly match — they just have to point to the same module on the filesystem (e.g., `./foo` and `./foo.js`). 2. This version distinguishes `type` imports from standard imports. Examples of **incorrect** code for this rule: ```javascript import { x } from './foo'; import { y } from './foo'; ``` ```javascript import SomeDefaultClass from './mod'; import * as names from './mod'; import { something } from './mod.js'; ``` Examples of **correct** code for this rule: ```javascript import SomeDefaultClass, * as names from './mod'; import type SomeType from './mod'; ``` ```javascript import { x } from './foo'; import { y } from './bar'; ``` ## Options ### `considerQueryString` - **Default:** - `false` by default - `true` if using the `importPlugin.configs.recommended` preset When set to `true`, imports with different query strings are treated as different modules. ```json { "import/no-duplicates": ["error", { "considerQueryString": false }] } ``` For example, these imports are reported as duplicates when `considerQueryString` is `false`, but are allowed when it is `true`: ```javascript import iconUrl from './icon.svg?url'; import iconSource from './icon.svg?raw'; ``` ### `prefer-inline` - **Default:** `false` When set to `true`, supports TypeScript inline type imports, allowing `import type { X }` to be merged into `import { type X }`. ```json { "import/no-duplicates": ["error", { "prefer-inline": true }] } ``` ## Original Documentation - [eslint-plugin-import: no-duplicates](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-duplicates.md) - [Source code](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/src/rules/no-duplicates.js) --- url: /rules/import/no-mutable-exports.md --- # no-mutable-exports [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, importPlugin } from '@rslint/core'; export default defineConfig([ importPlugin.configs.recommended, { rules: { 'import/no-mutable-exports': 'error', }, }, ]); ``` ## Rule Details Forbids the use of mutable exports with `var` or `let`. Mutable exports can lead to hard-to-understand code because importers might not expect the exported value to change after import. Use `const` for exported values, or export functions/classes instead. Examples of **incorrect** code for this rule: ```javascript export let count = 1; export var count = 1; let count = 1; export { count }; ``` Examples of **correct** code for this rule: ```javascript export const count = 1; export function getCount() {} export class Counter {} const count = 1; export { count }; ``` ## Original Documentation - [eslint-plugin-import: no-mutable-exports](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-mutable-exports.md) - [Source code](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/src/rules/no-mutable-exports.js) --- url: /rules/import/no-restricted-paths.md --- # no-restricted-paths [Added in v0.8.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, importPlugin } from '@rslint/core'; export default defineConfig([ importPlugin.configs.recommended, { rules: { 'import/no-restricted-paths': 'error', }, }, ]); ``` ## Rule Details Some projects contain files that are not meant to run in the same environment. A web application, for example, may hold server-only code next to browser code, and importing the server code from the client bundle would ship it to the browser. This rule lets you declare restricted zones: a `target` set of files, and a `from` set of files those targets are not allowed to import. The rule takes one option object with a list of `zones` and an optional `basePath` used to resolve the relative paths inside each zone. `basePath` defaults to the current working directory. Each zone accepts: - `target` — which files belong to the zone. A directory path (matching everything inside it recursively), a glob pattern, or an array of either. - `from` — which files the zone may not import. A directory path, a glob pattern, or an array of only directory paths or only glob patterns. - `except` — optional. Imports that are allowed even though `from` covers them. When `from` is a directory path, each entry is resolved relative to `from` and must stay inside it. When `from` is a glob pattern, each entry must be a glob pattern too. - `message` — optional. Appended to the reported message. `from` is matched against the resolved path of the imported file, not against the specifier text as written in the source. Given this folder structure: ``` . ├── client │ ├── foo.ts │ └── baz.ts └── server └── bar.ts ``` Examples of **incorrect** code for this rule: ```json { "import/no-restricted-paths": ["error", { "zones": [{ "target": "./client", "from": "./server" }] }] } ``` ```javascript // client/foo.ts import bar from '../server/bar'; ``` Examples of **correct** code for this rule: ```json { "import/no-restricted-paths": ["error", { "zones": [{ "target": "./client", "from": "./server" }] }] } ``` ```javascript // server/bar.ts import baz from '../client/baz'; ``` ### `except` Given this folder structure: ``` . └── server ├── one │ ├── a.ts │ └── b.ts └── two └── a.ts ``` Examples of **incorrect** code for this rule: ```json { "import/no-restricted-paths": [ "error", { "zones": [{ "target": "./server/one", "from": "./server", "except": ["./one"] }] } ] } ``` ```javascript // server/one/a.ts import a from '../two/a'; ``` Examples of **correct** code for this rule: ```json { "import/no-restricted-paths": [ "error", { "zones": [{ "target": "./server/one", "from": "./server", "except": ["./one"] }] } ] } ``` ```javascript // server/one/a.ts import b from './b'; ``` ### `basePath` Relative `target` and `from` paths are resolved against `basePath`, and a relative `basePath` is itself resolved against the current working directory. `except` entries stay relative to their zone's `from`. ```json { "import/no-restricted-paths": [ "error", { "basePath": "./src", "zones": [{ "target": "./client", "from": "./server" }] } ] } ``` ### `message` ```json { "import/no-restricted-paths": [ "error", { "zones": [ { "target": "./client", "from": "./server", "message": "Use the API client instead." } ] } ] } ``` ```javascript // client/foo.ts import bar from '../server/bar'; ``` reports `Unexpected path "../server/bar" imported in restricted zone. Use the API client instead.` ## Differences from ESLint - Glob patterns support `*`, `**`, `?`, `[abc]` character classes and `{a,b}` alternatives. Extended glob syntax — `!(a)`, `@(a|b)`, `+(a)`, `?(a)`, `*(a)` — is matched as the literal text it is written as, so `./src/?(server)/**/*` covers a directory named `?(server)` rather than one named `server`. Write `{server,shared}` instead of `@(server|shared)`, and name the directories you want to cover instead of excluding one with `!(...)`. - A `*` matches path segments that begin with a dot, so `./src/*` covers `./src/.hidden.ts` as well. - A package specifier resolves the way TypeScript resolves it, so it lands on the file a package's `types` entry names. ESLint's resolver follows `main` instead, so for a package published with `"main": "index.js"` and `"types": "index.d.ts"` the same import resolves to `index.d.ts` here and to `index.js` under ESLint. This only shows up in a zone that names a single file inside a package: `from: "./node_modules/some-package/index.d.ts"` restricts the import here and nothing under ESLint, and `from: "./node_modules/some-package/index.js"` the other way around. Name the package directory — `./node_modules/some-package` — and the zone applies under both, whichever file the specifier lands on. - A relative specifier resolves under the project's TypeScript compiler options, so `moduleSuffixes` and `rootDirs` steer it to the file TypeScript itself would load. ESLint's resolver reads neither option, so a project that sets one can land the same specifier on a different file under each. Name the directory holding both candidates, and the zone applies under both. ## Original Documentation - [eslint-plugin-import: no-restricted-paths](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-restricted-paths.md) - [Source code](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/src/rules/no-restricted-paths.js) --- url: /rules/import/no-self-import.md --- # no-self-import [Added in v0.1.8](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.8) ## Configuration ```ts title=rslint.config.ts import { defineConfig, importPlugin } from '@rslint/core'; export default defineConfig([ importPlugin.configs.recommended, { rules: { 'import/no-self-import': 'error', }, }, ]); ``` ## Rule Details Disallows a module from importing itself. A module that imports itself creates a circular dependency on itself, which is always a mistake and can cause confusing runtime behavior or errors. This applies to both ES module `import` statements and CommonJS `require()` calls. Examples of **incorrect** code for this rule: ```javascript // in file "foo.js" import foo from './foo'; // in file "index.js" const index = require('./index'); ``` Examples of **correct** code for this rule: ```javascript // in file "foo.js" import bar from './bar'; // in file "index.js" const utils = require('./utils'); ``` ## Original Documentation - [eslint-plugin-import: no-self-import](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-self-import.md) - [Source code](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/src/rules/no-self-import.js) --- url: /rules/import/no-webpack-loader-syntax.md --- # no-webpack-loader-syntax [Added in v0.1.14](https://github.com/web-infra-dev/rslint/releases/tag/v0.1.14) ## Configuration ```ts title=rslint.config.ts import { defineConfig, importPlugin } from '@rslint/core'; export default defineConfig([ importPlugin.configs.recommended, { rules: { 'import/no-webpack-loader-syntax': 'error', }, }, ]); ``` ## Rule Details Disallows the use of webpack loader syntax (`!`) in `import` statements and `require()` calls. Webpack allows specifying loaders inline using `!` in the module path (e.g., `css-loader!./styles.css`), but this couples the code to webpack and makes it non-portable to other bundlers or environments. Loader configuration should be specified in the webpack configuration file instead. Examples of **incorrect** code for this rule: ```javascript import styles from 'css-loader!./styles.css'; import content from 'html-loader!./template.html'; const styles = require('style-loader!css-loader!./styles.css'); ``` Examples of **correct** code for this rule: ```javascript import styles from './styles.css'; import content from './template.html'; const styles = require('./styles.css'); ``` ## Original Documentation - [eslint-plugin-import: no-webpack-loader-syntax](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-webpack-loader-syntax.md) - [Source code](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/src/rules/no-webpack-loader-syntax.js) --- url: /rules/import/order.md --- # order [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, importPlugin } from '@rslint/core'; export default defineConfig([ importPlugin.configs.recommended, { rules: { 'import/order': 'error', }, }, ]); ``` Enforces a convention in module import order. Imports are sorted into groups (`builtin`, `external`, `parent`, `sibling`, `index`, plus optional `internal`, `unknown`, `object`, `type`) and each group must appear in the configured order. This rule is autofixable. ## Rule Details By default, imports are placed in this order: ``` builtin → external → parent → sibling → index ``` Examples of **incorrect** code: ```javascript var sibling = require('./foo'); var fs = require('fs'); ``` Examples of **correct** code: ```javascript var fs = require('fs'); var sibling = require('./foo'); ``` ## Options ### `groups` **Default:** `["builtin", "external", "parent", "sibling", "index"]` Defines the relative order of import groups. Items can be a single string or an array (entries in the same array share a rank — they're "interchangeable" within that group). ```json { "import/order": [ "error", { "groups": ["builtin", ["external", "internal"], "parent", "sibling", "index"] } ] } ``` ### `pathGroups` **Default:** `[]` Refines the group ordering by matching specifiers against minimatch patterns. Each entry has a `pattern`, a target `group`, and an optional `position` (`"before"` or `"after"`). `patternOptions` accepts the minimatch 3.1.5 controls for dot files, case-insensitive and basename matching, partial prefixes, and glob/brace/negation behavior. ```json { "import/order": [ "error", { "pathGroups": [ { "pattern": "@app/**", "group": "external", "position": "after" } ] } ] } ``` ### `pathGroupsExcludedImportTypes` **Default:** `["builtin", "external", "object"]` Lists import types that are NOT subject to `pathGroups` matching. If you want `@scope/*` imports to be re-ranked by a `pathGroup`, remove `"external"` from this list. ### `distinctGroup` **Default:** `true` When `true`, `pathGroups` with a `position` form their own sub-group (separated by an enforced newline when `newlines-between` is `"always"`). When `false`, they slot back into the parent group. ### `newlines-between` **Default:** `"ignore"` Controls newlines between import groups: - `"ignore"` — no enforcement - `"always"` — at least one empty line between different groups, none within - `"never"` — no empty lines between any imports - `"always-and-inside-groups"` — at least one empty line between groups, allowed within ```json { "import/order": ["error", { "newlines-between": "always" }] } ``` ```javascript import fs from 'fs'; import sibling from './foo'; ``` ### `newlines-between-types` Identical to `newlines-between` but only applies to type-only imports when `sortTypesGroup` is `true`. Defaults to the value of `newlines-between`. ### `alphabetize` **Default:** `{ "order": "ignore", "orderImportKind": "ignore", "caseInsensitive": false }` Sorts imports alphabetically within each group. - `order`: `"asc"` | `"desc"` | `"ignore"` - `orderImportKind`: `"asc"` | `"desc"` | `"ignore"` — secondary sort key used when two imports compare equal on path; sorts by kind (`type` vs `value`). - `caseInsensitive`: when `true`, lowercases values before comparison. ```json { "import/order": [ "error", { "alphabetize": { "order": "asc", "caseInsensitive": true } } ] } ``` ### `named` **Default:** `false` Enables ordering within named import, export, require, and CommonJS export lists. `alphabetize` controls name ordering; the `types` setting controls the type/value partition. Forms accepted: - `false` — disabled. - `true` — enable for named imports, exports, requires, and CJS exports. - Object form: - `enabled`: default for the four sub-toggles below. - `import`: check `import { ... } from 'mod'`. - `export`: check `export { ... } from 'mod'`. - `require`: check `var { ... } = require('mod')`. - `cjsExports`: check `module.exports = { ... }` and named CommonJS export assignments. As in ESLint, only declarations in the identifier's current lexical scope suppress `module` / `exports`; an outer-scope declaration by itself does not suppress a nested assignment. - `types`: `"mixed"` | `"types-first"` | `"types-last"`. Controls how `import { type T, a, b }` interleaves type and value specifiers. ### `sortTypesGroup` **Default:** `false` When `true` and `"type"` is in `groups`, type-only imports form a parallel sub-group hierarchy mirroring the value-import group order. ### `warnOnUnassignedImports` **Default:** `false` By default, side-effect imports (`import './styles.css'`) are ignored. Set this to `true` to treat them like other imports for ordering. Side-effect imports are never autofixed because their evaluation order can be load-bearing. ### `consolidateIslands` **Default:** `"never"` When `"inside-groups"`, multi-line imports are separated from neighboring imports with empty lines, while consecutive single-line imports stay together. Only meaningful with `"always-and-inside-groups"` newline modes. ## Settings | Setting | Behaviour | | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `import/internal-regex` | Specifier matching this regex classifies as `internal`. | | `import/core-modules` | Extra names treated as `builtin`. | | `import/external-module-folders` | Resolved paths outside the importing package, or under one of these package-relative folders, classify as `external` (default `["node_modules"]`). An explicit `[]` disables the folder check; `""` denotes the package root. | Exact Node.js builtin specifiers take precedence over TypeScript filesystem resolution. Non-exact builtin subpath specifiers and names from `import/core-modules` remain resolution-sensitive. ## Differences from ESLint Compared with eslint-plugin-import 2.32.0, users may observe: - **Aliases and workspace packages may be grouped differently.** Rslint can classify an import as `internal` where ESLint says `external`, or vice versa. - **Custom resolver settings are ignored.** Imports known only through `settings["import/resolver"]` may be grouped and ordered differently. - **Flow `import typeof` is a parse error.** Rslint produces no `import/order` diagnostic for that file. - **Messages for `import type Default, { Named }` can differ.** Rslint calls `Named` a `type import`; ESLint may call it an ordinary import. - **Mixed `../` and `./` paths sharing a rank have a fixed order.** Ascending puts `../` first; descending reverses it, and repeated `--fix` converges. - **A move across an unassigned side-effect import is not autofixed.** The ordering diagnostic remains, but rslint leaves the source unchanged. - **Named sorting skips `const { name, ...rest } = require('pkg')`.** Rslint leaves it unchanged instead of failing as eslint-plugin-import 2.32.0 can. ## Upstream References - [eslint-plugin-import: order](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/order.md) - [Source code, including the relative-path comparator fix](https://github.com/import-js/eslint-plugin-import/blob/5ebd8fd2879e033016d7ed7ebe6a9af7f5d5295a/src/rules/order.js) - [Relative-path comparator convergence issue](https://github.com/import-js/eslint-plugin-import/issues/3235) --- url: /rules/jest/expect-expect.md --- # expect-expect [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"warn"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/expect-expect': 'error', }, }, ]); ``` ## Rule Details Ensure every Jest test callback contains at least one assertion. The rule tracks test APIs such as `test`, `it`, `fit`, `xit`, and `xtest` (including chained forms like `it.each` that the Jest integration recognizes) and reports when none of the configured assertion callee patterns appear in the body. Assertions inside a named function declaration or variable function passed as the test callback are attributed to every test that references it, regardless of whether the callback is declared before or after the registration. This guards against tests that run side effects but never verify outcomes. Skipped [`test.todo` / `it.todo`](https://jestjs.io/docs/api#testtodotitle) bodies are ignored. ### Divergence from `eslint-plugin-jest` When a callback is passed by reference, this rule resolves its declaration and counts the assertions found there, wherever that declaration sits: ```js function myTest() { expect(true).toBeDefined(); } it('should pass', myTest); ``` Upstream `eslint-plugin-jest` reports `Test has no assertions` here, because it clears a registration only when the registration was already seen at the time the assertion was walked. The declaration is hoisted, so this is the same program as the call-first form `it('should pass', myTest); function myTest() { ... }` that both rules accept, and reporting one but not the other is an order-dependent false positive. Callbacks declared with `const` or `var` are resolved the same way, which upstream does not do at all — it only ever looks at function declarations, so it reports those tests in either order. Examples of **incorrect** code for this rule: ```js it('should be a test', () => { console.log('no assertion'); }); test('should assert something', () => {}); ``` Examples of **correct** code for this rule: ```js it('should be a test', () => { expect(true).toBeDefined(); }); it('should work with callbacks/async', () => { somePromise().then(res => expect(res).toBe('passed')); }); ``` ### Options ```ts interface Options { assertFunctionNames?: string[]; additionalTestBlockFunctions?: string[]; } ``` - **`assertFunctionNames`** (default `["expect"]`): callee chains that count as assertions. Patterns follow [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/expect-expect.md): `*` matches a dot-separated segment; `**` matches zero or more segments. The pattern is matched case-insensitively against the full chain (for example `request.**.expect` for [SuperTest](https://www.npmjs.com/package/supertest) `.expect`). Special regex characters in names may need escaping when mirroring ESLint behavior. - **`additionalTestBlockFunctions`**: extra global function names treated like `test`/`it` wrappers (for example helpers from [`jest-theories`](https://www.npmjs.com/package/jest-theories)) so their callbacks are also required to contain an assertion. For more option examples and edge cases, see the upstream rule documentation linked below. ## Original Documentation - [eslint-plugin-jest: expect-expect](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/expect-expect.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/expect-expect.ts) --- url: /rules/jest/max-expects.md --- # max-expects [Added in v0.6.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/max-expects': 'error', }, }, ]); ``` ## Rule Details Enforce a maximum number of `expect()` calls in a test body. As more assertions are added, a test is more likely to mix multiple objectives. This rule reports when a single test callback exceeds the configured limit. The rule counts top-level `expect()` calls inside each `test` or `it` callback (including `async` callbacks and forms such as `test.each` and `it.each` that the Jest integration recognizes). The counter resets when entering a new test case. Nested `expect()` calls used as matchers (for example `expect.any(Boolean)` inside `toEqual`) and static `expect` APIs such as `expect.hasAssertions()` are not counted. `expect` calls inside nested functions within a test (for example a helper arrow function defined in the callback) are counted toward that test's limit. `expect` calls in standalone helper functions defined outside the test callback are not attributed to the test body. Examples of **incorrect** code for this rule (with the default `{ "max": 5 }`): ```javascript test('should not pass', () => { expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); }); it('should not pass', async () => { expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); }); describe('test', () => { test('should not pass', () => { expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); }); }); ``` Examples of **correct** code for this rule (with the default `{ "max": 5 }`): ```javascript test('should pass'); test('should pass', () => {}); test.skip('should pass', () => {}); test('should pass', () => { expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); }); test('should pass', async () => { expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toEqual(expect.any(Boolean)); }); function myHelper() { expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); } test('should pass', () => { expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); myHelper(); }); ``` ## Options - First argument (optional): object with `max` - `max`: maximum allowed `expect()` calls per test callback. Default is `5`. Examples of **correct** code with `{ "max": 10 }`: ```javascript test('should pass', () => { expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); expect(true).toBeDefined(); }); ``` Examples of **incorrect** code with `{ "max": 1 }`: ```javascript test('should not pass', () => { expect(true).toBeDefined(); expect(true).toBeDefined(); }); ``` ## Original Documentation - [eslint-plugin-jest: max-expects](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/max-expects.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/max-expects.ts) --- url: /rules/jest/max-nested-describe.md --- # max-nested-describe [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/max-nested-describe': 'error', }, }, ]); ``` ## Rule Details Enforce a maximum depth for nested `describe()` calls. Grouping tests with `describe` is useful, but too many nested levels make suites harder to read and navigate. This rule counts every Jest suite call as a nesting level, including `fdescribe`, `xdescribe`, `describe.only`, `describe.skip`, and `describe.each`. Examples of **incorrect** code for this rule (with the default `{ "max": 5 }`): ```javascript describe('foo', () => { describe('bar', () => { describe('baz', () => { describe('qux', () => { describe('quxx', () => { describe('too many', () => { it('should get something', () => { expect(getSomething()).toBe('Something'); }); }); }); }); }); }); }); describe('foo', function () { describe('bar', function () { describe('baz', function () { describe('qux', function () { describe('quxx', function () { describe('too many', function () { it('should get something', () => { expect(getSomething()).toBe('Something'); }); }); }); }); }); }); }); ``` Examples of **correct** code for this rule (with the default `{ "max": 5 }`): ```javascript describe('foo', () => { describe('bar', () => { it('should get something', () => { expect(getSomething()).toBe('Something'); }); }); describe('qux', () => { it('should get something', () => { expect(getSomething()).toBe('Something'); }); }); }); describe('foo2', function () { it('should get something', () => { expect(getSomething()).toBe('Something'); }); }); describe('foo', function () { describe('bar', function () { describe('baz', function () { describe('qux', function () { describe('this is the limit', function () { it('should get something', () => { expect(getSomething()).toBe('Something'); }); }); }); }); }); }); ``` ## Options - First argument (optional): object with `max` - `max`: maximum allowed nesting depth for `describe()` calls. Default is `5`. A value of `0` disallows any `describe` block. Examples of **correct** code with `{ "max": 2 }`: ```javascript describe('foo', () => { describe('bar', () => { it('should get something', () => { expect(getSomething()).toBe('Something'); }); }); }); ``` Examples of **incorrect** code with `{ "max": 2 }`: ```javascript fdescribe('foo', () => { describe.only('bar', () => { describe.skip('baz', () => { it('should get something', () => { expect(getSomething()).toBe('Something'); }); }); }); }); ``` ## Original Documentation - [eslint-plugin-jest: max-nested-describe](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/max-nested-describe.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/max-nested-describe.ts) --- url: /rules/jest/no-alias-methods.md --- # no-alias-methods [Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-alias-methods': 'error', }, }, ]); ``` ## Rule Details This rule triggers a warning if the alias name, rather than the canonical name, of a method is used. Examples of **incorrect** code for this rule: ```javascript expect(a).toBeCalled(); expect(a).toBeCalledTimes(); expect(a).toBeCalledWith(); expect(a).lastCalledWith(); expect(a).nthCalledWith(); expect(a).toReturn(); expect(a).toReturnTimes(); expect(a).toReturnWith(); expect(a).lastReturnedWith(); expect(a).nthReturnedWith(); expect(a).toThrowError(); ``` Examples of **correct** code for this rule: ```javascript expect(a).toHaveBeenCalled(); expect(a).toHaveBeenCalledTimes(); expect(a).toHaveBeenCalledWith(); expect(a).toHaveBeenLastCalledWith(); expect(a).toHaveBeenNthCalledWith(); expect(a).toHaveReturned(); expect(a).toHaveReturnedTimes(); expect(a).toHaveReturnedWith(); expect(a).toHaveLastReturnedWith(); expect(a).toHaveNthReturnedWith(); expect(a).toThrow(); ``` ## Original Documentation - [eslint-plugin-jest: no-alias-methods](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-alias-methods.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-alias-methods.ts) --- url: /rules/jest/no-commented-out-tests.md --- # no-commented-out-tests [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"warn"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-commented-out-tests': 'error', }, }, ]); ``` ## Rule Details Disallow commenting out Jest tests. Reviewers often skim past comments, so disabled cases can sit in the tree indefinitely. Prefer removing dead tests, extracting helpers, or using `.skip` / `test.todo` when you need an explicit, auditable signal. This is the comment-side complement to `jest/no-disabled-tests`, which reports `skip` / `only` / `todo` on real call sites instead of commented-out text. rslint walks each comment body line by line: the slice after `//`, or the text inside `/* … */`. If **any** line matches the eslint-plugin-jest-style heuristic—optional `x` or `f` prefix (`xit`, `fit`, …), then `test`, `it`, or `describe`, optional dot- or bracket-member chains (e.g. `.skip`, `.only`, `.concurrent`, `['skip']`), then optional whitespace and `(`—it reports the **entire** comment range with the message “Do not comment out tests”. Examples of **incorrect** code for this rule: ```javascript // describe('foo', () => {}); // it('foo', () => {}); // test('foo', () => {}); // describe.skip('foo', () => {}); // it.skip('foo', () => {}); // test.skip('foo', () => {}); // describe['skip']('bar', () => {}); // it['skip']('bar', () => {}); // test['skip']('bar', () => {}); // xdescribe('foo', () => {}); // xit('foo', () => {}); // xtest('foo', () => {}); // it.only('foo', () => {}); // it.concurrent('foo', () => {}); // fit('foo', () => {}); /* describe('foo', () => {}); */ ``` Examples of **correct** code for this rule: ```javascript describe('foo', () => {}); it('foo', () => {}); test('foo', () => {}); describe.only('bar', () => {}); it.only('bar', () => {}); test.only('bar', () => {}); // foo('bar', () => {}); // latest(dates) ``` ## Limitations Matching is based on the **literal** shape of test API names inside comment text, not on full parsing of the commented code. It will not flag indirect or renamed patterns, for example: ```javascript // const testSkip = test.skip; // testSkip('skipped test', () => {}); // const myTest = test; // myTest('does not have function body'); ``` Because the heuristic treats any `test` / `it` / `describe`-like call opening inside a comment as suspicious, a comment that merely **mentions** that shape (for example documenting an API) can be reported; prefer rephrasing such comments or using examples that do not mirror a call form. ## Original Documentation - [eslint-plugin-jest: no-commented-out-tests](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-commented-out-tests.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-commented-out-tests.ts) --- url: /rules/jest/no-conditional-expect.md --- # no-conditional-expect [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-conditional-expect': 'error', }, }, ]); ``` ## Rule Details Disallow calling `expect` conditionally. Jest only marks a test as failed when it throws; if an assertion runs inside a branch that is skipped, the test can pass without exercising the assertion at all. Conditionals also make tests harder to read and reason about. While `expect.assertions` and `expect.hasAssertions` can help catch silent skips, combining them with conditionals usually adds even more complexity. This rule reports `expect` calls that sit inside conditional control flow, including: - `if` / `else` branches - `switch` cases - `try` / `catch` handlers (including empty `catch` blocks that contain `expect`) - Short-circuit expressions (`&&`, `||`) and ternary expressions where `expect` is on a branch that may not run - Promise `.catch()` callbacks whose parameter is treated as an error handler (for example `.catch(error => expect(error)...)`) The same checks apply when the conditional `expect` lives in a helper function passed as the test callback. Conditionals that run **before** an unconditional `expect`, or that only affect the value passed **into** `expect`, are allowed. Examples of **incorrect** code for this rule: ```javascript it('foo', () => { doTest && expect(1).toBe(2); }); it('bar', () => { if (!skipTest) { expect(1).toEqual(2); } }); it('baz', () => { something ? expect(something).toHaveBeenCalled() : noop(); }); it('qux', () => { switch (something) { case 'value': expect(something).toHaveBeenCalled(); break; default: break; } }); it('handles errors', () => { try { processRequest(request); } catch (err) { expect(err).toMatchObject({ code: 'MODULE_NOT_FOUND' }); } }); it('throws an error', async () => { await foo().catch(error => expect(error).toBeInstanceOf(Error)); }); ``` Examples of **correct** code for this rule: ```javascript it('foo', () => { expect(!value).toBe(false); }); it('foo', () => { process.env.FAIL && setNum(1); expect(num).toBe(2); }); function getValue() { if (process.env.FAIL) { return 1; } return 2; } it('foo', () => { expect(getValue()).toBe(2); }); it('validates the request', () => { try { processRequest(request); } catch { // ignore errors } finally { expect(validRequest).toHaveBeenCalledWith(request); } }); it('throws an error', async () => { await expect(foo).rejects.toThrow(Error); }); ``` ### Testing thrown errors without violating this rule A common pattern is asserting properties on a caught error when `toThrow` only checks the message. A `try` / `catch` with `expect` in the `catch` block looks fine but still passes if nothing is thrown: ```javascript it('includes the status code in the error', async () => { try { await makeRequest(url); } catch (error) { expect(error).toHaveProperty('statusCode', 404); } }); ``` Prefer a small wrapper that always returns a value (or throws a sentinel when no error occurred), then assert unconditionally: ```javascript class NoErrorThrownError extends Error {} const getError = async call => { try { await call(); throw new NoErrorThrownError(); } catch (error) { return error; } }; it('includes the status code in the error', async () => { const error = await getError(() => makeRequest(url)); expect(error).not.toBeInstanceOf(NoErrorThrownError); expect(error).toHaveProperty('statusCode', 404); }); ``` ## Original Documentation - [eslint-plugin-jest: no-conditional-expect](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-conditional-expect.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-conditional-expect.ts) --- url: /rules/jest/no-conditional-in-test.md --- # no-conditional-in-test [Added in v0.7.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.1) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-conditional-in-test': 'error', }, }, ]); ``` ## Rule Details Disallow conditional logic in test bodies. A conditional usually indicates that a test is covering multiple execution paths, which can make it unclear which behavior the test is intended to verify. Prefer a separate test for each branch. Examples of **incorrect** code for this rule: ```javascript it('foo', () => { if (true) { doTheThing(); } }); it('bar', () => { switch (mode) { case 'none': generateNone(); case 'single': generateOne(); case 'multiple': generateMany(); } expect(fixtures.length).toBeGreaterThan(-1); }); it('qux', async () => { const promiseValue = () => { return something instanceof Promise ? something : Promise.resolve(something); }; await expect(promiseValue()).resolves.toBe(1); }); ``` Examples of **correct** code for this rule: ```javascript describe('my tests', () => { if (true) { it('foo', () => { doTheThing(); }); } }); beforeEach(() => { switch (mode) { case 'none': generateNone(); case 'single': generateOne(); case 'multiple': generateMany(); } }); it('bar', () => { expect(fixtures.length).toBeGreaterThan(-1); }); const promiseValue = something => { return something instanceof Promise ? something : Promise.resolve(something); }; it('qux', async () => { await expect(promiseValue()).resolves.toBe(1); }); ``` Conditionals outside test bodies, including conditionals in `describe` blocks, hooks, and helper functions declared outside a test, are not reported. ## Options - First argument (optional): object with `allowOptionalChaining` - `allowOptionalChaining`: whether optional chaining (`?.`) is allowed inside test bodies. Default is `true`. When `allowOptionalChaining` is `false`, optional property access, element access, and calls are also reported: ```json { "jest/no-conditional-in-test": [ "error", { "allowOptionalChaining": false } ] } ``` Examples of **incorrect** code with `{ "allowOptionalChaining": false }`: ```javascript it('foo', () => { const value = obj?.bar; }); it('bar', () => { obj?.foo(); }); ``` Examples of **correct** code with `{ "allowOptionalChaining": false }`: ```javascript it('foo', () => { const value = obj!.bar; }); ``` ## Limitations Unlike the upstream rule, an inner registration exiting does not clear the outer test's scope, so a conditional written after a nested `it(...)` is still reported. ## Original Documentation - [eslint-plugin-jest: no-conditional-in-test](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-conditional-in-test.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-conditional-in-test.ts) --- url: /rules/jest/no-confusing-set-timeout.md --- # no-confusing-set-timeout [Added in v0.6.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.3) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-confusing-set-timeout': 'error', }, }, ]); ``` ## Rule Details Disallow confusing usages of `jest.setTimeout`. In a single test file Jest applies only the **last** `jest.setTimeout` call that runs **before** any tests execute; later calls and calls inside suites or cases do not change the timeout the way many authors expect. This rule flags patterns that look file- or suite-specific but are misleading. rslint walks each Jest API call site (including `jest` imported from `@jest/globals` and renamed bindings such as `Jest.setTimeout`). For every `jest.setTimeout` call it may report: - **`globalSetTimeout`**: the call is not at module/global top level (for example inside a `describe` / `test` / `it` callback, a `beforeEach` body, a block statement, or a class). - **`orderSetTimeout`**: another Jest API (`describe`, `test`, `it`, hooks, `expect`, and so on) appears **earlier** in the same file. - **`multipleSetTimeouts`**: `jest.setTimeout` is invoked more than once in the file (only the last pre-test call matters to Jest). Plain `setTimeout` and `window.setTimeout` are not checked. Examples of **incorrect** code for this rule: ```javascript describe('test foo', () => { jest.setTimeout(1000); it('test-description', () => { // test logic }); }); describe('test bar', () => { it('test-description', () => { jest.setTimeout(1000); // test logic }); }); test('foo-bar', () => { jest.setTimeout(1000); }); describe('unit test', () => { beforeEach(() => { jest.setTimeout(1000); }); }); jest.setTimeout(1000); describe('suite', () => { it('case', () => {}); }); jest.setTimeout(800); jest.setTimeout(800); jest.setTimeout(900); import { jest } from '@jest/globals'; { jest.setTimeout(800); } ``` Examples of **correct** code for this rule: ```javascript jest.setTimeout(500); test('test test', () => { // do some stuff }); ``` ```javascript jest.setTimeout(1000); describe('test bar bar', () => { it('test-description', () => { // test logic }); }); ``` ```javascript jest.setTimeout(1000); window.setTimeout(60000); setTimeout(1000); ``` ## Original Documentation - [eslint-plugin-jest: no-confusing-set-timeout](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-confusing-set-timeout.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-confusing-set-timeout.ts) --- url: /rules/jest/no-deprecated-functions.md --- # no-deprecated-functions [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-deprecated-functions': 'error', }, }, ]); ``` ## Rule Details Jest sometimes deprecates globals and `jest` helpers in favor of newer APIs. This rule flags **calls** to those deprecated members and reports a replacement. A **fix** rewrites the callee to the suggested API; bracket-style access is preserved (for example `jest['genMockFromModule']` becomes `jest['createMockFromModule']`). Which names are considered deprecated **depends on the Jest version** rslint uses for the file (from `settings.jest.version` or the resolved `package.json` dependency). A symbol is only reported once your configured major version is at least the version that deprecated it: | Deprecated | Replacement | Starting at Jest major | | -------------------------- | --------------------------- | ---------------------- | | `jest.resetModuleRegistry` | `jest.resetModules` | 15 | | `jest.addMatchers` | `expect.extend` | 17 | | `require.requireMock` | `jest.requireMock` | 21 | | `require.requireActual` | `jest.requireActual` | 21 | | `jest.runTimersToTime` | `jest.advanceTimersByTime` | 22 | | `jest.genMockFromModule` | `jest.createMockFromModule` | 26 | If the resolved Jest version is too old for any of these deprecations, the rule does not report them. Examples of **incorrect** code for this rule (assuming a Jest version where the corresponding API is deprecated): ```js jest.resetModuleRegistry(); jest.addMatchers({}); require.requireMock('a'); require.requireActual('a'); jest.runTimersToTime(1000); jest.genMockFromModule('m'); ``` Examples of **correct** code for this rule: ```js jest.resetModules(); expect.extend({}); jest.requireMock('a'); jest.requireActual('a'); jest.advanceTimersByTime(1000); jest.createMockFromModule('m'); ``` ## Original Documentation - [eslint-plugin-jest: no-deprecated-functions](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-deprecated-functions.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-deprecated-functions.ts) --- url: /rules/jest/no-disabled-tests.md --- # no-disabled-tests [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"warn"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-disabled-tests': 'error', }, }, ]); ``` ## Rule Details Disallow disabled or incomplete Jest tests. This rule reports skipped suites/tests via `.skip` and `x*` aliases, disallows `pending()` in test bodies, and flags `it()` / `test()` calls that omit the callback function (except `test.todo(...)`). It helps prevent accidentally committing tests that are skipped or not actually executed. Examples of **incorrect** code for this rule: ```javascript describe.skip('foo', () => {}); it.skip('foo', () => {}); test.skip('foo', () => {}); describe['skip']('bar', () => {}); it['skip']('bar', () => {}); test['skip']('bar', () => {}); xdescribe('foo', () => {}); xit('foo', () => {}); xtest('foo', () => {}); it('bar'); test('bar'); it('foo', () => { pending(); }); ``` Examples of **correct** code for this rule: ```javascript describe('foo', () => {}); it('foo', () => {}); test('foo', () => {}); describe.only('bar', () => {}); it.only('bar', () => {}); test.only('bar', () => {}); ``` ## Limitations The plugin looks at the literal function names within test code, so will not catch more complex examples of disabled tests, such as: ```javascript const testSkip = test.skip; testSkip('skipped test', () => {}); const myTest = test; myTest('does not have function body'); ``` ## Original Documentation - [eslint-plugin-jest: no-disabled-tests](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-disabled-tests.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-disabled-tests.ts) --- url: /rules/jest/no-done-callback.md --- # no-done-callback [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-done-callback': 'error', }, }, ]); ``` ## Rule Details Disallow using a `done`-style callback in Jest tests and hooks. Returning a Promise (or using `async`/`await`) is more reliable than relying on `done`, which can silently pass or time out when not invoked correctly. For non-`async` functions the rule reports `noDoneCallback` and suggests wrapping the body in `new Promise(done => ...)`. For `async` functions it reports `useAwaitInsteadOfCallback`. Examples of **incorrect** code for this rule: ```javascript beforeEach(done => { done(); }); test('myFunction()', done => { done(); }); test('myFunction()', async done => { await fetchData(); done(); }); ``` Examples of **correct** code for this rule: ```javascript beforeEach(() => { return setupUsTheBomb(); }); test('myFunction()', () => { expect(myFunction()).toBeTruthy(); }); test('myFunction()', async () => { const data = await fetchData(); expect(data).toBe('peanut butter'); }); ``` ## Original Documentation - [eslint-plugin-jest: no-done-callback](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-done-callback.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-done-callback.ts) --- url: /rules/jest/no-duplicate-hooks.md --- # no-duplicate-hooks [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-duplicate-hooks': 'error', }, }, ]); ``` ## Rule Details Disallow duplicate Jest lifecycle hooks **in the same scope**. Each `describe` block (including `describe.skip`, `describe.each`, and tagged `describe.each`) opens a new scope; registering the same hook name twice (`beforeEach`, `afterEach`, `beforeAll`, or `afterAll`) reports the **second and later** calls. - **Same scope**: hooks directly in a `describe` callback, or anywhere still inside that `describe` while it is active (including inside nested `test` / `it` bodies). - **Separate scopes**: nested `describe` blocks; sibling `describe` blocks; file top level (hooks outside any `describe` share one scope). - **Allowed**: one of each hook type in the same block; the same hook name again in a child or sibling `describe`. - **Imports**: `@jest/globals` hooks and renamed bindings (e.g. `afterEach as somethingElse`) count toward the same hook name. Examples of **incorrect** code for this rule: ```javascript describe('foo', () => { beforeEach(() => { // some setup }); beforeEach(() => { // some setup }); test('foo_test', () => { // some test }); }); // Nested describe scenario describe('foo', () => { beforeEach(() => { // some setup }); test('foo_test', () => { // some test }); describe('bar', () => { test('bar_test', () => { afterAll(() => { // some teardown }); afterAll(() => { // some teardown }); }); }); }); ``` Examples of **correct** code for this rule: ```javascript describe('foo', () => { beforeEach(() => { // some setup }); test('foo_test', () => { // some test }); }); // Nested describe scenario describe('foo', () => { beforeEach(() => { // some setup }); test('foo_test', () => { // some test }); describe('bar', () => { test('bar_test', () => { beforeEach(() => { // some setup }); }); }); }); ``` ## Original Documentation - [eslint-plugin-jest: no-duplicate-hooks](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-duplicate-hooks.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-duplicate-hooks.ts) --- url: /rules/jest/no-export.md --- # no-export [Added in v0.6.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.3) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-export': 'error', }, }, ]); ``` ## Rule Details Disallow exporting from files that contain Jest tests or suites. If a file has at least one `test` or `describe` (including equivalent aliases and chained forms), this rule reports any export in that file. Exporting from a test file is risky because importing that file runs its tests again in every consumer. That can duplicate test runs, slow down suites, and make failures harder to trace. Move shared helpers into a separate non-test module instead. This rule checks: - ES module exports (`export const`, `export default`, `export =`, and other `export` forms) - CommonJS-style assignments rooted at `module.exports` (including `module["exports"]` and deeply nested properties) Locally declared variables or parameters named `module` are not treated as the CommonJS global. Files that export but contain no Jest tests or suites are allowed. Examples of **incorrect** code for this rule: ```javascript export function myHelper() {} module.exports = function () {}; module.exports = { something: 'that should be moved to a non-test file', }; describe('a test', () => { expect(1).toBe(1); }); ``` Examples of **correct** code for this rule: ```javascript function myHelper() {} const myThing = { something: 'that can live here', }; describe('a test', () => { expect(1).toBe(1); }); ``` ## When Not To Use It Do not enable this rule on files that are not Jest test files. For shared test utilities that must export helpers, either disable the rule for those files or keep helpers in a dedicated module that does not define tests. ## Original Documentation - [eslint-plugin-jest: no-export](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-export.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-export.ts) --- url: /rules/jest/no-focused-tests.md --- # no-focused-tests [Added in v0.4.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.0) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-focused-tests': 'error', }, }, ]); ``` ## Rule Details Disallow focused Jest tests and suites. This rule reports usages like `.only` and focused aliases such as `fdescribe` / `fit`, because they cause only part of the test suite to run and can accidentally hide failing tests in CI or local verification. Examples of **incorrect** code for this rule: ```javascript describe.only('foo', () => {}); it.only('foo', () => {}); describe['only']('bar', () => {}); it['only']('bar', () => {}); test.only('foo', () => {}); test['only']('bar', () => {}); fdescribe('foo', () => {}); fit('foo', () => {}); fit.each` table `(); ``` Examples of **correct** code for this rule: ```javascript describe('foo', () => {}); it('foo', () => {}); describe.skip('bar', () => {}); it.skip('bar', () => {}); test('foo', () => {}); test.skip('bar', () => {}); it.each()(); it.each` table `(); test.each()(); test.each` table `(); ``` ## Original Documentation - [eslint-plugin-jest: no-focused-tests](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-focused-tests.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-focused-tests.ts) --- url: /rules/jest/no-hooks.md --- # no-hooks [Added in v0.3.4](https://github.com/web-infra-dev/rslint/releases/tag/v0.3.4) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-hooks': 'error', }, }, ]); ``` ## Rule Details Disallow Jest lifecycle hooks (`beforeEach`, `afterEach`, `beforeAll`, `afterAll`). This rule helps enforce tests that are isolated and explicit, instead of relying on shared setup/teardown behavior that can make test order and failures harder to reason about. Examples of **incorrect** code for this rule: ```javascript beforeEach(() => { setupDatabase(); }); afterAll(() => { cleanup(); }); ``` Examples of **correct** code for this rule: ```javascript test("works with explicit setup", () => { const db = createTestDatabase(); expect(runWith(db)).toBe(true); }); describe("suite", () => { test("case", () => { expect(1 + 1).toBe(2); }); }); ``` ## Options - First argument (optional): object with `allow` - `allow`: array of hook names that are allowed. Supported values: `beforeEach`, `afterEach`, `beforeAll`, `afterAll`. ## Original Documentation - [eslint-plugin-jest: no-hooks](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-hooks.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-hooks.ts) --- url: /rules/jest/no-identical-title.md --- # no-identical-title [Added in v0.5.3](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.3) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-identical-title': 'error', }, }, ]); ``` ## Rule Details Disallow the same title for two tests or two `describe` blocks **in the same scope**. Only **static** first arguments count (plain strings / simple templates); dynamic titles and `*.each` calls are ignored. Examples of **incorrect** code for this rule: ```javascript describe("foo", () => { it("bar", () => {}); it("bar", () => {}); }); describe("x", () => {}); describe("x", () => {}); ``` Examples of **correct** code for this rule: ```javascript describe("foo", () => { it("a", () => {}); it("b", () => {}); describe("foo", () => {}); // same as parent name, different scope }); test("x" + n, () => {}); test("x" + n, () => {}); // not static — skipped ``` ## Original Documentation - [eslint-plugin-jest: no-identical-title](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-identical-title.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-identical-title.ts) --- url: /rules/jest/no-interpolation-in-snapshots.md --- # no-interpolation-in-snapshots [Added in v0.7.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.0) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-interpolation-in-snapshots': 'error', }, }, ]); ``` ## Rule Details Disallow string interpolation inside inline snapshots. Interpolation prevents Jest from updating snapshots; instead, overload dynamic properties with a matcher via [property matchers](https://jestjs.io/docs/snapshot-testing#property-matchers). Examples of **incorrect** code for this rule: ```javascript expect(something).toMatchInlineSnapshot( `Object { property: ${interpolated} }`, ); expect(something).toMatchInlineSnapshot( { other: expect.any(Number) }, `Object { other: Any, property: ${interpolated} }`, ); expect(errorThrowingFunction).toThrowErrorMatchingInlineSnapshot( `${interpolated}`, ); ``` Examples of **correct** code for this rule: ```javascript expect(something).toMatchInlineSnapshot(); expect(something).toMatchInlineSnapshot( `Object { property: 1 }`, ); expect(something).toMatchInlineSnapshot( { property: expect.any(Date) }, `Object { property: Any }`, ); expect(errorThrowingFunction).toThrowErrorMatchingInlineSnapshot(); expect(errorThrowingFunction).toThrowErrorMatchingInlineSnapshot( `Error Message`, ); ``` ## Original Documentation - [eslint-plugin-jest: no-interpolation-in-snapshots](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-interpolation-in-snapshots.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-interpolation-in-snapshots.ts) --- url: /rules/jest/no-jasmine-globals.md --- # no-jasmine-globals [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-jasmine-globals': 'error', }, }, ]); ``` ## Rule Details Jest supports running without Jasmine globals. This rule disallows using Jasmine-specific globals and APIs in tests, and requires the Jest equivalents instead. Examples of **incorrect** code for this rule: ```typescript spyOn(obj, 'method'); fail(); pending(); jasmine.addMatchers(matchers); jasmine.createSpy(); jasmine.any(Number); jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000; ``` Examples of **correct** code for this rule: ```typescript jest.spyOn(obj, 'method'); throw new Error('failed'); test.skip('skipped for now', () => {}); expect.extend(matchers); jest.fn(); expect.any(Number); jest.setTimeout(5000); ``` ## Original Documentation - [eslint-plugin-jest: no-jasmine-globals](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-jasmine-globals.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-jasmine-globals.ts) --- url: /rules/jest/no-mocks-import.md --- # no-mocks-import [Added in v0.5.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.5.2) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-mocks-import': 'error', }, }, ]); ``` ## Rule Details When using `jest.mock`, tests should import from the original module path (for example `./x`), not from `./__mocks__/x`. Importing directly from a `__mocks__` path can leave you with more than one instance of the mocked module that are not the same reference, which is easy to misread and can make assertions fail in surprising ways. This rule reports `import` declarations and `require()` calls whose module specifier path contains a `__mocks__` segment. Examples of **incorrect** code for this rule: ```typescript import thing from './__mocks__/index'; require('./__mocks__/index'); ``` Examples of **correct** code for this rule: ```typescript import thing from 'thing'; require('thing'); ``` ## Original Documentation - [eslint-plugin-jest: no-mocks-import](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-mocks-import.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-mocks-import.ts) --- url: /rules/jest/no-restricted-jest-methods.md --- # no-restricted-jest-methods [Added in v0.7.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-restricted-jest-methods': 'error', }, }, ]); ``` ## Rule Details Disallow specific `jest` methods. Use this rule to ban particular `jest.*` calls that your team prefers to avoid, such as spies, mocks, or timer helpers, and optionally provide custom messages explaining the preferred alternative. Restrictions are matched against the **first member** of a `jest` call chain. For example, banning `fn` reports `jest.fn()` and `jest["fn"]()`, but not bare `jest` or `jest()` without a method name. By default, no `jest` methods are restricted. Examples of **incorrect** code for this rule with the following configuration: ```json { "jest/no-restricted-jest-methods": [ "error", { "advanceTimersByTime": null, "spyOn": "Don't use spies" } ] } ``` ```javascript jest.useFakeTimers(); it('calls the callback after 1 second via advanceTimersByTime', () => { // ... jest.advanceTimersByTime(1000); // ... }); test('plays video', () => { const spy = jest.spyOn(video, 'play'); // ... }); ``` ## Options - First argument (required to enable the rule): object whose keys are restricted `jest` method names and whose values are custom messages. - Keys are method names such as `fn`, `mock`, `spyOn`, or `advanceTimersByTime`. - Values are either a string (shown as the diagnostic message) or `null` (uses the default message: ``Use of `{method}` is disallowed``). Examples of **incorrect** code with `{ "mock": "Do not use mocks" }`: ```javascript jest.mock(); jest['mock'](); ``` Examples of **incorrect** code with `{ "fn": null }`: ```javascript jest.fn(); jest['fn'](); ``` Examples of **incorrect** code with `{ "advanceTimersByTime": null }`: ```javascript import { jest } from '@jest/globals'; jest.advanceTimersByTime(1000); ``` ## Original Documentation - [eslint-plugin-jest: no-restricted-jest-methods](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-restricted-jest-methods.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-restricted-jest-methods.ts) --- url: /rules/jest/no-restricted-matchers.md --- # no-restricted-matchers [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-restricted-matchers': 'error', }, }, ]); ``` ## Rule Details Disallow specific Jest matchers and modifiers in `expect()` chains. Use this rule to ban matchers or modifiers that your team prefers to avoid, and optionally suggest alternatives via custom messages. Restrictions are matched against the **start** of an `expect()` chain. For example, banning `not` reports any chain that begins with `.not`, while banning `not.toBe` only reports that specific prefix. To ban a matcher in every form (with or without `.not`, `.resolves`, or `.rejects`), list each permutation you want to disallow. By default, no matchers or modifiers are restricted. Examples of **incorrect** code for this rule with the following configuration: ```json { "jest/no-restricted-matchers": [ "error", { "toBeFalsy": null, "resolves": "Use `expect(await promise)` instead.", "toHaveBeenCalledWith": null, "not.toHaveBeenCalledWith": null, "resolves.toHaveBeenCalledWith": null, "rejects.toHaveBeenCalledWith": null, "resolves.not.toHaveBeenCalledWith": null, "rejects.not.toHaveBeenCalledWith": null } ] } ``` ```javascript it('is false', () => { // if this has a modifier (i.e. `not.toBeFalsy`), it would be considered fine expect(a).toBeFalsy(); }); it('resolves', async () => { // all uses of this modifier are disallowed, regardless of matcher await expect(myPromise()).resolves.toBe(true); }); describe('when an error happens', () => { it('does not upload the file', async () => { // all uses of this matcher are disallowed expect(uploadFileMock).not.toHaveBeenCalledWith('file.name'); }); }); ``` ## Options - First argument (required to enable the rule): object whose keys are restricted matcher chains and whose values are custom messages. - Keys are dot-separated chains such as `toBe`, `not.toBe`, `resolves.toBe`, or `resolves.not.toBe`. - Values are either a string (shown as the diagnostic message) or `null` (uses the default message: ``Use of `{chain}` is restricted``). Examples of **incorrect** code with `{ "toBe": "Prefer `toStrictEqual` instead" }`: ```javascript expect(a).toBe(b); expect(a)['toBe'](b); ``` Examples of **incorrect** code with `{ "not.toBe": null }`: ```javascript expect(a).not.toBe(b); ``` Examples of **correct** code with `{ "not.toBe": null }`: ```javascript expect(a).toBe(b); expect(a).resolves.not.toBe(b); ``` ## Original Documentation - [eslint-plugin-jest: no-restricted-matchers](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-restricted-matchers.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-restricted-matchers.ts) --- url: /rules/jest/no-standalone-expect.md --- # no-standalone-expect [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-standalone-expect': 'error', }, }, ]); ``` ## Rule Details Disallow using `expect` outside of `it` or `test` blocks. This rule reports `expect` calls that sit directly in a `describe` block, at module scope, or in other places where Jest will not run them as part of a test case. That helps catch assertions that look meaningful but never execute. `expect` inside a helper function is allowed, even when the helper is defined outside the `it`/`test` callback, because the assertion still runs when the helper is invoked from a test. Static `expect` APIs such as `expect.any()` and `expect.extend()` at module scope are also allowed. Examples of **incorrect** code for this rule: ```javascript describe('a test', () => { expect(1).toBe(1); }); describe('a test', () => { it('an it', () => { expect(1).toBe(1); }); expect(1).toBe(1); }); expect(1).toBe(1); expect.hasAssertions(); ``` Examples of **correct** code for this rule: ```javascript describe('a test', () => { it('an it', () => { expect(1).toBe(1); }); }); describe('a test', () => { const helper = () => { expect(1).toBe(1); }; it('an it', () => { helper(); }); }); expect.any(String); expect.extend({}); ``` ## Options - First argument (optional): object with `additionalTestBlockFunctions` - `additionalTestBlockFunctions`: array of function names that should also be treated as test blocks (for example `each.test`). ## Differences from ESLint rslint treats method, constructor, getter, and setter bodies as helper function scopes. An `expect` inside one of those bodies is therefore allowed, just like an assertion inside a function declaration or arrow-function helper. The upstream rule reports method and accessor bodies. rslint also balances the test scope opened by every recognized registration. As a result, a standalone assertion after a chained registration such as `test.only('case', () => {})` is still reported. The upstream rule can leave the registration scope open and miss that assertion. Every `expect..()` chain is treated as a static value constructor and allowed outside a test block. That covers the asymmetric matcher constructors jest supports, such as `expect.not.stringContaining('value')`, but also chains that assert rather than build a value, such as `expect.resolves.toBe(1)` and `expect.rejects.toThrow()`. The upstream rule allows a one-member chain only and reports all of these. `expect.assertions()` and `expect.hasAssertions()` are reported here as well. ## Original Documentation - [eslint-plugin-jest: no-standalone-expect](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-standalone-expect.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-standalone-expect.ts) --- url: /rules/jest/no-test-prefixes.md --- # no-test-prefixes [Added in v0.4.1](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.1) ## Configuration | Preset | Configured Value | | -------------------------------- | ---------------- | | ✅ jestPlugin.configs.recommended | `"error"` | ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-test-prefixes': 'error', }, }, ]); ``` ## Rule Details Jest lets you focus or skip tests in more than one way. You can use **`.only` and `.skip`** on the normal APIs—for example `it.only`, `test.only`, `describe.only`, `it.skip`, `test.skip`, and `describe.skip`. Alternatively, Jest supports **short `f` and `x` prefixes**: `fit`, `fdescribe`, `xit`, `xtest`, and `xdescribe`. This rule requires the **`.only` / `.skip`** style and reports calls that use the **`f` / `x`** spellings. Replacements are suggested automatically (for example `fit` → `it.only`, `xit` → `it.skip`). Examples of **incorrect** code for this rule: ```typescript fit('foo'); fdescribe('foo'); xit('foo'); xtest('foo'); xdescribe('foo'); ``` Examples of **correct** code for this rule: ```typescript it.only('foo'); test.only('foo'); describe.only('foo'); it.skip('foo'); test.skip('foo'); describe.skip('foo'); ``` ## Original Documentation - [eslint-plugin-jest: no-test-prefixes](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-test-prefixes.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-test-prefixes.ts) --- url: /rules/jest/no-unneeded-async-expect-function.md --- # no-unneeded-async-expect-function [Added in v0.6.5](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.5) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/no-unneeded-async-expect-function': 'error', }, }, ]); ``` ## Rule Details Disallow wrapping an expected promise in an unnecessary async function when using Jest promise assertions. Jest promise assertions can receive the promise directly: `await expect(doSomethingAsync()).rejects.toThrow()` or `await expect(doSomethingAsync()).resolves.toBe(value)`. Wrapping that call in `async () => { await doSomethingAsync(); }` is more verbose and makes the test harder to read without changing the assertion. This rule reports `expect()` calls whose first argument is an async function with a single awaited call expression. It is fixable: the async wrapper is replaced with the awaited call. Renamed `expect` bindings imported from `@jest/globals` are also recognized. Examples of **incorrect** code for this rule: ```js it('wrong1', async () => { await expect(async () => { await doSomethingAsync(); }).rejects.toThrow(); }); it('wrong2', async () => { await expect(async function () { await doSomethingAsync(); }).rejects.toThrow(); }); ``` Examples of **correct** code for this rule: ```js it('right1', async () => { await expect(doSomethingAsync()).rejects.toThrow(); }); ``` ## Differences from ESLint rslint also fixes equivalent concise arrow functions and parenthesized async function arguments, such as `expect(async () => await doSomethingAsync())` and `expect((async () => { await doSomethingAsync(); }))`. These shapes are handled as the same safe unwrap because tsgo preserves them explicitly in the AST. ## Original Documentation - [eslint-plugin-jest: no-unneeded-async-expect-function](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/no-unneeded-async-expect-function.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/no-unneeded-async-expect-function.ts) --- url: /rules/jest/padding-around-after-all-blocks.md --- # padding-around-after-all-blocks [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/padding-around-after-all-blocks': 'error', }, }, ]); ``` ## Rule Details Require a blank line before and after `afterAll` statements. No trailing blank line is required when the hook is the last statement in its scope. ## Incorrect ```js const database = createDatabase(); afterAll(() => database.close()); test('loads a user', loadUser); ``` ## Correct ```js const database = createDatabase(); afterAll(() => database.close()); test('loads a user', loadUser); ``` ## Autofix The rule inserts missing blank lines before and after `afterAll` statements. ## Original Documentation - [eslint-plugin-jest: padding-around-after-all-blocks](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/padding-around-after-all-blocks.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/padding-around-after-all-blocks.ts) --- url: /rules/jest/padding-around-after-each-blocks.md --- # padding-around-after-each-blocks [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/padding-around-after-each-blocks': 'error', }, }, ]); ``` ## Rule Details Require a blank line before and after `afterEach` statements. No trailing blank line is required when the hook is the last statement in its scope. ## Incorrect ```js const database = createDatabase(); afterEach(() => database.reset()); test('loads a user', loadUser); ``` ## Correct ```js const database = createDatabase(); afterEach(() => database.reset()); test('loads a user', loadUser); ``` ## Autofix The rule inserts missing blank lines before and after `afterEach` statements. ## Original Documentation - [eslint-plugin-jest: padding-around-after-each-blocks](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/padding-around-after-each-blocks.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/padding-around-after-each-blocks.ts) --- url: /rules/jest/padding-around-all.md --- # padding-around-all [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/padding-around-all': 'error', }, }, ]); ``` ## Rule Details Require blank lines around Jest lifecycle hooks, suites, tests, and assertion groups. This rule combines all seven `padding-around-*` rules in one configuration entry. Consecutive `expect` statements form one group and do not require blank lines between them. ## Incorrect ```js const database = createDatabase(); beforeAll(() => database.connect()); test('loads a user', () => { const user = loadUser(); expect(user.name).toBe('Ada'); }); ``` ## Correct ```js const database = createDatabase(); beforeAll(() => database.connect()); test('loads a user', () => { const user = loadUser(); expect(user.name).toBe('Ada'); }); ``` ## Autofix The rule inserts missing blank lines around matching statements and assertion groups. ## Original Documentation - [eslint-plugin-jest: padding-around-all](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/padding-around-all.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/padding-around-all.ts) --- url: /rules/jest/padding-around-before-all-blocks.md --- # padding-around-before-all-blocks [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/padding-around-before-all-blocks': 'error', }, }, ]); ``` ## Rule Details Require a blank line before and after `beforeAll` statements. No trailing blank line is required when the hook is the last statement in its scope. ## Incorrect ```js const database = createDatabase(); beforeAll(() => database.connect()); test('loads a user', loadUser); ``` ## Correct ```js const database = createDatabase(); beforeAll(() => database.connect()); test('loads a user', loadUser); ``` ## Autofix The rule inserts missing blank lines before and after `beforeAll` statements. ## Original Documentation - [eslint-plugin-jest: padding-around-before-all-blocks](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/padding-around-before-all-blocks.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/padding-around-before-all-blocks.ts) --- url: /rules/jest/padding-around-before-each-blocks.md --- # padding-around-before-each-blocks [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/padding-around-before-each-blocks': 'error', }, }, ]); ``` ## Rule Details Require a blank line before and after `beforeEach` statements. No trailing blank line is required when the hook is the last statement in its scope. ## Incorrect ```js const database = createDatabase(); beforeEach(() => database.reset()); test('loads a user', loadUser); ``` ## Correct ```js const database = createDatabase(); beforeEach(() => database.reset()); test('loads a user', loadUser); ``` ## Autofix The rule inserts missing blank lines before and after `beforeEach` statements. ## Original Documentation - [eslint-plugin-jest: padding-around-before-each-blocks](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/padding-around-before-each-blocks.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/padding-around-before-each-blocks.ts) --- url: /rules/jest/padding-around-describe-blocks.md --- # padding-around-describe-blocks [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/padding-around-describe-blocks': 'error', }, }, ]); ``` ## Rule Details Require a blank line before and after Jest suite statements, including `describe`, `fdescribe`, and `xdescribe`. No trailing blank line is required when the suite is the last statement in its scope. ## Incorrect ```js const account = createAccount(); describe('account', () => {}); describe.skip('archived account', () => {}); ``` ## Correct ```js const account = createAccount(); describe('account', () => {}); describe.skip('archived account', () => {}); ``` ## Autofix The rule inserts missing blank lines before and after suite statements. ## Original Documentation - [eslint-plugin-jest: padding-around-describe-blocks](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/padding-around-describe-blocks.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/padding-around-describe-blocks.ts) --- url: /rules/jest/padding-around-expect-groups.md --- # padding-around-expect-groups [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/padding-around-expect-groups': 'error', }, }, ]); ``` ## Rule Details Require a blank line around each consecutive group of `expect` statements. Adjacent assertions remain together without blank lines between them. Awaited `expect` statements are included. ## Incorrect ```js const account = loadAccount(); expect(account.name).toBe('Ada'); expect(account.active).toBe(true); saveAccount(account); ``` ## Correct ```js const account = loadAccount(); expect(account.name).toBe('Ada'); expect(account.active).toBe(true); saveAccount(account); ``` ## Autofix The rule inserts missing blank lines at assertion-group boundaries. ## Original Documentation - [eslint-plugin-jest: padding-around-expect-groups](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/padding-around-expect-groups.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/padding-around-expect-groups.ts) --- url: /rules/jest/padding-around-test-blocks.md --- # padding-around-test-blocks [Added in v0.9.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.9.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/padding-around-test-blocks': 'error', }, }, ]); ``` ## Rule Details Require a blank line before and after Jest test statements, including `test`, `it`, `fit`, `xit`, and `xtest`. No trailing blank line is required when the test is the last statement in its scope. ## Incorrect ```js const account = createAccount(); test('saves the account', saveAccount); it('loads the account', loadAccount); ``` ## Correct ```js const account = createAccount(); test('saves the account', saveAccount); it('loads the account', loadAccount); ``` ## Autofix The rule inserts missing blank lines before and after test statements. ## Original Documentation - [eslint-plugin-jest: padding-around-test-blocks](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/padding-around-test-blocks.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/padding-around-test-blocks.ts) --- url: /rules/jest/prefer-called-with.md --- # prefer-called-with [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/prefer-called-with': 'error', }, }, ]); ``` ## Rule Details The `toHaveBeenCalled()` and `toBeCalled()` matchers assert that a mock function has been called one or more times, without checking the arguments passed. The assertion is stronger when arguments are also validated using `toHaveBeenCalledWith()` or `toBeCalledWith()`. When some arguments are difficult to check, using generic matchers such as `expect.anything()` at least enforces the number and position of arguments. Examples of **incorrect** code for this rule: ```js expect(someFunction).toBeCalled(); expect(someFunction).toHaveBeenCalled(); ``` Examples of **correct** code for this rule: ```js expect(noArgsFunction).toHaveBeenCalledWith(); expect(roughArgsFunction).toHaveBeenCalledWith( expect.anything(), expect.any(Date), ); expect(anyArgsFunction).toHaveBeenCalledTimes(1); expect(uncalledFunction).not.toHaveBeenCalled(); ``` ## Original Documentation - [eslint-plugin-jest: prefer-called-with](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/prefer-called-with.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/prefer-called-with.ts) --- url: /rules/jest/prefer-comparison-matcher.md --- # prefer-comparison-matcher [Added in v0.7.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.7.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/prefer-comparison-matcher': 'error', }, }, ]); ``` ## Rule Details Prefer Jest's built-in comparison matchers over wrapping a relational operator in `expect(...).toBe(true)` (or `toEqual` / `toStrictEqual`). Assertions such as `expect(x > 5).toBe(true)` are harder to read and produce less helpful failure output than `expect(x).toBeGreaterThan(5)`. This rule reports `expect(left OP right).(true|false)` patterns that can use one of these matchers instead: - `toBeGreaterThan` - `toBeGreaterThanOrEqual` - `toBeLessThan` - `toBeLessThanOrEqual` Violations are automatically fixed where possible. Examples of **incorrect** code for this rule: ```js expect(x > 5).toBe(true); expect(x < 7).not.toEqual(true); expect(x <= y).toStrictEqual(true); ``` Examples of **correct** code for this rule: ```js expect(x).toBeGreaterThan(5); expect(x).not.toBeLessThanOrEqual(7); expect(x).toBeLessThanOrEqual(y); // special case - see below expect(x < 'Carl').toBe(true); ``` **String comparisons.** These matchers only accept numbers and bigints. The rule assumes operands are numeric and does not report comparisons that involve string literals (for example, `expect(x < 'Carl').toBe(true)`). If you intentionally compare strings with `>` or `<`, disable the rule for that line—otherwise the fix rewrites the assertion to a numeric matcher and fails at runtime: ```js // rslint-disable-next-line jest/prefer-comparison-matcher expect(myName > theirName).toBe(true); ``` Negative expectations use the opposite comparison operator, matching eslint-plugin-jest. This assumes neither operand is `NaN`: for example, `expect(NaN > 1).toBe(false)` passes, but its fix `expect(NaN).toBeLessThanOrEqual(1)` fails. Disable the rule for comparisons that may involve `NaN` and need to retain that behavior. ## Differences from ESLint - Parentheses around comma-expression operands are preserved, so moving `(read(), value)` does not turn it into multiple arguments. - Type assertions on boolean expectations are removed with the boolean, rather than being applied to the replacement operand. For example, `toBe(true as const)` does not become `toBeGreaterThan(limit as const)`. - String literals inside TypeScript type assertions are excluded just like unwrapped string literals. - Only one diagnostic is emitted for the equality matcher when further calls follow it, such as `expect(a > b).toBe(true).toString()`. - Assertions with parentheses around the receiver, such as `(expect(a > b)).toBe(true)`, are reported without an autofix to avoid removing only the closing parentheses. ## Original Documentation - [eslint-plugin-jest: prefer-comparison-matcher](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.1/docs/rules/prefer-comparison-matcher.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.1/src/rules/prefer-comparison-matcher.ts) --- url: /rules/jest/prefer-each.md --- # prefer-each [Added in v0.6.0](https://github.com/web-infra-dev/rslint/releases/tag/v0.6.0) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/prefer-each': 'error', }, }, ]); ``` ## Rule Details Prefer `.each` over wrapping `describe`/`test`/`it` in native `for` loops, for clearer output and easier filtering. Loops inside a test function are ignored. Examples of **incorrect** code for this rule: ```js for (const number of getNumbers()) { it('is greater than five', function () { expect(number).toBeGreaterThan(5); }); } for (const [input, expected] of data) { beforeEach(() => setupSomething(input)); test(`results in ${expected}`, () => { expect(doSomething()).toBe(expected); }); } ``` Examples of **correct** code for this rule: ```js it.each(getNumbers())( 'only returns numbers that are greater than seven', number => { expect(number).toBeGreaterThan(7); }, ); describe.each(data)('when input is %s', ([input, expected]) => { beforeEach(() => setupSomething(input)); test(`results in ${expected}`, () => { expect(doSomething()).toBe(expected); }); }); // we don't warn on loops _in_ test functions because those typically involve // complex setup that is better done in the test function itself it('returns numbers that are greater than five', () => { for (const number of getNumbers()) { expect(number).toBeGreaterThan(5); } }); ``` ## Original Documentation - [eslint-plugin-jest: prefer-each](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/docs/rules/prefer-each.md) - [Source code](https://github.com/jest-community/eslint-plugin-jest/blob/v29.16.0/src/rules/prefer-each.ts) --- url: /rules/jest/prefer-ending-with-an-expect.md --- # prefer-ending-with-an-expect [Added in v0.8.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.8.2) ## Configuration ```ts title=rslint.config.ts import { defineConfig, jestPlugin } from '@rslint/core'; export default defineConfig([ jestPlugin.configs.recommended, { rules: { 'jest/prefer-ending-with-an-expect': 'error', }, }, ]); ``` ## Rule Details Prefer ending a test body with an assertion. A test whose last statement is not an `expect` (or another configured assert function) often indicates unfinished work that may pass silently. Examples of **incorrect** code for this rule: ```javascript it('lets me change the selected option', () => { const container = render(MySelect, { props: { options: [1, 2, 3], selected: 1 }, }); expect(container).toBeDefined(); expect(container.toHTML()).toContain('