Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 10, 2024
1 parent 95ece9b commit 66ca363
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/eslint/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,17 @@ function findFlatConfigFile(cwd) {
);
}

/**
* Check if the file is a TypeScript file.
* @param {string} filePath The file path to check.
* @returns {boolean} `true` if the file is a TypeScript file, `false` if it's not.
*/
function isFileTS(filePath) {
const fileExtension = path.extname(filePath);

return fileExtension.endsWith("ts");
}

/**
* Load the config array from the given filename.
* @param {string} filePath The filename to load from.
Expand Down Expand Up @@ -318,16 +329,16 @@ async function loadFlatConfigFile(filePath) {

let config;

if (filePath.match(/\.[mc]?ts/)) {
const { tsImport } = await import('tsx/esm/api')
if (isFileTS(filePath)) {
const { tsImport } = await import("tsx/esm/api");
config = await tsImport(fileURL.pathname, __filename);

Check failure on line 334 in lib/eslint/eslint.js

View workflow job for this annotation

GitHub Actions / Verify Files

Expected blank line before this statement
}

Check failure on line 335 in lib/eslint/eslint.js

View workflow job for this annotation

GitHub Actions / Verify Files

Closing curly brace does not appear on the same line as the subsequent block
else {
config = await import(fileURL);
}

if (config.default) {
config = await config.default
config = await config.default;
}

importedConfigFileModificationTime.set(filePath, mtime);
Expand Down

0 comments on commit 66ca363

Please sign in to comment.