-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from shopsmart/eslint
Eslint
- Loading branch information
Showing
15 changed files
with
303 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module BdLint | ||
VERSION = "0.4.1".freeze | ||
VERSION = "0.5.0".freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
Description: | ||
Adds jscs, rubocop, and scss-lint config files to your rails app | ||
Adds eslint, jscs, rubocop, and scss-lint config files to your rails app | ||
|
||
Example: | ||
rails generate lint_configs | ||
|
||
This will create: | ||
.eslintrc.js | ||
.jscsrc | ||
.rubocop.yml | ||
.scss-lint.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = { | ||
'env': { | ||
'browser': true, | ||
'es6': true, | ||
'jasmine': true, | ||
'jest': true | ||
}, | ||
'extends': [ | ||
'airbnb-base', | ||
'plugin:vue/recommended' // Add ability to parse Vue files | ||
], | ||
'globals': { | ||
'Atomics': 'readonly', | ||
'SharedArrayBuffer': 'readonly' | ||
}, | ||
'parserOptions': { | ||
'ecmaVersion': 2018, | ||
'sourceType': 'module' | ||
}, | ||
'plugins': [ | ||
'vue' // if you want to add vue support | ||
], | ||
'rules': { | ||
'vue/max-attributes-per-line': 'off' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
require "pre-commit/error_list" | ||
require "pre-commit/checks/plugin" | ||
require "pre-commit/configuration/top_level" | ||
require "pre-commit/checks/shell" | ||
require "mkmf" | ||
require "find" | ||
|
||
module PreCommit | ||
module Checks | ||
class Eslint < Shell | ||
include PreCommit::Configuration::TopLevel | ||
|
||
def self.description | ||
'Support for eslint linting' | ||
end | ||
|
||
def call(staged_files) | ||
return 'ESLint executable could not be located' if eslint_source.nil? | ||
# Check for .js files in the Webpack Pipeline | ||
staged_files = staged_files.grep(/^((?!\/javascripts\/).)+\.(js|vue)$/) | ||
return if staged_files.empty? | ||
result = in_groups(staged_files).map do |files| | ||
run_check(files) | ||
end.compact | ||
|
||
result.empty? ? nil : result.join("\n") | ||
end | ||
|
||
def run_check(files) | ||
args = [eslint_source] + config_file_flag + files | ||
execute(args) | ||
end | ||
|
||
def config_file_flag | ||
config_file ? ['-c', config_file] : [] | ||
end | ||
|
||
def alternate_config_file | ||
'.eslintrc.js' | ||
end | ||
|
||
def node_modules_bin | ||
@node_modules_bin ||= File.join(self.top_level, 'node_modules', '.bin') | ||
end | ||
|
||
# First look for eslint in the top_level | ||
def app_source | ||
@app_source ||= begin | ||
return unless File.directory?(node_modules_bin) | ||
Find.find(node_modules_bin) { |path| @app_source = path if path =~ /eslint$/ } | ||
end | ||
end | ||
|
||
# If eslint is not in the top_level see if its defined within the system | ||
def sys_source | ||
@sys_source ||= MakeMakefile.find_executable('eslint') | ||
end | ||
|
||
def eslint_source | ||
app_source || sys_source | ||
end | ||
end | ||
end | ||
end | ||
|
||
# Pevents MakeMakefile from generating log file | ||
module Logging | ||
@logfile = File::NULL | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.