Skip to content

Commit

Permalink
[Fix] adjust "is source type module" checks for flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath authored and ljharb committed Sep 15, 2024
1 parent 1fa8a07 commit d27a639
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
- [`export`]: False positive for exported overloaded functions in TS ([#3065], thanks [@liuxingbaoyu])
- `exportMap`: export map cache is tainted by unreliable parse results ([#3062], thanks [@michaelfaith])
- `exportMap`: improve cacheKey when using flat config ([#3072], thanks [@michaelfaith])
- adjust "is source type module" checks for flat config ([#2996], thanks [@G-Rath])

### Changed
- [Docs] [`no-relative-packages`]: fix typo ([#3066], thanks [@joshuaobrien])
Expand Down Expand Up @@ -1165,6 +1166,7 @@ for info on changes for earlier releases.
[#3011]: https://github.com/import-js/eslint-plugin-import/pull/3011
[#3004]: https://github.com/import-js/eslint-plugin-import/pull/3004
[#2998]: https://github.com/import-js/eslint-plugin-import/pull/2998
[#2996]: https://github.com/import-js/eslint-plugin-import/pull/2996
[#2993]: https://github.com/import-js/eslint-plugin-import/pull/2993
[#2991]: https://github.com/import-js/eslint-plugin-import/pull/2991
[#2989]: https://github.com/import-js/eslint-plugin-import/pull/2989
Expand Down
9 changes: 7 additions & 2 deletions src/core/sourceType.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/**
* @param {import('eslint').Rule.RuleContext} context
* @returns 'module' | 'script' | undefined
* @returns 'module' | 'script' | 'commonjs' | undefined
*/
export default function sourceType(context) {
return context.parserOptions.sourceType;
if ('sourceType' in context.parserOptions) {
return context.parserOptions.sourceType;
}
if ('languageOptions' in context && context.languageOptions) {
return context.languageOptions.sourceType;
}
}

0 comments on commit d27a639

Please sign in to comment.