Skip to content
Sarj Code Standards

TypeScript

95 rules oxlint@1.91.0

Complete effective rule inventory.

Docs

Rules

31 rules on this page · 95 total

  • typescript/no-useless-empty-export

    Disallow empty exports that don't change anything in a module file

    : error in All TypeScript contexts
    Autofix available
  • typescript/no-wrapper-object-types

    Disallow using confusing built-in primitive class wrappers

    : error in All TypeScript contexts
    Autofix available
  • typescript/non-nullable-type-assertion-style

    Enforce non-null assertions over explicit type assertions

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    Autofix available; suggestions available
  • typescript/only-throw-error

    Disallow throwing non-Error values as exceptions

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    No autofix
  • typescript/prefer-as-const

    Enforce the use of as const over literal type

    : error in All TypeScript contexts
    Autofix available
  • typescript/prefer-find

    Enforce the use of Array.prototype.find() over Array.prototype.filter() followed by [0] when looking for a single result

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    Autofix available; suggestions available
  • typescript/prefer-for-of

    Enforce the use of for-of loop over the standard for loop where possible

    : error in All TypeScript contexts
    No autofix
  • typescript/prefer-function-type

    Enforce using function types instead of interfaces with call signatures

    : error in All TypeScript contexts
    Autofix available
  • typescript/prefer-includes

    Enforce includes method over indexOf method

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    Autofix available
  • typescript/prefer-literal-enum-member

    Require all enum members to be literal values

    : error in All TypeScript contexts
    No autofix
  • typescript/prefer-namespace-keyword

    Require using namespace keyword over module keyword to declare custom TypeScript modules

    : error in All TypeScript contexts
    Autofix available
  • typescript/prefer-nullish-coalescing

    Enforce using the nullish coalescing operator instead of logical assignments or chaining

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    Autofix available
  • typescript/prefer-optional-chain

    Enforce using concise optional chain expressions instead of chained logical ands, negated logical ors, or empty objects

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    Autofix available; suggestions available
  • typescript/prefer-promise-reject-errors

    Require using Error objects as Promise rejection reasons

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    No autofix
  • typescript/prefer-readonly

    Require private members to be marked as readonly if they're never modified outside of the constructor

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    Autofix available
  • typescript/prefer-reduce-type-parameter

    Enforce using type parameter when calling Array#reduce instead of using a type assertion

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    Autofix available
  • typescript/prefer-regexp-exec

    Enforce RegExp#exec over String#match if no global flag is provided

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    No autofix
  • typescript/prefer-return-this-type

    Enforce that this is used when only this type is returned

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    Autofix available
  • typescript/prefer-string-starts-ends-with

    Enforce using String#startsWith and String#endsWith over other equivalent methods of checking substrings

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    Autofix available
  • typescript/related-getter-setter-pairs

    Enforce that get() types should be assignable to their equivalent set() type

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    No autofix
  • typescript/require-array-sort-compare

    Require Array#sort and Array#toSorted calls to always provide a compareFunction

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    No autofix
  • typescript/require-await

    Disallow async functions which do not return promises and have no await expression

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, Design-system React source
    Autofix available; suggestions available
  • typescript/restrict-plus-operands

    Require both operands of addition to be the same type and be bigint, number, or string

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    No autofix
  • typescript/restrict-template-expressions

    Enforce template literal expressions to be of string type

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    No autofix
  • typescript/return-await

    Enforce consistent awaiting of returned promises

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    Autofix available; suggestions available
  • typescript/strict-void-return

    Disallow passing a value-returning function in a position accepting a void function

    : warning in TypeScript source, JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests
    No autofix
  • typescript/switch-exhaustiveness-check

    Require switch-case statements to be exhaustive

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    No autofix; suggestions available
  • typescript/triple-slash-reference

    Disallow certain triple slash directives in favor of ES6-style import declarations

    : error in All TypeScript contexts
    No autofix
  • typescript/unbound-method

    Enforce unbound methods are called with their expected scope

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    No autofix
  • typescript/unified-signatures

    Disallow two overloads that could be unified into one with a union or an optional/rest parameter

    : error in All TypeScript contexts
    No autofix
  • typescript/use-unknown-in-catch-callback-variable

    Enforce typing arguments in Promise rejection callbacks as unknown

    : error in TypeScript source, React source, JavaScript source, React JavaScript source, TypeScript tests, Bun tests, Playwright end-to-end tests, Design-system React source
    Autofix available; suggestions available