1+ import eslint from '@eslint/js' ;
2+ import tsParser from '@typescript-eslint/parser' ;
3+ import { defineConfig } from 'eslint/config' ;
4+ import importPlugin from 'eslint-plugin-import' ;
5+ import jest from 'eslint-plugin-jest' ;
6+ import prettier from 'eslint-plugin-prettier' ;
7+ import unusedImports from 'eslint-plugin-unused-imports' ;
8+ import globals from 'globals' ;
9+ import tseslint from 'typescript-eslint' ;
10+
11+ export default defineConfig (
12+ eslint . configs . recommended ,
13+ tseslint . configs . recommended ,
14+ importPlugin . flatConfigs . recommended ,
15+ importPlugin . flatConfigs . typescript ,
16+ {
17+ files : [ '**/*.{ts,js}' ] ,
18+ ignores : [
19+ 'build/*' ,
20+ 'coverage/*' ,
21+ '**/*.d.ts' , // data definition files
22+ 'src/public/' , //3rd party libs
23+ 'src/types/' ,
24+ 'openapi.yaml' , //# auto-generated REST client for the STFC UserOfficeWebService
25+ 'generated/' ,
26+ // node_modules is ignored by default
27+ ] ,
28+ languageOptions : {
29+ parser : tsParser ,
30+ parserOptions : {
31+ ecmaVersion : 'es2018' ,
32+ sourceType : 'module' ,
33+ } ,
34+ globals : { ...globals . node } ,
35+ } ,
36+ // settings: {
37+ // node: {
38+ // extensions: ['.js', '.ts'],
39+ // }
40+ // },
41+ plugins : {
42+ 'unused-imports' : unusedImports ,
43+ prettier,
44+ jest
45+ } ,
46+ rules : {
47+ semi : [ 'error' , 'always' ] ,
48+ quotes : [ 'error' , 'single' ] ,
49+ 'no-console' : 'error' , // prefer `duo-logger` over console
50+
51+ 'import/order' : [
52+ 'error' ,
53+ {
54+ groups : [
55+ 'builtin' ,
56+ 'external' ,
57+ 'internal' ,
58+ [ 'parent' , 'sibling' ] ,
59+ 'index' ,
60+ ] ,
61+ // distinctGroup: true,
62+ pathGroups : [
63+ {
64+ pattern : '@src/**' ,
65+ group : 'internal' ,
66+ position : 'after' ,
67+ } ,
68+ ] ,
69+ pathGroupsExcludedImportTypes : [ 'builtin' ] ,
70+ 'newlines-between' : 'always' ,
71+ alphabetize : {
72+ order : 'asc' ,
73+ caseInsensitive : true ,
74+ } ,
75+ } ,
76+ ] ,
77+
78+ // TypeScript rules
79+ '@typescript-eslint/explicit-module-boundary-types' : 'off' ,
80+ '@typescript-eslint/naming-convention' : [
81+ 'error' ,
82+ {
83+ selector : 'variable' ,
84+ format : [ 'camelCase' , 'PascalCase' , 'UPPER_CASE' ] ,
85+ leadingUnderscore : 'allow' ,
86+ trailingUnderscore : 'allow' ,
87+ } ,
88+ {
89+ selector : 'function' ,
90+ format : [ 'PascalCase' , 'camelCase' ] ,
91+ } ,
92+ ] ,
93+ '@typescript-eslint/no-explicit-any' : 'warn' ,
94+ '@typescript-eslint/no-inferrable-types' : [
95+ 'warn' ,
96+ {
97+ ignoreParameters : true ,
98+ } ,
99+ ] ,
100+ '@typescript-eslint/no-unused-vars' : 'warn' ,
101+ '@typescript-eslint/ban-ts-comment' : 'warn' ,
102+
103+ // Other style rules
104+ 'padding-line-between-statements' : [
105+ 'error' ,
106+ { blankLine : 'always' , prev : '*' , next : 'return' } ,
107+ ] ,
108+
109+ // Handle unused imports
110+ 'unused-imports/no-unused-imports' : 'error' ,
111+ //TS already handles undef variables
112+ 'no-undef' : 'off' ,
113+ 'no-unused-vars' : 'off' ,
114+ 'no-prototype-builtins' : 'off' ,
115+
116+ } ,
117+ } ,
118+ ) ;
0 commit comments