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

Unrelated error is thrown in the event of a syntax error #304

Closed
dmabuada opened this issue Feb 3, 2023 · 0 comments · Fixed by #305
Closed

Unrelated error is thrown in the event of a syntax error #304

dmabuada opened this issue Feb 3, 2023 · 0 comments · Fixed by #305

Comments

@dmabuada
Copy link

dmabuada commented Feb 3, 2023

Excerpt of an erb-lint yml file:

glob: "**/*{.html,*}[!.atom,!.text,!.js,!.svg].erb"
linters:
  FinalNewline:
    enabled: false
  SpaceAroundErbTag:
    enabled: false
  RightTrim:
    enabled: false
  AllowedScriptType:
    enabled: true
    allowed_types:
      - 'application/ld+json'
      - 'application/json'
      - 'text/javascript'
      - 'text/html'....

Now if I remove one of the hyphens in allowed_types:

glob: "**/*{.html,*}[!.atom,!.text,!.js,!.svg].erb"
linters:
  FinalNewline:
    enabled: false
  SpaceAroundErbTag:
    enabled: false
  RightTrim:
    enabled: false
  AllowedScriptType:
    enabled: true
    allowed_types:
      'application/ld+json'
      - 'application/json'
      - 'text/javascript'
      - 'text/html'....

And then run autocorrect on a file, it raises a NoMethodError:

@dmabuada ➜ /workspaces/github $ bin/erblint --enable-linters rubocop --autocorrect app/views/index.erb

NoMethodError: undefined method `merge!' for nil:NilClass
/workspaces/github/vendor/gems/3.2.0/ruby/3.2.0/gems/erb_lint-0.3.0/lib/erb_lint/cli.rb:224:in `ensure in load_config'
/workspaces/github/vendor/gems/3.2.0/ruby/3.2.0/gems/erb_lint-0.3.0/lib/erb_lint/cli.rb:224:in `load_config'
/workspaces/github/vendor/gems/3.2.0/ruby/3.2.0/gems/erb_lint-0.3.0/lib/erb_lint/cli.rb:40:in `run'
/workspaces/github/vendor/gems/3.2.0/ruby/3.2.0/gems/erb_lint-0.3.0/exe/erblint:9:in `<main>'
/workspaces/github/vendor/gems/3.2.0/ruby/3.2.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load'
/workspaces/github/vendor/gems/3.2.0/ruby/3.2.0/gems/bootsnap-1.9.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load'
bin/erblint:8:in `<main>'

It should probably be raising a SyntaxError instead.

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 a pull request may close this issue.

1 participant