Skip to content

Add rubocop to Rails template #264

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

Open
wants to merge 1 commit into
base: edge
Choose a base branch
from
Open

Conversation

m-o-e
Copy link
Member

@m-o-e m-o-e commented Oct 5, 2019

Update:
Oops! Sorry, please don't merge (yet).

I just noticed that our opal-dep unfortunately blocks
the latest version of rubocop from getting installed:

Bundler could not find compatible versions for gem "parser":
  In snapshot (Gemfile.lock):
    parser (= 2.3.3.1)

  In Gemfile:
    rails-hyperstack (~> 1.0.alpha1.0) was resolved to 1.0.alpha1.5, which depends on
      opal-browser (~> 0.2.0) was resolved to 0.2.0, which depends on
        opal was resolved to 0.11.4, which depends on
          parser (= 2.3.3.1)

    rubocop (>= 0.67.2) was resolved to 0.68.1, which depends on
      parser (>= 2.5, != 2.5.1.1)

I still think that adding rubocop would be a good idea,
but this PR should not be merged until our opal dependency
has been updated to >= 1.0.0 (which should resolve the conflict).

Sorry for spotting this problem late (after the PR was already up).
In my testing it worked as intended because I have a recent version
of rubocop installed globally (outside the bundle). But this can obv
not be relied on in the installer that is shipped to users.


This gives users who start with the rails template
a lint-clean installation and a safe .rubocop.yml.

You can try it out by running:

rails new MyApp -T -m https://raw.githubusercontent.com/m-o-e/hyperstack/8cfe59b4df54b9b947f45ba204b9342da623daae/install/rails-webpacker.rb

This will:

  • Perform the regular Hyperstack install
  • Run rubocop -a to auto-fix the (minor) linter-complaints that the default install comes with
  • Leave you with a lint-clean MyApp and a safe .rubocop.yml that disables all rules that can break Hyperstack, plus tweaks some to allow for Hyperstacky syntax (e.g. multi-line blocks with { })

It does in no way enforce the use of rubocop in the new project
but provides a safe starting point to users who want to use it.

I believe this is important because the rubocop defaults (without a .rubocop.yml)
are not safe for Hyperstack. As of today, when you run rubocop -a on a vanilla
Hyperstack project without this config then it will almost certainly break.

@m-o-e m-o-e added the discussion needs on going discussion before resolving what kind of problem it is, and what to do with it. label Oct 5, 2019
@catmando
Copy link
Contributor

I agree with this 100%. I use rubocop with a custom set of rules no problem. Not sure what the issue is you r referring to

@m-o-e
Copy link
Member Author

m-o-e commented Oct 11, 2019

Not sure what the issue is you r referring to

Sorry, should've clarified: The latest version of rubocop that our opal dep allows
to be installed only supports Ruby up to version 2.4. I don't think we should ship it that way,
that's why I set the PR "on hold". ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion needs on going discussion before resolving what kind of problem it is, and what to do with it.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants