Shopify / erb_lint

Lint your ERB or HTML files
MIT License
680 stars 122 forks source link

Exception occurred when processing #354

Open AndrewKrasnoff opened 5 months ago

AndrewKrasnoff commented 5 months ago

Hello. I have this error for all my erb files in project

Exception occurred when processing: app/views/shared/_header.html.erb
If this file cannot be processed by erb-lint, you can exclude it in your configuration file.
No such file or directory @ rb_sysopen - /home/andrew/MyApps/vhospital/.better-html.yml
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/file_loader.rb:26:in `read'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/file_loader.rb:26:in `read_content'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/file_loader.rb:14:in `yaml'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/linters/erb_safety.rb:58:in `better_html_config'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/linters/erb_safety.rb:48:in `block in testers_for'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/linters/erb_safety.rb:47:in `map'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/linters/erb_safety.rb:47:in `testers_for'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/linters/erb_safety.rb:24:in `run'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/linter.rb:59:in `run_and_update_offense_status'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/runner.rb:28:in `block in run'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/runner.rb:27:in `each'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/runner.rb:27:in `run'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/cli.rb:161:in `block in run_with_corrections'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/cli.rb:159:in `times'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/cli.rb:159:in `run_with_corrections'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/cli.rb:130:in `run_on_file'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/cli.rb:86:in `block in run'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/cli.rb:83:in `each'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/lib/erb_lint/cli.rb:83:in `run'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/erb_lint-0.5.0/exe/erblint:9:in `<top (required)>'
/home/andrew/.rbenv/versions/3.2.4/bin/erblint:25:in `load'
/home/andrew/.rbenv/versions/3.2.4/bin/erblint:25:in `<top (required)>'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bundler-2.3.5/lib/bundler/cli/exec.rb:58:in `load'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bundler-2.3.5/lib/bundler/cli/exec.rb:58:in `kernel_load'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bundler-2.3.5/lib/bundler/cli/exec.rb:23:in `run'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bundler-2.3.5/lib/bundler/cli.rb:484:in `exec'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bundler-2.3.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bundler-2.3.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bundler-2.3.5/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bundler-2.3.5/lib/bundler/cli.rb:31:in `dispatch'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bundler-2.3.5/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bundler-2.3.5/lib/bundler/cli.rb:25:in `start'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bundler-2.3.5/exe/bundle:48:in `block in <top (required)>'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bundler-2.3.5/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
/home/andrew/.rbenv/versions/3.2.4/lib/ruby/gems/3.2.0/gems/bundler-2.3.5/exe/bundle:36:in `<top (required)>'
/home/andrew/.rbenv/versions/3.2.4/bin/bundle:25:in `load'
/home/andrew/.rbenv/versions/3.2.4/bin/bundle:25:in `<main>'

.erb-lint.yml

---
EnableDefaultLinters: true
linters:
  ErbSafety:
    enabled: true
    better_html_config: .better-html.yml
  Rubocop:
    enabled: true
    rubocop_config:
      inherit_from:
        - .rubocop.yml

rubocop 1.64

What is wrong in my config?

KarimElsayad247 commented 1 month ago

you don't have a .better_html config file. You either need to create it, or remove better_html_config: .better-html.yml entirely from your .erb_lint.yml

I fell into the same trap: copied the example config file and tried to run it. they should really point this out in the readme

etiennebarrie commented 1 month ago

Please PR an update to the README 🙏