Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: streamlined eslint.config.js with better tseslint.config usage #1697

Merged
merged 7 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 13 additions & 39 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default tseslint.config(
packageJson,
perfectionist.configs["recommended-natural"],
regexp.configs["flat/recommended"],
...tseslint.config({
{
extends: [
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
Expand All @@ -59,23 +59,13 @@ export default tseslint.config(
parserOptions: {
projectService: {
allowDefaultProject: ["*.config.*s", "bin/*.js", "script/*.ts"],
defaultProject: "./tsconfig.json",
},
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
// These off-by-default rules work well for this repo and we like them on.
"logical-assignment-operators": [
"error",
"always",
{ enforceForIfStatements: true },
],
"operator-assignment": "error",

// These on-by-default rules don't work well for this repo and we like them off.
"jsdoc/lines-before-block": "off",
"no-constant-condition": "off",

// These on-by-default rules work well for this repo if configured
"@typescript-eslint/no-unnecessary-condition": [
Expand All @@ -84,7 +74,6 @@ export default tseslint.config(
allowConstantLoopConditions: true,
},
],
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "all" }],
"@typescript-eslint/prefer-nullish-coalescing": [
"error",
{ ignorePrimitives: true },
Expand All @@ -97,47 +86,32 @@ export default tseslint.config(
"error",
{ allowExperimental: true },
],
"perfectionist/sort-objects": [
"error",
{
order: "asc",
partitionByComment: true,
type: "natural",
},
],

// Stylistic concerns that don't interfere with Prettier
"logical-assignment-operators": [
"error",
"always",
{ enforceForIfStatements: true },
],
"no-useless-rename": "error",
"object-shorthand": "error",
"operator-assignment": "error",
},
}),
{
files: ["*.jsonc"],
rules: {
"jsonc/comma-dangle": "off",
"jsonc/no-comments": "off",
"jsonc/sort-keys": "error",
settings: {
perfectionist: {
partitionByComment: true,
type: "natural",
},
},
},
{
extends: [tseslint.configs.disableTypeChecked],
files: ["**/*.md/*.ts"],
rules: {
"n/no-missing-import": [
"error",
{ allowModules: ["create-typescript-app"] },
],
},
},
{
extends: [vitest.configs.recommended],
files: ["**/*.test.*"],
languageOptions: {
globals: vitest.environments.env.globals,
},
plugins: { vitest },
rules: {
...vitest.configs.recommended.rules,

// These on-by-default rules aren't useful in test files.
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"tsup": "^8.3.0",
"tsx": "^4.17.0",
"typescript": "^5.6.2",
"typescript-eslint": "^8.1.0",
"typescript-eslint": "^8.15.0",
"vitest": "^2.1.0"
},
"engines": {
Expand Down
Loading
Loading