Component files should appear before their test file in code review
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
What
The current view for code review sorts files alphabetically. This means that component files have a chance to appear after their test file, which disrupts the natural reading flow during reviews.
Why this matters
When reviewing changes, developers typically want to:
- Understand the implementation changes first
- Then verify the test coverage
Having test files appear before their related components breaks this natural review flow and can make code reviews less efficient.
Proposal
Implement a sorting strategy that ensures implementation files appear before their associated test files.
Assumptions
- Spec files typically have
.spec.js,.spec.ts,.spec.jsx,.spec.tsx,.unit.js,.unit.ts,.unit.jsx,.unit.tsxextensions (or similar test patterns) - Implementation files commonly use extensions:
.vue,.js,.jsx,.ts,.tsx,.svelte,.astro
Suggested approach
When sorting files, group related files together with this priority:
- Implementation file (e.g.,
component.vue,component.tsx,utils.js) - Test files (e.g.,
component.spec.js,component.unit.tsx)
Within each group, maintain alphabetical ordering.
Example
Before (current):
component.spec.tsxcomponent.tsxutils.jsutils.unit.js
After (proposed):
component.tsxcomponent.spec.tsxutils.jsutils.unit.js
Open questions
- Should this behavior be configurable or always-on?
- How should we handle edge cases where multiple test files exist for one implementation file?
Edited by 🤖 GitLab Bot 🤖

