-
Notifications
You must be signed in to change notification settings - Fork 121
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
Rules breaking the code in .erb files #222
Comments
Related to #189 |
In addition, it's also a good idea to disable these cops: # Enabling this adds a frozen string literal magic comment to every block.
Style/FrozenStringLiteralComment:
Enabled: false
# erb_lint reports errors with this cop.
Style/MultilineTernaryOperator:
Enabled: false
# False flags for view files. ViewComponents should never see this, though, as they should never need to assign in a view.
Lint/UselessAssignment:
Exclude:
- "app/views/**/*"
# Empty blocks have utility in views, e.g. for resetting content_for and
# rendering slots without args.
Lint/EmptyBlock:
Enabled: false |
I think it makes sense to have these cops (besides maybe the |
Configure the [erb_lint][] utility to apply our `standard`-backed RuboCop linting tool to our application's `.erb` files. The initial `.erb-lint.yml` file is configured according to the gem's [README.md][]. Additionally, there are some key RuboCop rules that we're disabling [according to some feedback from the community of `erb_lint` users][issue]. The Rails tasks defined in `lib/tasks/erblint.rake` are inspired by those defined in [standard/rake.rb][]. They define the `erblint:autocorrect` and `erblint` tasks to execute the `erblint` command with and without the `--autocorrect` flag. Additional arguments can be passed in with the `ERBLINTOPTS` environment variable. By default, executing `rails standard` will execute `rails erblint`, and `rails standard:fix` will execute `rails erblint:autocorrect`. Also depend on the [erblint-github][] gem to provide additional, accessibility-focused rules for how we statically analyze ERB templates. Finally, the [ERBLint][] tool depends on [BetterHtml][], and claims to execute BetterHtml's [ERBSafety][] test suite. In our experience, this isn't the case, and [requires manual configuration][better_html_tests]. This commit also introduces the `config/better_html.yml` configuration file, and makes sure that `BetterHtml` and `ERBLint` consistently read its contents. [erb_lint]: https://github.com/Shopify/erb-lint [README.md]: https://github.com/Shopify/erb-lint#configuration [standard/rake.rb]: https://github.com/testdouble/standard/blob/main/lib/standard/rake.rb [exe/erblint]: https://github.com/Shopify/erb-lint/blob/main/exe/erblint [issue]: Shopify/erb_lint#222 (comment) [erblint-github]: https://github.com/github/erblint-github [ERBLint]: https://github.com/Shopify/erb-lint [ERBSafety]: https://github.com/Shopify/erb-lint#erbsafety [BetterHtml]: https://github.com/Shopify/better-html [better_html_tests]: https://github.com/Shopify/better-html#testing-for-valid-html-and-erb
Configure the [erb_lint][] utility to apply our `standard`-backed RuboCop linting tool to our application's `.erb` files. The initial `.erb-lint.yml` file is configured according to the gem's [README.md][]. Additionally, there are some key RuboCop rules that we're disabling [according to some feedback from the community of `erb_lint` users][issue]. The Rails tasks defined in `lib/tasks/erblint.rake` are inspired by those defined in [standard/rake.rb][]. They define the `erblint:autocorrect` and `erblint` tasks to execute the `erblint` command with and without the `--autocorrect` flag. Additional arguments can be passed in with the `ERBLINTOPTS` environment variable. By default, executing `rails standard` will execute `rails erblint`, and `rails standard:fix` will execute `rails erblint:autocorrect`. Also depend on the [erblint-github][] gem to provide additional, accessibility-focused rules for how we statically analyze ERB templates. Finally, the [ERBLint][] tool depends on [BetterHtml][], and claims to execute BetterHtml's [ERBSafety][] test suite. In our experience, this isn't the case, and [requires manual configuration][better_html_tests]. This commit also introduces the `config/better_html.yml` configuration file, and makes sure that `BetterHtml` and `ERBLint` consistently read its contents. [erb_lint]: https://github.com/Shopify/erb-lint [README.md]: https://github.com/Shopify/erb-lint#configuration [standard/rake.rb]: https://github.com/testdouble/standard/blob/main/lib/standard/rake.rb [exe/erblint]: https://github.com/Shopify/erb-lint/blob/main/exe/erblint [issue]: Shopify/erb_lint#222 (comment) [erblint-github]: https://github.com/github/erblint-github [ERBLint]: https://github.com/Shopify/erb-lint [ERBSafety]: https://github.com/Shopify/erb-lint#erbsafety [BetterHtml]: https://github.com/Shopify/better-html [better_html_tests]: https://github.com/Shopify/better-html#testing-for-valid-html-and-erb
I'd hazard a guess that ties in with the need for this rule to be disabled: Layout/InitialIndentation:
Enabled: false # This rule removes the "<%" e "<%=" from the code, if enabled. |
Hm, looks like I had that one disabled. Interestingly it was only on this line and one other, both comment lines where the author put a space betwixt the |
I think this gem assumes that every block of Ruby in a
.erb
file is a different Ruby file.In my case, I've explicitly disabled some rules, to make this gem not break my code.
I suggest 3 options for this:
The text was updated successfully, but these errors were encountered: