Skip to content

Commit 98fca73

Browse files
feat: switched ESLint config from JS to TS (#2351)
<!-- 👋 Hi, thanks for sending a PR to create-typescript-app! Please fill out all fields below and make sure each item is true and [x] checked. Otherwise we may not be able to review your PR. --> ## PR Checklist - [x] Addresses an existing open issue: fixes #000 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Switches the file formats from `.mjs` & `.js` to `.mts` and `.ts`. 🎁
1 parent c2b7597 commit 98fca73

3 files changed

Lines changed: 23 additions & 18 deletions

File tree

File renamed without changes.

src/blocks/blockESLint.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe("blockESLint", () => {
113113
},
114114
],
115115
"files": {
116-
"eslint.config.js": "import eslint from "@eslint/js";
116+
"eslint.config.ts": "import eslint from "@eslint/js";
117117
import { defineConfig, globalIgnores } from "eslint/config";
118118
import tseslint from "typescript-eslint";
119119
@@ -267,7 +267,7 @@ describe("blockESLint", () => {
267267
},
268268
],
269269
"files": {
270-
"eslint.config.js": "import eslint from "@eslint/js";
270+
"eslint.config.ts": "import eslint from "@eslint/js";
271271
import { defineConfig, globalIgnores } from "eslint/config";
272272
import tseslint from "typescript-eslint";
273273
@@ -424,7 +424,7 @@ describe("blockESLint", () => {
424424
},
425425
],
426426
"files": {
427-
"eslint.config.mjs": "import eslint from "@eslint/js";
427+
"eslint.config.mts": "import eslint from "@eslint/js";
428428
import { defineConfig, globalIgnores } from "eslint/config";
429429
import tseslint from "typescript-eslint";
430430
@@ -584,7 +584,7 @@ describe("blockESLint", () => {
584584
},
585585
],
586586
"files": {
587-
"eslint.config.js": "/*
587+
"eslint.config.ts": "/*
588588
This is a great config!
589589
*/
590590
/*
@@ -752,7 +752,7 @@ describe("blockESLint", () => {
752752
},
753753
],
754754
"files": {
755-
"eslint.config.js": "import eslint from "@eslint/js";
755+
"eslint.config.ts": "import eslint from "@eslint/js";
756756
import { defineConfig, globalIgnores } from "eslint/config";
757757
import tseslint from "typescript-eslint";
758758
@@ -899,7 +899,7 @@ describe("blockESLint", () => {
899899
},
900900
],
901901
"files": {
902-
"eslint.config.js": "import eslint from "@eslint/js";
902+
"eslint.config.ts": "import eslint from "@eslint/js";
903903
import { defineConfig, globalIgnores } from "eslint/config";
904904
import tseslint from "typescript-eslint";
905905
@@ -1059,7 +1059,7 @@ describe("blockESLint", () => {
10591059
},
10601060
],
10611061
"files": {
1062-
"eslint.config.js": "import eslint from "@eslint/js";
1062+
"eslint.config.ts": "import eslint from "@eslint/js";
10631063
import { defineConfig, globalIgnores } from "eslint/config";
10641064
import tseslint from "typescript-eslint";
10651065
@@ -1207,7 +1207,7 @@ describe("blockESLint", () => {
12071207
},
12081208
],
12091209
"files": {
1210-
"eslint.config.js": "import eslint from "@eslint/js";
1210+
"eslint.config.ts": "import eslint from "@eslint/js";
12111211
import { defineConfig, globalIgnores } from "eslint/config";
12121212
import tseslint from "typescript-eslint";
12131213
@@ -1333,7 +1333,7 @@ describe("blockESLint", () => {
13331333
},
13341334
],
13351335
"files": {
1336-
"eslint.config.js": "import eslint from "@eslint/js";
1336+
"eslint.config.ts": "import eslint from "@eslint/js";
13371337
import { defineConfig, globalIgnores } from "eslint/config";
13381338
import tseslint from "typescript-eslint";
13391339
@@ -1459,7 +1459,7 @@ describe("blockESLint", () => {
14591459
},
14601460
],
14611461
"files": {
1462-
"eslint.config.js": "import eslint from "@eslint/js";
1462+
"eslint.config.ts": "import eslint from "@eslint/js";
14631463
import { defineConfig, globalIgnores } from "eslint/config";
14641464
import tseslint from "typescript-eslint";
14651465
@@ -1582,7 +1582,7 @@ describe("blockESLint", () => {
15821582
},
15831583
],
15841584
"files": {
1585-
"eslint.config.mjs": "import eslint from "@eslint/js";
1585+
"eslint.config.mts": "import eslint from "@eslint/js";
15861586
import { defineConfig, globalIgnores } from "eslint/config";
15871587
import tseslint from "typescript-eslint";
15881588
@@ -1705,7 +1705,7 @@ describe("blockESLint", () => {
17051705
},
17061706
],
17071707
"files": {
1708-
"eslint.config.js": "import eslint from "@eslint/js";
1708+
"eslint.config.ts": "import eslint from "@eslint/js";
17091709
import { defineConfig, globalIgnores } from "eslint/config";
17101710
import tseslint from "typescript-eslint";
17111711
@@ -1736,25 +1736,25 @@ describe("blockESLint", () => {
17361736
expect(actual).toBeUndefined();
17371737
});
17381738

1739-
it("returns data when there is an eslint.config.js file", () => {
1739+
it("returns data when there is an eslint.config.ts file", () => {
17401740
const sourceText = "export default ...";
17411741

17421742
const actual = testIntake(blockESLint, {
17431743
files: {
1744-
"eslint.config.js": [sourceText],
1744+
"eslint.config.ts": [sourceText],
17451745
},
17461746
});
17471747

17481748
expect(mockBlockESLintIntake).toHaveBeenCalledWith(sourceText);
17491749
expect(actual).toBe(mockIntakeData);
17501750
});
17511751

1752-
it("returns data when there is an eslint.config.mjs file", () => {
1752+
it("returns data when there is an eslint.config.mts file", () => {
17531753
const sourceText = "export default ...";
17541754

17551755
const actual = testIntake(blockESLint, {
17561756
files: {
1757-
"eslint.config.mjs": [sourceText],
1757+
"eslint.config.mts": [sourceText],
17581758
},
17591759
});
17601760

src/blocks/blockESLint.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ export const blockESLint = base.createBlock({
3838
},
3939
intake({ files }) {
4040
const eslintConfigRaw = intakeFile(files, [
41-
["eslint.config.js", "eslint.config.mjs"],
41+
[
42+
"eslint.config.ts",
43+
"eslint.config.mts",
44+
"eslint.config.js",
45+
"eslint.config.mjs",
46+
],
4247
]);
4348

4449
return eslintConfigRaw ? blockESLintIntake(eslintConfigRaw[0]) : undefined;
@@ -47,7 +52,7 @@ export const blockESLint = base.createBlock({
4752
const { explanations, extensions, ignores, imports } = addons;
4853

4954
const configFileName =
50-
options.type === "commonjs" ? "eslint.config.mjs" : "eslint.config.js";
55+
options.type === "commonjs" ? "eslint.config.mts" : "eslint.config.ts";
5156

5257
const explanation =
5358
explanations.length > 0

0 commit comments

Comments
 (0)