Features: 1) Add astro-eslint-parser as a new devDependency;
Fixes: Extra: 1) Refactor ESLint configuration to simplify overrides with modular imports for Astro and Vue; 2) Format ESLint config for consistency.
This commit is contained in:
parent
587c7d3428
commit
6894015954
3 changed files with 41 additions and 87 deletions
|
|
@ -1,96 +1,48 @@
|
||||||
module.exports = {
|
import astroPlugin from 'eslint-plugin-astro';
|
||||||
root: true,
|
import astroParser from 'astro-eslint-parser';
|
||||||
env: {
|
import vuePlugin from 'eslint-plugin-vue';
|
||||||
browser: true,
|
import vueParser from 'vue-eslint-parser';
|
||||||
node: true,
|
|
||||||
es2021: true,
|
|
||||||
},
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: 2021,
|
|
||||||
sourceType: 'module',
|
|
||||||
// Allow ESLint to recognize .vue and .astro files
|
|
||||||
extraFileExtensions: ['.vue', '.astro'],
|
|
||||||
},
|
|
||||||
extends: [
|
|
||||||
// Basic recommended rules from ESLint
|
|
||||||
'eslint:recommended',
|
|
||||||
|
|
||||||
// Vue 3 best practices (uses vue-eslint-parser under the hood)
|
export default [
|
||||||
'plugin:vue/vue3-recommended', // :contentReference[oaicite:0]{index=0}
|
|
||||||
|
|
||||||
// TypeScript support (if you’re using TS in .js/.ts or inside .vue/.astro)
|
|
||||||
'plugin:@typescript-eslint/recommended',
|
|
||||||
|
|
||||||
// Astro’s own recommended ruleset
|
|
||||||
'plugin:astro/recommended', // :contentReference[oaicite:1]{index=1}
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
'vue',
|
|
||||||
'@typescript-eslint',
|
|
||||||
'astro',
|
|
||||||
],
|
|
||||||
rules: {
|
|
||||||
// Customize global rules here (if needed). For example:
|
|
||||||
// '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
|
||||||
},
|
|
||||||
overrides: [
|
|
||||||
// ————— Override for `.astro` files —————
|
|
||||||
{
|
{
|
||||||
files: ['*.astro'],
|
files: ['*.astro'],
|
||||||
parser: 'astro-eslint-parser',
|
languageOptions: {
|
||||||
parserOptions: {
|
parser: astroParser,
|
||||||
// Inside <script> blocks in .astro, treat code as TS by default
|
parserOptions: {
|
||||||
parser: '@typescript-eslint/parser',
|
ecmaVersion: 2021,
|
||||||
ecmaVersion: 2021,
|
sourceType: 'module',
|
||||||
sourceType: 'module',
|
},
|
||||||
},
|
},
|
||||||
extends: [
|
plugins: {
|
||||||
// Minimal Astro linting (parses frontmatter, template, etc.)
|
astro: astroPlugin,
|
||||||
'plugin:astro/recommended', // :contentReference[oaicite:2]{index=2}
|
},
|
||||||
],
|
extends: ['plugin:astro/recommended'],
|
||||||
rules: {
|
rules: {},
|
||||||
// Astro-specific rule overrides, e.g.:
|
|
||||||
// 'astro/no-set-html-directive': 'error'
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// ————— Override for `.vue` files —————
|
|
||||||
{
|
{
|
||||||
files: ['*.vue'],
|
files: ['*.vue'],
|
||||||
parser: 'vue-eslint-parser',
|
languageOptions: {
|
||||||
parserOptions: {
|
parser: vueParser,
|
||||||
// Delegate script blocks in .vue to TypeScript or plain JS
|
parserOptions: {
|
||||||
parser: '@typescript-eslint/parser',
|
ecmaVersion: 2021,
|
||||||
ecmaVersion: 2021,
|
sourceType: 'module',
|
||||||
sourceType: 'module',
|
},
|
||||||
},
|
},
|
||||||
extends: [
|
plugins: {
|
||||||
// Vue 3 recommended rules
|
vue: vuePlugin,
|
||||||
'plugin:vue/vue3-recommended', // :contentReference[oaicite:3]{index=3}
|
},
|
||||||
// If using TS inside .vue, this ensures type-aware rules
|
extends: ['plugin:vue/vue3-recommended'],
|
||||||
'plugin:@typescript-eslint/recommended',
|
rules: {},
|
||||||
],
|
|
||||||
rules: {
|
|
||||||
// Vue-specific rule overrides, e.g.:
|
|
||||||
// 'vue/no-mutating-props': 'error'
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// ————— Override for plain `.js` / `.ts` / `.jsx` / `.tsx` files —————
|
|
||||||
{
|
{
|
||||||
files: ['*.js', '*.jsx', '*.ts', '*.tsx'],
|
files: ['*.js', '*.jsx'],
|
||||||
parser: '@typescript-eslint/parser',
|
languageOptions: {
|
||||||
parserOptions: {
|
ecmaVersion: 2021,
|
||||||
ecmaVersion: 2021,
|
sourceType: 'module',
|
||||||
sourceType: 'module',
|
},
|
||||||
},
|
extends: ['eslint:recommended'],
|
||||||
extends: [
|
rules: {},
|
||||||
'eslint:recommended',
|
|
||||||
'plugin:@typescript-eslint/recommended',
|
|
||||||
],
|
|
||||||
rules: {
|
|
||||||
// Project-wide JS/TS rule overrides, if any
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
];
|
||||||
}
|
|
||||||
|
|
|
||||||
1
storefront/package-lock.json
generated
1
storefront/package-lock.json
generated
|
|
@ -25,6 +25,7 @@
|
||||||
"vue3-marquee-slider": "^1.0.5"
|
"vue3-marquee-slider": "^1.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"astro-eslint-parser": "^1.2.2",
|
||||||
"eslint": "^9.28.0",
|
"eslint": "^9.28.0",
|
||||||
"eslint-plugin-astro": "^1.3.1",
|
"eslint-plugin-astro": "^1.3.1",
|
||||||
"eslint-plugin-vue": "^10.1.0",
|
"eslint-plugin-vue": "^10.1.0",
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
"vue3-marquee-slider": "^1.0.5"
|
"vue3-marquee-slider": "^1.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"astro-eslint-parser": "^1.2.2",
|
||||||
"eslint": "^9.28.0",
|
"eslint": "^9.28.0",
|
||||||
"eslint-plugin-astro": "^1.3.1",
|
"eslint-plugin-astro": "^1.3.1",
|
||||||
"eslint-plugin-vue": "^10.1.0",
|
"eslint-plugin-vue": "^10.1.0",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue