Skip to content

Commit

Permalink
feat: add .cts and .mts extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Zamiell committed Aug 7, 2023
1 parent 0501367 commit 044478d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions config/typescript.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
/**
* 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'];
/**
* We omit `.d.ts` because:
* 1) TypeScript compilation already confirms that types are resolved
* 2) it would mask an unresolved `.ts`/`.tsx`/`.js`/`.jsx` implementation
*/
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 All @@ -25,7 +30,7 @@ module.exports = {
rules: {
// analysis/correctness

// TypeScript compilation already ensures that named imports exist in the referenced module
// TypeScript compilation already ensures that named imports exist in the referenced module.
'import/named': 'off',
},
};

0 comments on commit 044478d

Please sign in to comment.