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

Linter for single/double quotes of html attribute values #259

Open
toy opened this issue Jun 17, 2022 · 3 comments
Open

Linter for single/double quotes of html attribute values #259

toy opened this issue Jun 17, 2022 · 3 comments

Comments

@toy
Copy link

toy commented Jun 17, 2022

While both single and double quotes are allowed for attribute values, it would be helpful for common style to have linter to force using only one of those.

<div class="something" data-foo='bar'>
</div>
@camertron
Copy link

You should be able to use Rubocop's rules for this:

linters:
  Rubocop:
    enabled: true
    rubocop_config:
      AllCops:
        Enabled: false
      Style/StringLiterals:
        Enabled: true
        EnforcedStyle: double_quotes # or single_quotes

@toy toy changed the title Linter for single/double quotes Linter for html attributes single/double quotes Jul 4, 2022
@toy toy changed the title Linter for html attributes single/double quotes Linter for single/double quotes of html attribute values Jul 4, 2022
@toy
Copy link
Author

toy commented Jul 4, 2022

Issue is not about ruby quotes, but about html attribute value quotes, I've clarified title and added example.

@toy toy reopened this Jul 4, 2022
@owaiswiz
Copy link

owaiswiz commented Dec 23, 2023

I wrote a custom linter for this which can be used to enforce a quote style for HTML attributes (w/ auto-correction): https://owaiskhan.me/post/enforce-quote-style-html-attributes-erb-lint

I can open a PR if there's interest to upstream this.

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

No branches or pull requests

4 participants