Skip to content

Commit

Permalink
[New] TypeScript config: add .cts and .mts extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Zamiell authored and ljharb committed Aug 7, 2023
1 parent cd95728 commit 4d32d68
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Expand Up @@ -6,6 +6,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

## [Unreleased]

### Added
- TypeScript config: add .cts and .mts extensions ([#2851], thanks [@Zamiell])

## [2.28.1] - 2023-08-18

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

[#2854]: https://github.com/import-js/eslint-plugin-import/pull/2854
[#2851]: https://github.com/import-js/eslint-plugin-import/pull/2851
[#2850]: https://github.com/import-js/eslint-plugin-import/pull/2850
[#2842]: https://github.com/import-js/eslint-plugin-import/pull/2842
[#2835]: https://github.com/import-js/eslint-plugin-import/pull/2835
Expand Down Expand Up @@ -1896,4 +1900,5 @@ for info on changes for earlier releases.
[@xpl]: https://github.com/xpl
[@yndajas]: https://github.com/yndajas
[@yordis]: https://github.com/yordis
[@zloirock]: https://github.com/zloirock
[@Zamiell]: https://github.com/Zamiell
[@zloirock]: https://github.com/zloirock
11 changes: 7 additions & 4 deletions config/typescript.js
@@ -1,19 +1,22 @@
/**
* Adds `.jsx`, `.ts` and `.tsx` as an extension, and enables JSX/TSX parsing.
* This config:
* 1) adds `.jsx`, `.ts`, `.cts`, `.mts`, and `.tsx` as an extension
* 2) enables JSX/TSX parsing
*/

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

module.exports = {
const allExtensions = [...typeScriptExtensions, '.js', '.jsx'];

module.exports = {
settings: {
'import/extensions': allExtensions,
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
'@typescript-eslint/parser': typeScriptExtensions,
},
'import/resolver': {
node: {
Expand Down

0 comments on commit 4d32d68

Please sign in to comment.