Skip to content

lvjiaxuan/eslint-config

Repository files navigation

npm code style

All rules inherit from @antfu/eslint-config.

Features

  1. Add my @lvjiaxuan/eslint-plugin.
  2. Auto-detect tsconfig.json and its references if TypeScript is enabled, which means enabling type-aware rules.
  3. Add my @lvjiaxuan/eslint-plugin-oxlint.

Usage

Follow antfu's.

Disable tsconfig.json auto-detected

// eslint.config.js
import lv from '@lvjiaxuan/eslint-config'

export default lv({
  typescript: {
    notDetectTsconfig: true
  }
})

With OXLint

A number of rules will be taken care of by OXLint to reduce ESLint's burden.

Note

The rules settings of antfu's will be overwritten.

// eslint.config.js
import lv from '@lvjiaxuan/eslint-config'

export default lv({
  oxlint: true // equals to `{ deny: 'correctness' }`.
})

Options type, respects its original options:

/**
 * References https://oxc-project.github.io/docs/guide/usage/linter.html#useful-options-and-examples
 */
export type OXLintOptions = {

  /**
   * Deny the rule or category.
   *
   * @default 'correctness'
   */
  deny?: 'all' | Categories | Categories[]

  /**
   * Allow the rule or category.
   */
  allow?: (keyof OXLintRules)[]
} | boolean

Tip

  1. Categories of OXLint.
  2. Rules supported by OXLint.

Modify lint scritp:

// package.json
{
  "scripts": {
-    "lint": "eslint ."
+    "lint": "npx oxlint . && eslint",
+    "lintf": "npx oxlint . --fix && eslint --fix"
  }
}