General Logic & Style
Rules for code quality, control flow, and common pitfalls. Browse all 37 rules in this category.
Showing 37 rules
No Recursive
no-recursiveDisallow recursive function calls to prevent stack overflow.
- Suggestion
Directive Disable Enable Pair
directive-disable-enable-pairRequire a matching enable comment for every `oxlint-disable` or `eslint-disable` block directive.
- Suggestion
Directive No Aggregating Enable
directive-no-aggregating-enableDisallow aggregating `oxlint-enable` or `eslint-enable` comments across multiple disable directives.
- Suggestion
Directive No Duplicate Disable
directive-no-duplicate-disableDisallow duplicate `oxlint-disable` or `eslint-disable` comments.
- Problem
Directive No Restricted Disable
directive-no-restricted-disableDisallow `oxlint-disable` or `eslint-disable` comments for configured rules.
- Suggestion
Directive No Unlimited Disable
directive-no-unlimited-disableDisallow `oxlint-disable` or `eslint-disable` comments without rule names.
- Suggestion
Directive No Unused Enable
directive-no-unused-enableDisallow unused `oxlint-enable` or `eslint-enable` comments.
- Suggestion
Directive No Use
directive-no-useDisallow block ESLint/Oxlint directive comments.
- Suggestion
Directive Require Description
directive-require-descriptionRequire descriptions for `oxlint` and `eslint` disable/enable directives.
- Suggestion
No Async Constructor
no-async-constructorDisallow asynchronous operations inside class constructors. Constructors return immediately, so async work causes race conditions, unhandled rejections, and incomplete object states.
- Problem
No Commented Code
no-commented-codeDisallow commented-out code
- Suggestion
- Editor suggestions
No Constant Condition With Break
no-constant-condition-with-breakDisallow constant conditions, but allow constant loops that include loop exits such as break, return, or configured calls.
- Problem
Isolated Functions
isolated-functionsPrevent usage of variables from outside the scope of isolated functions.
- Problem
No Dead Store
no-dead-storeDisallow assignments whose value is never read.
- Problem
No Discarded Rejection
no-discarded-rejectionWarn when a Promise rejection handler explicitly discards the failure and resolves to undefined.
- Suggestion
No Error
no-errorUse throw instead of error().
- Problem
No Filter Map Chain
no-filter-map-chainDisallow map(...) directly after filter(...).
- Suggestion
No Floating Point Equality
no-floating-point-equalityDisallow exact comparisons involving inexact floating-point values.
- Problem
No Identity Map
no-identity-mapDisallow pointless identity `.map()` calls that return the parameter unchanged
- Suggestion
- Automatic fix
No Increment Decrement
no-increment-decrementDisallow standalone `++` and `--` statements and for-loop update clauses.
- Suggestion
- Automatic fix
No Loop Iterable Mutation
no-loop-iterable-mutationDisallow mutating a loop iterable during iteration.
- Problem
No Restricted Property Assignment
no-restricted-property-assignmentDisallow assignment to restricted object properties.
- Problem
No Trivial Assertions
no-trivial-assertionsDisallow assertions that always succeed or compare against freshly created values.
- Problem
No Unused Imports
no-unused-importsDisallow unused imports
- Problem
- Automatic fix
No Use Of Empty Return Value
no-use-of-empty-return-valueDisallow using the return value of functions that do not return anything.
- Problem
No Useless Constants
no-useless-constantsDisallow constants that do not add value.
- Problem
- Automatic fix
No Useless Empty String Comparison
no-useless-empty-string-comparisonDisallow equality comparisons against an empty-string literal.
- Suggestion
- Automatic fix and editor suggestions
No Variadic Spread
no-variadic-spreadDisallow spreading a potentially unbounded array into a variadic call, because every element becomes a stack-allocated argument.
- Problem
Only Type Imports
only-type-importsRequire all imports to be type-only imports. Benchmarks cannot import non-types because the benchmarker plugin will throw an error.
- Problem
Prefer Class Properties
prefer-class-propertiesPrefer class properties to assignment of literals in constructors.
- Suggestion
Prefer Early Return
prefer-early-returnPrefer early returns over full-body conditional wrapping.
- Suggestion
Prefer Expect Assertions
prefer-expect-assertionsEnforce expect assertion guards in tests and prefer expect.assertions(n) over expect.hasAssertions() when the count is known.
- Suggestion
- Automatic fix and editor suggestions
Prefer Module Scope Constants
prefer-module-scope-constantsPrefer screaming snake case constants at module scope or the allowed top-level wrapper scope.
- Suggestion
Require Paired Calls
require-paired-callsEnforces balanced opener/closer function calls across all execution paths
- Problem
Require Switch Case Braces
require-switch-case-bracesRequire braces around switch case bodies selected by line span or statement count.
- Problem
- Automatic fix
Require Throw Error Capture
require-throw-error-captureRequire 'Error.captureStackTrace' before directly throwing new Error instances in named functions.
- Suggestion
- Automatic fix
Require Unicode Regex
require-unicode-regexRequire the 'u' or 'v' unicode flag on calls named regex().
- Problem