Skip to main content

Configuration

Oxc tools use JSON-based configuration files for customizing behavior. This guide covers both oxlint and oxfmt configuration formats.

oxlint Configuration

Configuration File

oxlint reads configuration from .oxlintrc.json or .oxlintrc.jsonc (JSON with comments).
{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "plugins": ["typescript", "unicorn", "react", "import"],
  "env": {
    "browser": true,
    "node": true
  },
  "globals": {
    "myGlobal": "readonly",
    "anotherGlobal": "writable"
  },
  "categories": {
    "correctness": "error",
    "suspicious": "warn",
    "pedantic": "off"
  },
  "rules": {
    "no-console": "warn",
    "no-debugger": "error",
    "eqeqeq": ["error", "always"],
    "curly": ["error", "multi-line"],
    "react/jsx-key": "error",
    "typescript/no-explicit-any": "warn",
    "import/no-cycle": "error"
  },
  "ignorePatterns": [
    "dist/**",
    "build/**",
    "*.min.js",
    "node_modules/**"
  ],
  "overrides": [
    {
      "files": ["*.test.ts", "*.spec.ts"],
      "rules": {
        "typescript/no-explicit-any": "off"
      }
    }
  ]
}

Configuration Schema

$schema
string
URI to JSON schema for editor autocomplete and validation.
"$schema": "./node_modules/oxlint/configuration_schema.json"
plugins
string[]
Array of plugin names to enable. Setting this field overrides the default plugins.Available plugins:
  • typescript (default)
  • unicorn (default)
  • oxc (default)
  • react
  • import
  • jsdoc
  • jest
  • vitest
  • jsx-a11y
  • nextjs
  • react-perf
  • promise
  • node
  • vue
"plugins": ["typescript", "react", "import"]
env
object
Enable or disable collections of global variables.Available environments:
  • browser - Browser globals (window, document, etc.)
  • node - Node.js globals (process, Buffer, etc.)
  • es2015, es2017, es2020, es2021, etc. - ECMAScript version globals
  • builtin - Built-in JavaScript globals (default: true)
"env": {
  "browser": true,
  "node": true,
  "es2021": true
}
globals
object
Define custom global variables.Values:
  • "readonly" or "readable" - Read-only global
  • "writable" or "writeable" - Writable global
  • "off" - Disable the global
"globals": {
  "jQuery": "readonly",
  "$": "readonly",
  "myGlobal": "writable"
}
categories
object
Set severity levels for entire rule categories.Categories:
  • correctness - Outright wrong or useless code
  • suspicious - Most likely wrong code
  • pedantic - Strict rules with occasional false positives
  • perf - Performance improvements
  • style - Idiomatic style improvements
  • restriction - Language feature restrictions
  • nursery - New rules under development
"categories": {
  "correctness": "error",
  "suspicious": "warn",
  "pedantic": "off"
}
rules
object
Configure individual rules with severity and options.Severity levels:
  • "off" or 0 - Disable rule
  • "warn" or 1 - Warning
  • "error" or 2 - Error
Rule configuration formats:
  • Simple: "rule-name": "error"
  • With options: "rule-name": ["error", { "option": value }]
"rules": {
  "no-console": "warn",
  "no-debugger": "error",
  "eqeqeq": ["error", "always"],
  "curly": ["error", "multi-line"],
  "prefer-const": ["error", { "destructuring": "all" }]
}
settings
object
Plugin-specific settings shared across rules.
"settings": {
  "react": {
    "version": "18.2.0"
  },
  "import/resolver": {
    "typescript": true
  }
}
ignorePatterns
string[]
Glob patterns for files to ignore. Resolved from configuration file location.
"ignorePatterns": [
  "dist/**",
  "build/**",
  "*.min.js",
  "**/*.d.ts",
  "node_modules/**"
]
extends
string[]
Inherit configuration from other files. Files are merged in order, with later files overriding earlier ones.
"extends": [
  "./base-config.json",
  "./typescript-config.json"
]
overrides
array
Override rules for specific files or patterns.
"overrides": [
  {
    "files": ["*.test.ts", "*.spec.ts"],
    "rules": {
      "typescript/no-explicit-any": "off",
      "no-console": "off"
    }
  },
  {
    "files": ["scripts/**/*.js"],
    "env": {
      "node": true
    },
    "rules": {
      "no-console": "off"
    }
  }
]
jsPlugins
array
Enable ESLint plugins written in JavaScript (experimental).
"jsPlugins": [
  "./custom-plugin.js",
  { "name": "import-js", "specifier": "eslint-plugin-import" }
],
"rules": {
  "custom/rule-name": "warn",
  "import-js/no-unresolved": "error"
}
options
object
Oxlint-specific options.
"options": {
  "typeAware": true,
  "typeCheck": true
}
options.typeAware
boolean
default:"false"
Enable rules requiring type information.
options.typeCheck
boolean
default:"false"
Enable experimental TypeScript compiler diagnostics.

Real-World Examples

