1+ import { defineConfig , globalIgnores } from "eslint/config" ;
2+ import { fixupConfigRules , fixupPluginRules } from "@eslint/compat" ;
3+ import typescriptEslint from "@typescript-eslint/eslint-plugin" ;
4+ import _import from "eslint-plugin-import" ;
5+ import prettier from "eslint-plugin-prettier" ;
6+ import globals from "globals" ;
7+ import tsParser from "@typescript-eslint/parser" ;
8+ import path from "node:path" ;
9+ import { fileURLToPath } from "node:url" ;
10+ import js from "@eslint/js" ;
11+ import { FlatCompat } from "@eslint/eslintrc" ;
12+ import jestPlugin from "eslint-plugin-jest" ;
13+
14+ const __filename = fileURLToPath ( import . meta. url ) ;
15+ const __dirname = path . dirname ( __filename ) ;
16+ const compat = new FlatCompat ( {
17+ baseDirectory : __dirname ,
18+ recommendedConfig : js . configs . recommended ,
19+ allConfig : js . configs . all
20+ } ) ;
21+
22+ export default defineConfig ( [
23+ globalIgnores ( [ "out/**/*" , "**/node_modules" , "**/coverage" , "**/*.d.ts" ] ) ,
24+ {
25+ extends : fixupConfigRules ( compat . extends (
26+ "eslint:recommended" ,
27+ "plugin:@typescript-eslint/recommended" ,
28+ "plugin:@typescript-eslint/recommended-requiring-type-checking" ,
29+ "plugin:import/errors" ,
30+ "plugin:import/warnings" ,
31+ "plugin:import/typescript" ,
32+ "plugin:prettier/recommended" ,
33+ ) ) ,
34+
35+ plugins : {
36+ "@typescript-eslint" : fixupPluginRules ( typescriptEslint ) ,
37+ import : fixupPluginRules ( _import ) ,
38+ prettier : fixupPluginRules ( prettier ) ,
39+ } ,
40+
41+ languageOptions : {
42+ globals : {
43+ ...globals . node ,
44+ } ,
45+
46+ parser : tsParser ,
47+ ecmaVersion : 2018 ,
48+ sourceType : "module" ,
49+
50+ parserOptions : {
51+ project : "./tsconfig.json" ,
52+ tsconfigRootDir : "/Users/data-douser/Git/data-douser/codeql-sap-js/extractors/cds/tools" ,
53+ createDefaultProgram : true ,
54+ } ,
55+ } ,
56+
57+ settings : {
58+ "import/resolver" : {
59+ typescript : {
60+ alwaysTryTypes : true ,
61+ project : "./tsconfig.json" ,
62+ } ,
63+
64+ node : {
65+ extensions : [ ".js" , ".jsx" , ".ts" , ".tsx" ] ,
66+ } ,
67+ } ,
68+ } ,
69+
70+ rules : {
71+ "no-console" : "off" ,
72+ "no-duplicate-imports" : "error" ,
73+ "no-unused-vars" : "off" ,
74+ "no-use-before-define" : "off" ,
75+ "no-trailing-spaces" : "error" ,
76+ "@typescript-eslint/explicit-module-boundary-types" : "off" ,
77+
78+ "@typescript-eslint/no-unused-vars" : [ "warn" , {
79+ argsIgnorePattern : "^_" ,
80+ varsIgnorePattern : "^_" ,
81+ } ] ,
82+
83+ "@typescript-eslint/no-use-before-define" : [ "error" , {
84+ functions : false ,
85+ classes : true ,
86+ } ] ,
87+
88+ "@typescript-eslint/explicit-function-return-type" : [ "warn" , {
89+ allowExpressions : true ,
90+ allowTypedFunctionExpressions : true ,
91+ } ] ,
92+
93+ "@typescript-eslint/no-explicit-any" : "warn" ,
94+ "@typescript-eslint/ban-ts-comment" : "warn" ,
95+ "@typescript-eslint/prefer-nullish-coalescing" : "warn" ,
96+ "@typescript-eslint/prefer-optional-chain" : "warn" ,
97+
98+ "import/order" : [ "error" , {
99+ groups : [ "builtin" , "external" , "internal" , [ "parent" , "sibling" ] , "index" ] ,
100+ "newlines-between" : "always" ,
101+
102+ alphabetize : {
103+ order : "asc" ,
104+ caseInsensitive : true ,
105+ } ,
106+ } ] ,
107+
108+ "import/no-duplicates" : "error" ,
109+
110+ "prettier/prettier" : [ "error" , {
111+ singleQuote : true ,
112+ trailingComma : "all" ,
113+ printWidth : 100 ,
114+ tabWidth : 2 ,
115+ } ] ,
116+ } ,
117+ } ,
118+ {
119+ files : [ "**/*.ts" ] ,
120+
121+ languageOptions : {
122+ ecmaVersion : 5 ,
123+ sourceType : "script" ,
124+
125+ parserOptions : {
126+ project : "./tsconfig.json" ,
127+ tsconfigRootDir : "/Users/data-douser/Git/data-douser/codeql-sap-js/extractors/cds/tools" ,
128+ } ,
129+ } ,
130+ } ,
131+ {
132+ files : [ "**/*.test.ts" , "test/**/*.ts" , "**/index-files.ts" ] ,
133+ extends : fixupConfigRules ( compat . extends ( "plugin:jest/recommended" ) ) ,
134+ plugins : {
135+ jest : fixupPluginRules ( jestPlugin ) ,
136+ } ,
137+ languageOptions : {
138+ ecmaVersion : 2018 ,
139+ sourceType : "module" ,
140+
141+ parserOptions : {
142+ project : "./tsconfig.json" ,
143+ tsconfigRootDir : "/Users/data-douser/Git/data-douser/codeql-sap-js/extractors/cds/tools" ,
144+ } ,
145+ } ,
146+
147+ rules : {
148+ "@typescript-eslint/explicit-function-return-type" : "off" ,
149+ "@typescript-eslint/no-unsafe-assignment" : "off" ,
150+ "@typescript-eslint/no-unsafe-call" : "off" ,
151+ "@typescript-eslint/no-unsafe-member-access" : "off" ,
152+ "@typescript-eslint/no-unsafe-return" : "off" ,
153+ "@typescript-eslint/restrict-template-expressions" : "off" ,
154+ "@typescript-eslint/no-unsafe-argument" : "off" ,
155+ "@typescript-eslint/unbound-method" : "off"
156+ } ,
157+ } ,
158+ // Add JavaScript-specific configuration that doesn't use TypeScript parser
159+ {
160+ files : [ "**/*.js" , "**/.prettierrc.js" , "**/jest.config.js" ] ,
161+ languageOptions : {
162+ // Use default parser for JS files (removes TS parser requirement)
163+ parser : undefined ,
164+ ecmaVersion : 2018 ,
165+ sourceType : "module"
166+ } ,
167+ rules : {
168+ // Disable TypeScript-specific rules for JS files
169+ "@typescript-eslint/explicit-function-return-type" : "off" ,
170+ "@typescript-eslint/no-unsafe-assignment" : "off" ,
171+ "@typescript-eslint/no-unsafe-call" : "off" ,
172+ "@typescript-eslint/no-unsafe-member-access" : "off" ,
173+ "@typescript-eslint/no-unsafe-return" : "off" ,
174+ "@typescript-eslint/restrict-template-expressions" : "off" ,
175+ "@typescript-eslint/no-unsafe-argument" : "off" ,
176+ "@typescript-eslint/unbound-method" : "off"
177+ }
178+ } ,
179+ {
180+ files : [ "test/src/**/*.js" ] ,
181+ extends : fixupConfigRules ( compat . extends ( "plugin:jest/recommended" ) ) ,
182+ plugins : {
183+ jest : fixupPluginRules ( jestPlugin ) ,
184+ } ,
185+ languageOptions : {
186+ // Use default parser for JS files (removes TS parser requirement)
187+ parser : undefined ,
188+ ecmaVersion : 2018 ,
189+ sourceType : "module"
190+ } ,
191+ } ,
192+ ] ) ;
0 commit comments