Skip to content

Commit

Permalink
feat: add eslint config for astro framework (#410)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
kaivanwong and antfu committed Mar 3, 2024
1 parent abcf691 commit 4a0ad1f
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 70 deletions.
21 changes: 20 additions & 1 deletion README.md
Expand Up @@ -12,7 +12,7 @@
- [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), compose easily!
- Using [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
- Respects `.gitignore` by default
- Optional [React](#react), [Svelte](#svelte), [UnoCSS](#unocss) support
- Optional [React](#react), [Svelte](#svelte), [UnoCSS](#unocss), [Astro](#astro) support
- Optional [formatters](#formatters) support for CSS, HTML, etc.
- **Style principle**: Minimal for reading, stable for diff, consistent

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

#### Astro

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

```js
// eslint.config.js
import antfu from '@antfu/eslint-config'

export default antfu({
astro: true,
})
```

Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:

```bash
npm i -D eslint-plugin-astro
```

#### UnoCSS

To enable UnoCSS support, you need to explicitly turn it on:
Expand Down
7 changes: 7 additions & 0 deletions fixtures/input/astro.astro
@@ -0,0 +1,7 @@
---
const content = "hi!";
---

<article>
<div>{content}</div>
</article>
7 changes: 7 additions & 0 deletions fixtures/output/all/astro.astro
@@ -0,0 +1,7 @@
---
const content = 'hi!';
---

<article>
<div>{content}</div>
</article>
10 changes: 10 additions & 0 deletions package.json
Expand Up @@ -38,7 +38,9 @@
},
"peerDependencies": {
"@unocss/eslint-plugin": ">=0.50.0",
"astro-eslint-parser": "^0.16.3",
"eslint": ">=8.40.0",
"eslint-plugin-astro": "^0.31.4",
"eslint-plugin-format": ">=0.1.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
Expand All @@ -51,6 +53,12 @@
"@unocss/eslint-plugin": {
"optional": true
},
"astro-eslint-parser": {
"optional": true
},
"eslint-plugin-astro": {
"optional": true
},
"eslint-plugin-format": {
"optional": true
},
Expand Down Expand Up @@ -122,9 +130,11 @@
"@types/prompts": "^2.4.9",
"@types/yargs": "^17.0.32",
"@unocss/eslint-plugin": "^0.58.5",
"astro-eslint-parser": "^0.16.3",
"bumpp": "^9.3.0",
"eslint": "npm:eslint-ts-patch@^8.56.0-0",
"eslint-flat-config-viewer": "^0.1.11",
"eslint-plugin-astro": "^0.31.4",
"eslint-plugin-format": "^0.1.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
Expand Down

0 comments on commit 4a0ad1f

Please sign in to comment.