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

Write test to make sure asset naming matches component #1540

Merged
merged 5 commits into from
Oct 26, 2022

Conversation

jonrohan
Copy link
Member

@jonrohan jonrohan commented Oct 25, 2022

Description

This PR introduces a test to make sure that assets are named to match the component ruby file. This follows convention setup for view components and also allows us to write tests around this convention to match assest with their component.

app/components
  ├── component.rb
  ├── component.pcss
  └── component.html.erb

Integration

Does this change require any updates to code in production?

no

Merge checklist

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

@jonrohan jonrohan requested a review from a team as a code owner October 25, 2022 20:43
@jonrohan jonrohan requested review from a team, langermank and keithamus October 25, 2022 20:43
@changeset-bot
Copy link

changeset-bot bot commented Oct 25, 2022

🦋 Changeset detected

Latest commit: 303617a

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

@jonrohan jonrohan added the skip changeset Pull requests that don't change the library output label Oct 25, 2022
@github-actions github-actions bot added the css Pull requests that update CSS code label Oct 25, 2022
@jonrohan jonrohan temporarily deployed to review-pr-1540 October 25, 2022 20:44 Inactive
@jonrohan jonrohan temporarily deployed to github-pages October 25, 2022 20:50 Inactive
@jonrohan jonrohan temporarily deployed to review-pr-1540 October 25, 2022 23:57 Inactive
@jonrohan jonrohan enabled auto-merge (squash) October 25, 2022 23:59
@jonrohan jonrohan temporarily deployed to github-pages October 26, 2022 00:01 Inactive
@jonrohan jonrohan temporarily deployed to review-pr-1540 October 26, 2022 17:27 Inactive
@jonrohan jonrohan removed the skip changeset Pull requests that don't change the library output label Oct 26, 2022
@jonrohan jonrohan temporarily deployed to github-pages October 26, 2022 17:31 Inactive
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.

Hmm I'm not sure I'm in favor of this change. I learned recently that web components are required to include a hyphen in their names, eg. nav-list instead of navlist. Up until now it hasn't been a problem, but I was bitten last week by banner and flash. Apparently it's common to prefix single-word web component names with x-, so the custom element names are x-banner and x-flash. We have an eslint rule that forces the element name to match the file name, so I had to use x_banner.ts. I really don't want to have to name the component x_banner.rb and x_banner.html.erb too 😓

@jonrohan
Copy link
Member Author

jonrohan commented Oct 26, 2022

Hmm I'm not sure I'm in favor of this change. I learned recently that web components are required to include a hyphen in their names, eg. nav-list instead of navlist. Up until now it hasn't been a problem, but I was bitten last week by banner and flash. Apparently it's common to prefix single-word web component names with x-, so the custom element names are x-banner and x-flash. We have an eslint rule that forces the element name to match the file name, so I had to use x_banner.ts. I really don't want to have to name the component x_banner.rb and x_banner.html.erb too 😓

I can drop the ts file requirement. I do need the CSS files to match so I can build testing around class coverage

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.

Ok I'm cool with that. We might also consider relaxing the eslint rule.

@jonrohan jonrohan merged commit 94c6b7f into main Oct 26, 2022
@jonrohan jonrohan deleted the test_asset_naming branch October 26, 2022 20:29
@primer-css primer-css mentioned this pull request Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css Pull requests that update CSS code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants