Skip to content

Commit f1205f5

Browse files
committed
docs: update readme
1 parent ea92125 commit f1205f5

File tree

2 files changed

+256
-34
lines changed

2 files changed

+256
-34
lines changed

README.md

+127-15
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
We provided a CLI tool to help you set up your project, or migrate from the legacy config to the new flat config with one command.
5252

5353
```bash
54-
npx @kirklin/eslint-config@latest
54+
pnpm dlx @kirklin/eslint-config@latest
5555
```
5656

5757
### Manual Install
@@ -119,7 +119,12 @@ For example:
119119
}
120120
```
121121

122-
## VS Code support (auto fix on save)
122+
## IDE Support (auto fix on save)
123+
124+
<details>
125+
<summary>🟦 VS Code support</summary>
126+
127+
<br>
123128

124129
Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
125130

@@ -139,16 +144,16 @@ Add the following settings to your `.vscode/settings.json`:
139144

140145
// Silent the stylistic rules in you IDE, but still auto fix them
141146
"eslint.rules.customizations": [
142-
{ "rule": "style/*", "severity": "off" },
143-
{ "rule": "format/*", "severity": "off" },
144-
{ "rule": "*-indent", "severity": "off" },
145-
{ "rule": "*-spacing", "severity": "off" },
146-
{ "rule": "*-spaces", "severity": "off" },
147-
{ "rule": "*-order", "severity": "off" },
148-
{ "rule": "*-dangle", "severity": "off" },
149-
{ "rule": "*-newline", "severity": "off" },
150-
{ "rule": "*quotes", "severity": "off" },
151-
{ "rule": "*semi", "severity": "off" }
147+
{ "rule": "style/*", "severity": "off", "fixable": true },
148+
{ "rule": "format/*", "severity": "off", "fixable": true },
149+
{ "rule": "*-indent", "severity": "off", "fixable": true },
150+
{ "rule": "*-spacing", "severity": "off", "fixable": true },
151+
{ "rule": "*-spaces", "severity": "off", "fixable": true },
152+
{ "rule": "*-order", "severity": "off", "fixable": true },
153+
{ "rule": "*-dangle", "severity": "off", "fixable": true },
154+
{ "rule": "*-newline", "severity": "off", "fixable": true },
155+
{ "rule": "*quotes", "severity": "off", "fixable": true },
156+
{ "rule": "*semi", "severity": "off", "fixable": true }
152157
],
153158

154159
// Enable eslint for all supported languages
@@ -168,6 +173,7 @@ Add the following settings to your `.vscode/settings.json`:
168173
"gql",
169174
"graphql",
170175
"astro",
176+
"svelte",
171177
"css",
172178
"less",
173179
"scss",
@@ -177,6 +183,90 @@ Add the following settings to your `.vscode/settings.json`:
177183
}
178184
```
179185

