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

ESlint and Stylelintrc generators #2

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ Or install it yourself as:

```sh
rails generate auxiliary_rails:install_errors
rails generate auxiliary_rails:install_eslint
rails generate auxiliary_rails:install_rubocop
rails generate auxiliary_rails:install_rubocop --no-specify-gems
rails generate auxiliary_rails:install_stylelint
```

### View Helpers
Expand Down
32 changes: 32 additions & 0 deletions lib/generators/auxiliary_rails/install_eslint_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'rails'

module AuxiliaryRails
class InstallEslintGenerator < ::Rails::Generators::Base
PACKAGES = %w[
eslint
eslint-config-standard
eslint-plugin-standard
eslint-plugin-promise
eslint-plugin-import
eslint-plugin-node
].freeze

source_root File.expand_path('templates/eslint', __dir__)

def copy_config_files
copy_file 'eslintrc_template.yml',
'.eslintrc.yml'
end

def install_elint_packages
run 'yarn add -D ' + PACKAGES.join(' ')
end

def show_instructions
say %(
Run `eslint` using this command:
=> yarn run eslint --ext .js app/assets/javascripts
)
end
end
end
28 changes: 28 additions & 0 deletions lib/generators/auxiliary_rails/install_stylelint_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'rails'

module AuxiliaryRails
class InstallStylelintGenerator < ::Rails::Generators::Base
PACKAGES = %w[
stylelint
stylelint-config-standard
].freeze

source_root File.expand_path('templates/stylelint', __dir__)

def copy_config_files
copy_file 'stylelintrc_template.yml',
'.stylelintrc.yml'
end

def install_stylelint_packages
run 'yarn add -D ' + PACKAGES.join(' ')
end

def show_instructions
say %(
Run `stylelint` using this command:
=> yarn run stylelint app/assets/stylesheets/
)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
env:
browser: true
es6: true
extends: standard
globals:
$: readonly
Atomics: readonly
SharedArrayBuffer: readonly
parserOptions:
ecmaVersion: 2018
rules:
semi: [2, 'always']
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends: stylelint-config-standard