|
6 | 6 |
|
7 | 7 | ## Feature
|
8 | 8 |
|
9 |
| -- ✨ Single quotes, no semi |
10 | 9 | - 🛠️ Auto fix for formatting
|
| 10 | +- ✨ Support Vue, React, Svelte. |
11 | 11 | - 🎯 Designed to work with TypeScript, Vue out-of-box
|
12 |
| -- 🔍 Lints also for json |
13 |
| -- 🧩 Sorted imports, dangling commas |
14 | 12 | - 🏆 Reasonable defaults, best practices, only one-line of config
|
15 |
| -- 🚀 [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), compose easily! |
16 |
| -- 🎨 Use ESlint and Prettier to format HTML, CSS, LESS, SCSS, YAML, TOML, Markdown. |
| 13 | +- 🎨 Use ESlint and Prettier to format HTML, CSS, LESS, SCSS, YAML, TOML, Markdown, JSON, JSONC. |
17 | 14 |
|
18 | 15 | ## Usage
|
19 | 16 |
|
@@ -60,8 +57,6 @@ For example:
|
60 | 57 |
|
61 | 58 | ## VS Code support (auto fix)
|
62 | 59 |
|
63 |
| -Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) |
64 |
| - |
65 | 60 | Add the following settings to your `.vscode/settings.json`:
|
66 | 61 |
|
67 | 62 | ```jsonc
|
@@ -109,12 +104,166 @@ If you want to apply lint and auto-fix before every commit, you can add the foll
|
109 | 104 | }
|
110 | 105 | }
|
111 | 106 | ```
|
112 |
| - |
113 | 107 | and then
|
114 | 108 |
|
115 | 109 | ```bash
|
116 | 110 | npm i -D lint-staged simple-git-hooks
|
117 | 111 | ```
|
| 112 | +## Options |
| 113 | + |
| 114 | +### interface Options |
| 115 | + |
| 116 | +```ts |
| 117 | +interface OptionsConfig { |
| 118 | + /** |
| 119 | + * The current working directory |
| 120 | + * |
| 121 | + * @default process.cwd() |
| 122 | + */ |
| 123 | + cwd?: string |
| 124 | + |
| 125 | + /** |
| 126 | + * Enable gitignore support. |
| 127 | + * |
| 128 | + * Passing an object to configure the options. |
| 129 | + * |
| 130 | + * @see https://github.com/antfu/eslint-config-flat-gitignore |
| 131 | + * @default true |
| 132 | + */ |
| 133 | + gitignore?: boolean | FlatGitignoreOptions |
| 134 | + |
| 135 | + /** |
| 136 | + * Core rules. Can't be disabled. |
| 137 | + */ |
| 138 | + javascript?: OptionsOverrides |
| 139 | + |
| 140 | + /** |
| 141 | + * Enable TypeScript support. |
| 142 | + * |
| 143 | + * Passing an object to enable TypeScript Language Server support. |
| 144 | + * |
| 145 | + * @default auto-detect based on the dependencies |
| 146 | + */ |
| 147 | + typescript?: boolean | OptionsTypescript |
| 148 | + |
| 149 | + /** |
| 150 | + * Enable test support. |
| 151 | + * |
| 152 | + * @default true |
| 153 | + */ |
| 154 | + test?: boolean | OptionsOverrides |
| 155 | + |
| 156 | + /** |
| 157 | + * Enable Vue support. |
| 158 | + * |
| 159 | + * @default auto-detect based on the dependencies |
| 160 | + */ |
| 161 | + vue?: boolean | OptionsVue |
| 162 | + |
| 163 | + /** |
| 164 | + * Enable JSONC support. |
| 165 | + * |
| 166 | + * @default true |
| 167 | + */ |
| 168 | + jsonc?: boolean | OptionsOverrides |
| 169 | + |
| 170 | + /** |
| 171 | + * Enable react rules. |
| 172 | + * |
| 173 | + * Requires installing: |
| 174 | + * - `eslint-plugin-react` |
| 175 | + * - `eslint-plugin-react-hooks` |
| 176 | + * - `eslint-plugin-react-refresh` |
| 177 | + * |
| 178 | + * @default false |
| 179 | + */ |
| 180 | + react?: boolean | OptionsOverrides |
| 181 | + |
| 182 | + /** |
| 183 | + * Enable svelte rules. |
| 184 | + * |
| 185 | + * Requires installing: |
| 186 | + * - `eslint-plugin-svelte` |
| 187 | + * |
| 188 | + * @default false |
| 189 | + */ |
| 190 | + svelte?: boolean | OptionsOverrides |
| 191 | + |
| 192 | + /** |
| 193 | + * Enable unocss rules. |
| 194 | + * |
| 195 | + * Requires installing: |
| 196 | + * - `@unocss/eslint-plugin` |
| 197 | + * |
| 198 | + * @default false |
| 199 | + */ |
| 200 | + unocss?: boolean | OptionsUnoCSS |
| 201 | + |
| 202 | + /** |
| 203 | + * Whether to use prettierrc |
| 204 | + * |
| 205 | + * If true, the rules in prettierrc will override the default rules |
| 206 | + * |
| 207 | + * @default true |
| 208 | + */ |
| 209 | + usePrettierrc?: boolean |
| 210 | + |
| 211 | + /** |
| 212 | + * Use external formatters to format files. |
| 213 | + * |
| 214 | + * Requires installing: |
| 215 | + * - `eslint-plugin-prettier` |
| 216 | + * |
| 217 | + * @default |
| 218 | + * { |
| 219 | + * "html": true, |
| 220 | + * "css": true, |
| 221 | + * "graphql": true, |
| 222 | + * "markdown": true |
| 223 | + * "yaml": true |
| 224 | + * "toml": true |
| 225 | + * } |
| 226 | + */ |
| 227 | + formatter?: OptionsFormatters |
| 228 | + |
| 229 | + /** |
| 230 | + * Default prettier rules |
| 231 | + * |
| 232 | + * @default |
| 233 | + * ```json |
| 234 | + * { |
| 235 | + * "arrowParens": "avoid", |
| 236 | + * "htmlWhitespaceSensitivity": "ignore" |
| 237 | + * "printWidth": 120, |
| 238 | + * "semi": false, |
| 239 | + * "singleQuote": true, |
| 240 | + * } |
| 241 | + * ``` |
| 242 | + */ |
| 243 | + prettierRules?: PartialPrettierExtendedOptions |
| 244 | + |
| 245 | + /** |
| 246 | + * Control to disable some rules in editors. |
| 247 | + * @default auto-detect based on the process.env |
| 248 | + */ |
| 249 | + isInEditor?: boolean |
| 250 | + |
| 251 | + /** |
| 252 | + * Provide overrides for rules for each integration. |
| 253 | + * |
| 254 | + * @deprecated use `overrides` option in each integration key instead |
| 255 | + */ |
| 256 | + overrides?: { |
| 257 | + javascript?: FlatConfigItem['rules'] |
| 258 | + typescript?: FlatConfigItem['rules'] |
| 259 | + test?: FlatConfigItem['rules'] |
| 260 | + vue?: FlatConfigItem['rules'] |
| 261 | + jsonc?: FlatConfigItem['rules'] |
| 262 | + react?: FlatConfigItem['rules'] |
| 263 | + svelte?: FlatConfigItem['rules'] |
| 264 | + } |
| 265 | +} |
| 266 | +``` |
118 | 267 |
|
119 | 268 | ## Thanks
|
120 | 269 |
|
|
0 commit comments