Skip to content

Commit 4d32d68

Browse files
Zamiellljharb
authored andcommitted
[New] TypeScript config: add .cts and .mts extensions
1 parent cd95728 commit 4d32d68

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
66

77
## [Unreleased]
88

9+
### Added
10+
- TypeScript config: add .cts and .mts extensions ([#2851], thanks [@Zamiell])
11+
912
## [2.28.1] - 2023-08-18
1013

1114
### Fixed
@@ -1088,6 +1091,7 @@ for info on changes for earlier releases.
10881091
[`memo-parser`]: ./memo-parser/README.md
10891092

10901093
[#2854]: https://github.com/import-js/eslint-plugin-import/pull/2854
1094+
[#2851]: https://github.com/import-js/eslint-plugin-import/pull/2851
10911095
[#2850]: https://github.com/import-js/eslint-plugin-import/pull/2850
10921096
[#2842]: https://github.com/import-js/eslint-plugin-import/pull/2842
10931097
[#2835]: https://github.com/import-js/eslint-plugin-import/pull/2835
@@ -1896,4 +1900,5 @@ for info on changes for earlier releases.
18961900
[@xpl]: https://github.com/xpl
18971901
[@yndajas]: https://github.com/yndajas
18981902
[@yordis]: https://github.com/yordis
1899-
[@zloirock]: https://github.com/zloirock
1903+
[@Zamiell]: https://github.com/Zamiell
1904+
[@zloirock]: https://github.com/zloirock

config/typescript.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
/**
2-
* Adds `.jsx`, `.ts` and `.tsx` as an extension, and enables JSX/TSX parsing.
2+
* This config:
3+
* 1) adds `.jsx`, `.ts`, `.cts`, `.mts`, and `.tsx` as an extension
4+
* 2) enables JSX/TSX parsing
35
*/
46

57
// Omit `.d.ts` because 1) TypeScript compilation already confirms that
68
// types are resolved, and 2) it would mask an unresolved
79
// `.ts`/`.tsx`/`.js`/`.jsx` implementation.
8-
const allExtensions = ['.ts', '.tsx', '.js', '.jsx'];
10+
const typeScriptExtensions = ['.ts', '.cts', '.mts', '.tsx'];
911

10-
module.exports = {
12+
const allExtensions = [...typeScriptExtensions, '.js', '.jsx'];
1113

14+
module.exports = {
1215
settings: {
1316
'import/extensions': allExtensions,
1417
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
1518
'import/parsers': {
16-
'@typescript-eslint/parser': ['.ts', '.tsx'],
19+
'@typescript-eslint/parser': typeScriptExtensions,
1720
},
1821
'import/resolver': {
1922
node: {

0 commit comments

Comments
 (0)