186+
</details>
187+
188+
<details>
189+
<summary>🟩 Neovim Support</summary>
190+
191+
<br>
192+
193+
Update your configuration to use the following:
194+
195+
```lua
196+
local customizations = {
197+
{ rule = 'style/*', severity = 'off', fixable = true },
198+
{ rule = 'format/*', severity = 'off', fixable = true },
199+
{ rule = '*-indent', severity = 'off', fixable = true },
200+
{ rule = '*-spacing', severity = 'off', fixable = true },
201+
{ rule = '*-spaces', severity = 'off', fixable = true },
202+
{ rule = '*-order', severity = 'off', fixable = true },
203+
{ rule = '*-dangle', severity = 'off', fixable = true },
204+
{ rule = '*-newline', severity = 'off', fixable = true },
205+
{ rule = '*quotes', severity = 'off', fixable = true },
206+
{ rule = '*semi', severity = 'off', fixable = true },
207+
}
208+
209+
local lspconfig = require('lspconfig')
210+
-- Enable eslint for all supported languages
211+
lspconfig.eslint.setup(
212+
{
213+
filetypes = {
214+
"javascript",
215+
"javascriptreact",
216+
"javascript.jsx",
217+
"typescript",
218+
"typescriptreact",
219+
"typescript.tsx",
220+
"vue",
221+
"html",
222+
"markdown",
223+
"json",
224+
"jsonc",
225+
"yaml",
226+
"toml",
227+
"xml",
228+
"gql",
229+
"graphql",
230+
"astro",
231+
"svelte",
232+
"css",
233+
"less",
234+
"scss",
235+
"pcss",
236+
"postcss"
237+
},
238+
settings = {
239+
-- Silent the stylistic rules in you IDE, but still auto fix them
240+
rulesCustomizations = customizations,
241+
},
242+
}
243+
)
244+
```
245+
246+
### Neovim format on save
247+
248+
There's few ways you can achieve format on save in neovim:
249+
250+
- `nvim-lspconfig` has a `EslintFixAll` command predefined, you can create a autocmd to call this command after saving file.
251+
252+
```lua
253+
lspconfig.eslint.setup({
254+
--- ...
255+
on_attach = function(client, bufnr)
256+
vim.api.nvim_create_autocmd("BufWritePre", {
257+
buffer = bufnr,
258+
command = "EslintFixAll",
259+
})
260+
end,
261+
})
262+
```
263+
264+
- Use [conform.nvim](https://github.com/stevearc/conform.nvim).
265+
- Use [none-ls](https://github.com/nvimtools/none-ls.nvim)
266+
- Use [nvim-lint](https://github.com/mfussenegger/nvim-lint)
267+
268+
</details>
269+
180270
## Customization
181271

182272
Since v1.0, we migrated to [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new). It provides much better organization and composition.
@@ -197,6 +287,9 @@ And that's it! Or you can configure each integration individually, for example:
197287
import kirklin from "@kirklin/eslint-config";
198288

199289
export default kirklin({
290+
// Type of the project. 'lib' for libraries, the default is 'app'
291+
type: "lib",
292+
200293
// Enable stylistic formatting rules
201294
// stylistic: true,
202295

@@ -206,7 +299,7 @@ export default kirklin({
206299
quotes: "double", // or 'single'
207300
},
208301

209-
// TypeScript and Vue are auto-detected, you can also explicitly enable them:
302+
// TypeScript and Vue are autodetected, you can also explicitly enable them:
210303
typescript: true,
211304
vue: true,
212305

@@ -309,7 +402,7 @@ Since flat config requires us to explicitly provide the plugin names (instead of
309402
| `yaml/*` | `yml/*` | [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) |
310403
| `ts/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
311404
| `style/*` | `@stylistic/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic) |
312-
| `test/*` | `vitest/*` | [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest) |
405+
| `test/*` | `vitest/*` | [@vitest/eslint-plugin](https://github.com/vitest-dev/eslint-plugin-vitest) |
313406
| `test/*` | `no-only-tests/*` | [eslint-plugin-no-only-tests](https://github.com/levibuzolic/eslint-plugin-no-only-tests) |
314407

315408
When you want to override rules, or disable them inline, you need to update to the new prefix:
@@ -329,7 +422,26 @@ type foo = { bar: 2 }
329422
>
330423
> Feel free to open issues if you want to combine this config with some other config presets but faced naming collisions. I am happy to figure out a way to make them work. But at this moment I have no plan to revert the renaming.
331424
332-
Since v2.9.0, this preset will automatically rename the plugins also for your custom configs. You can use the original prefix to override the rules directly.
425+
Since v2.3.0, this preset will automatically rename the plugins also for your custom configs. You can use the original prefix to override the rules directly.
426+
427+
<details>
428+
<summary>Change back to original prefix</summary>
429+
430+
If you really want to use the original prefix, you can revert the plugin renaming by:
431+
432+
```ts
433+
import kirklin from "@kirklin/eslint-config";
434+
435+
export default kirklin()
436+
.renamePlugins({
437+
ts: "@typescript-eslint",
438+
yaml: "yml",
439+
node: "n"
440+
// ...
441+
});
442+
```
443+
444+
</details>
333445

334446
### Rules Overrides
335447

0 commit comments

Comments
 (0)