1+ import eslint from "@eslint/js" ;
2+ import tseslint from "@typescript-eslint/eslint-plugin" ;
3+ import tsparser from "@typescript-eslint/parser" ;
4+
5+ export default [
6+ // Base ESLint recommended rules
7+ eslint . configs . recommended ,
8+
9+ // TypeScript configuration
10+ {
11+ files : [ "src/**/*.ts" ] ,
12+ languageOptions : {
13+ parser : tsparser ,
14+ parserOptions : {
15+ ecmaVersion : 2022 ,
16+ sourceType : "module" ,
17+ project : "./tsconfig.json" ,
18+ } ,
19+ globals : {
20+ process : "readonly" ,
21+ console : "readonly" ,
22+ Buffer : "readonly" ,
23+ __dirname : "readonly" ,
24+ __filename : "readonly" ,
25+ global : "writable" ,
26+ } ,
27+ } ,
28+ plugins : {
29+ "@typescript-eslint" : tseslint ,
30+ } ,
31+ rules : {
32+ // TypeScript-specific rules for medical/healthcare code
33+ "@typescript-eslint/no-explicit-any" : "error" ,
34+ "@typescript-eslint/no-unused-vars" : [ "error" , { argsIgnorePattern : "^_" , varsIgnorePattern : "^_" } ] ,
35+ "no-unused-vars" : [ "error" , { argsIgnorePattern : "^_" , varsIgnorePattern : "^_" } ] ,
36+ "@typescript-eslint/explicit-function-return-type" : "error" ,
37+ "@typescript-eslint/no-non-null-assertion" : "error" ,
38+ "@typescript-eslint/prefer-nullish-coalescing" : "error" ,
39+ "@typescript-eslint/prefer-optional-chain" : "error" ,
40+ "@typescript-eslint/no-floating-promises" : "error" ,
41+ "@typescript-eslint/await-thenable" : "error" ,
42+ "@typescript-eslint/no-misused-promises" : "error" ,
43+ "@typescript-eslint/require-await" : "error" ,
44+
45+ // Naming conventions (Australian English preference)
46+ "@typescript-eslint/naming-convention" : [
47+ "error" ,
48+ {
49+ selector : "default" ,
50+ format : [ "camelCase" ] ,
51+ leadingUnderscore : "allow" ,
52+ trailingUnderscore : "forbid" ,
53+ } ,
54+ {
55+ selector : "variable" ,
56+ format : [ "camelCase" , "UPPER_CASE" ] ,
57+ } ,
58+ {
59+ selector : "typeLike" ,
60+ format : [ "PascalCase" ] ,
61+ } ,
62+ {
63+ selector : "enumMember" ,
64+ format : [ "PascalCase" ] ,
65+ } ,
66+ ] ,
67+
68+ // Code quality and safety rules for healthcare data
69+ "complexity" : [ "error" , 10 ] ,
70+ "max-depth" : [ "error" , 4 ] ,
71+ "max-lines-per-function" : [ "error" , 50 ] ,
72+ "no-console" : [ "warn" , { allow : [ "warn" , "error" ] } ] ,
73+ "no-debugger" : "error" ,
74+ "no-eval" : "error" ,
75+ "no-implied-eval" : "error" ,
76+ "no-new-func" : "error" ,
77+ "no-var" : "error" ,
78+ "prefer-const" : "error" ,
79+ "eqeqeq" : [ "error" , "always" ] ,
80+
81+ // Import and module rules
82+ "no-duplicate-imports" : "error" ,
83+ "sort-imports" : [ "error" , {
84+ ignoreCase : true ,
85+ ignoreDeclarationSort : true ,
86+ ignoreMemberSort : false ,
87+ memberSyntaxSortOrder : [ "none" , "all" , "multiple" , "single" ]
88+ } ] ,
89+
90+ // Error handling - critical for medical data processing
91+ "no-throw-literal" : "error" ,
92+
93+ // Disable rules that conflict with Prettier
94+ "indent" : "off" ,
95+ "quotes" : "off" ,
96+ "semi" : "off" ,
97+ "comma-dangle" : "off" ,
98+ "max-len" : "off" ,
99+ } ,
100+ } ,
101+
102+ // Test files configuration
103+ {
104+ files : [ "src/**/*.test.ts" ] ,
105+ rules : {
106+ // Relax some rules for test files
107+ "@typescript-eslint/explicit-function-return-type" : "off" ,
108+ "@typescript-eslint/no-explicit-any" : "off" ,
109+ "max-lines-per-function" : "off" ,
110+ "no-console" : "off" ,
111+ "complexity" : "off" ,
112+ } ,
113+ } ,
114+
115+ // ANTLR visitor files configuration
116+ {
117+ files : [ "src/fhirpath/visitor.ts" , "src/fhirpath/transpiler.ts" ] ,
118+ rules : {
119+ // Relax rules for complex ANTLR visitor code
120+ "complexity" : [ "error" , 30 ] ,
121+ "@typescript-eslint/no-explicit-any" : "warn" ,
122+ "@typescript-eslint/no-non-null-assertion" : "warn" ,
123+ "@typescript-eslint/prefer-nullish-coalescing" : "warn" ,
124+ } ,
125+ } ,
126+
127+ // Ignore patterns
128+ {
129+ ignores : [
130+ "dist/**/*" ,
131+ "out/**/*" ,
132+ "node_modules/**/*" ,
133+ "coverage/**/*" ,
134+ "src/generated/**/*" , // Generated ANTLR grammar files
135+ "*.d.ts" ,
136+ "*.config.js" ,
137+ "*.config.ts" ,
138+ ] ,
139+ } ,
140+ ] ;
0 commit comments