Skip to content

Commit

Permalink
Add formatter option, switch default formatter
Browse files Browse the repository at this point in the history
We are now using eslint-friendly-formatter as the default, which gives
a small visual representation of where in your code the actual linting
error is. You can override it by following the directions in README.
  • Loading branch information
Evan Jacobs committed Mar 2, 2016
1 parent 1ee09bc commit d7c11a1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,29 @@ browserify your_file.js -t [ eslintify --extension html --extension haml ]

via JS
```js
.transform({ extensions: ['html', 'haml'] }, eslintify)
.transform({extensions: ['html', 'haml']}, eslintify)
```

### other result formatters

Starting with eslintify 2.0, the default formatter is [royriojas/eslint-friendly-formatter](https://github.com/royriojas/eslint-friendly-formatter). You can opt to switch it out for your own choice by providing one of the [eslint official formatter names](http://eslint.org/docs/developer-guide/nodejs-api#getformatter) or a path to a requireable node module.

via CLI
```bash
browserify your_file.js -t [ eslintify --formatter json ]
```

via JS
```js
.transform({formatter: 'json'}, eslintify)
```

custom formatter via CLI
```bash
browserify your_file.js -t [ eslintify --formatter ./node_modules/eslint-path-formatter ]
```

custom formatter via JS
```bash
.transform({formatter: './node_modules/eslint-path-formatter'}, eslintify)
```
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ var through = require('through');
var error = console.error.bind(console);

function lint(file, options) {
var cli = new eslint.CLIEngine(options || {});
var formatter = cli.getFormatter();
options = options || {};

var cli = new eslint.CLIEngine(options);
var formatter = cli.getFormatter(options.formatter || __dirname + '/node_modules/eslint-friendly-formatter');
var data = '';

function write(buf) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"bugs": "https://github.com/yaycmyk/eslintify/issues",
"dependencies": {
"eslint": "^1.0.0",
"eslint-friendly-formatter": "^1.2.2",
"through": "^2.0.0"
},
"keywords": [
Expand Down

0 comments on commit d7c11a1

Please sign in to comment.