Skip to content

oxlint

oxlint is an emerging linter that requires no configuration by default and is mainly used for script files.

Positioning of oxlint

oxlint is not a complete replacement for ESLint; rather, oxlint complements ESLint because oxlint is very fast. You can run oxlint before running ESLint to get a faster feedback loop.

Installation

You have to install oxlint first. Currently oxlint v0.5 is supported.

shell
npm install oxlint -D
shell
yarn add oxlint -D
shell
pnpm install oxlint -D
shell
bun install oxlint -d

Configuration

CLI

Update your package.json and add lint:oxlint script.

json
{
  "scripts": {
    "lint:oxlint": "oxlint --fix"
  }
}

Ignoring files

While the ESLint config provides .gitignore, .eslintignore, and some built-in ignore files support, oxlint only supports specifying a single ignore pattern file, and uses both the .gitignore and .eslintignore ignore pattern files by default.

If you have other files to ignore, you can use --ignore-pattern like below. It ignores all dts files, which is useful in projects that automatically generate dts files.

json
{
  "scripts": {
    "lint:oxlint": "oxlint --ignore-pattern=*.d.ts --fix"
  }
}

Integration

VSC

Install the corresponding oxlint plugin.

lint-staged

If you are using the lint-staged configuration provided by the package, see the lint-staged chapter.

If you are not, you can refer to the following configuration.

javascript
// lint-staged.config.mjs
// or lint-staged.config.js with "type": "module" in package.json
import { filterFilenames } from '@modyqyw/fabric';

export default {
  '*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,vue}': (filenames) => {
    const filtered = filterFilenames(filenames);
    return [
      `oxlint --fix ${filtered.join(' ')}`,
      `eslint --fix --cache --no-error-on-unmatched-pattern ${filtered.join(' ')}`,
    ];
  },
};

Released under the MIT License.