Skip to content

Commit d561625

Browse files
feat: eslint v9 with flat config (#2075)
1 parent 295b349 commit d561625

30 files changed

+1765
-1254
lines changed

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"access": "public",
1111
"baseBranch": "main",
1212
"updateInternalDependencies": "patch",
13-
"ignore": ["@ct3a/www", "@ct3a/upgrade"],
13+
"ignore": ["@ct3a/www"],
1414
"changedFilePatterns": ["src/**", "template/**"]
1515
}

.changeset/proud-trainers-swim.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-t3-app": minor
3+
---
4+
5+
feat: use eslint v9 with flat config

.eslintrc.cjs

Lines changed: 0 additions & 50 deletions
This file was deleted.

cli/.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

cli/eslint.config.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// @ts-check
2+
import tseslint from "typescript-eslint";
3+
// import isaacscript from "eslint-plugin-isaacscript";
4+
import importPlugin from "eslint-plugin-import-x";
5+
6+
export default tseslint.config(
7+
{ ignores: ["dist", "*.config.*"] },
8+
{
9+
files: ["**/*.{ts,tsx}"],
10+
plugins: {
11+
// isaacscript, // REENABLE
12+
"import-x": importPlugin,
13+
},
14+
extends: [
15+
...tseslint.configs.recommended,
16+
],
17+
rules: {
18+
"@typescript-eslint/no-unused-vars": [
19+
"error",
20+
{ argsIgnorePattern: "^_", destructuredArrayIgnorePattern: "^_" },
21+
],
22+
"@typescript-eslint/consistent-type-imports": [
23+
"error",
24+
{ prefer: "type-imports", fixStyle: "inline-type-imports" },
25+
],
26+
"import-x/consistent-type-specifier-style": ["error", "prefer-inline"],
27+
28+
// // For educational purposes we format our comments/jsdoc nicely
29+
// "isaacscript/complete-sentences-jsdoc": "warn",
30+
// "isaacscript/format-jsdoc-comments": "warn",
31+
32+
// These lint rules don't make sense for us but are enabled in the preset configs
33+
"@typescript-eslint/no-confusing-void-expression": "off",
34+
"@typescript-eslint/restrict-template-expressions": "off",
35+
36+
// This rule doesn't seem to be working properly
37+
"@typescript-eslint/prefer-nullish-coalescing": "off",
38+
},
39+
},
40+
{
41+
files: ["src/**/*.{ts,tsx}"],
42+
extends: [
43+
...tseslint.configs.recommendedTypeChecked,
44+
...tseslint.configs.stylisticTypeChecked,
45+
],
46+
rules: {
47+
"@typescript-eslint/no-explicit-any": "error",
48+
},
49+
},
50+
{
51+
// Template files don't have reliable type information
52+
files: ["./template/**/*.{ts,tsx}"],
53+
extends: [tseslint.configs.disableTypeChecked],
54+
},
55+
{
56+
linterOptions: {
57+
reportUnusedDisableDirectives: true,
58+
},
59+
languageOptions: {
60+
sourceType: "module",
61+
parserOptions: {
62+
project: [
63+
"./tsconfig.eslint.json",
64+
],
65+
// projectService: {
66+
// defaultProject: "tsconfig.eslint.json",
67+
// },
68+
tsconfigRootDir: import.meta.dirname,
69+
},
70+
},
71+
},
72+
);

cli/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"dev": "tsup --watch",
4141
"clean": "rm -rf dist .turbo node_modules",
4242
"start": "node dist/index.js",
43-
"lint": "eslint . --ext .ts,.tsx",
43+
"lint": "eslint",
4444
"lint:fix": "pnpm lint --fix",
4545
"format": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --write",
4646
"format:check": "prettier '**/*.{cjs,mjs,ts,tsx,md,json}' --ignore-path ../.gitignore --ignore-unknown --no-error-on-unmatched-pattern --check",
@@ -79,12 +79,12 @@
7979
"@types/gradient-string": "^1.1.6",
8080
"@types/node": "^20.14.10",
8181
"drizzle-kit": "^0.30.5",
82-
"drizzle-orm": "^0.40.0",
82+
"drizzle-orm": "^0.41.0",
8383
"mysql2": "^3.11.0",
8484
"next": "^15.2.3",
8585
"next-auth": "^4.24.7",
8686
"postgres": "^3.4.4",
87-
"prettier": "^3.3.2",
87+
"prettier": "^3.5.3",
8888
"prettier-plugin-tailwindcss": "^0.6.11",
8989
"prisma": "^5.14.0",
9090
"react": "^18.3.0",

cli/src/helpers/installDependencies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const runInstallCommand = async (
5555

5656
if (text.includes("Progress")) {
5757
spinner.text = text.includes("|")
58-
? text.split(" | ")[1] ?? ""
58+
? (text.split(" | ")[1] ?? "")
5959
: text;
6060
}
6161
},

cli/src/helpers/setImportAlias.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function replaceTextInFiles(
2323
export const setImportAlias = (projectDir: string, importAlias: string) => {
2424
const normalizedImportAlias = importAlias
2525
.replace(/\*/g, "") // remove any wildcards (~/* -> ~/)
26-
.replace(/[^\/]$/, "$&/"); // ensure trailing slash (@ -> ~/)
26+
.replace(/[^/]$/, "$&/"); // ensure trailing slash (@ -> ~/)
2727

2828
// update import alias in any files if not using the default
2929
replaceTextInFiles(projectDir, `~/`, normalizedImportAlias);

cli/src/installers/dependencyVersionMap.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const dependencyVersionMap = {
1515

1616
// Drizzle
1717
"drizzle-kit": "^0.30.5",
18-
"drizzle-orm": "^0.40.0",
18+
"drizzle-orm": "^0.41.0",
1919
mysql2: "^3.11.0",
2020
"@planetscale/database": "^1.19.0",
2121
postgres: "^3.4.4",
@@ -40,12 +40,11 @@ export const dependencyVersionMap = {
4040

4141
// eslint / prettier
4242
prettier: "^3.3.2",
43+
"@eslint/eslintrc": "^3.3.1",
4344
"prettier-plugin-tailwindcss": "^0.6.11",
44-
eslint: "^8.57.0",
45+
eslint: "^9.23.0",
4546
"eslint-config-next": "^15.2.3",
4647
"eslint-plugin-drizzle": "^0.2.3",
47-
"@types/eslint": "^8.56.10",
48-
"@typescript-eslint/eslint-plugin": "^8.1.0",
49-
"@typescript-eslint/parser": "^8.1.0",
48+
"typescript-eslint": "^8.27.0",
5049
} as const;
5150
export type AvailableDependencies = keyof typeof dependencyVersionMap;

cli/src/installers/envVars.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const envVariablesInstaller: Installer = ({
1515
const usingPrisma = packages?.prisma.inUse;
1616
const usingDrizzle = packages?.drizzle.inUse;
1717

18-
const usingDb = usingPrisma || usingDrizzle;
18+
const usingDb = usingPrisma === true || usingDrizzle === true;
1919
const usingPlanetScale = databaseProvider === "planetscale";
2020

2121
const envContent = getEnvContent(

0 commit comments

Comments
 (0)