Skip to content

Conversation

@yeonjuan
Copy link
Owner

Checklist

Description

@yeonjuan yeonjuan requested a review from Copilot August 11, 2025 13:26

This comment was marked as outdated.

@yeonjuan yeonjuan requested a review from Copilot August 11, 2025 14:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds pattern support to the priority option in the sort-attrs ESLint rule, addressing issue #404. The enhancement allows users to specify regular expression patterns to match attribute names in addition to exact string matches.

  • Extends the priority option schema to accept objects with a pattern property containing regex patterns
  • Implements pattern matching logic using RegExp to evaluate attribute names against priority patterns
  • Adds comprehensive test coverage for pattern-based priority sorting scenarios

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/eslint-plugin/lib/rules/sort-attrs.js Core implementation adding pattern support with regex compilation and matching logic
packages/eslint-plugin/tests/rules/sort-attrs.test.js Comprehensive test cases covering pattern matching scenarios for both valid and invalid cases
docs/rules/sort-attrs.md Documentation updates explaining the new pattern syntax and providing usage examples
.cspell.json Adds "describedby" to the spell check dictionary for test attributes

Comment on lines +76 to +78
return {
...item,
regex: new RegExp(item.pattern, "u"),
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

Creating RegExp objects during rule execution can impact performance. Consider validating and compiling patterns once during rule initialization or caching compiled regexes to avoid repeated compilation for the same patterns.

Suggested change
return {
...item,
regex: new RegExp(item.pattern, "u"),
let regex = regexCache.get(item.pattern);
if (!regex) {
regex = new RegExp(item.pattern, "u");
regexCache.set(item.pattern, regex);
}
return {
...item,
regex,

Copilot uses AI. Check for mistakes.
@yeonjuan yeonjuan merged commit 55a0220 into main Aug 11, 2025
5 checks passed
@yeonjuan yeonjuan deleted the feat-404-sort-attrs branch August 11, 2025 14:10
@codecov
Copy link

codecov bot commented Aug 11, 2025

Codecov Report

❌ Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.53%. Comparing base (f01a157) to head (00061fb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/eslint-plugin/lib/rules/sort-attrs.js 95.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #408      +/-   ##
==========================================
- Coverage   98.56%   98.53%   -0.03%     
==========================================
  Files          83       83              
  Lines        2716     2733      +17     
  Branches      756      763       +7     
==========================================
+ Hits         2677     2693      +16     
- Misses         39       40       +1     
Flag Coverage Δ
unittest 98.53% <95.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/eslint-plugin/lib/rules/sort-attrs.js 98.85% <95.00%> (-1.15%) ⬇️
🚀 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.

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.

[FEATURE] Allow patterns in sort-attrs

2 participants