11// eslint.config.js - ESLint 9 flat-config, JS + CJS
22import js from '@eslint/js' ;
3- import nodePlugin from 'eslint-plugin-node ' ;
3+ import nodePlugin from 'eslint-plugin-n ' ;
44import importPlugin from 'eslint-plugin-import' ;
5+ import tsParser from '@typescript-eslint/parser' ;
56
67const nodeGlobals = {
78 require : 'readonly' ,
@@ -29,6 +30,8 @@ const browserGlobals = {
2930 clearTimeout : 'readonly' ,
3031 clearInterval : 'readonly' ,
3132 console : 'readonly' ,
33+ HTMLElement : 'readonly' ,
34+ Element : 'readonly' ,
3235} ;
3336
3437export default [
@@ -41,10 +44,10 @@ export default [
4144 /* 3 - CommonJS (*.cjs) */
4245 {
4346 files : [ '**/*.cjs' ] ,
44- plugins : { node : nodePlugin , import : importPlugin } ,
47+ plugins : { n : nodePlugin , import : importPlugin } ,
4548 languageOptions : { ecmaVersion : 'latest' , sourceType : 'script' , globals : nodeGlobals } ,
4649 rules : {
47- 'node /no-unsupported-features/es-syntax' : 'off' ,
50+ 'n /no-unsupported-features/es-syntax' : 'off' ,
4851 'import/no-unresolved' : 'error' , // Catch unresolved imports
4952 'import/named' : 'error' , // Catch missing named exports
5053 'import/default' : 'error' , // Catch missing default exports
@@ -55,16 +58,30 @@ export default [
5558 /* 4 - ES-module / browser (*.js) */
5659 {
5760 files : [ '**/*.js' ] ,
58- plugins : { node : nodePlugin , import : importPlugin } ,
61+ plugins : { n : nodePlugin , import : importPlugin } ,
5962 languageOptions : { ecmaVersion : 'latest' , sourceType : 'module' , globals : { ...nodeGlobals , ...browserGlobals } } ,
6063 rules : {
61- 'node /no-unsupported-features/es-syntax' : 'off' ,
64+ 'n /no-unsupported-features/es-syntax' : 'off' ,
6265 'import/no-unresolved' : 'error' ,
6366 'import/named' : 'error' ,
6467 'import/default' : 'error' ,
6568 'import/no-absolute-path' : 'error' ,
6669 } ,
6770 } ,
6871
69- /* 5 - JSX files */
72+ /* 5 - TypeScript files (*.ts, *.tsx) */
73+ {
74+ files : [ '**/*.ts' , '**/*.tsx' ] ,
75+ plugins : { n : nodePlugin , import : importPlugin } ,
76+ languageOptions : { parser : tsParser , ecmaVersion : 'latest' , sourceType : 'module' , globals : { ...nodeGlobals , ...browserGlobals } } ,
77+ rules : {
78+ 'n/no-unsupported-features/es-syntax' : 'off' ,
79+ 'import/no-unresolved' : 'off' , // TypeScript handles this
80+ 'import/named' : 'off' , // TypeScript handles this
81+ 'import/default' : 'off' , // TypeScript handles this
82+ 'import/no-absolute-path' : 'error' ,
83+ 'no-unused-vars' : 'off' , // TypeScript handles this better
84+ 'no-undef' : 'off' , // TypeScript handles this
85+ } ,
86+ } ,
7087] ;
0 commit comments