Skip to content

Commit 4a0ad1f

Browse files
Kaivan Wongantfu
Kaivan Wong
andauthored
feat: add eslint config for astro framework (#410)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
1 parent abcf691 commit 4a0ad1f

12 files changed

+194
-70
lines changed

README.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
- [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), compose easily!
1313
- Using [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
1414
- Respects `.gitignore` by default
15-
- Optional [React](#react), [Svelte](#svelte), [UnoCSS](#unocss) support
15+
- Optional [React](#react), [Svelte](#svelte), [UnoCSS](#unocss), [Astro](#astro) support
1616
- Optional [formatters](#formatters) support for CSS, HTML, etc.
1717
- **Style principle**: Minimal for reading, stable for diff, consistent
1818

@@ -431,6 +431,25 @@ Running `npx eslint` should prompt you to install the required dependencies, oth
431431
npm i -D eslint-plugin-svelte
432432
```
433433

434+
#### Astro
435+
436+
To enable astro support, you need to explicitly turn it on:
437+
438+
```js
439+
// eslint.config.js
440+
import antfu from '@antfu/eslint-config'
441+
442+
export default antfu({
443+
astro: true,
444+
})
445+
```
446+
447+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
448+
449+
```bash
450+
npm i -D eslint-plugin-astro
451+
```
452+
434453
#### UnoCSS
435454

436455
To enable UnoCSS support, you need to explicitly turn it on:

fixtures/input/astro.astro

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
const content = "hi!";
3+
---
4+
5+
<article>
6+
<div>{content}</div>
7+
</article>

fixtures/output/all/astro.astro

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
const content = 'hi!';
3+
---
4+
5+
<article>
6+
<div>{content}</div>
7+
</article>

package.json

+10
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
},
3939
"peerDependencies": {
4040
"@unocss/eslint-plugin": ">=0.50.0",
41+
"astro-eslint-parser": "^0.16.3",
4142
"eslint": ">=8.40.0",
43+
"eslint-plugin-astro": "^0.31.4",
4244
"eslint-plugin-format": ">=0.1.0",
4345
"eslint-plugin-react": "^7.33.2",
4446
"eslint-plugin-react-hooks": "^4.6.0",
@@ -51,6 +53,12 @@
5153
"@unocss/eslint-plugin": {
5254
"optional": true
5355
},
56+
"astro-eslint-parser": {
57+
"optional": true
58+
},
59+
"eslint-plugin-astro": {
60+
"optional": true
61+
},
5462
"eslint-plugin-format": {
5563
"optional": true
5664
},
@@ -122,9 +130,11 @@
122130
"@types/prompts": "^2.4.9",
123131
"@types/yargs": "^17.0.32",
124132
"@unocss/eslint-plugin": "^0.58.5",
133+
"astro-eslint-parser": "^0.16.3",
125134
"bumpp": "^9.3.0",
126135
"eslint": "npm:eslint-ts-patch@^8.56.0-0",
127136
"eslint-flat-config-viewer": "^0.1.11",
137+
"eslint-plugin-astro": "^0.31.4",
128138
"eslint-plugin-format": "^0.1.0",
129139
"eslint-plugin-react": "^7.33.2",
130140
"eslint-plugin-react-hooks": "^4.6.0",

0 commit comments

Comments
 (0)