1+ import js from '@eslint/js'
2+ import globals from 'globals'
3+ import reactHooks from 'eslint-plugin-react-hooks'
4+ import reactRefresh from 'eslint-plugin-react-refresh'
5+ import tseslint from 'typescript-eslint'
6+
7+
8+ export default tseslint . config (
9+ {
10+ ignores : [
11+ 'dist' ,
12+ 'node_modules' ,
13+ '.yalc' ,
14+ 'src/rest/*' // do not lint generated code
15+ ]
16+ } ,
17+ {
18+ extends : [ js . configs . recommended , ...tseslint . configs . recommended ] ,
19+ files : [ '**/*.{ts,tsx,js,jsx}' ] ,
20+ languageOptions : {
21+ ecmaVersion : "latest" ,
22+ globals : globals . browser ,
23+ sourceType : "module"
24+ } ,
25+ plugins : {
26+ 'react-hooks' : reactHooks ,
27+ 'react-refresh' : reactRefresh ,
28+ } ,
29+ rules : {
30+ ...reactHooks . configs . recommended . rules ,
31+ 'react-refresh/only-export-components' : [
32+ 'warn' ,
33+ { allowConstantExport : true } ,
34+ ] ,
35+ indent : [ "error" , 2 , {
36+ SwitchCase : 1 ,
37+ } ] ,
38+ curly : "error" , // enforce braces for one-line blocks
39+ "no-tabs" : "error" , // enforce no tabs
40+ "no-console" : [ "warn" , {
41+ allow : [ "warn" , "error" , "debug" ] ,
42+ } ] ,
43+ "@typescript-eslint/no-explicit-any" : "off" , // No strict typing (annoying especially with React elements and events callbacks)
44+ "consistent-return" : "warn" , // https://eslint.org/docs/latest/rules/consistent-return
45+ "prefer-arrow-callback" : [ "warn" ] ,
46+ "object-curly-spacing" : [ "warn" , "always" ] , // enforce consistent spacing inside braces
47+ "func-style" : "off" , // function expressions or arrow functions are equally valid
48+ "no-unneeded-ternary" : "warn" , // disallow unnecessary ternary expressions
49+ // React rules: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules
50+ "react/prop-types" : "off" , // PropTypes are not forced
51+ "react/forbid-prop-types" : "off" , // all PropTypes are allowed
52+ "react-hooks/rules-of-hooks" : "error" , // https://react.dev/reference/rules/rules-of-hooks
53+ "react-hooks/exhaustive-deps" : "warn" , // Hooks dependency array, sometimes it's better to ignore
54+ } ,
55+ }
56+ )
0 commit comments