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,