Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
13OnTheCode committed Aug 11, 2023
1 parent 9abacfe commit 62409cb
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 38 deletions.
90 changes: 71 additions & 19 deletions README.CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@

[English](README.md) | 简体中文

为 JavaScript、TypeScript、Node.js 和 React 项目提供了预定义的配置文件,可根据项目需求选择性地导入配置
一个通用的 ESLint 配置库,它遵循最佳实践,为 JavaScript、TypeScript、Node.js 和 React 项目提供基础配置

## Features

- 固执己见, 但同时保持合理的默认配置和最佳实践
- 按需导入适合你项目的配置文件
- 自动修复格式(旨在独立使用,无需使用 Prettier)
- 主流常用 ESLint 插件集成
- 遵循最佳实践,实现准确可靠的代码检查
- 灵活配置选项,适应不同项目需求
- 自动修复格式,无需使用 Prettier
- 主流插件集成,为项目提供广泛的功能拓展
- 持续维护更新,支持最新的版本和特性

## Prerequisites

- ESLint 版本需要 8.23.0 或更高
- 使用 ESLint Flat Config
### Node.js
- 版本 >= 16.0.0
- ESM 项目

### ESLint
- 版本 >= 8.23.0
- 使用 Flat Config

## Install

Expand All @@ -29,34 +35,80 @@ npm install @13onthecode/eslint-config --save-dev

## Usage

创建 ESLint 配置文件 `eslint.config.js`,并根据你的项目需求导入所需的预设配置:
首先,确保你正在使用 ESM(在你的 `package.json` 中设置 `"type": "module"`

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

### Base

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

```javascript
import { javascript, typescript, react, node } from '@13onthecode/eslint-config'
import { base } from '@13onthecode/eslint-config'

export default [
node,
react,
javascript,
typescript
...base
]
```

## Packages
### Node

该包是以下共享 ESLint 配置包的集合:
此配置继承了 [Base](#base) 配置

- [`@13onthecode/eslint-config-javascript`](https://github.com/13OnTheCode/eslint-config/tree/main/packages/javascript)
- [`@13onthecode/eslint-config-typescript`](https://github.com/13OnTheCode/eslint-config/tree/main/packages/typescript)
- [`@13onthecode/eslint-config-node`](https://github.com/13OnTheCode/eslint-config/tree/main/packages/node)
- [`@13onthecode/eslint-config-react`](https://github.com/13OnTheCode/eslint-config/tree/main/packages/react)
用于 Node 项目的预设配置,为 JavaScript 和 TypeScript 文件提供了 Node 环境的支持

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

export default [
...node
]
```

### React

此配置继承了 [Node](#node) 配置

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

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

export default [
...react
]
```

## Override

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

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

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

## FAQ

### 为什么不使用 Prettier?
- [《Why I don't use Prettier》](https://antfu.me/posts/why-not-prettier)
- [《The Blurry Line Between Formatting and Style》](https://blog.joshuakgoldberg.com/the-blurry-line-between-formatting-and-style/)

### 为什么不使用 CommonJS?
- [《Get Ready For ESM》](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)

## Check Also
- [`@13onthecode/typescript-config`](https://github.com/13OnTheCode/typescript-config/tree/main)

## License

[MIT](LICENSE.md) License © 2023-PRESENT [13OnTheCode](https://github.com/13OnTheCode)
90 changes: 71 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@

English | [简体中文](README.CN.md)

It provides predefined configuration files for JavaScript, TypeScript, Node.js, and React projects, allowing selective importing of configurations based on project requirements
A versatile ESLint configuration library that follows best practices, offering foundational setups for JavaScript, TypeScript, Node.js, and React projects

## Features

- Opinionated, yet maintaining reasonable defaults and best practices
- Selectively import the configuration files that fit your project
- Auto fix for formatting (aimed to be used standalone without Prettier)
- Integration with other popular ESLint plugins out of the box
- Follow best practices to achieve accurate and reliable code inspection
- Flexible configuration options to cater to different project needs
- Automatically fixing formatting without the need for Prettier
- Integrating mainstream plugins to provide extensive functionality enhancements for projects
- Continuously maintained and updated to support the latest versions and features

## Prerequisites

- ESLint version 8.23.0 or higher
- ESLint Flat Config to be enabled and used
### Node.js
- Version >= 16.0.0
- ESM Project

### ESLint
- Version >= 8.23.0
- Using Flat Config

## Install

Expand All @@ -29,34 +35,80 @@ npm install @13onthecode/eslint-config --save-dev

## Usage

Create ESLint configuration file `eslint.config.js` and import the preset configurations that you need based on your project requirements:
First, ensure you're using ESM (set `"type": "module"` in your `package.json`)

Then, create ESLint configuration file `eslint.config.js` in the project's root directory, and import the preset configurations you need based on your project requirements:

### Base

Preset configuration for pure JavaScript and TypeScript projects, excluding Node environment and `.jsx` and `.tsx` files

```javascript
import { javascript, typescript, react, node } from '@13onthecode/eslint-config'
import { base } from '@13onthecode/eslint-config'

export default [
node,
react,
javascript,
typescript
...base
]
```

## Packages
### Node

This package is a collection of the following shareable ESLint configurations:
This configuration extends the [Base](#base) configuration

- [`@13onthecode/eslint-config-javascript`](https://github.com/13OnTheCode/eslint-config/tree/main/packages/javascript)
- [`@13onthecode/eslint-config-typescript`](https://github.com/13OnTheCode/eslint-config/tree/main/packages/typescript)
- [`@13onthecode/eslint-config-node`](https://github.com/13OnTheCode/eslint-config/tree/main/packages/node)
- [`@13onthecode/eslint-config-react`](https://github.com/13OnTheCode/eslint-config/tree/main/packages/react)
Preset configuration for Node.js projects, providing Node environment support for JavaScript and TypeScript files

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

export default [
...node
]
```

### React

This configuration extends the [Node](#node) configuration

Preset configuration for React projects, providing support for `.jsx` and `.tsx` files

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

export default [
...react
]
```

## Override

To override things, just concat the config you want together, for example:

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

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

## FAQ

### Why not Prettier?
- [《Why I don't use Prettier》](https://antfu.me/posts/why-not-prettier)
- [《The Blurry Line Between Formatting and Style》](https://blog.joshuakgoldberg.com/the-blurry-line-between-formatting-and-style/)

### Why not CommonJS?
- [《Get Ready For ESM》](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)

## Check Also
- [`@13onthecode/typescript-config`](https://github.com/13OnTheCode/typescript-config/tree/main)

## License

[MIT](LICENSE.md) License © 2023-PRESENT [13OnTheCode](https://github.com/13OnTheCode)

0 comments on commit 62409cb

Please sign in to comment.