Skip to content

Commit d27a639

Browse files
G-Rathljharb
authored andcommitted
[Fix] adjust "is source type module" checks for flat config
Also see jest-community/eslint-plugin-jest#1639
1 parent 1fa8a07 commit d27a639

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1515
- [`export`]: False positive for exported overloaded functions in TS ([#3065], thanks [@liuxingbaoyu])
1616
- `exportMap`: export map cache is tainted by unreliable parse results ([#3062], thanks [@michaelfaith])
1717
- `exportMap`: improve cacheKey when using flat config ([#3072], thanks [@michaelfaith])
18+
- adjust "is source type module" checks for flat config ([#2996], thanks [@G-Rath])
1819

1920
### Changed
2021
- [Docs] [`no-relative-packages`]: fix typo ([#3066], thanks [@joshuaobrien])
@@ -1165,6 +1166,7 @@ for info on changes for earlier releases.
11651166
[#3011]: https://github.com/import-js/eslint-plugin-import/pull/3011
11661167
[#3004]: https://github.com/import-js/eslint-plugin-import/pull/3004
11671168
[#2998]: https://github.com/import-js/eslint-plugin-import/pull/2998
1169+
[#2996]: https://github.com/import-js/eslint-plugin-import/pull/2996
11681170
[#2993]: https://github.com/import-js/eslint-plugin-import/pull/2993
11691171
[#2991]: https://github.com/import-js/eslint-plugin-import/pull/2991
11701172
[#2989]: https://github.com/import-js/eslint-plugin-import/pull/2989

src/core/sourceType.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
/**
22
* @param {import('eslint').Rule.RuleContext} context
3-
* @returns 'module' | 'script' | undefined
3+
* @returns 'module' | 'script' | 'commonjs' | undefined
44
*/
55
export default function sourceType(context) {
6-
return context.parserOptions.sourceType;
6+
if ('sourceType' in context.parserOptions) {
7+
return context.parserOptions.sourceType;
8+
}
9+
if ('languageOptions' in context && context.languageOptions) {
10+
return context.languageOptions.sourceType;
11+
}
712
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy