From f035fbbef3fa461b5f5b5a4706e765194aa13c65 Mon Sep 17 00:00:00 2001
From: tommy-mitchell <tmitchell7@uh.edu>
Date: Wed, 9 Aug 2023 20:38:26 -0500
Subject: [PATCH] Add `.mts` and `.cts` extensions

---
 config/plugins.cjs                             |  2 ++
 lib/constants.js                               |  2 ++
 readme.md                                      |  2 +-
 .../typescript/child/extra-semicolon.cts       |  1 +
 .../typescript/child/extra-semicolon.mts       |  1 +
 test/lint-files.js                             | 18 ++++++++++++++++++
 6 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 test/fixtures/typescript/child/extra-semicolon.cts
 create mode 100644 test/fixtures/typescript/child/extra-semicolon.mts

diff --git a/config/plugins.cjs b/config/plugins.cjs
index b9f7d6c9..fe477045 100644
--- a/config/plugins.cjs
+++ b/config/plugins.cjs
@@ -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': [
diff --git a/lib/constants.js b/lib/constants.js
index a6b67659..114b5cb8 100644
--- a/lib/constants.js
+++ b/lib/constants.js
@@ -24,6 +24,8 @@ const MERGE_OPTIONS_CONCAT = [
 const TYPESCRIPT_EXTENSION = [
 	'ts',
 	'tsx',
+	'mts',
+	'cts',
 ];
 
 const DEFAULT_EXTENSION = [
diff --git a/readme.md b/readme.md
index 7c35fdbe..36c505fe 100644
--- a/readme.md
+++ b/readme.md
@@ -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.
 
diff --git a/test/fixtures/typescript/child/extra-semicolon.cts b/test/fixtures/typescript/child/extra-semicolon.cts
new file mode 100644
index 00000000..786cdaa6
--- /dev/null
+++ b/test/fixtures/typescript/child/extra-semicolon.cts
@@ -0,0 +1 @@
+console.log('extra-semicolon');;
diff --git a/test/fixtures/typescript/child/extra-semicolon.mts b/test/fixtures/typescript/child/extra-semicolon.mts
new file mode 100644
index 00000000..786cdaa6
--- /dev/null
+++ b/test/fixtures/typescript/child/extra-semicolon.mts
@@ -0,0 +1 @@
+console.log('extra-semicolon');;
diff --git a/test/lint-files.js b/test/lint-files.js
index d9f4ca4b..affdea9f 100644
--- a/test/lint-files.js
+++ b/test/lint-files.js
@@ -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,