Skip to content

Commit 0c3ccb1

Browse files
fiskersindresorhus
andauthored
prefer-top-level-await: Ignore .cjs files (#2072)
Co-authored-by: Sindre Sorhus <[email protected]>
1 parent a3bc120 commit 0c3ccb1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

rules/prefer-top-level-await.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ const isAwaitArgument = node => {
5959

6060
/** @param {import('eslint').Rule.RuleContext} context */
6161
function create(context) {
62+
if (context.getFilename().toLowerCase().endsWith('.cjs')) {
63+
return;
64+
}
65+
6266
const sourceCode = context.getSourceCode();
6367

6468
return {

test/prefer-top-level-await.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ test.snapshot({
7171
}
7272
}
7373
`,
74+
{
75+
code: 'foo.then(bar)',
76+
filename: 'foo.cjS',
77+
},
7478
],
7579
invalid: [
7680
'foo.then(bar)',

0 commit comments

Comments
 (0)