Skip to content

Conversation

@Nightfirecat
Copy link
Contributor

Checklist

Description

This commit adds detection and fixers of not-lowercase doctypes in documents, eg. <!DOCTYPE html>, <!doctype HTML>, or any other capitalization besides the all-lowercased <!doctype html>.

I originally wanted to condense the changes to the rule in a single generalized check() function, but that ended up feeling kludgy because of the different shape of Doctype versus the existing assumptions for the input Tag | StyleTag | ScriptTag types. As a result, there is some duplicated code in my implementation here--I'd be happy to clean that up if there is a more ideal structure you'd like to see.

@yeonjuan yeonjuan requested a review from Copilot August 14, 2025 16:19
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 support for linting doctype declarations to ensure they are in lowercase. The feature addresses issue #410 by detecting and automatically fixing doctype declarations that aren't fully lowercase (e.g., <!DOCTYPE html> or <!doctype HTML>).

Key changes:

  • Extended the lowercase ESLint rule to handle Doctype nodes in addition to existing tag types
  • Added comprehensive test coverage for various doctype capitalization scenarios
  • Updated example HTML to use the preferred lowercase doctype format

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/eslint-plugin/lib/rules/lowercase.js Added checkDoctype function and visitor to lint doctype declarations
packages/eslint-plugin/tests/rules/lowercase.test.js Added test cases for valid and invalid doctype scenarios
packages/website/src/scripts/playground/helpers.js Updated example HTML to use lowercase doctype

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link

codecov bot commented Aug 15, 2025

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.50%. Comparing base (39d3cc1) to head (f811d81).

Files with missing lines Patch % Lines
packages/eslint-plugin/lib/rules/lowercase.js 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #411      +/-   ##
==========================================
- Coverage   98.53%   98.50%   -0.03%     
==========================================
  Files          83       83              
  Lines        2733     2748      +15     
  Branches      763      769       +6     
==========================================
+ Hits         2693     2707      +14     
- Misses         40       41       +1     
Flag Coverage Δ
unittest 98.50% <93.33%> (-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/lowercase.js 98.48% <93.33%> (-1.52%) ⬇️
🚀 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.

@Nightfirecat Nightfirecat force-pushed the feat-check-lowercase-doctype branch from f811d81 to f2e2f6a Compare August 15, 2025 08:28
Copy link
Owner

@yeonjuan yeonjuan left a comment

Choose a reason for hiding this comment

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

@Nightfirecat Thanks LGTM!

@yeonjuan yeonjuan merged commit b6c3c51 into yeonjuan:main Aug 17, 2025
3 checks passed
@Nightfirecat Nightfirecat deleted the feat-check-lowercase-doctype branch August 17, 2025 13:46
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.

[BUG] lowercase rule does not check for lowercased doctype

2 participants