11import babelParser from '@babel/eslint-parser' ;
22import js from '@eslint/js' ;
33import { defineConfig } from 'eslint/config' ;
4+ import chaiFriendly from 'eslint-plugin-chai-friendly' ;
45import importPlugin from 'eslint-plugin-import' ;
56import prettierRecommended from 'eslint-plugin-prettier/recommended' ;
67import unusedImports from 'eslint-plugin-unused-imports' ;
78import globals from 'globals' ;
9+ import ts from 'typescript-eslint' ;
810
9- export default defineConfig ( [
11+ const noUnusedVarsRule = [
12+ 'error' ,
13+ {
14+ argsIgnorePattern : '^_' ,
15+ varsIgnorePattern : '^_' ,
16+ caughtErrorsIgnorePattern : '^_' ,
17+ } ,
18+ ] ;
19+
20+ export default defineConfig (
1021 js . configs . recommended ,
22+ ts . configs . recommended ,
23+ ts . configs . stylistic ,
1124 prettierRecommended ,
25+ chaiFriendly . configs . recommendedFlat ,
1226
27+ // all files
1328 {
1429 languageOptions : {
1530 ecmaVersion : 2021 ,
31+ sourceType : 'module' ,
1632 } ,
1733 plugins : {
1834 import : importPlugin ,
1935 'unused-imports' : unusedImports ,
36+ 'chai-friendly' : chaiFriendly ,
2037 } ,
2138 rules : {
2239 complexity : [ 'error' , { max : 35 } ] ,
@@ -42,32 +59,44 @@ export default defineConfig([
4259 'newlines-between' : 'always' ,
4360 } ,
4461 ] ,
45- 'no-unused-vars' : [
62+ 'no-unused-vars' : noUnusedVarsRule ,
63+ '@typescript-eslint/no-unused-vars' : noUnusedVarsRule ,
64+ '@typescript-eslint/no-empty-function' : [
4665 'error' ,
4766 {
48- argsIgnorePattern : '^_' ,
49- varsIgnorePattern : '^_' ,
50- caughtErrorsIgnorePattern : '^_' ,
67+ allow : [ 'arrowFunctions' ] ,
5168 } ,
5269 ] ,
70+
71+ // disabled for now
72+ '@typescript-eslint/consistent-indexed-object-style' : 'off' ,
73+ '@typescript-eslint/consistent-type-assertions' : 'off' ,
74+ '@typescript-eslint/consistent-type-definitions' : 'off' ,
75+ '@typescript-eslint/no-explicit-any' : 'off' ,
76+ '@typescript-eslint/no-this-alias' : 'off' ,
77+ '@typescript-eslint/prefer-for-of' : 'off' ,
78+ '@typescript-eslint/prefer-function-type' : 'off' ,
79+ 'chai-friendly/no-unused-expressions' : 'off' ,
80+ 'no-undef' : 'off' ,
81+ 'no-var' : 'off' ,
5382 } ,
5483 } ,
5584
5685 // globals
5786 {
58- files : [ 'test/**/*.js ' ] ,
87+ files : [ 'test/**/*.[tj]s ' ] ,
5988 languageOptions : { globals : { ...globals . mocha } } ,
6089 } ,
6190 {
62- files : [ 'src/**/*.{js,cjs} ' , 'test/**/*.js ' ] ,
91+ files : [ 'src/**/*.c?[tj]s ' , 'test/**/*.[tj]s ' ] ,
6392 languageOptions : { globals : { ...globals . browser } } ,
6493 } ,
6594 {
6695 files : [
67- 'src/server/**/*.js ' ,
68- 'src/react-native/**/*.js ' ,
69- 'test/**/server.*.js ' ,
70- 'scripts/**/*.js ' ,
96+ 'src/server/**/*.[tj]s ' ,
97+ 'src/react-native/**/*.[tj]s ' ,
98+ 'test/**/server.*.[tj]s ' ,
99+ 'scripts/**/*.[tj]s ' ,
71100 ] ,
72101 languageOptions : { globals : { ...globals . node } } ,
73102 } ,
@@ -82,14 +111,34 @@ export default defineConfig([
82111 ecmaVersion : 2021 ,
83112 } ,
84113 } ,
85- rules : { strict : [ 'error' , 'safe' ] } ,
114+ rules : {
115+ strict : [ 'error' , 'safe' ] ,
116+ '@typescript-eslint/no-unused-vars' : 'off' ,
117+ } ,
118+ } ,
119+
120+ // ts
121+ {
122+ files : [ '**/*.ts' ] ,
123+ rules : {
124+ 'no-unused-vars' : 'off' ,
125+ } ,
86126 } ,
87127
88128 // cjs
89129 {
90130 files : [ '**/*.cjs' ] ,
91131 languageOptions : { sourceType : 'commonjs' } ,
92- rules : { strict : 'off' } ,
132+ rules : {
133+ strict : 'off' ,
134+ '@typescript-eslint/no-require-imports' : 'off' ,
135+ } ,
136+ } ,
137+
138+ // tests
139+ {
140+ files : [ 'test/**/*.[tj]s' ] ,
141+ rules : { '@typescript-eslint/no-empty-function' : 'off' } ,
93142 } ,
94143
95144 // scripts
@@ -101,4 +150,4 @@ export default defineConfig([
101150 {
102151 ignores : [ 'dist' , 'examples' , 'node_modules' , 'vendor' , 'coverage' ] ,
103152 } ,
104- ] ) ;
153+ ) ;
0 commit comments