Skip to content

configurajs/eslint

Repository files navigation

logo

@configurajs/eslint

A simple eslint flat configuration

English | 中文介绍

version stars license


Features

  • 📦   Support javascript presets
  • 📦   Support typescript presets
  • 📦   Support vue(2 and 3) presets
  • 📦   Support react presets
  • 📦   Support jsx presets
  • 📦   Support vitest presets
  • 📦   Support eslint comments presets
  • 📦   Support overrides eslint config

Quick Start

Installation

# npm
npm i @configurajs/eslint -D
# yarn
yarn add @configurajs/eslint -D
# pnpm
pnpm add @configurajs/eslint -D

Usage

// eslint.config.js
import { defineConfig } from '@configurajs/eslint'

export default defineConfig()

OR

// eslint.config.js
const { defineConfig } = require('@configurajs/eslint')

module.exports = defineConfig()

Switch Framework Presets

Switching framework presets requires manual setup.

Vue2

// eslint.config.js
import { defineConfig } from '@configurajs/eslint'

export default defineConfig({
  vue: { version: 2 },
})

React

// eslint.config.js
import { defineConfig } from '@configurajs/eslint'

export default defineConfig({
  vue: false,
  react: true,
})

Options

// prettier.config.js
import { defineConfig } from '@configurajs/eslint'

export default defineConfig({ ... })
export interface DefineConfigOptions {
  /**
   * Enable TypeScript support
   * @default true
   */
  ts?: boolean
  /**
   * Enable JSX support
   * @default true
   */
  jsx?: boolean
  /**
   * Enable Vue support, version 3 by default
   * @default true
   */
  vue?: boolean | { version: 2 | 3 }
  /**
   * Enable React support
   * @default false
   */
  react?: boolean
  /**
   * Enable Vitest support
   * @default true
   */
  vitest?: boolean
  /**
   * Enable eslint comments support
   * @default true
   */
  comments?: boolean
  /**
   * Custom rules
   */
  rules?: Linter.RulesRecord
  /**
   * Ignore files
   */
  ignores?: string[]
  /**
   * Override eslint configs
   */
  overrides?: Linter.Config[]
}

Contributors

ChangeLog

ChangeLog

License

MIT

Inspired By

This project structure is inspired by antfu-eslint-config.