Skip to content

Commit

Permalink
prefer-top-level-await: Ignore .cjs files (#2072)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
  • Loading branch information
fisker and sindresorhus committed Apr 23, 2023
1 parent a3bc120 commit 0c3ccb1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rules/prefer-top-level-await.js
Expand Up @@ -59,6 +59,10 @@ const isAwaitArgument = node => {

/** @param {import('eslint').Rule.RuleContext} context */
function create(context) {
if (context.getFilename().toLowerCase().endsWith('.cjs')) {
return;
}

const sourceCode = context.getSourceCode();

return {
Expand Down
4 changes: 4 additions & 0 deletions test/prefer-top-level-await.mjs
Expand Up @@ -71,6 +71,10 @@ test.snapshot({
}
}
`,
{
code: 'foo.then(bar)',
filename: 'foo.cjS',
},
],
invalid: [
'foo.then(bar)',
Expand Down

0 comments on commit 0c3ccb1

Please sign in to comment.