0.6.0 ā€¢ Published 5 days ago

unplugin-oxlint v0.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 days ago

unplugin-oxlint

NPM version

šŸŒ‹ A universal bundler plugin for integrating the Oxlint linter into your project, based on vite-plugin-oxlint.

Features

šŸš€ A quick and simple way to use oxlint in your project.

šŸ› ļø Support linting with both bundler plugin and Node.js API.

āš™ļø Support common bundlers like Vite, Rollup, esbuild, and Webpack by unplugin.

šŸ” Support mixed use in eslint projects by eslint-plugin-oxlint.

šŸ˜Š Friendly output in terminal, grouped by filepath, and support including targets with glob patterns.

āš” Only lint the files that have changed for better performance by chokidar.

screenshot

Installation

# npm
npm i -D oxlint unplugin-oxlint

# pnpm
pnpm add -D oxlint unplugin-oxlint

# yar
yarn add -D oxlint unplugin-oxlint

Usage

Bundler Plugin

Recommended the bundler plugin way to use the full options of unplugin-oxlint.

// vite.config.ts
import Oxlint from 'unplugin-oxlint/vite'

export default defineConfig({
  plugins: [Oxlint()],
})

// rollup.config.js
import Oxlint from 'unplugin-oxlint/rollup'

export default {
  plugins: [Oxlint()],
}

// esbuild.config.js
import { build } from 'esbuild'

build({
  plugins: [require('unplugin-oxlint/esbuild')()],
})

// webpack.config.js
module.exports = {
  /* ... */
  plugins: [require('unplugin-oxlint/webpack')()],
}

Command

You can also use unox command to lint files like eslint

// package.json
{
  "scripts": {
    "lint": "unox",
    "lint:fix": "unox --fix"
  }
}

unox support most of the options of unplugin-oxlint, use them as params like:

unox src/**/*.ts --watch

For further configuration, create a config file named unox.config.{js,cjs,mjs,ts,mts,cts}

Playground

See playground.

ESLint

If you are looking for a way to use oxlint in projects that still need ESLint, You can use eslint-plugin-oxlint to turn off ESLint rules that are already supported by oxlint.

The rules are extracted from here

unplugin-oxlint will automatically run the eslint script after oxlint when build start and file change.

# npm
npm i -D eslint eslint-plugin-oxlint

# pnpm
pnpm add -D eslint eslint-plugin-oxlint

# yarn
yarn add -D eslint eslint-plugin-oxlint

Example

Use eslint-plugin-oxlint with @antfu/eslint-config

// eslint.config.js
import antfu from '@antfu/eslint-config'
import oxlint from 'eslint-plugin-oxlint'

export default antfu({
  ...oxlint.configs['flat/recommended'],
})

Options

For all options please refer to docs.

This plugin accepts most options of vite-plugin-oxlint, and some extra options that are specific to this plugin.

options.path

  • Type: string | string[]
  • Default: '.'

options.includes

  • Type: string | string[]
  • Default: '**/*.{js,ts,jsx,tsx,vue}'

Paths to files, dirs to be watched by glob patterns

options.excludes

  • Type: RegExp[]
  • Default: [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/]

options.rootDir

  • Type: string
  • Default: '.'

options.fix

  • Type: boolean
  • Default: false

Fix as many issues as possible. Only unfixed issues are reported in the output

options.watch

  • Type: boolean
  • Default: false

Continue to watch for changes in any of the resolved path

options.config

  • Type: string
  • Default: ''

ESLint configuration file

options.noIgnore

  • Type: boolean
  • Default: false

Disables excluding of files from .eslintignore files, --ignore-path flags and --ignore-pattern flags

options.quiet

  • Type: boolean
  • Default: false

Disable reporting on warnings, only errors are reported

options.denyWarnings

  • Type: boolean
  • Default: false

Ensure warnings produce a non-zero exit code

options.packageManager

  • Type: 'npm' | 'pnpm' | 'yarn' | 'bun'

Declare the package manager which you want to use

Normally you don't need to modify this option. unplugin-oxlint will automatically detect package.json and lock file by nypm

License

MIT License Ā© 2024-PRESENT Tamago

0.6.0

5 days ago

0.5.5

8 days ago

0.5.4

22 days ago

0.5.3

1 month ago

0.5.2

2 months ago

0.5.0

2 months ago

0.5.1

2 months ago

0.4.2

2 months ago

0.4.1

2 months ago

0.4.0

2 months ago

0.3.1

2 months ago

0.3.0

2 months ago

0.2.1

2 months ago

0.2.0

2 months ago

0.2.0-rc.1

2 months ago

0.2.3

2 months ago

0.1.4

2 months ago

0.2.2

2 months ago

0.1.3

2 months ago

0.1.2

2 months ago

0.1.1

2 months ago

0.1.0

2 months ago

0.0.1

2 months ago