1- import { configs } from 'typescript-eslint'
1+ import js from '@eslint/js'
2+ import tsEslint from 'typescript-eslint'
3+ import react from 'eslint-plugin-react'
4+ import reactHooks from 'eslint-plugin-react-hooks'
5+ import importPlugin from 'eslint-plugin-import'
6+ import nextPlugin from '@next/eslint-plugin-next'
27import { globalIgnores } from 'eslint/config'
3- import pluginReact from 'eslint-plugin-react'
4- import { FlatCompat } from '@eslint/eslintrc'
58
69
7- const plugins = new FlatCompat ( )
8- . config ( {
9- extends : [
10- 'next' ,
11- 'next/core-web-vitals' ,
12- 'plugin:import/errors' ,
13- 'plugin:import/warnings' ,
14- 'plugin:import/recommended' ,
15- ] ,
16- plugins : [
17- 'import' ,
18- ] ,
19- } )
20-
21- /** @type {import('eslint').Linter.Config[] } */
22- const config = [
23- ...plugins ,
24- ...configs . recommended ,
25- pluginReact . configs . flat . recommended ,
10+ export default [
11+ js . configs . recommended ,
12+ ...tsEslint . configs . recommended ,
13+ react . configs . flat . recommended ,
14+ nextPlugin . configs . recommended ,
2615 {
27- files : [
28- '**/*.{js,ts,jsx,tsx}' ,
29- ] ,
16+ files : [ '**/*.{js,ts,jsx,tsx}' ] ,
17+ settings : {
18+ react : {
19+ version : 'detect'
20+ }
21+ } ,
22+ plugins : {
23+ import : importPlugin ,
24+ 'react-hooks' : reactHooks ,
25+ } ,
26+ rules : {
27+ ...importPlugin . configs . recommended . rules ,
28+ ...importPlugin . configs . errors ?. rules ,
29+ ...importPlugin . configs . warnings ?. rules ,
30+ } ,
31+ } ,
32+ {
33+ files : [ '**/*.{js,ts,jsx,tsx}' ] ,
34+
3035 rules : {
3136 // Common
37+ 'no-empty' : 0 ,
38+ 'no-empty-pattern' : 0 ,
39+ 'no-loss-of-precision' : 0 ,
3240 'no-trailing-spaces' : 1 ,
33- 'semi' : [ 'error' , 'never' ] ,
34- "max-len" : [ 'warn' , { 'code' : 140 } ] ,
35- 'object-curly-spacing' : [ 'error' , 'always' ] ,
36- 'array-bracket-spacing' : [ 'error' , 'always' ] ,
37- 'no-multiple-empty-lines' : [ 'error' , { 'max' : 2 } ] ,
41+ semi : [ 'error' , 'never' ] ,
42+ 'no-irregular-whitespace' : 0 ,
43+ 'no-extra-boolean-cast' : 'off' ,
44+ 'max-len' : [ 'warn' , { code : 140 } ] ,
45+ 'object-curly-spacing' : [ 'error' , 'always' ] ,
46+ 'array-bracket-spacing' : [ 'error' , 'always' ] ,
47+ 'no-multiple-empty-lines' : [ 'error' , { max : 2 } ] ,
3848 'jsx-a11y/alt-text' : 0 ,
3949 'comma-dangle' : [
40- 'warn' , {
41- 'arrays' : 'always-multiline' ,
42- 'objects' : 'always-multiline' ,
43- 'imports' : 'always-multiline' ,
44- 'exports' : 'always-multiline' ,
45- 'functions' : 'never' ,
50+ 'warn' ,
51+ {
52+ arrays : 'always-multiline' ,
53+ objects : 'always-multiline' ,
54+ imports : 'always-multiline' ,
55+ exports : 'always-multiline' ,
56+ functions : 'never' ,
4657 } ,
4758 ] ,
48- // Special
59+
60+ // TypeScript
4961 '@typescript-eslint/no-namespace' : 0 ,
5062 '@typescript-eslint/ban-ts-comment' : 0 ,
5163 '@typescript-eslint/no-explicit-any' : 0 ,
5264 '@typescript-eslint/no-require-imports' : 0 ,
5365 '@typescript-eslint/no-empty-object-type' : 0 ,
5466 '@typescript-eslint/no-unnecessary-type-constraint' : 0 ,
55-
5667 '@typescript-eslint/no-unused-vars' : [
5768 'error' ,
5869 {
59- ' argsIgnorePattern' : '^_' ,
60- ' varsIgnorePattern' : '^_' ,
61- ' caughtErrorsIgnorePattern' : '^_'
62- }
70+ argsIgnorePattern : '^_' ,
71+ varsIgnorePattern : '^_' ,
72+ caughtErrorsIgnorePattern : '^_' ,
73+ } ,
6374 ] ,
6475
76+ // Restricted
6577 'no-restricted-globals' : [
6678 'error' ,
6779 {
68- 'name' : 'localStorage' ,
69- 'message' : 'Use localStorage module from @stakewise/frontwise-modules!' ,
80+ name : 'localStorage' ,
81+ message :
82+ 'Use localStorage module from @stakewise/frontwise-modules!' ,
7083 } ,
7184 ] ,
72-
7385 'no-restricted-imports' : [
7486 'error' ,
7587 {
76- ' name' : 'FixedNumber' ,
77- ' message' : 'Do not use FixedNumber, it is not safe.' ,
88+ name : 'FixedNumber' ,
89+ message : 'Do not use FixedNumber, it is not safe.' ,
7890 } ,
7991 ] ,
8092
8193 // Next
8294 '@next/next/no-html-link-for-pages' : 0 ,
8395
84- // React hooks plugin
96+ // React hooks
8597 'react-hooks/rules-of-hooks' : 'error' ,
8698 'react-hooks/exhaustive-deps' : 'warn' ,
8799
88- // Import plugin
100+ // Import
89101 'import/named' : 0 ,
90102 'import/first' : 0 ,
91103 'import/extensions' : 0 ,
@@ -96,18 +108,44 @@ const config = [
96108 'import/no-named-as-default-member' : 1 ,
97109 'import/no-extraneous-dependencies' : 0 ,
98110 'import/no-anonymous-default-export' : 0 ,
99- 'import/newline-after-import' : [ 'error' , { ' count' : 2 } ] ,
111+ 'import/newline-after-import' : [ 'error' , { count : 2 } ] ,
100112 } ,
101113 } ,
114+
102115 globalIgnores ( [
103- '**/*.graphql.ts' ,
116+ 'next-env.d.ts' ,
117+ '**/node_modules/**' ,
118+ '**/playwright-report/**' ,
119+ '**/test-results/**' ,
120+ '**/.next/**' ,
121+ '**/dist/**' ,
122+ '**/build/**' ,
123+ '**/coverage/**' ,
124+ '**/.turbo/**' ,
125+ '**/out/**' ,
104126 ] ) ,
127+
105128 {
129+ files : [ 'e2e/**/*.{js,ts,jsx,tsx}' ] ,
106130 rules : {
107131 'react-hooks/rules-of-hooks' : 'off' ,
108132 } ,
109133 } ,
110- ]
111-
112134
113- export default config
135+ {
136+ files : [
137+ '**/*.config.*' ,
138+ 'scripts/**/*.{js,ts,jsx,tsx}' ,
139+ ] ,
140+ languageOptions : {
141+ globals : {
142+ require : 'readonly' ,
143+ module : 'readonly' ,
144+ __dirname : 'readonly' ,
145+ process : 'readonly' ,
146+ console : 'readonly' ,
147+ URL : 'readonly' ,
148+ } ,
149+ } ,
150+ } ,
151+ ]
0 commit comments