CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-oxlint

High-performance JavaScript and TypeScript linter written in Rust, designed as part of the Oxc (Oxidation Compiler) suite of tools

Overview
Eval results
Files

rules.mddocs/

Rule Management

Oxlint provides a hierarchical rule management system with categories, individual rule configuration, and flexible severity controls. Rules can be configured through command-line options or configuration files with fine-grained control over scope and application.

Rule Categories

Oxlint organizes rules into logical categories that can be enabled or disabled as groups:

Correctness

oxlint -D correctness  # Deny (error level)
oxlint -W correctness  # Warn level
oxlint -A correctness  # Allow (suppress)

Code that is outright wrong or useless. Enabled by default at error level.

Examples: no-debugger, no-unreachable, no-duplicate-keys

Suspicious

oxlint -D suspicious
oxlint -W suspicious
oxlint -A suspicious

Code that is most likely wrong or problematic but may have legitimate uses.

Examples: no-empty, no-implicit-coercion, no-unused-vars

Pedantic

oxlint -D pedantic
oxlint -W pedantic
oxlint -A pedantic

Strict rules that enforce best practices but may have occasional false positives.

Examples: prefer-const, no-var, eqeqeq

Style

oxlint -D style
oxlint -W style
oxlint -A style

Code style and formatting rules for consistent code appearance.

Examples: semi, quotes, indent, comma-dangle

Nursery

oxlint -D nursery
oxlint -W nursery
oxlint -A nursery

New rules under development that may change behavior or have limited testing.

Restriction

oxlint -D restriction
oxlint -W restriction
oxlint -A restriction

Rules that prevent the use of specific language features or patterns.

Examples: no-eval, no-with, no-implicit-globals

All Categories

oxlint -A all  # Allow all rules
oxlint -D all  # Deny all rules (except nursery)

Applies to all categories except nursery. Does not automatically enable plugins.

Rule Severity Levels

Command Line Severity Control

# Allow (suppress) - rules produce no output
oxlint --allow RULE_NAME
oxlint -A RULE_NAME

# Warn - rules produce warnings (exit code 0 unless --deny-warnings)
oxlint --warn RULE_NAME
oxlint -W RULE_NAME

# Deny (error) - rules produce errors (exit code 1)
oxlint --deny RULE_NAME
oxlint -D RULE_NAME

Configuration File Severity

{
  "rules": {
    "rule-name": "off",     // 0 - disable rule
    "rule-name": "warn",    // 1 - warning level
    "rule-name": "error"    // 2 - error level
  }
}

Individual Rule Configuration

Basic Rule Configuration

{
  "rules": {
    "no-debugger": "error",
    "no-console": "warn",
    "no-unused-vars": "off",
    "eqeqeq": "error",
    "prefer-const": "warn"
  }
}

Rule Configuration with Options

{
  "rules": {
    "prefer-const": ["error", {
      "destructuring": "any",
      "ignoreReadBeforeAssign": false
    }],
    "no-unused-vars": ["warn", {
      "vars": "all",
      "args": "after-used",
      "ignoreRestSiblings": true
    }],
    "quotes": ["error", "single", {
      "avoidEscape": true,
      "allowTemplateLiterals": false
    }]
  }
}

Command Line Rule Management

Layered Rule Configuration

Rules are applied in order from left to right, allowing fine-grained control:

# Start with all rules allowed, then deny specific categories
oxlint -A all -D correctness -D suspicious src/

# Allow a category but deny specific rules
oxlint -A pedantic -D prefer-const -D no-var src/

# Mix of category and individual rule controls
oxlint -D suspicious --allow no-debugger -W no-console src/

Rule Precedence

Command-line options override configuration file settings:

# Override config file rules
oxlint -c .oxlintrc.json -A no-debugger -D prefer-const src/

Advanced Rule Management

File-Specific Rule Overrides

{
  "rules": {
    "no-console": "error"
  },
  "overrides": [
    {
      "files": ["**/*.test.js", "**/*.spec.js"],
      "rules": {
        "no-console": "off"
      }
    },
    {
      "files": ["scripts/**/*.js"],
      "rules": {
        "no-console": "warn",
        "no-process-exit": "off"
      }
    }
  ]
}

Plugin-Specific Rules

{
  "plugins": ["typescript", "react"],
  "rules": {
    // TypeScript rules
    "@typescript-eslint/no-unused-vars": "error",
    "@typescript-eslint/explicit-function-return-type": "warn",

    // React rules
    "react/jsx-uses-react": "error",
    "react/jsx-uses-vars": "error",

    // Disable conflicting core rules when using TypeScript
    "no-unused-vars": "off"
  }
}

Category-Level Configuration

{
  "categories": {
    "correctness": "error",
    "suspicious": "warn",
    "pedantic": "off",
    "style": "warn"
  },
  "rules": {
    // Override specific rules within categories
    "no-debugger": "warn",  // Override correctness default
    "prefer-const": "error" // Override pedantic default
  }
}

Rule Discovery and Information

List Available Rules

oxlint --rules

Displays all available rules organized by plugin and category.

Rule Documentation

Rules follow standard naming conventions:

  • Core rules: rule-name
  • Plugin rules: plugin-name/rule-name
  • TypeScript rules: @typescript-eslint/rule-name

Warning and Error Handling

Warning Thresholds

# Set maximum number of warnings before exit code 1
oxlint --max-warnings 10 src/

# Treat any warning as error
oxlint --deny-warnings src/

# Suppress warnings, show errors only
oxlint --quiet src/

Inline Directive Reporting

# Report unused eslint-disable directives
oxlint --report-unused-disable-directives src/

# Report with specific severity
oxlint --report-unused-disable-directives-severity error src/

Common Rule Configuration Patterns

Strict Configuration

{
  "categories": {
    "correctness": "error",
    "suspicious": "error",
    "pedantic": "error"
  },
  "rules": {
    "no-debugger": "error",
    "no-console": "error",
    "eqeqeq": "error",
    "prefer-const": "error"
  }
}

Gradual Adoption

{
  "categories": {
    "correctness": "error",
    "suspicious": "warn",
    "pedantic": "off"
  },
  "rules": {
    // Gradually enable pedantic rules
    "prefer-const": "warn",
    "no-var": "warn"
  }
}

Framework-Specific Rules

{
  "plugins": ["react", "typescript"],
  "overrides": [
    {
      "files": ["**/*.tsx", "**/*.jsx"],
      "rules": {
        "react/jsx-uses-react": "error",
        "react/jsx-key": "error",
        "react/no-unused-state": "warn"
      }
    },
    {
      "files": ["**/*.ts", "**/*.tsx"],
      "rules": {
        "@typescript-eslint/no-unused-vars": "error",
        "@typescript-eslint/no-explicit-any": "warn",
        "no-unused-vars": "off"
      }
    }
  ]
}

Install with Tessl CLI

npx tessl i tessl/npm-oxlint

docs

cli.md

configuration.md

index.md

nodejs-api.md

output-formats.md

plugins.md

rules.md

tile.json