Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New] TypeScript config: add .cts and .mts extensions #2851

Merged
merged 1 commit into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Loading