-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
120 lines (113 loc) · 2.77 KB
/
eslint.config.js
File metadata and controls
120 lines (113 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import { defineConfig } from 'eslint/config';
import js from '@eslint/js';
import react from 'eslint-plugin-react';
import astro from 'eslint-plugin-astro';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
export default defineConfig([
// Ignore patterns (MUST be first)
{
ignores: [
'dist/**',
'.astro/**',
'node_modules/**',
'.vercel/**',
'coverage/**',
'pnpm-lock.yaml',
'.prettierignore',
'*.min.js',
'**/*.md',
'public/**',
'postcss.config.cjs',
],
},
// Global settings
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
ecmaVersion: 'latest',
sourceType: 'module',
},
settings: {
react: {
version: 'detect',
},
},
},
// Base JavaScript configuration
js.configs.recommended,
// TypeScript configurations
tseslint.configs.recommended,
// Prettier
eslintConfigPrettier,
// Astro configurations
astro.configs.recommended,
astro.configs['jsx-a11y-recommended'],
// Astro-specific rules
{
files: ['**/*.astro'],
languageOptions: {
parser: astro.parser,
parserOptions: {
parser: tseslint.parser,
extraFileExtensions: ['.astro'],
sourceType: 'module',
ecmaVersion: 'latest',
project: './tsconfig.json',
},
},
rules: {
// Astro rules
'astro/prefer-class-list-directive': 'off',
'astro/prefer-split-class-list': 'warn',
'astro/no-set-html-directive': 'warn',
'astro/jsx-a11y/iframe-has-title': 'warn',
'@typescript-eslint/no-empty-object-type': 'off',
// Disable React rules that don't apply to Astro
'react/no-unknown-property': 'off',
'react/jsx-key': 'off',
},
},
// TypeScript files configuration
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: './tsconfig.json',
},
},
rules: {
'@typescript-eslint/no-require-imports': 'warn',
},
},
// Custom rules for all source files
{
files: ['**/*.{js,mjs,cjs,ts,tsx,jsx,astro}'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
// General rules
'no-console': ['warn', { allow: ['log', 'warn', 'error'] }],
'no-undef': 'off', // Handled by TypeScript
'prefer-const': 'warn',
},
},
// React-specific rules (only for React files)
{
...react.configs.flat.recommended,
files: ['**/*.{jsx,tsx}'],
rules: {
'react/react-in-jsx-scope': 'off', // Not needed with React 17+
'react/prop-types': 'off', // Using TypeScript
'react/jsx-no-target-blank': 'warn', // Security best practice
},
},
]);