Skip to content
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

Lint for reserved HTML classes #1823

Merged
merged 5 commits into from
Feb 22, 2023
Merged

Conversation

neall
Copy link
Contributor

@neall neall commented Feb 10, 2023

Description

This linter checks for HTML classes that we consider "internal" to Primer ViewComponents.

Integration

Does this change require any updates to code in production?

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews

@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2023

🦋 Changeset detected

Latest commit: b9ed9a1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/view-components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@neall neall temporarily deployed to review-pr-1823 February 10, 2023 16:14 — with GitHub Actions Inactive
@neall neall temporarily deployed to github-pages February 10, 2023 16:19 — with GitHub Actions Inactive
@neall neall force-pushed the neall/lint-for-reserved-html-classes branch from 281d8d6 to 3c85f8a Compare February 10, 2023 18:46
@neall neall force-pushed the neall/lint-for-reserved-html-classes branch from 3c85f8a to a8f50e8 Compare February 10, 2023 18:50
@neall neall temporarily deployed to github-pages February 10, 2023 18:55 — with GitHub Actions Inactive
In order to preserve our ability to add, remove, and change styles for
the HTML classes we create for Primer ViewComponents, this linter will
complain if it sees those classes being used in ERB templates.
The `DisallowViewComponentHtmlClasses` linter will scan ERB files for
use of classes that we want to reserve for internal use by Primer
ViewComponents. This commit augments the `export-css-selectors` script
to also generate a list of such classes that we want to restrict. Those
classes are written out to `static/classes.json` and read into a
constant when the linter is loaded.

The script will also add classes to the individual `*.css.json` files
that live alongside our CSS files for test purposes. Most of these json
files are not committed.
BaseLinter already has class checking and exception count functionality.

We did have to modify BaseLinter to allow an empty `TAGS` array
constant, thereby checking all tags.
`DisallowComponentCssCounter` hints at the purpose of this linter better
than `ViewComponentHtmlClassesCounter`.
Copy link
Contributor

@camertron camertron left a comment

Choose a reason for hiding this comment

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

🎉

@lesliecdubs
Copy link
Member

@neall is this one ready to go out? 🚀

@neall neall merged commit 5eadffd into main Feb 22, 2023
@neall neall deleted the neall/lint-for-reserved-html-classes branch February 22, 2023 20:09
@primer-css primer-css mentioned this pull request Feb 22, 2023
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.

4 participants