Skip to content

feat: add 8 composable quality ESLint rules#34

Merged
kelsos merged 1 commit intomainfrom
feat/composable-quality-rules
Feb 20, 2026
Merged

feat: add 8 composable quality ESLint rules#34
kelsos merged 1 commit intomainfrom
feat/composable-quality-rules

Conversation

@kelsos
Copy link
Copy Markdown
Member

@kelsos kelsos commented Feb 20, 2026

Summary

  • Add 8 new ESLint rules enforcing composable best practices (based on VueUse style guide)
  • Add strict and stylistic config presets alongside existing recommended
  • Fix config filter bug: was checking meta.recommended instead of meta.docs.recommendation

strict rules (5)

Rule Fixable Description
composable-no-default-export No Forbid default exports in composable files
composable-prefer-shallowref Yes Prefer shallowRef() for primitive values
composable-return-readonly Yes Wrap returned refs with readonly()
composable-require-cleanup No Require cleanup hooks for side effects
composable-ssr-safety No Guard window/document/navigator access

stylistic rules (3)

Rule Fixable Description
composable-naming-convention No Enforce Use{Name}Options/Use{Name}Return naming
composable-input-flexibility Yes Prefer MaybeRefOrGetter over Ref for params
require-jsdoc-on-composable-options No Require JSDoc on Use*Options interface properties

Tested against rotki frontend composables

Rule Hits
composable-return-readonly 146
composable-prefer-shallowref 38
require-jsdoc-on-composable-options 30
composable-input-flexibility 30
composable-naming-convention 13
composable-ssr-safety 10
composable-require-cleanup 4
composable-no-default-export 0

272 total warnings (215 auto-fixable), no false positives observed.

Test plan

  • pnpm run build — passes
  • pnpm run test — 134 tests pass (16 test files)
  • pnpm run lint — 0 errors
  • pnpm run typecheck — passes
  • pnpm run docs:build — passes
  • Tested against rotki frontend composables

Add rules enforcing composable best practices based on VueUse style guide:

strict:
- composable-no-default-export: forbid default exports in composable files
- composable-prefer-shallowref: prefer shallowRef() for primitives
- composable-return-readonly: wrap returned refs with readonly()
- composable-require-cleanup: require cleanup hooks for side effects
- composable-ssr-safety: guard browser globals in composables

stylistic:
- composable-naming-convention: enforce Use{Name}Options/Return naming
- composable-input-flexibility: prefer MaybeRefOrGetter over Ref params
- require-jsdoc-on-composable-options: require JSDoc on options properties

Also adds strict/stylistic config presets and fixes config filter to use
meta.docs.recommendation instead of meta.recommended.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 81.68168% with 61 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.20%. Comparing base (ecc108b) to head (419e7fe).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/rules/composable-ssr-safety.ts 82.60% 9 Missing and 3 partials ⚠️
src/rules/composable-require-cleanup.ts 82.25% 9 Missing and 2 partials ⚠️
src/utils/composable.ts 66.66% 8 Missing and 2 partials ⚠️
src/rules/composable-naming-convention.ts 84.31% 8 Missing ⚠️
src/rules/composable-input-flexibility.ts 78.78% 6 Missing and 1 partial ⚠️
src/rules/composable-return-readonly.ts 81.81% 5 Missing and 1 partial ⚠️
src/utils/config.ts 0.00% 3 Missing and 1 partial ⚠️
src/rules/require-jsdoc-on-composable-options.ts 88.88% 2 Missing ⚠️
src/rules/composable-no-default-export.ts 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #34      +/-   ##
==========================================
- Coverage   85.12%   84.20%   -0.93%     
==========================================
  Files          19       28       +9     
  Lines         726     1057     +331     
  Branches      206      325     +119     
==========================================
+ Hits          618      890     +272     
- Misses         94      144      +50     
- Partials       14       23       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kelsos kelsos merged commit 419e7fe into main Feb 20, 2026
5 checks passed
@kelsos kelsos deleted the feat/composable-quality-rules branch February 20, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants