22
33import eslint from '@eslint/js'
44import prettierRecommended from 'eslint-plugin-prettier/recommended'
5- import tseslint from 'typescript-eslint'
5+ import { config , configs } from 'typescript-eslint'
6+ import { flatConfigs as pluginImport } from 'eslint-plugin-import'
67import globals from 'globals'
78
8- export default tseslint . config (
9+ export default config (
910 {
1011 ignores : [ 'dist' , 'jest.config.ts' ] ,
1112 } ,
1213 eslint . configs . recommended ,
13- ...tseslint . configs . strictTypeChecked ,
14+ ...configs . strictTypeChecked ,
15+ pluginImport . recommended ,
16+ pluginImport . typescript ,
1417 prettierRecommended ,
1518 {
1619 languageOptions : {
@@ -25,18 +28,34 @@ export default tseslint.config(
2528 } ,
2629 rules : {
2730 '@typescript-eslint/explicit-function-return-type' : 'error' ,
31+ 'import/no-nodejs-modules' : 'error' ,
32+ } ,
33+ } ,
34+ {
35+ files : [ 'lib/__tests__/**' , 'test/**' ] ,
36+ rules : {
37+ // We only run tests in node, so we can use node's builtins
38+ 'import/no-nodejs-modules' : 'off' ,
2839 } ,
2940 } ,
3041 {
3142 // Once we remove the legacy vows tests in ./test, we can remove these JS-specific rules
3243 files : [ 'test/**/*.js' , 'eslint.config.mjs' ] ,
33- ...tseslint . configs . disableTypeChecked ,
44+ ...configs . disableTypeChecked ,
3445 rules : {
35- ...tseslint . configs . disableTypeChecked . rules ,
46+ ...configs . disableTypeChecked . rules ,
3647 '@typescript-eslint/explicit-function-return-type' : 'off' ,
3748 '@typescript-eslint/no-var-requires' : 'off' ,
3849 '@typescript-eslint/no-unused-vars' : 'off' ,
3950 '@typescript-eslint/no-require-imports' : 'off' ,
4051 } ,
4152 } ,
53+ {
54+ // other configuration are omitted for brevity
55+ settings : {
56+ 'import/resolver' : {
57+ typescript : { } , // this loads <rootdir>/tsconfig.json to eslint
58+ } ,
59+ } ,
60+ } ,
4261)
0 commit comments