-
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
Conversation
related to issue ManageIQ/manageiq#2389 |
You may also need to deal with this...perhaps not this PR, but... miq_bot/app/workers/commit_monitor_handlers/commit_range/rubocop_checker/message_builder.rb Line 45 in a056a9b
|
@himdel Is this good to go? Or is there more stuff to be done? |
@Fryguy this it's really missing only 2 things now.. a) verify that all the linter's JSON output formats are compatible enough b) cache node_modules - in the end I think the fastest solution is to shasum package.json and .. essentially set |
<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush. |
@himdel please rebase and push again |
…parsed ..so that these can be overriden in linters that have special parsing/running needs the default `parse_output` is the original JSON.parse + exceptions and could be overriden for linters that don't output JSON the default `convert_parsed` is an identity function, but is needed by eslint & scss to convert between the different JSON formats
converting from each format to the one used by rubocop eslint output: ``` [ { filePath: "foo/bar", messages: [ { ruleId: "baz", severity: 1, message: "quux", line: 4, column: 5, }, ], }, ] ``` scss output: ``` { "foo/bar": [ { line: 4, column: 5, severity: "warning", reason: "quux", linter: "baz", }, ], } ``` converted output: ``` { files: [ { path: "foo/bar", offenses: [ { severity: "warning", message: "quux", location: { line: 4, column: 5, }, cop_name: "baz", }, ], }, ], summary: { target_file_count: 1, offense_count: 1, }, } ```
Checked commits https://github.com/himdel/miq_bot/compare/c1966dde3a5e20dcccb836c123a7ff05ddb95a4b~...156d75696f87554809da6d49aad24493230a7712 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 Gemfile
lib/linter/base.rb
lib/linter/eslint.rb
lib/linter/scss.rb
|
end | ||
end | ||
|
||
# overriden in linters with different JSON format |
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
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I believe files.reduce(0) { |memo, f| memo + f.offenses.count }
can be simplified to files.map { |f| f.offenses.count }.reduce(:+)
This pull request is not mergeable. Please rebase and repush. |
#406 will likely supercede this |
Or #500 will :) |
going to close this in favor of Pronto work as it's being revived. |
@NickLaMuro for eslint, we need the following npm packages:
You can assume current versions, I'll be updating them on ui-classic side soon. (=> ManageIQ/manageiq-ui-classic#7423) I guess it makes sense to just copy those dependencies to manageiq-style, and update both places. One more catch .. the |
Turns out it is probably for the best that we aren't using https://github.com/zendesk/eslintrb/tree/master/vendor [ref] And probably doesn't have all of the plugins you want. That said, the list of plugins is going to be a bit of a nightmare to source consistently, so we might want to consider vendoring them into this repo to avoid inconsistencies. This would mean that when run via a potential future "cli client", there is no concern about potentially getting the wrong dependencies. Alternatively, we could consider creating a stand-alone repo for doing just that, and it can also have a |
Oh, well, a CLI client would be great for miq-bot development, but that may just be complicating matters now. What about something as simple as having a manageiq-style package.json with the dependencies (and possibly a .nvmrc with a node version), and a base .eslintrc.json to apply when no root eslintrc.json is present. The primary goal is to get this running on the bot, and it can just be statically installed there. |
In fact, I'd propose this directory structure, if doable...
That way, |
(and since |
This adds two more linters to miq-bot - eslint (for javascript) and scss-lint (for sass/scss).
Their JSON output has a different structure, so this also adds a
convert_parsed
method to Linter::Base, and overrides to convert to the rubocop format:eslint output:
scss output:
converted output:
TODO: