Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Add ability to run summaries #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

raulpopadineti
Copy link

This PR adds the ability to run a summary on all javascript files from the project and display the number of warnings either grouped by filename or by warning (type).

I've also included a summary per file where you can see the number of warnings you have on a certain JS/JSX.

It's a very similar output to what Rubocop does with the offenses formatter (http://rubocop.readthedocs.io/en/latest/formatters/#offense-count-formatter).

I think it's a good way of having a glimpse on what to focus on first, when getting your hands on a bigger project.

Here are a few sample outputs of the commands:

Full summary examples (by filename and warning)

$ rake eslint:summary[filename]
517       app/assets/javascripts/lib/rollbar.js
177       app/assets/javascripts/lib/nprogress.js
6         app/assets/javascripts/homepage.js
6         app/assets/javascripts/card_form.js
6         app/assets/javascripts/application.js
6         app/assets/javascripts/board.js
6         app/assets/javascripts/test_bundle.js
--
724 warning(s) found.
$ rake eslint:summary[warning]
121       VariableDeclarator/space-infix-ops
108       Punctuator/comma-spacing
69        Literal/quotes
54        Identifier/no-shadow
45        ReturnStatement/semi-spacing
44        Identifier/no-undef
35        VariableDeclaration/semi
31        VariableDeclarator/no-underscore-dangle
25        IfStatement/curly
23        Identifier/no-use-before-define
22        Program/no-trailing-spaces
19        SequenceExpression/no-sequences
19        ExpressionStatement/no-unused-expressions
13        BinaryExpression/eqeqeq
9         ObjectExpression/key-spacing
8         BinaryExpression/yoda
8         BinaryExpression/space-infix-ops
7         Program/no-empty-class
7         Program/no-extra-strict
7         Punctuator/no-multi-spaces
7         Program/no-empty-label
7         Program/space-return-throw-case
7         Program/no-wrap-func
7         Program/global-strict
5         CatchClause/no-catch-shadow
3         ExpressionStatement/strict
2         ExpressionStatement/semi
2         Identifier/no-unused-vars
2         NewExpression/new-parens
2         NewExpression/new-cap
2         BlockStatement/no-empty
1         EmptyStatement/no-extra-semi
1         MemberExpression/no-console
1         FunctionExpression/consistent-return
1         ForStatement/no-cond-assign
--
724 warning(s) found.

File summary (by default for application.js)

$ rake eslint:file_summary
1         Program/no-empty-class
1         Program/no-empty-label
1         Program/no-extra-strict
1         Program/no-wrap-func
1         Program/global-strict
1         Program/space-return-throw-case
--
6 warning(s) found.

@raulpopadineti
Copy link
Author

@jonkessler can you have a look at this and let me know if it needs anything else?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant