Skip to content

Conversation

@mheob
Copy link
Owner

@mheob mheob commented Oct 21, 2025

Summary

Improved JSDoc ESLint configuration to better support TypeScript projects by using TypeScript-specific recommended rules and adding explicit file targeting.

Changes

  • Switched from flat/recommended to flat/recommended-typescript config
  • Added explicit file targeting with GLOB_JS and GLOB_TS
  • Removed jsdoc/no-restricted-syntax rule
  • Updated jsdoc/require-jsdoc to not require JSDoc on ArrowFunctionExpression or FunctionDeclaration

Motivation

The previous configuration used generic JSDoc recommended rules which were not optimized for TypeScript. The TypeScript-specific preset provides better defaults for TypeScript projects. Additionally, requiring JSDoc on arrow functions (which are more commonly used in modern codebases) while making it optional for function declarations provides better documentation coverage without being overly restrictive.

Summary by CodeRabbit

  • Style

    • Switched JSDoc linting to a TypeScript-focused baseline.
    • JSDoc is no longer required on arrow functions or function declarations.
    • Removed a restrictive JSDoc syntax rule.
  • Chores

    • Improved JavaScript/TypeScript file targeting in lint configuration.

@changeset-bot
Copy link

changeset-bot bot commented Oct 21, 2025

🦋 Changeset detected

Latest commit: 453737a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@mheob/eslint-config Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
eslint-config Ready Ready Preview Comment Oct 21, 2025 6:52am

💡 Enable Vercel Agent with $100 free credit for automated AI reviews

@coderabbitai
Copy link

coderabbitai bot commented Oct 21, 2025

Walkthrough

Updates the @mheob/eslint-config JSDoc ESLint configuration: adds explicit file globs (GLOB_JS, GLOB_TS), switches the base from flat/recommended to flat/recommended-typescript, removes jsdoc/no-restricted-syntax, and tightens jsdoc/require-jsdoc to exempt arrow functions and function declarations. Also updates a changeset and a docs file.

Changes

Cohort / File(s) Summary
Changeset entry
\.changeset/whole-cobras-knock.md``
Documents the @mheob/eslint-config update and lists JSDoc rule and file-targeting changes.
ESLint JSDoc configuration
packages/eslint-config/src/configs/jsdoc.ts
Adds GLOB_JS and GLOB_TS to files, switches extends/recommended source to flat/recommended-typescript, removes jsdoc/no-restricted-syntax, and replaces jsdoc/require-jsdoc with ['warn', { require: { ArrowFunctionExpression: false, FunctionDeclaration: false } }].
Documentation update
\.claude/commands/create-commit.md
Edits guidance for change-message length and related editorial tweaks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

eslint, Configuration changes, Review effort [1-5]: 3

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "fix(eslint): improve JSDoc config for TS" directly and clearly describes the main change in the pull request. The changeset primarily focuses on updating the JSDoc ESLint configuration with TypeScript-specific recommendations, explicit file targeting, and adjusted JSDoc requirements—all of which are accurately captured by the title. The title is concise, avoids vague terminology, uses a conventional commit format with appropriate scope and type, and provides enough specificity that a developer scanning commit history would understand this concerns ESLint configuration improvements for TypeScript projects. While minor changes exist in other files, they are secondary to the main JSDoc configuration updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-jsdoc-react-ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link

claude bot commented Oct 21, 2025

Code Review - PR #317

Summary

This PR improves the JSDoc ESLint configuration for better TypeScript support. The changes are well-motivated and generally sound.

Positives

TypeScript-specific rules - Switching from flat/recommended to flat/recommended-typescript is appropriate for a TypeScript-focused config package

Explicit file targeting - Adding files: [GLOB_JS, GLOB_TS] makes the configuration more explicit and maintainable

Proper changeset - The changeset is well-documented with clear descriptions of all changes

Follows conventions - Commit message follows conventional commits pattern as per the project's requirements

Issues & Considerations

1. JSDoc Comment Requirement Logic (packages/eslint-config/src/configs/jsdoc.ts:31-33)

The new configuration requires JSDoc on arrow functions but not on regular function declarations:

{ require: { ArrowFunctionExpression: true, FunctionDeclaration: false } }

