Skip to content

Repository files navigation




Contents

About

Strict ESLint presets for modern TypeScript.

Features

  • Enforces type safety
  • Prohibits potentially unsafe patterns
  • Encourages modern syntax
  • Encourages more accurate Zod (eslint-plugin-zod)
  • Encourages the use of arrow functions
  • Encourages the use of try/catch
  • Bans var and warns about proper use of const and let
  • Disallows interfaces, using only types
  • Requires explicit readonly and accessibility modifiers in classes
  • ...and much more!

Installation

You can install it as follows.

ⓘ Note

During installation, these packages are installed automatically: @eslint/js, @types/node, eslint, eslint-plugin-prefer-arrow-functions, eslint-plugin-zod, jiti, typescript, and typescript-eslint.

Therefore, you do not need to install these packages separately. If they are already listed in your project's dependencies, keeping them is unnecessary and they can be safely removed.

# NPM
npm add rulint

# PNPM
pnpm add rulint

# Yarn
yarn add rulint

# Bun
bun add rulint

# Deno
deno add rulint

Documentation

Tree

Briefly as follows.

rulint

└── rulint(options?)

rulint/types

├── type ESLintConfig
└── type RulintOptions

Import

Briefly as follows.

📁 ./eslint.config.ts

import { rulint } from 'rulint';

export default rulint();

Methods

rulint(options?)

ESLint configuration generated by Rulint.

Parameter Type Default Description
options? RulintOptions rulint_options Rulint options.

returns ESLintConfig[]

Example:

export default rulint();

Recommended use

Suggested uses are as follows. We recommend using Prettier.

📁 ./eslint.config.ts

import { rulint } from 'rulint';

export default rulint();

📁 ./tsconfig.json

{
  "compilerOptions": {
    "strict": true,

    "outDir": "./dist",
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "lib": ["ESNext", "DOM"],

    "types": ["*"],
    "typeRoots": ["./src/types", "./node_modules/@types"]
  }
}

📁 ./.prettierrc.json

{
  "semi": true,
  "singleQuote": true,

  "printWidth": 1000,
  "tabWidth": 2,

  "trailingComma": "none"
}

Types

Type
ESLintConfig
RulintOptions

Rules

Rulint adds 203 rules to your workspace.

Rule Description
arrow-body-style Require braces around arrow function bodies.
curly Enforce consistent brace style for all control statements.
dot-notation Enforce dot notation whenever possible.
eqeqeq Require the use of === and !==.
for-direction Enforce for loop update clause moving the counter in the right direction.
no-array-constructor Disallow Array constructors.
no-async-promise-executor Disallow using an async function as a Promise executor.
no-case-declarations Disallow lexical declarations in case clauses.
no-compare-neg-zero Disallow comparing against -0.
no-cond-assign Disallow assignment operators in conditional expressions.
no-constant-binary-expression Disallow expressions where the operation doesn't affect the value.
no-constant-condition Disallow constant expressions in conditions.
no-control-regex Disallow control characters in regular expressions.
no-debugger Disallow the use of debugger.
no-delete-var Disallow deleting variables.
no-dupe-else-if Disallow duplicate conditions in if-else-if chains.
no-duplicate-case Disallow duplicate case labels.
no-duplicate-imports Disallow duplicate module imports.
no-empty-character-class Disallow empty character classes in regular expressions.
no-empty-function Disallow empty functions.
no-empty-pattern Disallow empty destructuring patterns.
no-empty-static-block Disallow empty static blocks.
no-empty Disallow empty block statements.
no-eval Disallow the use of eval().
no-ex-assign Disallow reassigning exceptions in catch clauses.
no-extra-boolean-cast Disallow unnecessary boolean casts.
no-fallthrough Disallow fallthrough of case statements.
no-global-assign Disallow assignments to native objects or read-only global variables.
no-implied-eval Disallow the use of eval()-like methods.
no-invalid-regexp Disallow invalid regular expression strings in RegExp constructors.
no-irregular-whitespace Disallow irregular whitespace.
no-loss-of-precision Disallow literal numbers that lose precision.
no-misleading-character-class Disallow characters which are made with multiple code points in character class syntax.
no-new-func Disallow new operators with the Function object.
no-new-wrappers Disallow new operators with the String, Number, and Boolean objects.
no-nonoctal-decimal-escape Disallow \8 and \9 escape sequences in string literals.
no-object-constructor Disallow calls to the Object constructor without an argument.
no-octal Disallow octal literals.
no-prototype-builtins Disallow calling some Object.prototype methods directly on objects.
no-regex-spaces Disallow multiple spaces in regular expressions.
no-restricted-imports Disallow specified modules when loaded by import.
no-restricted-syntax Disallow specified syntax.
no-return-await Disallow unnecessary return await.
no-self-assign Disallow assignments where both sides are exactly the same.
no-shadow-restricted-names Disallow identifiers from shadowing restricted names.
no-sparse-arrays Disallow sparse arrays.
no-throw-literal Disallow throwing literals as exceptions.
no-unassigned-vars Disallow let or var variables that are read but never assigned.
no-unexpected-multiline Disallow confusing multiline expressions.
no-unsafe-finally Disallow control flow statements in finally blocks.
no-unsafe-optional-chaining Disallow use of optional chaining in contexts where the undefined value is not allowed.
no-unused-expressions Disallow unused expressions.
no-unused-labels Disallow unused labels.
no-unused-private-class-members Disallow unused private class members.
no-unused-vars Disallow unused variables.
no-useless-assignment Disallow variable assignments when the value is not used.
no-useless-backreference Disallow useless backreferences in regular expressions.
no-useless-call Disallow unnecessary calls to .call() and .apply().
no-useless-catch Disallow unnecessary catch clauses.
no-useless-computed-key Disallow unnecessary computed property keys in objects and classes.
no-useless-concat Disallow unnecessary concatenation of literals or template literals.
no-useless-constructor Disallow unnecessary constructors.
no-useless-escape Disallow unnecessary escape characters.
no-useless-rename Disallow renaming import, export, and destructured assignments to the same name.
no-useless-return Disallow redundant return statements.
no-var Require let or const instead of var.
object-shorthand Require or disallow method and property shorthand syntax for object literals.
one-var Enforce variables to be declared either together or separately in functions.
prefer-const Require const declarations for variables that are never reassigned after declared.
prefer-promise-reject-errors Require using Error objects as Promise rejection reasons.
prefer-rest-params Require rest parameters instead of arguments.
prefer-spread Require spread operators instead of .apply().
prefer-template Require template literals instead of string concatenation.
preserve-caught-error Disallow losing originally caught error when re-throwing custom errors.
require-await Disallow async functions which have no await expression.
require-yield Require generator functions to contain yield.
use-isnan Require calls to isNaN() when checking for NaN.
valid-typeof Enforce comparing typeof expressions against valid strings.
@typescript-eslint/adjacent-overload-signatures Require that function overload signatures be consecutive.
@typescript-eslint/array-type Require consistently using either T[] or Array<T> for arrays.
@typescript-eslint/await-thenable Disallow awaiting a value that is not a Thenable.
@typescript-eslint/ban-ts-comment Disallow @ts-<directive> comments or require descriptions after directives.
@typescript-eslint/ban-tslint-comment Disallow // tslint:<rule-flag> comments.
@typescript-eslint/class-literal-property-style Enforce that literals on classes are exposed in a consistent style.
@typescript-eslint/consistent-generic-constructors Enforce specifying generic type arguments on type annotation or constructor name of a constructor call.
@typescript-eslint/consistent-indexed-object-style Require or disallow the Record type.
@typescript-eslint/consistent-type-assertions Enforce consistent usage of type assertions.
@typescript-eslint/consistent-type-definitions Enforce type definitions to consistently use either interface or type.
@typescript-eslint/consistent-type-exports Enforce consistent usage of type exports.
@typescript-eslint/consistent-type-imports Enforce consistent usage of type imports.
@typescript-eslint/dot-notation Enforce dot notation whenever possible.
@typescript-eslint/explicit-member-accessibility Require explicit accessibility modifiers on class properties and methods.
@typescript-eslint/no-array-constructor Disallow generic Array constructors.
@typescript-eslint/no-array-delete Disallow using the delete operator on array values.
@typescript-eslint/no-base-to-string Require .toString() and .toLocaleString() to only be called on objects which provide useful information when stringified.
@typescript-eslint/no-confusing-non-null-assertion Disallow non-null assertion in locations that may be confusing.
@typescript-eslint/no-confusing-void-expression Require expressions of type void to appear in statement position.
@typescript-eslint/no-deprecated Disallow using code marked as @deprecated.
@typescript-eslint/no-duplicate-enum-values Disallow duplicate enum member values.
@typescript-eslint/no-duplicate-type-constituents Disallow duplicate constituents of union or intersection types.
@typescript-eslint/no-dynamic-delete Disallow using the delete operator on computed key expressions.
@typescript-eslint/no-empty-function Disallow empty functions.
@typescript-eslint/no-empty-object-type Disallow accidentally using the "empty object" type.
@typescript-eslint/no-explicit-any Disallow the any type.
@typescript-eslint/no-extra-non-null-assertion Disallow extra non-null assertions.
@typescript-eslint/no-extraneous-class Disallow classes used as namespaces.
@typescript-eslint/no-floating-promises Require Promise-like statements to be handled appropriately.
@typescript-eslint/no-for-in-array Disallow iterating over an array with a for-in loop.
@typescript-eslint/no-implied-eval Disallow the use of eval()-like functions.
@typescript-eslint/no-inferrable-types Disallow explicit type declarations for variables or parameters initialized to a number, string, or boolean.
@typescript-eslint/no-invalid-void-type Disallow void type outside of generic or return types.
@typescript-eslint/no-meaningless-void-operator Disallow the void operator except when used to discard a value.
@typescript-eslint/no-misused-new Enforce valid definition of new and constructor.
@typescript-eslint/no-misused-promises Disallow Promises in places not designed to handle them.
@typescript-eslint/no-misused-spread Disallow using the spread operator when it might cause unexpected behavior.
@typescript-eslint/no-mixed-enums Disallow enums from having both number and string members.
@typescript-eslint/no-namespace Disallow TypeScript namespaces.
@typescript-eslint/no-non-null-asserted-nullish-coalescing Disallow non-null assertions in the left operand of a nullish coalescing operator.
@typescript-eslint/no-non-null-asserted-optional-chain Disallow non-null assertions after an optional chain expression.
@typescript-eslint/no-non-null-assertion Disallow non-null assertions using the ! postfix operator.
@typescript-eslint/no-redundant-type-constituents Disallow members of unions and intersections that do nothing or override type information.
@typescript-eslint/no-require-imports Disallow invocation of require().
@typescript-eslint/no-this-alias Disallow aliasing this.
@typescript-eslint/no-unnecessary-boolean-literal-compare Disallow unnecessary equality comparisons against boolean literals.
@typescript-eslint/no-unnecessary-condition Disallow conditionals where the type is always truthy or always falsy.
@typescript-eslint/no-unnecessary-template-expression Disallow unnecessary template expressions.
@typescript-eslint/no-unnecessary-type-arguments Disallow type arguments that are equal to the default.
@typescript-eslint/no-unnecessary-type-assertion Disallow type assertions that do not change the type of an expression.
@typescript-eslint/no-unnecessary-type-constraint Disallow unnecessary constraints on generic types.
@typescript-eslint/no-unnecessary-type-conversion Disallow conversion idioms when they do not change the type or value of the expression.
@typescript-eslint/no-unnecessary-type-parameters Disallow type parameters that aren't used multiple times.
@typescript-eslint/no-unsafe-argument Disallow calling a function with a value with type any.
@typescript-eslint/no-unsafe-assignment Disallow assigning a value with type any to variables and properties.
@typescript-eslint/no-unsafe-call Disallow calling a value with type any.
@typescript-eslint/no-unsafe-declaration-merging Disallow unsafe declaration merging.
@typescript-eslint/no-unsafe-enum-comparison Disallow comparing an enum value with a non-enum value.
@typescript-eslint/no-unsafe-function-type Disallow using the unsafe built-in Function type.
@typescript-eslint/no-unsafe-member-access Disallow member access on a value with type any.
@typescript-eslint/no-unsafe-return Disallow returning a value with type any from a function.
@typescript-eslint/no-unsafe-unary-minus Require unary negation to take a number.
@typescript-eslint/no-unused-expressions Disallow unused expressions.
@typescript-eslint/no-unused-vars Disallow unused variables.
@typescript-eslint/no-useless-constructor Disallow unnecessary constructors.
@typescript-eslint/no-useless-default-assignment Disallow default values that will never be used.
@typescript-eslint/no-wrapper-object-types Disallow using confusing built-in primitive class wrappers.
@typescript-eslint/non-nullable-type-assertion-style Enforce non-null assertions over explicit type assertions.
@typescript-eslint/only-throw-error Disallow throwing non-Error values as exceptions.
@typescript-eslint/prefer-as-const Enforce the use of as const over literal type.
@typescript-eslint/prefer-find Enforce the use of Array.prototype.find() over Array.prototype.filter() followed by [0] when looking for a single result.
@typescript-eslint/prefer-for-of Enforce the use of for-of loop over the standard for loop where possible.
@typescript-eslint/prefer-function-type Enforce using function types instead of interfaces with call signatures.
@typescript-eslint/prefer-includes Enforce includes method over indexOf method.
@typescript-eslint/prefer-literal-enum-member Require all enum members to be literal values.
@typescript-eslint/prefer-namespace-keyword Require using namespace keyword over module keyword to declare custom TypeScript modules.
@typescript-eslint/prefer-nullish-coalescing Enforce using the nullish coalescing operator instead of logical assignments or chaining.
@typescript-eslint/prefer-optional-chain Enforce using concise optional chain expressions instead of chained logical ands, negated logical ors, or empty objects.
@typescript-eslint/prefer-promise-reject-errors Require using Error objects as Promise rejection reasons.
@typescript-eslint/prefer-readonly Require private members to be marked as readonly if they're never modified outside of the constructor.
@typescript-eslint/prefer-reduce-type-parameter Enforce using type parameter when calling Array#reduce instead of using a type assertion.
@typescript-eslint/prefer-regexp-exec Enforce RegExp#exec over String#match if no global flag is provided.
@typescript-eslint/prefer-return-this-type Enforce that this is used when only this type is returned.
@typescript-eslint/prefer-string-starts-ends-with Enforce using String#startsWith and String#endsWith over other equivalent methods of checking substrings.
@typescript-eslint/related-getter-setter-pairs Enforce that get() types should be assignable to their equivalent set() type.
@typescript-eslint/require-await Disallow async functions which do not return promises and have no await expression.
@typescript-eslint/restrict-plus-operands Require both operands of addition to be the same type and be bigint, number, or string.
@typescript-eslint/restrict-template-expressions Enforce template literal expressions to be of string type.
@typescript-eslint/return-await Enforce consistent awaiting of returned promises.
@typescript-eslint/strict-boolean-expressions Disallow certain types in boolean expressions.
@typescript-eslint/triple-slash-reference Disallow certain triple slash directives in favor of ES6-style import declarations.
@typescript-eslint/unbound-method Enforce unbound methods are called with their expected scope.
@typescript-eslint/unified-signatures Disallow two overloads that could be unified into one with a union or an optional/rest parameter.
@typescript-eslint/use-unknown-in-catch-callback-variable Enforce typing arguments in Promise rejection callbacks as unknown.
prefer-arrow-functions/prefer-arrow-functions Auto-fix plain Functions into Arrow Functions, in all cases where conversion would result in the same behaviour.
zod/array-style Enforce consistent Zod array style.
zod/consistent-import Enforce a consistent import style for Zod.
zod/consistent-schema-var-name Enforce a consistent naming convention for Zod schema variables.
zod/no-any-schema Disallow usage of z.any() in Zod schemas.
zod/no-coerce-boolean Disallow z.coerce.boolean() because it treats any non-empty string as true.
zod/no-duplicate-schema-methods Disallow calling the same schema method more than once in a single chain.
zod/no-empty-custom-schema Disallow usage of z.custom() without arguments.
zod/no-native-enum Disallow deprecated z.nativeEnum() in favor of z.enum().
zod/no-number-schema-with-finite Disallow deprecated z.number().finite(). In Zod 4+ number schemas do not allow infinite values by default, so it is a no-op.
zod/no-number-schema-with-int Disallow usage of z.number().int() as it is considered legacy.
zod/no-number-schema-with-is-finite Disallow using deprecated isFinite on a Zod number schema; in v4+ it is always true.
zod/no-number-schema-with-is-int Disallow using deprecated isInt on a Zod number schema; check the format property instead.
zod/no-number-schema-with-safe Disallow deprecated z.number().safe(). Use z.int(); .safe() is now identical to .int().
zod/no-number-schema-with-step Disallow deprecated z.number().step(). Use .multipleOf() instead.
zod/no-optional-and-default-together Disallow using both .optional() and .default() on the same Zod schema.
zod/no-promise-schema Disallow deprecated z.promise() schemas.
zod/no-schema-with-is-nullable Disallow deprecated .isNullable() on a Zod schema; use safeParse(null).success instead.
zod/no-schema-with-is-optional Disallow deprecated .isOptional() on a Zod schema; use safeParse(undefined).success instead.
zod/no-throw-in-refine Disallow throwing errors directly inside Zod refine callbacks.
zod/prefer-enum-over-literal-union Prefer z.enum() over z.union() when all members are string literals.
zod/prefer-loose-object Prefer z.looseObject() over z.object().passthrough() and z.object().loose().
zod/prefer-meta-last Enforce .meta() as last method.
zod/prefer-meta Enforce usage of .meta() over .describe().
zod/prefer-nullish Enforce .nullish() instead of combining .optional() and .nullable().
zod/prefer-strict-object Prefer z.strictObject() over z.object().strict().
zod/prefer-string-schema-with-trim Enforce z.string().trim() to prevent accidental leading/trailing whitespace.
zod/prefer-top-level-string-formats Prefer top-level string format schemas over deprecated z.string().<format>() methods.
zod/prefer-trim-before-string-length-checks Enforce .trim() is called before string length checks to ensure accurate validation.
zod/require-brand-type-parameter Require type parameter on .brand() functions.
zod/require-error-message Enforce that custom refinements include an error message.

About

Strict ESLint presets for modern TypeScript.

Topics

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages