From d2029333f23c245cbd2f3bc7caa88f51c190d613 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Mon, 16 Sep 2024 08:07:30 +1200 Subject: [PATCH] fix: adjust "is source type module" checks for flat config Also see https://github.com/jest-community/eslint-plugin-jest/pull/1639 --- src/rules/no-default-export.js | 5 ++++- src/rules/no-named-export.js | 5 ++++- src/rules/unambiguous.js | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/rules/no-default-export.js b/src/rules/no-default-export.js index fcb4f1b2f..d1aab1248 100644 --- a/src/rules/no-default-export.js +++ b/src/rules/no-default-export.js @@ -15,7 +15,10 @@ module.exports = { create(context) { // ignore non-modules - if (context.parserOptions.sourceType !== 'module') { + if ( + context.parserOptions.sourceType !== 'module' + && (!context.languageOptions || context.languageOptions.sourceType !== 'module') + ) { return {}; } diff --git a/src/rules/no-named-export.js b/src/rules/no-named-export.js index efaf9dc4c..7a29ca01d 100644 --- a/src/rules/no-named-export.js +++ b/src/rules/no-named-export.js @@ -13,7 +13,10 @@ module.exports = { create(context) { // ignore non-modules - if (context.parserOptions.sourceType !== 'module') { + if ( + context.parserOptions.sourceType !== 'module' + && (!context.languageOptions || context.languageOptions.sourceType !== 'module') + ) { return {}; } diff --git a/src/rules/unambiguous.js b/src/rules/unambiguous.js index 91152ea2a..568802716 100644 --- a/src/rules/unambiguous.js +++ b/src/rules/unambiguous.js @@ -19,7 +19,10 @@ module.exports = { create(context) { // ignore non-modules - if (context.parserOptions.sourceType !== 'module') { + if ( + context.parserOptions.sourceType !== 'module' + && (!context.languageOptions || context.languageOptions.sourceType !== 'module') + ) { return {}; }