1
+ import { defineConfig } from "eslint/config" ;
2
+ import globals from "globals" ;
3
+ import js from "@eslint/js" ;
4
+ import tseslint from "typescript-eslint" ;
5
+
6
+ // Plugins
7
+ import jsdocPlugin from 'eslint-plugin-jsdoc' ;
8
+ import reactPlugin from 'eslint-plugin-react' ;
9
+ import reactHooksPlugin from 'eslint-plugin-react-hooks' ;
10
+
11
+ /** Files to include in linting. */
12
+ const filesToParse = [ "**/*.{mjs,ts,tsx}" ]
13
+
14
+ export default defineConfig ( [
15
+ // Auto generated features
16
+ { files : filesToParse , languageOptions : { globals : globals . browser } } ,
17
+ { files : filesToParse , plugins : { js } , extends : [ "js/recommended" ] } ,
18
+ // General
19
+ tseslint . configs . recommended ,
20
+ {
21
+ files : filesToParse ,
22
+ rules : {
23
+ "indent" : [ "error" , 4 , { "SwitchCase" : 1 } ] ,
24
+ "no-undef" : "off" ,
25
+ "camelcase" : "off" ,
26
+ "curly" : [ "error" , "all" ] ,
27
+ "no-multi-spaces" : "error" ,
28
+ "padding-line-between-statements" : [
29
+ "warn" ,
30
+ { "blankLine" : "always" , "prev" : "*" , "next" : "block" } ,
31
+ { "blankLine" : "always" , "prev" : "block" , "next" : "*" } ,
32
+ { "blankLine" : "always" , "prev" : "*" , "next" : "block-like" } ,
33
+ { "blankLine" : "always" , "prev" : "block-like" , "next" : "*" }
34
+ ] ,
35
+ "@typescript-eslint/no-explicit-any" : "off" ,
36
+ // Disables warnings for unused vars that start with a '_'
37
+ "@typescript-eslint/no-unused-vars" : [
38
+ "error" ,
39
+ {
40
+ "argsIgnorePattern" : "^_" ,
41
+ "varsIgnorePattern" : "^_" ,
42
+ "caughtErrorsIgnorePattern" : "^_" ,
43
+ "destructuredArrayIgnorePattern" : "^_"
44
+ }
45
+ ] ,
46
+ } ,
47
+ } ,
48
+ // JSDocs
49
+ jsdocPlugin . configs [ 'flat/recommended-typescript' ] ,
50
+ {
51
+ files : filesToParse ,
52
+ plugins : { jsdoc : jsdocPlugin } ,
53
+ rules : {
54
+ "jsdoc/require-description" : "warn" ,
55
+ "jsdoc/check-alignment" : "warn" ,
56
+ "jsdoc/check-param-names" : "warn" ,
57
+ "jsdoc/check-tag-names" : "warn" ,
58
+ "jsdoc/check-types" : "warn" ,
59
+ "jsdoc/implements-on-classes" : "warn" ,
60
+ "jsdoc/no-undefined-types" : "warn" ,
61
+ "jsdoc/require-jsdoc" : "warn" ,
62
+ "jsdoc/require-param" : "warn" ,
63
+ "jsdoc/require-param-description" : "warn" ,
64
+ "jsdoc/require-param-name" : "warn" ,
65
+ "jsdoc/require-returns-check" : "warn" ,
66
+ "jsdoc/require-returns-description" : "warn" ,
67
+ "jsdoc/valid-types" : "warn" ,
68
+ "jsdoc/require-returns" : "warn" ,
69
+ }
70
+ } ,
71
+ // React
72
+ reactPlugin . configs . flat . recommended , // This is not a plugin object, but a shareable config object
73
+ reactPlugin . configs . flat [ 'jsx-runtime' ] , // Add this if you are using React 17+
74
+ reactHooksPlugin . configs [ 'recommended-latest' ] ,
75
+ {
76
+ files : filesToParse ,
77
+ plugins : {
78
+ react : reactPlugin ,
79
+ } ,
80
+ languageOptions : {
81
+ parserOptions : {
82
+ ecmaFeatures : {
83
+ jsx : true ,
84
+ } ,
85
+ } ,
86
+ globals : {
87
+ ...globals . browser ,
88
+ } ,
89
+ } ,
90
+ rules : {
91
+ "react/no-unescaped-entities" : "off" ,
92
+ "react-hooks/rules-of-hooks" : "error" ,
93
+ "react-hooks/exhaustive-deps" : "off" ,
94
+ "react/display-name" : "off" ,
95
+ "react/jsx-equals-spacing" : "error" ,
96
+ "react/jsx-closing-bracket-location" : "error" ,
97
+ "react/jsx-closing-tag-location" : "error" ,
98
+ "react/jsx-curly-spacing" : [
99
+ "error" ,
100
+ {
101
+ "when" : "never" ,
102
+ "children" : true
103
+ }
104
+ ] ,
105
+ "react/jsx-tag-spacing" : [
106
+ "error" ,
107
+ {
108
+ "afterOpening" : "never" ,
109
+ "beforeClosing" : "never" ,
110
+ "beforeSelfClosing" : "proportional-always" ,
111
+ "closingSlash" : "never"
112
+ }
113
+ ] ,
114
+ "react/jsx-curly-brace-presence" : [
115
+ "error" ,
116
+ {
117
+ "props" : "never" ,
118
+ "children" : "never"
119
+ }
120
+ ] ,
121
+ "react/jsx-uses-react" : "error" ,
122
+ "react/jsx-uses-vars" : "error" ,
123
+ } ,
124
+ settings : {
125
+ react : {
126
+ version : "detect"
127
+ }
128
+ }
129
+ } ,
130
+ ] )
0 commit comments