Skip to content

Commit

Permalink
Support all template-lint extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed May 14, 2024
1 parent 0e21b95 commit f5a2bbe
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/template-linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,27 @@ export default class TemplateLinter {
}
async getFindUp(): Promise<FindUp> {
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;
}
private async templateLintConfig(cwd: string): Promise<string | undefined> {
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<string | undefined> {
const findUp = await this.getFindUp();
Expand Down

0 comments on commit f5a2bbe

Please sign in to comment.