Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwaterston committed Apr 13, 2015
0 parents commit 2fb8907
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is for unifying the coding style for different editors and IDEs
# http://EditorConfig.org

root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4

[*.{js,json}]
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
67 changes: 67 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
// How to read the config:
//
// * 0 - rule is disabled.
// * 1 - rule is enabled but warnings will not affect the ESLint exit code.
// * 2 - rule is enabled and warnings will result in a non-zero ESLint exit code.
//
// These rules are compatible with ESLint version 0.16.0 and up.
// Detailed info about each of these rules can be found at http://eslint.org/docs/rules.

"env": {
"node": true
},
"rules": {
"block-scoped-var": 2,
"brace-style": [2, "1tbs", {"allowSingleLine": false}],
"comma-style": [2, "last"],
"consistent-return": 2,
"consistent-this": [0, "self"],
"default-case": 2,
"func-style": [2, "expression"],
"guard-for-in": 2,
"indent": [2, 4, {indentSwitchCase: true}],
"max-len": [2, 150],
"max-nested-callbacks": [2, 3],
"max-statements": [2, 40],
"no-array-constructor": 2,
"no-console": 2,
"no-constant-condition": 2,
"no-div-regex": 2,
"no-else-return": 2,
"no-eq-null": 2,
"no-floating-decimal": 2,
"no-inline-comments": 2,
"no-lonely-if": 2,
"no-multiple-empty-lines": [2, {"max": 3}],
"no-nested-ternary": 2,
"no-process-env": 2,
"no-reserved-keys": 2,
"no-return-assign": 2,
"no-self-compare": 2,
"no-shadow": 0,
"no-sync": 2,
"no-undefined": 2,
"no-void": 2,
"no-warning-comments": [2, { "terms": ["todo", "note", "fixme", "changes", "future"], "location": "start" }],
"operator-assignment": [2, "always"],
"quote-props": [2, "as-needed"],
"quotes": [2, "single"],
"radix": 2,
"semi": [2, "always"],
"sort-vars": [2, { "ignoreCase": false }],
"space-after-function-name": [2, "never"],
"space-after-keywords": [2, "always", {"checkFunctionKeyword": false}],
"space-before-blocks": [2, "always"],
"space-in-brackets": [2, "never"],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-return-throw-case": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-line-comment": [2, "always"],
"strict": [2, "global"],
"vars-on-top": 2,
"wrap-iife": [2, "outside"],
"wrap-regex": 2
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules/

.DS_Store
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [1.0.0] - 2015-04-13

### Added
- Initial release.
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 David Waterston

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

95 changes: 95 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
##A minimal [ESLint](http://eslint.org) custom formatter (reporter) that displays one summary line for all files processed.

<a href="http://semver.org" target="_blank" alt="Semantic Versioning"><img src="https://img.shields.io/badge/semver-1.0.0-lightgrey.svg"></a>
<a href="https://github.com/davidwaterston/eslint-summary/blob/master/LICENSE" target="_blank" alt="MIT License"><img src="http://img.shields.io/badge/license-MIT-blue.svg"></a>
<a href="https://david-dm.org/davidwaterston/eslint-summary" target="_blank" alt="Dependencies"><img src="https://david-dm.org/davidwaterston/eslint-summary.svg"></a>
<a href="#verifying-releases" alt="Releases signed with Gnu Privacy Guard"><img src="https://img.shields.io/badge/gpg-signed-green.svg"></a>
<a href="https://gitter.im/davidwaterston/eslint-summary" target="_blank" alt="Join the chat at https://gitter.im/davidwaterston/eslint-summary"><img src="https://badges.gitter.im/Join%20Chat.svg"></a>

A minimal [ESLint](http://eslint.org) custom formatter (reporter) that displays one summary line for all files processed. The summary line shows the number of files processed, the number of files passed linting (no errors or warnings) and the number of warning and/or errors (if there were any). Use this formatter when you simply want to verify the overall lint status of your project on Git pre-push, etc.


## Install

```sh
$ npm install --save-dev eslint-summary
```


## Getting started

Use it with:

#### [ESLint CLI](http://eslint.org/docs/user-guide/command-line-interface)

```sh
$ eslint --format node_modules/eslint-summary/summary.js *.js
```

#### [grunt-eslint](https://github.com/sindresorhus/grunt-eslint/)

```js
grunt.initConfig({
eslint: {
options: {
format: require('eslint-summary')
},
target: ['*.js']
}
});

grunt.loadNpmTasks('grunt-eslint');
grunt.registerTask('default', ['eslint']);
```


## Compatibility
This extension has been tested and confirmed to work with ESLint versions 0.18.0 and later.


## Example output
<img src="https://dvolvr.files.wordpress.com/2015/04/eslint-summary.png" width="800" alt="ESLint-Summary in action" />


## Release History
See the [change log](https://github.com/davidwaterston/eslint-summary/blob/master/CHANGELOG.md) file for more details.


## Verifying Releases
I use <a href="http://semver.org" target="_blank" alt="Semantic Versioning">Semantic Versioning</a> to number releases. Each release is tagged with the appropriate version number and signed using <a href="https://www.gnupg.org" target="_blank" alt="Gnu Privacy Guard (GPG)">Gnu Privacy Guard (GPG)</a>. The public key used to sign releases is
```
Name: David Waterston
Email: david@davidwaterston.com
Key ID: A7AD9C85
Signature: 71A9 DC13 447A 1E4F C6EB 5D64 DE08 A991 A7AD 9C85
```
This public key is included in the repository with a SHA1 of 16d013451476fa4a1a67d6ad4b90583e205b53b1.
After cloning the repo, and assuming you have GPG installed correctly, you can import this key into your keychain
```
git cat-file blob pubkey | gpg --import
```
When this public key is successfully imported, you can use it to verify the integrity of any of the tagged releases of this repo
```
git tag -v v1.0.0
```
which should produce output similar to:
```
object 04f37a55784c1f3abc2cf927a935a488aa954035
type commit
tag v1.0.0
tagger David Waterston <david@davidwaterston.com> 1427387056 +0000
Initial commit
This is just an example so don't get fixated on the details, what matters is the signature!
gpg: Signature made Thu 26 Mar 16:24:16 2015 GMT using RSA key ID A7AD9C85
gpg: Good signature from "David Waterston <david@davidwaterston.com>" [ultimate]
```
The important thing to notice here is that the RSA key ID matches mine (A7AD9C85) and the line that says that this is a good signature.

The public key can further be verified by checking the details held on <a href="http://pgp.mit.edu/pks/lookup?search=david%40davidwaterston.com&op=index&fingerprint=on&exact=on" target="_blank" alt="pgp.mit.edu">pgp.mit.edu</a>.


## License
Copyright (c) 2015 David Waterston. All rights reserved.
Distributed under an MIT license. See the [LICENSE](https://github.com/davidwaterston/eslint-summary/blob/master/LICENSE) file for more details.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('path').join(__dirname, 'summary.js');
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "eslint-summary",
"version": "1.0.0",
"description": "Minimal ESLint formatter (reporter) that displays only one summary line.",
"keywords": [
"eslint",
"formatter",
"reporter",
"lint",
"validate"
],
"license": "MIT",
"author": {
"name": "David Waterston",
"email": "david@davidwaterston.com",
"url": "http://dvolvr.davidwaterston.com"
},
"repository" :
{
"type" : "git",
"url" : "https://github.com/davidwaterston/eslint-summary.git"
},
"files": [
"index.js",
"summary.js"
],
"engines": {
"node": ">=0.10.0"
},
"dependencies": {
"chalk": "^1.0.0",
"text-table": "^0.2.0"
}
}
56 changes: 56 additions & 0 deletions summary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict';

var chalk = require('chalk');
var table = require('text-table');

var pluralize = function(word, count) {
var plural = count === 1 ? word : word + 's';
return plural;
};

module.exports = function(results) {

var errorColor = 'red';
var warningColor = 'yellow';

var errorCount = 0;
var fileCount;
var failureCount = 0;
var passCount = 0;
var warningCount = 0;

var summaryLineArray;


results.forEach(function(result) {

var messages = result.messages;

if (messages.length === 0) {
passCount++;
} else {
failureCount++;
warningCount += result.warningCount;
errorCount += result.errorCount;
}

});

fileCount = passCount + failureCount;

summaryLineArray = [
chalk.bold(fileCount + ' ' + pluralize('file', fileCount) + ' checked.'),
chalk.bold(passCount + ' passed.'),
chalk.bold(failureCount + ' failed.')
];

if (warningCount || errorCount) {
summaryLineArray.push(chalk[warningColor].bold(warningCount + ' ' + pluralize('warning', warningCount) + '.'));
summaryLineArray.push(chalk[errorColor].bold(errorCount + ' ' + pluralize('error', errorCount) + '.'));
}

return '\n'
+ table([summaryLineArray])
+ '\n';

};

0 comments on commit 2fb8907

Please sign in to comment.