@@ -5,6 +5,7 @@ module.exports = {
5
5
parserOptions : {
6
6
ecmaVersion : 2020 , // Allows for the parsing of modern ECMAScript features
7
7
sourceType : 'module' , // Allows for the use of imports
8
+ extraFileExtensions : [ '.astro' ] ,
8
9
ecmaFeatures : {
9
10
jsx : true , // Allows for the parsing of JSX
10
11
} ,
@@ -16,14 +17,118 @@ module.exports = {
16
17
} ,
17
18
extends : [
18
19
'eslint:recommended' ,
19
- 'plugin:@typescript-eslint/recommended' , // Uses the recommended rules from the @typescript -eslint/eslint-plugin
20
+ 'plugin:@typescript-eslint/recommended' ,
20
21
'plugin:react/recommended' ,
21
22
'plugin:react-hooks/recommended' ,
22
- 'plugin:prettier/recommended' , // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
23
+ 'plugin:import/recommended' ,
24
+ 'plugin:prettier/recommended' ,
25
+ 'plugin:astro/recommended' ,
23
26
] ,
24
27
plugins : [ 'react-refresh' ] ,
25
- ignorePatterns : [ 'dist' , '.eslintrc.cjs' ] ,
28
+ ignorePatterns : [ 'dist' , '.eslintrc.cjs' , 'rust.d.ts' ] ,
26
29
rules : {
27
30
'react-refresh/only-export-components' : [ 'warn' , { allowConstantExport : true } ] ,
28
31
} ,
32
+ overrides : [
33
+ // Configuration for mjs,cjs files
34
+ {
35
+ files : [ '*.mjs' , '*.cjs' ] ,
36
+ extends : [ 'plugin:prettier/recommended' ] ,
37
+ rules : {
38
+ 'import/no-extraneous-dependencies' : 'off' , // mjs is only used by Astro for configuration, false positive
39
+ 'import/no-unresolved' : 'off' , // Also false positive with mjs file
40
+ } ,
41
+ } ,
42
+ // Configuration for TypeScript files
43
+ {
44
+ parser : '@typescript-eslint/parser' ,
45
+ files : [ '*.ts' , '*.tsx' ] ,
46
+
47
+ plugins : [ '@typescript-eslint' , 'react' , 'unused-imports' , 'tailwindcss' , 'simple-import-sort' ] ,
48
+ extends : [ 'plugin:tailwindcss/recommended' , 'airbnb-typescript/base' , 'plugin:prettier/recommended' ] ,
49
+ parserOptions : {
50
+ project : './tsconfig.json' ,
51
+ } ,
52
+ rules : {
53
+ 'import/extensions' : [
54
+ 'error' ,
55
+ 'ignorePackages' ,
56
+ {
57
+ js : 'never' ,
58
+ jsx : 'never' ,
59
+ ts : 'never' ,
60
+ tsx : 'never' ,
61
+ '' : 'never' ,
62
+ } ,
63
+ ] , // Avoid missing file extension errors when using '@/' alias
64
+ 'react/destructuring-assignment' : 'off' , // Vscode doesn't support automatically destructuring, it's a pain to add a new variable
65
+ 'react/require-default-props' : 'off' , // Allow non-defined react props as undefined
66
+ 'react/jsx-props-no-spreading' : 'off' , // _app.tsx uses spread operator and also, react-hook-form
67
+ '@typescript-eslint/comma-dangle' : 'off' , // Avoid conflict rule between Eslint and Prettier
68
+ '@typescript-eslint/consistent-type-imports' : 'error' , // Ensure `import type` is used when it's necessary
69
+ 'import/prefer-default-export' : 'off' , // Named export is easier to refactor automatically
70
+ 'tailwindcss/classnames-order' : [
71
+ 'warn' ,
72
+ {
73
+ officialSorting : true ,
74
+ } ,
75
+ ] , // Follow the same ordering as the official plugin `prettier-plugin-tailwindcss`
76
+ 'simple-import-sort/imports' : 'error' , // Import configuration for `eslint-plugin-simple-import-sort`
77
+ 'simple-import-sort/exports' : 'error' , // Export configuration for `eslint-plugin-simple-import-sort`
78
+ '@typescript-eslint/no-unused-vars' : 'off' ,
79
+ 'unused-imports/no-unused-imports' : 'error' ,
80
+ 'unused-imports/no-unused-vars' : [ 'error' , { argsIgnorePattern : '^_' } ] ,
81
+ } ,
82
+ } ,
83
+ // Configuration for Astro
84
+ {
85
+ files : [ '*.astro' ] ,
86
+ plugins : [ '@typescript-eslint' , 'react' , 'unused-imports' , 'tailwindcss' , 'simple-import-sort' ] ,
87
+ extends : [ 'plugin:tailwindcss/recommended' , 'airbnb-typescript/base' , 'plugin:prettier/recommended' ] ,
88
+ parser : 'astro-eslint-parser' ,
89
+ parserOptions : {
90
+ parser : '@typescript-eslint/parser' ,
91
+ } ,
92
+ rules : {
93
+ 'import/extensions' : [
94
+ 'error' ,
95
+ 'ignorePackages' ,
96
+ {
97
+ js : 'never' ,
98
+ jsx : 'never' ,
99
+ ts : 'never' ,
100
+ tsx : 'never' ,
101
+ '' : 'never' ,
102
+ } ,
103
+ ] , // Avoid missing file extension errors in .astro files
104
+ 'import/no-unresolved' : [
105
+ 'error' ,
106
+ {
107
+ ignore : [ '@/*' ] ,
108
+ } ,
109
+ ] , // Disable no-unresolved rule for .astro files
110
+ 'react/jsx-filename-extension' : [ 1 , { extensions : [ '.astro' ] } ] , // Accept jsx in astro files
111
+ 'react/destructuring-assignment' : 'off' , // Vscode doesn't support automatically destructuring, it's a pain to add a new variable
112
+ 'react/require-default-props' : 'off' , // Allow non-defined react props as undefined
113
+ 'react/jsx-props-no-spreading' : 'off' , // _app.tsx uses spread operator and also, react-hook-form
114
+ '@typescript-eslint/comma-dangle' : 'off' , // Avoid conflict rule between Eslint and Prettier
115
+ '@typescript-eslint/consistent-type-imports' : 'error' , // Ensure `import type` is used when it's necessary
116
+ 'import/prefer-default-export' : 'off' , // Named export is easier to refactor automatically
117
+ 'tailwindcss/classnames-order' : [
118
+ 'warn' ,
119
+ {
120
+ officialSorting : true ,
121
+ } ,
122
+ ] , // Follow the same ordering as the official plugin `prettier-plugin-tailwindcss`
123
+ 'simple-import-sort/imports' : 'error' , // Import configuration for `eslint-plugin-simple-import-sort`
124
+ 'simple-import-sort/exports' : 'error' , // Export configuration for `eslint-plugin-simple-import-sort`
125
+ '@typescript-eslint/no-unused-vars' : 'off' ,
126
+ 'unused-imports/no-unused-imports' : 'error' ,
127
+ 'unused-imports/no-unused-vars' : [ 'error' , { argsIgnorePattern : '^_' } ] ,
128
+ } ,
129
+ globals : {
130
+ Astro : 'readonly' ,
131
+ } ,
132
+ } ,
133
+ ] ,
29
134
} ;
0 commit comments