-
Notifications
You must be signed in to change notification settings - Fork 39
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
[WIP] Linters - eslint, jscs, jshint & scss #221
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c1966dd
Linter::ESLint
himdel 53e39bf
Linter::SCSS
himdel 37e690f
Enable the new linters (eslint, scss)
himdel f16e125
Add scss_lint gem, eslint as a npm package
himdel b231b12
gitignore node_modules
himdel 742517f
Linter::Base - separate output parsing into parse_output and convert_…
himdel 156d756
Linter::ESLint & Linter::SCSS - add convert_parsed
himdel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,5 @@ | |
/repos | ||
|
||
/Gemfile.lock | ||
|
||
/node_modules |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module Linter | ||
class ESLint < Base | ||
private | ||
|
||
def config_files | ||
[".eslintrc.js", ".eslintrc.json"] | ||
end | ||
|
||
def linter_executable | ||
'eslint .' | ||
end | ||
|
||
def options | ||
{:format => 'json'} | ||
end | ||
|
||
def filtered_files(files) | ||
files.select do |file| | ||
file.end_with? '.js' | ||
end | ||
end | ||
|
||
def convert_parsed(array) | ||
files = array.map { |f| convert_file(f) } | ||
|
||
{:files => files, | ||
:summary => {:offense_count => files.reduce(0) { |memo, f| memo + f.offenses.count }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe |
||
:target_file_count => files.count}} | ||
end | ||
|
||
def convert_file(file) | ||
{:path => file[:filePath], | ||
:offenses => file[:messages].map { |m| convert_offense(m) }} | ||
end | ||
|
||
SEVERITY = ['off', 'warning', 'error'] | ||
def convert_offense(offense) | ||
{:severity => SEVERITY[offense[:severity]], | ||
:message => offense[:message], | ||
:location => {:line => offense[:line], | ||
:column => offense[:column]}, | ||
:cop_name => offense[:ruleId]} | ||
end | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module Linter | ||
class SCSS < Base | ||
private | ||
|
||
def config_files | ||
[".scss-lint.yml"] | ||
end | ||
|
||
def linter_executable | ||
'scss-lint' | ||
end | ||
|
||
def options | ||
{:format => 'JSON'} | ||
end | ||
|
||
def filtered_files(files) | ||
files.select { |file| file.end_with?(".scss") } | ||
end | ||
|
||
def convert_parsed(hash) | ||
files = hash.map { |path, offenses| convert_file(path, offenses) } | ||
|
||
{:files => files, | ||
:summary => {:offense_count => files.reduce(0) { |memo, f| memo + f.offenses.count }, | ||
:target_file_count => files.count}} | ||
end | ||
|
||
def convert_file(path, offenses) | ||
{:path => path, | ||
:offenses => offenses.map { |o| convert_offense(o) }} | ||
end | ||
|
||
def convert_offense(offense) | ||
{:severity => offense[:severity], | ||
:message => offense[:reason], | ||
:location => {:line => offense[:line], | ||
:column => offense[:column]}, | ||
:cop_name => offense[:linter]} | ||
end | ||
end | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"dependencies": { | ||
"eslint": "^3.13.1", | ||
"eslint-cli": "^1.1.0" | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment typo
overriden
->overridden