Concern: This seems counterintuitive for TypeScript projects because:

  • Arrow functions often have inline type annotations that make JSDoc redundant
  • Function declarations are more likely to be exported/public APIs that benefit from JSDoc
  • TypeScript's type system already provides type information for arrow functions

Suggestion: Consider reversing this or making both optional, especially since flat/recommended-typescript already has sensible defaults for TypeScript.

2. Missing JSDoc Update (packages/eslint-config/src/configs/jsdoc.ts:5-13)

The function's JSDoc comment still mentions no-restricted-syntax rule which was removed:

 * including the recommended rules, no-restricted-syntax, reject-any-type,

Recommendation: Update the JSDoc to reflect the current rule set.

3. Changeset Message (.changeset/whole-cobras-knock.md)

The changeset ends without a newline, which could cause issues with some tools.

Minor fix: Add a newline at the end of the file.

Security & Performance

✅ No security concerns identified
✅ No performance issues - changes are configuration only

Verdict

The PR is approved with minor suggestions. The core changes are solid, but the arrow function requirement deserves reconsideration based on TypeScript best practices.


🤖 Review generated by Claude Code

@claude
Copy link

claude bot commented Oct 21, 2025

Code Review for PR #317: fix(eslint): improve JSDoc config for TS

Overview

This PR improves the JSDoc ESLint configuration by switching to TypeScript-specific recommended rules and adding explicit file targeting. The changes are well-motivated and generally improve the configuration.

✅ Strengths

  1. Better TypeScript Integration: Switching from flat/recommended to flat/recommended-typescript is the right approach for a TypeScript-focused project.

  2. Explicit File Targeting: Adding files: [GLOB_JS, GLOB_TS] makes the configuration more explicit and predictable.

  3. Proper Documentation: The changeset clearly documents the changes made.

  4. Sensible Rule Adjustments: Setting both ArrowFunctionExpression and FunctionDeclaration to false in require-jsdoc is reasonable, as TypeScript types often provide sufficient documentation.

⚠️ Potential Issues

  1. Missing JSX/TSX Files (packages/eslint-config/src/configs/jsdoc.ts:21)

    The configuration currently only targets GLOB_JS and GLOB_TS, but the codebase also has JSX/TSX files. Consider whether JSDoc rules should also apply to:

    • GLOB_JSX (**/*.?([cm])jsx)
    • GLOB_TSX (**/*.?([cm])tsx)

    Recommendation: If JSDoc should apply to React components, update the files array:

    files: [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],

    Or use the more comprehensive GLOB_SRC if appropriate.

  2. Outdated JSDoc Comment (packages/eslint-config/src/configs/jsdoc.ts:10-11)

    The function's JSDoc comment still mentions no-restricted-syntax which was removed in this PR:

    * including the recommended rules, no-restricted-syntax, reject-any-type,

    Recommendation: Update the JSDoc to reflect current rules:

    * including the recommended rules for TypeScript, reject-any-type,
  3. Changeset Message Formatting (.changeset/whole-cobras-knock.md:9)

    The changeset file is missing a newline at the end, which may cause issues with some tools that expect files to end with a newline character.

    Recommendation: Add a trailing newline to the changeset file.

🔍 Code Quality

  • Best Practices: ✅ Follows ESLint flat config patterns correctly
  • Type Safety: ✅ Maintains proper TypeScript types
  • Convention: ✅ Follows the repository's conventional commit style

🚀 Performance

No performance concerns. The changes are configuration-only and won't impact runtime performance.

🔒 Security

No security concerns identified. This is a configuration change with no security implications.

📝 Summary

This is a solid improvement to the JSDoc configuration. The main suggestion is to verify whether JSX/TSX files should be included in the file targeting, and to update the outdated JSDoc comment. The changes align well with the project's TypeScript focus.

Recommendation: Approve with minor suggestions for improvement.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.claude/commands/create-commit.md (1)

20-20: Fix grammatical error in instruction.

"Omit mention Claude" is awkward phrasing. Use "omit mentioning Claude" or simply "omit Claude as author and generator."

Apply this diff:

- Please omit mention Claude as author and generator.
+ Please omit mentioning Claude as author and generator.
🧹 Nitpick comments (1)
packages/eslint-config/src/configs/jsdoc.ts (1)

5-14: Update JSDoc comment to reflect removed rule.

The JSDoc comment mentions no-restricted-syntax, but according to the PR summary, this rule was removed. Please update the comment to accurately reflect the current configuration.

 /**
  * Configures the ESLint rules for JSDoc.
  *
  * This function sets up the necessary ESLint plugin for JSDoc,
  * including the `eslint-plugin-jsdoc`. It also configures the rules for JSDoc,
- * including the recommended rules, no-restricted-syntax, reject-any-type,
+ * including the recommended rules, reject-any-type,
  * reject-function-type, require-jsdoc, require-next-type, and tag-lines rules.
  *
  * @returns Promise that resolves once the JSDoc ESLint rules are configured.
  */
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e9ce00c and 99665fc.

📒 Files selected for processing (3)
  • .changeset/whole-cobras-knock.md (1 hunks)
  • .claude/commands/create-commit.md (1 hunks)
  • packages/eslint-config/src/configs/jsdoc.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
.changeset/*.md

📄 CodeRabbit inference engine (CLAUDE.md)

Create a changeset for any user-facing change

Files:

  • .changeset/whole-cobras-knock.md
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/any-inside-generic-functions.mdc)

**/*.{ts,tsx}: When building generic functions in TypeScript, it is acceptable to use 'any' inside the function body if TypeScript cannot match runtime logic to type logic.
Outside of generic functions, use 'any' extremely sparingly in TypeScript code.

Unless explicitly required by the framework, do not use default exports in TypeScript files.

**/*.{ts,tsx}: Use TypeScript for all code. Prefer interfaces over types.
Follow the ESLint rules.
Use "function" keyword for pure functions.
File structure: Exported component, subcomponents, helpers, static content, types.
Avoid unnecessary curly braces in conditional statements.
For single-line statements in conditionals, omit curly braces.
Use concise, one-line syntax for simple conditional statements (e.g., if (condition) doSomething()).
Handle errors and edge cases at the beginning of functions.
Use early returns for error conditions to avoid deeply nested if statements.
Place the happy path last in the function for improved readability.
Avoid unnecessary else statements; use if-return pattern instead.
Use guard clauses to handle preconditions and invalid states early.
Implement proper error logging and user-friendly error messages.
Consider using custom error types or error factories for consistent error handling.
Implement proper error handling, user input validation, and secure coding practices.
Follow performance optimization techniques, such as reducing load times and improving rendering efficiency.
Provide clear and concise comments for complex logic.
Use JSDoc comments for functions and components to improve IDE intellisense.

**/*.{ts,tsx}: Proactively use discriminated unions to model data that can be in one of a few different shapes.
Use switch statements to handle the results of discriminated unions.
Use discriminated unions to prevent the 'bag of optionals' problem (i.e., avoid interfaces with multiple optional properties that can represent impossible states).

**/*.{ts,tsx}: Do not introduce new en...

Files:

  • packages/eslint-config/src/configs/jsdoc.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: mheob/config#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-09T12:39:52.494Z
Learning: Applies to eslint.config.ts : Maintain the root ESLint configuration in eslint.config.ts
📚 Learning: 2025-10-09T12:39:52.494Z
Learnt from: CR
PR: mheob/config#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-09T12:39:52.494Z
Learning: Applies to commitlint.config.js : Maintain the Commitlint configuration in commitlint.config.js to enforce conventional commits

Applied to files:

  • .claude/commands/create-commit.md
📚 Learning: 2025-10-09T12:39:52.494Z
Learnt from: CR
PR: mheob/config#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-09T12:39:52.494Z
Learning: Follow the conventional commits specification for all commit messages

Applied to files:

  • .claude/commands/create-commit.md
🧬 Code graph analysis (1)
packages/eslint-config/src/configs/jsdoc.ts (1)
packages/eslint-config/src/globs.ts (2)
  • GLOB_JS (4-4)
  • GLOB_TS (7-7)
🔇 Additional comments (2)
packages/eslint-config/src/configs/jsdoc.ts (2)

1-1: LGTM: Explicit file targeting improves clarity.

The addition of GLOB_JS and GLOB_TS imports and their use in the files array makes the configuration more explicit and easier to understand.

Also applies to: 21-21


17-17: Config name verified as correct.

The "flat/recommended-typescript" config is supported by eslint-plugin-jsdoc, confirming the change at line 17 is valid and properly targets TypeScript-specific JSDoc rules.

- Use flat/recommended-typescript instead of flat/recommended
- Add explicit file targeting with GLOB_JS and GLOB_TS
- Remove jsdoc/no-restricted-syntax rule
- Configure jsdoc/require-jsdoc for arrow functions only
@sonarqubecloud
Copy link

@claude
Copy link

claude bot commented Oct 21, 2025

PR Review: JSDoc Configuration Improvements

I've reviewed this pull request and have the following feedback:

Strengths

  1. Good alignment with TypeScript projects: Switching from flat/recommended to flat/recommended-typescript is the right approach for a configuration package designed to work with TypeScript. This provides better defaults for TypeScript codebases.

  2. Explicit file targeting: Adding files: [GLOB_JS, GLOB_TS] makes the configuration more explicit and maintainable. This is a best practice in ESLint flat configs.

  3. Proper changeset: The changeset is well-formatted and follows the project's conventions (patch version bump is appropriate).

  4. Follows conventional commits: The commit message follows the conventional commit format as required by the project.

⚠️ Issues & Concerns

1. Critical: Conflicting changeset and PR description

The changeset (line 9) states:

Updated jsdoc/require-jsdoc to not require JSDoc on ArrowFunctionExpression or FunctionDeclaration

However, the actual code in packages/eslint-config/src/configs/jsdoc.ts:31-34 sets both to false:

'jsdoc/require-jsdoc': [
  'warn',
  { require: { ArrowFunctionExpression: false, FunctionDeclaration: false } },
],

But the PR description claims:

Updated jsdoc/require-jsdoc to require JSDoc comments on arrow function expressions but not on function declarations

This is contradictory. If the intention was to require JSDoc on arrow functions, the config should be:

{ require: { ArrowFunctionExpression: true, FunctionDeclaration: false } }

Action required: Please clarify the intended behavior and align the code, changeset, and PR description accordingly.

2. Removal of jsdoc/no-restricted-syntax rule

The jsdoc/no-restricted-syntax rule was removed without explanation. While this might be intentional:

  • Why was it removed? Was it causing issues, or is it not needed in the TypeScript preset?
  • The changeset mentions it but doesn't explain the rationale.

Recommendation: Add a brief explanation in the PR description or changeset about why this rule was removed.

3. Potential breaking change for users

Switching from flat/recommended to flat/recommended-typescript could change linting behavior for existing users:

  • The TypeScript preset may have different rules enabled/disabled
  • This could introduce new warnings/errors in existing projects

Recommendation: Consider mentioning in the changeset or documentation whether users should expect any behavior changes when upgrading.

💡 Suggestions

  1. Missing tests: There are no test files in the eslint-config package. Consider adding integration tests to verify the configuration works as expected, especially for critical changes like this.

  2. Documentation update: Consider documenting the JSDoc behavior in the main README.md, as users might want to understand what JSDoc rules are enforced.

  3. Consider the jsdoc/require-next-type rule: This rule is set to 'warn', but with TypeScript, type information is already in the code. Is this rule still necessary? (This is a minor point, not a blocker.)

🔒 Security

No security concerns identified.

Performance

No performance concerns. The changes are configuration-only and should not impact runtime performance.

📝 Action Items

Must fix before merge:

  1. Resolve the contradiction between the changeset/PR description and the actual code regarding ArrowFunctionExpression and FunctionDeclaration behavior.

Nice to have:

  1. Add explanation for removing jsdoc/no-restricted-syntax
  2. Consider adding tests for JSDoc configuration
  3. Document potential behavior changes for users upgrading

Overall, this is a good improvement for TypeScript support, but please address the conflicting documentation before merging.

@mheob mheob merged commit af4e33f into main Oct 21, 2025
9 checks passed
@mheob mheob deleted the fix-jsdoc-react-ts branch October 21, 2025 06:57
mheob pushed a commit that referenced this pull request Oct 21, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @mheob/eslint-config@8.14.5

### Patch Changes

- [#317](#317)
([@mheob](https://github.com/mheob)): Updated JSDoc rules:
    -   Added explicit file targeting with GLOB_JS and GLOB_TS
- Switched from flat/recommended to flat/recommended-typescript config
    -   Removed jsdoc/no-restricted-syntax rule
- Updated jsdoc/require-jsdoc to not require JSDoc on
ArrowFunctionExpression or FunctionDeclaration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eslint 🚨 Belongs to ESLint config

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants