From f5a2bbe1455c199de5841fd5be80660300603563 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Tue, 14 May 2024 16:45:55 -0400 Subject: [PATCH] Support all template-lint extensions --- src/template-linter.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/template-linter.ts b/src/template-linter.ts index 4c809cff..b972635d 100644 --- a/src/template-linter.ts +++ b/src/template-linter.ts @@ -221,9 +221,9 @@ export default class TemplateLinter { } async getFindUp(): Promise { if (!this._findUp) { - const { findUp } = await eval(`import('find-up')`); + const { findUp } = await import('find-up'); - this._findUp = findUp; + this._findUp = findUp as FindUp; } return this._findUp; @@ -231,7 +231,17 @@ export default class TemplateLinter { private async templateLintConfig(cwd: string): Promise { const findUp = await this.getFindUp(); - return findUp('.template-lintrc.js', { cwd, type: 'file' }); + const candidates = ['.template-lintrc.js', '.template-lintrc.cjs', '.template-lintrc.mjs']; + + const results = await Promise.all( + // Check all candidates in "parallel" + // gotta go fast + candidates.map((candidate) => findUp(candidate, { cwd, type: 'file' })) + ); + + const result = results.filter(Boolean); + + return result[0]; } private async projectNodeModules(cwd: string): Promise { const findUp = await this.getFindUp();