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

Add new TypeScript extensions (.mts, .cts) #728

Merged
merged 1 commit into from Aug 12, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/plugins.cjs
Expand Up @@ -314,6 +314,8 @@ module.exports = {
// TypeScript doesn't yet support using extensions and fails with error TS2691.
'.ts': 'never',
'.tsx': 'never',
'.mts': 'never',
'.cts': 'never',
},
],
'n/no-mixed-requires': [
Expand Down
2 changes: 2 additions & 0 deletions lib/constants.js
Expand Up @@ -24,6 +24,8 @@ const MERGE_OPTIONS_CONCAT = [
const TYPESCRIPT_EXTENSION = [
'ts',
'tsx',
'mts',
'cts',
];

const DEFAULT_EXTENSION = [
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -315,7 +315,7 @@ Setting this to an object enables the resolver and passes the object as configur

## TypeScript

XO will automatically lint TypeScript files (`.ts`, `.d.ts` and `.tsx`) with the rules defined in [eslint-config-xo-typescript#use-with-xo](https://github.com/xojs/eslint-config-xo-typescript#use-with-xo).
XO will automatically lint TypeScript files (`.ts`, `.mts`, `.cts`, `.d.ts` and `.tsx`) with the rules defined in [eslint-config-xo-typescript#use-with-xo](https://github.com/xojs/eslint-config-xo-typescript#use-with-xo).

XO will handle the [@typescript-eslint/parser `project` option](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#parseroptionsproject) automatically even if you don't have a `tsconfig.json` in your project.

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/typescript/child/extra-semicolon.cts
@@ -0,0 +1 @@
console.log('extra-semicolon');;
1 change: 1 addition & 0 deletions test/fixtures/typescript/child/extra-semicolon.mts
@@ -0,0 +1 @@
console.log('extra-semicolon');;
18 changes: 18 additions & 0 deletions test/lint-files.js
Expand Up @@ -216,6 +216,24 @@ test.serial('typescript files', async t => {
),
);

t.true(
hasRule(
results,
path.resolve('fixtures/typescript/child/extra-semicolon.mts'),
'@typescript-eslint/no-extra-semi',
rulesMeta,
),
);

t.true(
hasRule(
results,
path.resolve('fixtures/typescript/child/extra-semicolon.cts'),
'@typescript-eslint/no-extra-semi',
rulesMeta,
),
);

t.true(
hasRule(
results,
Expand Down