Skip to content

Commit

Permalink
feat!: flat config (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
auvred authored Jan 2, 2024
1 parent b80cf53 commit 5352393
Show file tree
Hide file tree
Showing 36 changed files with 3,101 additions and 1,261 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
dist
4 changes: 4 additions & 0 deletions .vim/coc-settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"eslint.experimental.useFlatConfig": true,
"eslint.autoFixOnSave": true,
"eslint.validate": [
"javascript",
Expand All @@ -11,5 +12,8 @@
"json",
"jsonc",
"yaml"
],
"eslint.rules.customizations": [
{ "rule": "auvred/prettier", "severity": "off" }
]
}
9 changes: 6 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"eslint.experimental.useFlatConfig": true,
"prettier.enable": false,
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.addMissingImports": true,
"source.fixAll.eslint": true,
"source.organizeImports": false
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},
"eslint.validate": [
"javascript",
Expand All @@ -17,5 +17,8 @@
"json",
"jsonc",
"yaml"
],
"eslint.rules.customizations": [
{ "rule": "auvred/prettier", "severity": "off" }
]
}
73 changes: 35 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# @auvred/eslint-config

> Some code snippets were taken from these awesome repos: [`@so1ve/eslint-config`](https://github.com/so1ve/eslint-config), [`@antfu/eslint-config`](https://github.com/antfu/eslint-config)
> Partially based on these awesome configs: [`@so1ve/eslint-config`](https://github.com/so1ve/eslint-prettier-config), [`@antfu/eslint-config`](https://github.com/antfu/eslint-config)
## Features

- Single quotes, no semi, trailing commas
- Formatting with [Prettier](https://github.com/prettier/prettier)
- Typescript and Vue support out-of-box
- Sortable imports
- Lint also for html, json, yaml, markdown

## Usage

Expand All @@ -18,44 +17,41 @@
pnpm add -D @auvred/eslint-config eslint prettier
```

### Config `.eslintrc`
### Config `eslint.config.js`

```jsonc
{
// don't forget to mark the root config as root
"root": true,
"extends": "@auvred"
}
```

> You don't need .eslintignore normally as it has been provided by the preset.
In ESM projects:

## Extra configs
```js
import { auvred } from '@auvred/eslint-config'

### `@auvred/eslint-config/pnpm-workspace`

This config is intended to be used in monorepositories based on [`pnpm`](https://github.com/pnpm/pnpm)
export default auvred()
```

It finds `pnpm-workspace.yaml` in the root of the project, resolves the packages listed there and puts:
In CJS projects:

- found tsconfigs to the [typescript imports resolver](https://github.com/import-js/eslint-import-resolver-typescript) in the [`import/resolver`](https://github.com/import-js/eslint-plugin-import#importresolver)
- project package names scope to the [`import/internal-regex`](https://github.com/import-js/eslint-plugin-import#importinternal-regex)
```js
module.exports = (async () => {
const { auvred } = await import('@auvred/eslint-config')

```jsonc
{
"extends": ["@auvred", "@auvred/eslint-config/pnpm-workspace"]
}
return auvred()
})()
```

## Configure your editor

### coc.nvim
### VS Code

Install [`coc-eslint`](https://github.com/neoclide/coc-eslint) extension
Install [`dbaeumer.vscode-eslint`](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) extension

```jsonc
```json
{
"eslint.autoFixOnSave": true,
"eslint.experimental.useFlatConfig": true,
"prettier.enable": false,
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},
"eslint.validate": [
"javascript",
"javascriptreact",
Expand All @@ -67,25 +63,23 @@ Install [`coc-eslint`](https://github.com/neoclide/coc-eslint) extension
"json",
"jsonc",
"yaml"
],
"eslint.rules.customizations": [
{ "rule": "auvred/prettier", "severity": "off" }
]
}
```

> It's better to put these settings to workspace settings (`.vim/coc-settings.json`)
> It's better to put these settings to workspace settings (`.vscode/settings.json`)
### VS Code
### coc.nvim

Install [`dbaeumer.vscode-eslint`](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) extension
Install [`coc-eslint`](https://github.com/neoclide/coc-eslint) extension

```jsonc
{
"prettier.enable": false,
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.addMissingImports": true,
"source.fixAll.eslint": true,
"source.organizeImports": false
},
"eslint.experimental.useFlatConfig": true,
"eslint.autoFixOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
Expand All @@ -97,11 +91,14 @@ Install [`dbaeumer.vscode-eslint`](https://marketplace.visualstudio.com/items?it
"json",
"jsonc",
"yaml"
],
"eslint.rules.customizations": [
{ "rule": "auvred/prettier", "severity": "off" }
]
}
```

> It's better to put these settings to workspace settings (`.vscode/settings.json`)
> It's better to put these settings to workspace settings (`.vim/coc-settings.json`)
### JetBrains IDEs

Expand Down
17 changes: 17 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// eslint-disable-next-line import/no-useless-path-segments
import { auvred } from './dist/index.js'

export default auvred({
typescript: {
overrides: {
'ts/no-restricted-imports': [
'error',
{
name: 'eslint-define-config',
importNames: ['FlatESLintConfig'],
message: 'Use FlatConfigItem from types.ts instead',
},
],
},
},
})
Loading

0 comments on commit 5352393

Please sign in to comment.