Skip to content

Commit 9eea16c

Browse files
wagenetNullVoxPopuli
authored andcommitted
Clean up some
1 parent 76e97df commit 9eea16c

File tree

1 file changed

+15
-33
lines changed

1 file changed

+15
-33
lines changed

src/parser/gjs-gts-parser.js

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,23 @@ function parseCompilerOptionFromTsconfig(tsconfigPath, rootDir, property) {
4343
}
4444

4545
/**
46-
* @param {Array<boolean|undefined>} values
47-
* @param {string} source
46+
* @param {Array<{getCompilerOptions?: Function}>|undefined} programs
4847
* @returns {boolean|null}
4948
*/
50-
function resolveAllowJs(values, source) {
51-
const filtered = values.filter((val) => typeof val !== 'undefined');
49+
function getAllowJsFromPrograms(programs) {
50+
if (!Array.isArray(programs) || programs.length === 0) return null;
51+
const allowJsValues = programs
52+
.map((p) => p.getCompilerOptions?.())
53+
.filter(Boolean)
54+
.map((opts) => opts.allowJs);
55+
56+
const filtered = allowJsValues.filter((val) => typeof val !== 'undefined');
5257
if (filtered.length > 0) {
5358
const uniqueValues = [...new Set(filtered)];
5459
if (uniqueValues.length > 1) {
5560
// eslint-disable-next-line no-console
5661
console.warn(
57-
`[ember-eslint-parser] Conflicting allowJs values in ${source}. Defaulting allowGjs to false.`
62+
`[ember-eslint-parser] Conflicting allowJs values in programs. Defaulting allowGjs to false.`
5863
);
5964
return false;
6065
} else {
@@ -64,19 +69,6 @@ function resolveAllowJs(values, source) {
6469
return null;
6570
}
6671

67-
/**
68-
* @param {Array<{getCompilerOptions?: Function}>|undefined} programs
69-
* @returns {boolean|null}
70-
*/
71-
function getAllowJsFromPrograms(programs) {
72-
if (!Array.isArray(programs) || programs.length === 0) return null;
73-
const allowJsValues = programs
74-
.map((p) => p.getCompilerOptions?.())
75-
.filter(Boolean)
76-
.map((opts) => opts.allowJs);
77-
return resolveAllowJs(allowJsValues, 'programs');
78-
}
79-
8072
/**
8173
* @param {boolean|object|undefined} projectService
8274
* @returns {string|null}
@@ -108,10 +100,9 @@ function getProjectServiceTsconfigPath(projectService) {
108100
* @param {object} options - Parser options
109101
* @param {string} property - The compiler option property to resolve (e.g., 'allowJs', 'allowArbitraryExtensions')
110102
* @param {Function} [programsExtractor] - Function to extract the property from programs (optional)
111-
* @param {Function} [multiValueResolver] - Function to resolve conflicts when multiple values exist (optional)
112103
* @returns {boolean} - The resolved value
113104
*/
114-
function getCompilerOption(options, property, programsExtractor, multiValueResolver) {
105+
function getCompilerOption(options, property, programsExtractor) {
115106
// Check programs first (if extractor provided)
116107
if (programsExtractor) {
117108
const programsValue = programsExtractor(options.programs);
@@ -136,18 +127,9 @@ function getCompilerOption(options, property, programsExtractor, multiValueResol
136127
}
137128

138129
if (tsconfigPaths.length > 0) {
139-
if (multiValueResolver) {
140-
// For allowJs - handle multiple values with conflict resolution
141-
const values = tsconfigPaths.map((cfg) =>
142-
parseCompilerOptionFromTsconfig(cfg, rootDir, property)
143-
);
144-
return multiValueResolver(values, 'project');
145-
} else {
146-
// For allowArbitraryExtensions - return first found value
147-
for (const tsconfigPath of tsconfigPaths) {
148-
const result = parseCompilerOptionFromTsconfig(tsconfigPath, rootDir, property);
149-
if (result !== undefined) return result;
150-
}
130+
for (const tsconfigPath of tsconfigPaths) {
131+
const result = parseCompilerOptionFromTsconfig(tsconfigPath, rootDir, property);
132+
if (result !== undefined) return result;
151133
}
152134
}
153135

@@ -158,7 +140,7 @@ function getCompilerOption(options, property, programsExtractor, multiValueResol
158140
* Returns the resolved allowJs value based on priority: programs > projectService > project/tsconfig
159141
*/
160142
function getAllowJs(options) {
161-
return getCompilerOption(options, 'allowJs', getAllowJsFromPrograms, resolveAllowJs);
143+
return getCompilerOption(options, 'allowJs', getAllowJsFromPrograms);
162144
}
163145

164146
/**

0 commit comments

Comments
 (0)