Skip to content

feat(attr-sort): sort unknown attributes alphabetically #668

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

Merged
merged 2 commits into from
May 9, 2025

Conversation

chrisguttandin
Copy link
Contributor

Previously unknown attributes were just ignored. Now they get sorted alphabetically.

BREAKING CHANGE: HTMLHint will now throw an error if unkown attributes are not sorted.

fix #661

Short description of what this resolves:
This PR will make sure all attributes get sorted when using the attr-sorted rule. It will ensure that attributes linted with this rule will always get sorted the same way.

Please let me know if there is anything that should be changed to make this PR mergable.

@github-actions github-actions bot added core Relates to HTMLHint's core APIs and features test labels Aug 16, 2021
Copy link
Member

@thedaviddias thedaviddias left a comment

Choose a reason for hiding this comment

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

That's a pretty good addition! Thanks @chrisguttandin!

@stale

This comment was marked as outdated.

@stale stale bot added the bot:stale Issue marked as stale because there was no activity label Nov 17, 2021
@coliff coliff removed the bot:stale Issue marked as stale because there was no activity label Nov 17, 2021
@thedaviddias thedaviddias added the keep-unstale The issue will not be marked as stale by the stale-bot label Nov 23, 2021
@coliff
Copy link
Member

coliff commented Apr 26, 2023

Heya @chrisguttandin - can you please resolve the conflicts so we can get this one merged? Thanks!

@chrisguttandin
Copy link
Contributor Author

Hi @coliff, I've rebased the branch on top of the current master.

@chrisguttandin
Copy link
Contributor Author

@coliff Is there anything I can do about the failing CI tasks?

@coliff
Copy link
Member

coliff commented May 16, 2023

Sorry for the delay - I think we need @thedaviddias for assistance on this.

@chrisguttandin
Copy link
Contributor Author

Hi @coliff, should I maybe close this PR and create a new one with the same changes on top of the latest master?

@coliff
Copy link
Member

coliff commented Apr 28, 2025

hey @chrisguttandin - sorry for the trouble. We appreciate the PR and your patience with this - I know you opened this a long while back! :-)

Yes, I think closing it and making a new PR could be a good idea. I'll be sure to review it as soon as you do. I'm hoping we'll be able to get a new release of HTMLHint out soon. thanks again!

@chrisguttandin
Copy link
Contributor Author

Okay, I rebased the branch on top of master. Could you please take a look, @coliff?

@coliff coliff force-pushed the sort-all-attributes branch 2 times, most recently from 27489b7 to ae2f614 Compare May 8, 2025 03:07
@coliff
Copy link
Member

coliff commented May 8, 2025

Okay, I rebased the branch on top of master. Could you please take a look, @coliff?

I think if you run npm run build and include the updated files in the dist directory (it should update htmlhint.js and htmlhint.min.js then we should be good to merge!

@coliff coliff mentioned this pull request May 8, 2025
Previously unknown attributes were just ignored. Now they get sorted alphabetically.

BREAKING CHANGE: HTMLHint will now throw an error if unkown attributes are not sorted.

fix htmlhint#661
@chrisguttandin chrisguttandin force-pushed the sort-all-attributes branch from ae2f614 to ded3d9a Compare May 8, 2025 21:00
@chrisguttandin
Copy link
Contributor Author

I think if you run npm run build and include the updated files in the dist directory (it should update htmlhint.js and htmlhint.min.js then we should be good to merge!

Okay, I just did that.

@coliff
Copy link
Member

coliff commented May 9, 2025

thanks @chrisguttandin - nearly there! There's a test failure though.....

 FAIL test/rules/attr-sorted.spec.js
    ● Rules: attr-sorted › Attribute unsorted tags that are unrecognizable should throw error
  
      TypeError: Cannot read properties of undefined (reading 'be')
  
        30 |     const messages = HTMLHint.verify(code, ruleOptions)
        31 |
      > 32 |     expect(messages.length).to.be(1)
           |                               ^
        33 |     expect(messages[0].rule.id).to.be(ruleId)
        34 |     expect(messages[0].message).to.contain('["img","meta","font"]')
        35 |   })
  
        at Object.<anonymous> (test/rules/attr-sorted.spec.js:32:31)

I used GitHub Copilot to help find the issue and fix...

> The error occurs because the test is using .to.be() and .to.contain() methods, which are not part of the Jest assertion library. These methods are typically used in Chai, another assertion library. In Jest, the equivalent methods are .toBe() and .toContain().
Copy link

codecov bot commented May 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.46%. Comparing base (32d427f) to head (4bcc417).
Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #668   +/-   ##
=======================================
  Coverage   98.46%   98.46%           
=======================================
  Files           2        2           
  Lines        1627     1627           
  Branches      340      342    +2     
=======================================
  Hits         1602     1602           
  Misses         25       25           
Files with missing lines Coverage Δ
dist/htmlhint.js 98.46% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 32d427f...4bcc417. Read the comment docs.

🚀 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.

@coliff coliff merged commit 2c63ab0 into htmlhint:master May 9, 2025
13 checks passed
@chrisguttandin
Copy link
Contributor Author

Thanks @coliff, for taking care of the failing tests. I scratched my head wondering why I created these failing tests in the first place. It turns out I created the PR before the switch to Jest. :-) I'm happy that it's finally merged. Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Relates to HTMLHint's core APIs and features keep-unstale The issue will not be marked as stale by the stale-bot test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

attr-sorted doesn't sort unknown tags
3 participants