.oxlintrc.json
{
  "$schema": "./node_modules/oxlint/configuration_schema.json",
  "plugins": [
    "typescript",
    "react",
    "jsx-a11y",
    "react-perf"
  ],
  "env": {
    "browser": true,
    "es2021": true
  },
  "settings": {
    "react": {
      "version": "18.2.0"
    }
  },
  "categories": {
    "correctness": "error",
    "perf": "warn"
  },
  "rules": {
    "react/jsx-key": "error",
    "react/no-array-index-key": "warn",
    "jsx-a11y/alt-text": "error",
    "typescript/no-explicit-any": "warn"
  }
}

oxfmt Configuration

Configuration File

oxfmt reads configuration from .oxfmtrc.json or .oxfmtrc.jsonc.
.oxfmtrc.jsonc
{
  "$schema": "./node_modules/oxfmt/configuration_schema.json",
  // Formatting options
  "printWidth": 100,
  "tabWidth": 2,
  "useTabs": false,
  "semi": true,
  "singleQuote": false,
  "quoteProps": "as-needed",
  "jsxSingleQuote": false,
  "trailingComma": "es5",
  "bracketSpacing": true,
  "bracketSameLine": false,
  "arrowParens": "always",
  "proseWrap": "preserve",
  "htmlWhitespaceSensitivity": "css",
  "endOfLine": "lf",
  "insertFinalNewline": true,
  // Ignore patterns
  "ignorePatterns": [
    "dist/**",
    "build/**",
    "coverage/**",
    "*.min.js"
  ]
}

Formatting Options

printWidth
number
default:"80"
Maximum line width before wrapping.
"printWidth": 100
tabWidth
number
default:"2"
Number of spaces per indentation level.
"tabWidth": 4
useTabs
boolean
default:"false"
Use tabs instead of spaces for indentation.
"useTabs": false
semi
boolean
default:"true"
Print semicolons at the end of statements.
"semi": true
singleQuote
boolean
default:"false"
Use single quotes instead of double quotes.
"singleQuote": true
quoteProps
string
default:"as-needed"
When to quote object properties.Options: "as-needed", "consistent", "preserve"
"quoteProps": "as-needed"
jsxSingleQuote
boolean
default:"false"
Use single quotes in JSX.
"jsxSingleQuote": false
trailingComma
string
default:"es5"
Print trailing commas where valid in ES5.Options: "none", "es5", "all"
"trailingComma": "es5"
bracketSpacing
boolean
default:"true"
Print spaces between brackets in object literals.
"bracketSpacing": true
  • true: { foo: bar }
  • false: {foo: bar}
bracketSameLine
boolean
default:"false"
Put the > of multi-line elements at the end of the last line.
"bracketSameLine": false
arrowParens
string
default:"always"
Include parentheses around sole arrow function parameter.Options: "always", "avoid"
"arrowParens": "always"
  • "always": (x) => x
  • "avoid": x => x
proseWrap
string
default:"preserve"
How to wrap prose (markdown, etc.).Options: "always", "never", "preserve"
"proseWrap": "preserve"
htmlWhitespaceSensitivity
string
default:"css"
Whitespace sensitivity for HTML, Vue, Angular.Options: "css", "strict", "ignore"
"htmlWhitespaceSensitivity": "css"
endOfLine
string
default:"lf"
Line ending style.Options: "lf", "crlf", "cr"
"endOfLine": "lf"
insertFinalNewline
boolean
default:"true"
Insert a final newline at the end of files.
"insertFinalNewline": true
embeddedLanguageFormatting
string
default:"auto"
Format embedded code (CSS-in-JS, etc.).Options: "auto", "off"
"embeddedLanguageFormatting": "auto"
ignorePatterns
string[]
Glob patterns for files to ignore.
"ignorePatterns": [
  "dist/**",
  "build/**",
  "*.min.js",
  "**/*.d.ts"
]

Advanced Options

objectWrap
string
default:"preserve"
How to wrap object literals.Options: "preserve", "always", "never"
"objectWrap": "preserve"

EditorConfig Support

oxfmt respects .editorconfig settings. Configuration file options override EditorConfig values. Supported EditorConfig properties:
  • indent_styleuseTabs
  • indent_sizetabWidth
  • max_line_lengthprintWidth
  • end_of_lineendOfLine
  • insert_final_newlineinsertFinalNewline

Prettier Compatibility

oxfmt aims for Prettier compatibility with most options. Some differences:
  • No "auto" value for endOfLine
  • embeddedLanguageFormatting support is incomplete for some languages
  • Custom objectWrap option (Oxfmt extension)

Migration from Prettier

# Generate oxfmt config from Prettier config
oxfmt --migrate prettier
This reads .prettierrc, .prettierrc.json, or prettier.config.js and generates .oxfmtrc.json.

Configuration Discovery

Both tools search for configuration files in the following order:
  1. Command-line specified config (-c or --config)
  2. Configuration file in current directory
  3. Configuration file in parent directories (up to root)
oxlint: .oxlintrc.json.oxlintrc.jsoncoxlint.config.tsoxlint.config.js oxfmt: .oxfmtrc.json.oxfmtrc.jsonc

See Also

Build docs developers (and LLMs) love