1- // @ts -check
2-
1+ import { defineConfig } from 'eslint/config' ;
32import eslint from '@eslint/js' ;
43import stylistic from '@stylistic/eslint-plugin' ;
5- import tseslint from 'typescript-eslint' ;
4+ import { configs , parser } from 'typescript-eslint' ;
65import eslintImport from 'eslint-plugin-import' ;
76
8- import vitest from '@vitest/eslint-plugin' ;
9-
107import { includeIgnoreFile } from '@eslint/compat' ;
118import path from 'node:path' ;
129import { fileURLToPath } from 'node:url' ;
@@ -15,7 +12,7 @@ const __filename = fileURLToPath(import.meta.url);
1512const __dirname = path . dirname ( __filename ) ;
1613const gitignorePath = path . resolve ( __dirname , '.gitignore' ) ;
1714
18- const config = tseslint . config (
15+ const config = defineConfig (
1916 includeIgnoreFile ( gitignorePath ) ,
2017 {
2118 ignores : [
@@ -29,42 +26,41 @@ const config = tseslint.config(
2926 ] ,
3027 } ,
3128 eslint . configs . recommended ,
32- ...tseslint . configs . strict ,
33- ...tseslint . configs . stylistic ,
29+ ...configs . strict ,
30+ ...configs . stylistic ,
3431 {
32+ files : [ '{bin,lib,lambda}/**/*.{ts,tsx}' , '*.js' ] ,
3533 plugins : {
3634 '@stylistic' : stylistic ,
3735 } ,
36+ languageOptions : {
37+ ecmaVersion : 'latest' ,
38+ sourceType : 'module' ,
39+ parser,
40+ parserOptions : {
41+ tsconfigRootDir : __dirname ,
42+ project : [ './tsconfig-eslint.json' ] ,
43+ } ,
44+ } ,
45+ extends : [
46+ eslintImport . flatConfigs . recommended ,
47+ eslintImport . flatConfigs . typescript ,
48+ ] ,
49+ settings : {
50+ 'import/resolver' : {
51+ // You will also need to install and configure the TypeScript resolver
52+ // See also https://github.com/import-js/eslint-import-resolver-typescript#configuration
53+ 'typescript' : true ,
54+ 'node' : true ,
55+ } ,
56+ } ,
3857 rules : {
3958 '@stylistic/semi' : [ 'error' , 'always' ] ,
4059 '@stylistic/indent' : [ 'error' , 2 ] ,
4160 '@stylistic/comma-dangle' : [ 'error' , 'always-multiline' ] ,
4261 '@stylistic/quotes' : [ 'error' , 'single' ] ,
4362 } ,
4463 } ,
45- {
46- files : [ '{bin,lib,lambda}/**/*.{ts,tsx}' ] ,
47- plugins : {
48- '@stylistic/ts' : stylistic ,
49- } ,
50- extends : [ eslintImport . flatConfigs . recommended , eslintImport . flatConfigs . typescript ] ,
51- } ,
52- {
53- files : [ '*.js' ] ,
54- plugins : {
55- '@stylistic/js' : stylistic ,
56- } ,
57- } ,
58- {
59- files : [ 'test/**' ] , // or any other pattern
60- plugins : {
61- vitest
62- } ,
63- rules : {
64- ...vitest . configs . recommended . rules , // you can also use vitest.configs.all.rules to enable all rules
65- 'vitest/max-nested-describe' : [ 'error' , { 'max' : 3 } ] // you can also modify rules' behavior using option like this
66- } ,
67- } ,
6864) ;
6965
7066export default config ;
0 commit comments