Skip to content

Latest commit

 

History

History
117 lines (76 loc) · 2.86 KB

README.CN.md

File metadata and controls

117 lines (76 loc) · 2.86 KB

@13OnTheCode/ESLint-Config

ESLint

Version License

English | 简体中文

一个通用的 ESLint 配置库,它遵循最佳实践,为 JavaScript、TypeScript、Node.js 和 React 项目提供基础配置

Features

  • 遵循最佳实践,实现准确可靠的代码检查
  • 灵活配置选项,适应不同项目需求
  • 自动修复格式,无需使用 Prettier
  • 主流插件集成,为项目提供广泛的功能拓展
  • 持续维护更新,支持最新的版本和特性

Prerequisites

Node.js

  • 版本 >= 16.0.0
  • ESM 项目

ESLint

  • 版本 >= 8.23.0
  • 使用 Flat Config

Install

npm install @13onthecode/eslint-config --save-dev

Usage

首先,确保你正在使用 ESM(在你的 package.json 中设置 "type": "module"

然后,在项目根目录中创建 ESLint 配置文件 eslint.config.js,根据你的项目需求导入所需的预设配置:

Base

用于纯 JavaScript 和 TypeScript 项目的预设配置,不包括 Node 环境以及 .jsx.tsx 文件

import { base } from '@13onthecode/eslint-config'

export default [
  ...base
]

Node

此配置继承了 Base 配置

用于 Node 项目的预设配置,为 JavaScript 和 TypeScript 文件提供了 Node 环境的支持

import { node } from '@13onthecode/eslint-config'

export default [
  ...node
]

React

此配置继承了 Node 配置

用于 React 项目的预设配置,提供了 .jsx.tsx 文件的支持

import { react } from '@13onthecode/eslint-config'

export default [
  ...react
]

Override

要覆盖某些配置,只需将您想要的配置连接在一起,例如:

import { base } from '@13onthecode/eslint-config'

export default [
  ...base,
  {
    files: ["src/**/*.js"],
    rules: {
      "no-console": "off"
    }
  }
]

FAQ

为什么不使用 Prettier?

为什么不使用 CommonJS?

Check Also

License

MIT License © 2023-PRESENT 13OnTheCode