Skip to content

Commit 6c417d2

Browse files
authored
Merge pull request #500 from ansidev/patchfix/eslint-flat-config
Patchfix: Migrate to eslint flat config
2 parents 9ff591a + 4124e34 commit 6c417d2

File tree

10 files changed

+481
-136
lines changed

10 files changed

+481
-136
lines changed

.env.local.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ASTRO_BASE_URL=http://localhost:4321

.eslintrc.cjs

Lines changed: 0 additions & 53 deletions
This file was deleted.

eslint.config.cjs

Lines changed: 0 additions & 4 deletions
This file was deleted.

eslint.config.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import jseslint from '@eslint/js'
2+
import tsEslintParser from '@typescript-eslint/parser'
3+
import eslintAstroPlugin from 'eslint-plugin-astro'
4+
import eslintSimpleImportSortPlugin from 'eslint-plugin-simple-import-sort'
5+
import globals from 'globals'
6+
import tseslint from 'typescript-eslint'
7+
8+
const sharedConfigs = {
9+
quotes: 'single',
10+
semicolon: false,
11+
}
12+
13+
export default [
14+
{
15+
ignores: ['.gitignore', '.astro/**'],
16+
plugins: {
17+
'simple-import-sort': eslintSimpleImportSortPlugin,
18+
},
19+
languageOptions: {
20+
sourceType: 'module',
21+
ecmaVersion: 2023,
22+
globals: {
23+
...globals.browser,
24+
...globals.node
25+
}
26+
},
27+
rules: {
28+
'comma-spacing': [
29+
'error',
30+
{
31+
'before': false,
32+
'after': true
33+
}
34+
],
35+
'quotes': ['error', sharedConfigs.quotes],
36+
'simple-import-sort/imports': 'error',
37+
'simple-import-sort/exports': 'error',
38+
},
39+
},
40+
{
41+
files: ['src/**/*.astro'],
42+
plugins: {
43+
'astro': eslintAstroPlugin,
44+
},
45+
...tseslint.configs.eslintRecommended,
46+
...{ rules: eslintAstroPlugin.configs.recommended.rules },
47+
languageOptions: {
48+
parser: tsEslintParser,
49+
},
50+
rules: {
51+
'astro/semi': ['error', sharedConfigs.semicolon ? 'always' : 'never'],
52+
}
53+
},
54+
{
55+
files: ['*.ts'],
56+
...jseslint.configs.recommended,
57+
...tseslint.configs.eslintRecommended,
58+
languageOptions: {
59+
parser: tsEslintParser,
60+
}
61+
},
62+
{
63+
files: ['*.mjs'],
64+
...jseslint.configs.recommended,
65+
},
66+
]

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
"preview": "astro preview",
1414
"astro": "astro",
1515
"prepare": "astro telemetry disable && husky install",
16-
"lint:js": "eslint --ext .cjs,.mjs,.ts,.astro --ignore-path .gitignore .",
16+
"lint:js": "eslint .",
1717
"lint:ts": "astro check && tsc --noEmit",
1818
"lint": "pnpm run lint:js && pnpm run lint:ts"
1919
},
2020
"dependencies": {
21+
"@astrojs/check": "^0.5.5",
2122
"@astrojs/partytown": "^2.0.2",
2223
"@astrojs/rss": "^4.0.0",
2324
"@astrojs/sitemap": "^3.0.3",
@@ -38,15 +39,15 @@
3839
"@types/lodash.kebabcase": "^4.1.8",
3940
"@types/mustache": "^4.2.4",
4041
"@types/node": "^20.9.3",
41-
"@typescript-eslint/eslint-plugin": "^7.0.0",
42-
"@typescript-eslint/parser": "^7.0.0",
42+
"@typescript-eslint/parser": "^7.0.2",
4343
"commander": "^11.1.0",
4444
"commitizen": "^4.3.0",
4545
"dayjs": "^1.11.10",
4646
"dotenv": "^16.3.1",
47-
"eslint": "^8.52.0",
48-
"eslint-plugin-astro": "^0.31.0",
47+
"eslint": "^8.57.0",
48+
"eslint-plugin-astro": "^0.31.4",
4949
"eslint-plugin-simple-import-sort": "^12.0.0",
50+
"globals": "^14.0.0",
5051
"husky": "^9.0.0",
5152
"lodash.get": "^4.4.2",
5253
"lodash.kebabcase": "^4.1.1",
@@ -56,6 +57,7 @@
5657
"satori-html": "^0.3.2",
5758
"tailwindcss-themer": "^4.0.0",
5859
"tsx": "^4.2.0",
59-
"typescript": "^5.2.2"
60+
"typescript": "^5.3.3",
61+
"typescript-eslint": "^7.0.2"
6062
}
6163
}

0 commit comments

Comments
 (0)