We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 20f26c9 commit 27693b5Copy full SHA for 27693b5
1 file changed
scripts/lint.js
@@ -38,8 +38,17 @@ function lintJson(filePath) {
38
}
39
40
function lintSource(filePath) {
41
- const result = spawnSync(nodeCmd, ['--check', filePath], {
+ const ext = path.extname(filePath).toLowerCase();
42
+ const sourceText = fs.readFileSync(filePath, 'utf8');
43
+ const normalized = stripUtf8Bom(sourceText);
44
+ const treatsAsModule = ext === '.mjs'
45
+ || (ext === '.js' && /\b(?:import|export)\b|import\.meta/.test(normalized));
46
+ const args = treatsAsModule
47
+ ? ['--input-type=module', '--check']
48
+ : ['--check', filePath];
49
+ const result = spawnSync(nodeCmd, args, {
50
cwd: root,
51
+ input: treatsAsModule ? normalized : undefined,
52
encoding: 'utf8',
53
env: process.env
54
});
0 commit comments