11import eslintJS from "@eslint/js" ;
22import stylisticPlugin from "@stylistic/eslint-plugin" ;
33import vitestPlugin from "@vitest/eslint-plugin" ;
4+ import { defineConfig } from "eslint/config" ;
45import eslintConfigPrettier from "eslint-config-prettier" ;
5- import importPlugin from "eslint-plugin-import-x" ;
6+ import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript" ;
7+ import {
8+ importX as importXPlugin ,
9+ createNodeResolver ,
10+ } from "eslint-plugin-import-x" ;
611import nodePlugin from "eslint-plugin-n" ;
712import globals from "globals" ;
813import tsEslint from "typescript-eslint" ;
914
10- export default tsEslint . config (
11- ///////////////////////////////////////////////////////////////////
12- // ALL FILES
15+ // Shared constants:
16+ const PARSED_EXTENSIONS = [ ".ts" , ".js" ] ;
17+
18+ export default defineConfig (
19+ /////////////////////////////////////////////////////////////////////////////
20+ // GLOBAL CONFIGS
1321 {
14- files : [ "src/**/*.ts" , "./*.[tj]s" ] ,
15- linterOptions : { reportUnusedDisableDirectives : true } ,
22+ name : "global/ignores" ,
23+ ignores : [ "**/node_modules/" , "**/coverage/" , "**/dist/" ] ,
24+ } ,
25+ {
26+ name : "global/languageOptions" ,
1627 languageOptions : {
1728 ecmaVersion : "latest" ,
1829 sourceType : "module" ,
19- globals : globals . node ,
2030 parser : tsEslint . parser ,
2131 parserOptions : {
2232 projectService : true ,
2333 tsconfigRootDir : import . meta. dirname ,
2434 } ,
2535 } ,
36+ } ,
37+ {
38+ name : "global/linterOptions" ,
39+ linterOptions : {
40+ reportUnusedDisableDirectives : true ,
41+ } ,
42+ } ,
43+ {
44+ name : "global/plugins" ,
2645 plugins : {
2746 "@stylistic" : stylisticPlugin ,
2847 "@typescript-eslint" : tsEslint . plugin ,
29- "import-x" : importPlugin ,
48+ "import-x" : importXPlugin ,
3049 "n" : nodePlugin ,
50+ "vitest" : vitestPlugin ,
3151 } ,
3252 settings : {
33- "import-x/extensions" : [ ".ts" , ".js" ] ,
53+ ...importXPlugin . configs . typescript . settings ,
54+ "import-x/extensions" : PARSED_EXTENSIONS ,
3455 "import-x/parsers" : {
35- "@typescript-eslint/parser" : [ ".ts" , ".js" ] ,
56+ "@typescript-eslint/parser" : PARSED_EXTENSIONS ,
3657 } ,
37- "import-x/resolver" : {
38- node : { extensions : [ ".ts" , ".js" ] } ,
39- typescript : { project : [ "tsconfig.json" ] } ,
58+ "import-x/resolver-next" : [
59+ createTypeScriptImportResolver ( { alwaysTryTypes : true } ) ,
60+ createNodeResolver ( { extensions : PARSED_EXTENSIONS } ) ,
61+ ] ,
62+ "n" : {
63+ // Runtime nodejs version !== dev nodejs version
64+ version : ">=22.19.0" ,
4065 } ,
4166 } ,
67+ } ,
68+ /////////////////////////////////////////////////////////////////////////////
69+ // ALL FILES
70+ {
71+ name : "files:all/base" ,
72+ files : [ "src/**/*.ts" , "./*.[tj]s" ] ,
73+ languageOptions : {
74+ globals : globals . node ,
75+ } ,
4276 rules : {
4377 // MERGE PRESETS:
4478 ...stylisticPlugin . configs . customize (
4579 { semi : true , quotes : "double" , arrowParens : true , braceStyle : "1tbs" } // prettier-ignore
4680 ) . rules ,
4781 ...eslintJS . configs . recommended . rules ,
48- ...importPlugin . configs . recommended . rules ,
82+ ...importXPlugin . configs . recommended . rules ,
83+ ...importXPlugin . configs . typescript . rules ,
4984 ...nodePlugin . configs [ "flat/recommended-module" ] . rules ,
5085 ...[
5186 ...tsEslint . configs . strictTypeChecked ,
@@ -75,7 +110,7 @@ export default tsEslint.config(
75110 "import-x/order" : [
76111 "warn" ,
77112 {
78- "groups" : [ "builtin" , "external" , "internal" , "parent" , " sibling", "type" ] , // prettier-ignore
113+ "groups" : [ "builtin" , "external" , "internal" , "parent" , [ "index" , " sibling"] , "type" ] , // prettier-ignore
79114 "alphabetize" : { order : "asc" , orderImportKind : "desc" } ,
80115 "newlines-between" : "never" ,
81116 } ,
@@ -93,22 +128,19 @@ export default tsEslint.config(
93128 ...eslintConfigPrettier . rules ,
94129 } ,
95130 } ,
96- ///////////////////////////////////////////////////////////////////
131+ /////////////////////////////////////////////////////////////////////////////
97132 // TEST FILES
98133 {
99134 files : [ "src/**/*.test.ts" ] ,
100135 languageOptions : {
101136 globals : vitestPlugin . environments . env . globals ,
102137 } ,
103- plugins : {
104- vitest : vitestPlugin ,
105- } ,
106138 rules : {
107139 ...vitestPlugin . configs . recommended . rules ,
108140 "vitest/no-disabled-tests" : "warn" ,
109141 "vitest/no-focused-tests" : "warn" ,
110142 "vitest/valid-expect" : "warn" ,
111143 } ,
112144 }
113- ///////////////////////////////////////////////////////////////////
145+ /////////////////////////////////////////////////////////////////////////////
114146) ;
0 commit comments