feat: Autofix tag-self-close rule
#270
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new autofix feature for the
tag-self-closerule in thehtmlhint-serverand refactors existing code to simplify and improve maintainability. It also includes updates to the documentation and test cases to reflect the new functionality.New Feature:
tag-self-closeAutofixcreateTagSelfCloseFixfunction to automatically convert non-self-closing void HTML elements (e.g.,<img>) into self-closing tags (e.g.,<img />) to comply with standards. (htmlhint-server/src/server.ts, htmlhint-server/src/server.tsR1342-R1468)createAutoFixesfunction, enabling it to handle diagnostics for thetag-self-closerule. (htmlhint-server/src/server.ts, htmlhint-server/src/server.tsR1551-R1554)connection.onRequestto support thetag-self-closerule, including extracting raw tag data and ensuring proper range normalization. (htmlhint-server/src/server.ts, [1] [2] [3] [4]Code Refactoring
createAttrValueDoubleQuotesFix,createTagnameLowercaseFix,createAttrLowercaseFix, andcreateSpecCharEscapeFix) by replacing complex logic with a more direct approach usinglineIndex. (htmlhint-server/src/server.ts, [1] [2] [3] [4]Documentation Updates
tag-self-closerule to the list of supported autofix rules in theREADME.mdfile. (htmlhint/README.md, htmlhint/README.mdR41)CHANGELOG.mdto document the addition of thetag-self-closeautofix feature. (htmlhint/CHANGELOG.md, htmlhint/CHANGELOG.mdR8)Test Enhancements
tag-self-closerule in the.htmlhintrcconfiguration file for testing. (test/autofix/.htmlhintrc, test/autofix/.htmlhintrcL18-R18)tag-self-close-test.htmlto validate the autofix functionality for various scenarios. (test/autofix/tag-self-close-test.html, test/autofix/tag-self-close-test.htmlR1-R24)tag-self-closetest cases in the existingtest-autofixes.htmlfile. (test/autofix/test-autofixes.html, test/autofix/test-autofixes.htmlR33-R40)