Skip to content

Commit 3334b90

Browse files
wjhsfcolincasey
andauthored
chore: avoid nodejs modules (#487)
* chore: avoid nodejs modules * Fix no-unresolved errors + address extra lints --------- Co-authored-by: Colin Casey <casey.colin@gmail.com>
1 parent f27648d commit 3334b90

3 files changed

Lines changed: 1873 additions & 56 deletions

File tree

eslint.config.mjs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
import eslint from '@eslint/js'
44
import 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'
67
import 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

Comments
 (0)