Skip to content

Commit f43d17f

Browse files
feat: streamlined eslint.config.js with better tseslint.config usage (#1697)
## PR Checklist - [x] Addresses an existing open issue: fixes #1690 - [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 Applies the changes in the issue. This brings the file line count -including comments- from 166 to 140. Removes the `files: ["**/*.md/*.ts"],` from this repo's `eslint.config.js` because there's no `ts` codeblock in the README.md. Updates the `typescript-eslint` package by necessity for the `defaultProject` default. 💖
1 parent a8d9c3c commit f43d17f

File tree

7 files changed

+179
-257
lines changed

7 files changed

+179
-257
lines changed

eslint.config.js

+13-39
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default tseslint.config(
4949
packageJson,
5050
perfectionist.configs["recommended-natural"],
5151
regexp.configs["flat/recommended"],
52-
...tseslint.config({
52+
{
5353
extends: [
5454
...tseslint.configs.strictTypeChecked,
5555
...tseslint.configs.stylisticTypeChecked,
@@ -59,23 +59,13 @@ export default tseslint.config(
5959
parserOptions: {
6060
projectService: {
6161
allowDefaultProject: ["*.config.*s", "bin/*.js", "script/*.ts"],
62-
defaultProject: "./tsconfig.json",
6362
},
6463
tsconfigRootDir: import.meta.dirname,
6564
},
6665
},
6766
rules: {
68-
// These off-by-default rules work well for this repo and we like them on.
69-
"logical-assignment-operators": [
70-
"error",
71-
"always",
72-
{ enforceForIfStatements: true },
73-
],
74-
"operator-assignment": "error",
75-
7667
// These on-by-default rules don't work well for this repo and we like them off.
7768
"jsdoc/lines-before-block": "off",
78-
"no-constant-condition": "off",
7969

8070
// These on-by-default rules work well for this repo if configured
8171
"@typescript-eslint/no-unnecessary-condition": [
@@ -84,7 +74,6 @@ export default tseslint.config(
8474
allowConstantLoopConditions: true,
8575
},
8676
],
87-
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "all" }],
8877
"@typescript-eslint/prefer-nullish-coalescing": [
8978
"error",
9079
{ ignorePrimitives: true },
@@ -97,47 +86,32 @@ export default tseslint.config(
9786
"error",
9887
{ allowExperimental: true },
9988
],
100-
"perfectionist/sort-objects": [
101-
"error",
102-
{
103-
order: "asc",
104-
partitionByComment: true,
105-
type: "natural",
106-
},
107-
],
10889

10990
// Stylistic concerns that don't interfere with Prettier
91+
"logical-assignment-operators": [
92+
"error",
93+
"always",
94+
{ enforceForIfStatements: true },
95+
],
11096
"no-useless-rename": "error",
11197
"object-shorthand": "error",
98+
"operator-assignment": "error",
11299
},
113-
}),
114-
{
115-
files: ["*.jsonc"],
116-
rules: {
117-
"jsonc/comma-dangle": "off",
118-
"jsonc/no-comments": "off",
119-
"jsonc/sort-keys": "error",
100+
settings: {
101+
perfectionist: {
102+
partitionByComment: true,
103+
type: "natural",
104+
},
120105
},
121106
},
122107
{
123108
extends: [tseslint.configs.disableTypeChecked],
124109
files: ["**/*.md/*.ts"],
125-
rules: {
126-
"n/no-missing-import": [
127-
"error",
128-
{ allowModules: ["create-typescript-app"] },
129-
],
130-
},
131110
},
132111
{
112+
extends: [vitest.configs.recommended],
133113
files: ["**/*.test.*"],
134-
languageOptions: {
135-
globals: vitest.environments.env.globals,
136-
},
137-
plugins: { vitest },
138114
rules: {
139-
...vitest.configs.recommended.rules,
140-
141115
// These on-by-default rules aren't useful in test files.
142116
"@typescript-eslint/no-unsafe-assignment": "off",
143117
"@typescript-eslint/no-unsafe-call": "off",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"tsup": "^8.3.0",
101101
"tsx": "^4.17.0",
102102
"typescript": "^5.6.2",
103-
"typescript-eslint": "^8.1.0",
103+
"typescript-eslint": "^8.15.0",
104104
"vitest": "^2.1.0"
105105
},
106106
"engines": {

0 commit comments

Comments
 (0)