Skip to content

Commit 4ca4156

Browse files
authored
docs: add basic config for new ESLint v9 flat configs
- I had to search for a couple of hours to find out how to migrate to the new ESLint v9 flat config `eslint.config.mjs`, so I thought that I could add this to the docs to help others like me to get started with the new flat config
1 parent 66e3201 commit 4ca4156

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

docs/user-guide/index.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,49 @@ export default [
4747

4848
See [the rule list](../rules/index.md) to get the `configs` & `rules` that this plugin provides.
4949

50+
#### Configurations with `typescript-esLint` & Prettier (`eslint.config.js`)
51+
52+
```bash
53+
npm install --save-dev eslint eslint-config-prettier eslint-plugin-vue globals typescript-eslint
54+
```
55+
56+
```ts
57+
import eslint from '@eslint/js';
58+
import eslintConfigPrettier from 'eslint-config-prettier';
59+
import globals from 'globals';
60+
import pluginVue from 'eslint-plugin-vue';
61+
import tseslint from 'typescript-eslint';
62+
63+
export default tseslint.config(
64+
{
65+
ignores: ['*.d.ts', '**/coverage', '**/dist'],
66+
},
67+
{
68+
extends: [
69+
eslint.configs.recommended,
70+
...tseslint.configs.recommended,
71+
...pluginVue.configs['flat/recommended'],
72+
],
73+
plugins: {
74+
'@typescript-eslint': tseslint.plugin,
75+
},
76+
files: ['**/*.{ts,vue}'],
77+
languageOptions: {
78+
ecmaVersion: 2021,
79+
sourceType: 'module',
80+
globals: globals.browser,
81+
parserOptions: {
82+
parser: tseslint.parser,
83+
},
84+
},
85+
rules: {
86+
// your rules
87+
},
88+
},
89+
eslintConfigPrettier
90+
);
91+
```
92+
5093
#### Bundle Configurations (`eslint.config.js`)
5194

5295
This plugin provides some predefined configs.

0 commit comments

Comments
 (0)