Skip to content

Commit

Permalink
Require Node.js 6
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Nov 13, 2018
1 parent 7606f98 commit 3f5cd27
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- '10'
- '8'
- '6'
- '4'
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = results => {
results
.sort((a, b) => a.errorCount - b.errorCount)
.forEach(result => {
const messages = result.messages;
const {messages, filePath} = result;

if (messages.length === 0) {
return;
Expand All @@ -33,8 +33,6 @@ module.exports = results => {
lines.push({type: 'separator'});
}

const filePath = result.filePath;

lines.push({
type: 'header',
filePath,
Expand All @@ -50,14 +48,16 @@ module.exports = results => {
}

return a.line < b.line ? -1 : 1;
} else if ((a.fatal || a.severity === 2) && (!b.fatal || b.severity !== 2)) {
}

if ((a.fatal || a.severity === 2) && (!b.fatal || b.severity !== 2)) {
return 1;
}

return -1;
})
.forEach(x => {
let message = x.message;
let {message} = x;

// Stylize inline code blocks
message = message.replace(/\B`(.*?)`\B|\B'(.*?)'\B/g, (m, p1, p2) => chalk.bold(p1 || p2));
Expand Down Expand Up @@ -90,13 +90,13 @@ module.exports = results => {
let output = '\n';

if (process.stdout.isTTY && !process.env.CI) {
// Make relative paths Cmd+click'able in iTerm
// Make relative paths Command-clickable in iTerm
output += ansiEscapes.iTerm.setCwd();
}

output += lines.map(x => {
if (x.type === 'header') {
// Add the line number so it's Cmd+click'able in some terminals
// Add the line number so it's Command-click'able in some terminals
// Use dim & gray for terminals like iTerm that doesn't support `hidden`
const position = showLineNumbers ? chalk.hidden.dim.gray(`:${x.firstLineCol}`) : '';

Expand All @@ -110,7 +110,7 @@ module.exports = results => {
' '.repeat(maxLineWidth - x.lineWidth) + chalk.dim(x.line + chalk.gray(':') + x.column),
' '.repeat(maxColumnWidth - x.columnWidth) + x.message,
' '.repeat(maxMessageWidth - x.messageWidth) +
(supportsHyperlink(process.stdout) ? ansiEscapes.link(chalk.dim(x.ruleId), getRuleUrl(x.ruleId).url) : chalk.gray.dim(x.ruleId))
(supportsHyperlink(process.stdout) ? ansiEscapes.link(chalk.dim(x.ruleId), getRuleUrl(x.ruleId).url) : chalk.dim(x.ruleId))
];

if (!showLineNumbers) {
Expand Down
21 changes: 5 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
Expand All @@ -31,27 +31,16 @@
"chalk": "^2.1.0",
"eslint-rule-docs": "^1.1.5",
"log-symbols": "^2.0.0",
"plur": "^2.1.2",
"plur": "^3.0.1",
"string-width": "^2.0.0",
"supports-hyperlinks": "^1.0.1"
},
"devDependencies": {
"ava": "*",
"strip-ansi": "^4.0.0",
"xo": "*"
"ava": "^0.25.0",
"strip-ansi": "^5.0.0",
"xo": "^0.23.0"
},
"ava": {
"serial": true
},
"xo": {
"overrides": [
{
"files": "index.js",
"rules": {
"prefer-destructuring": 0,
"no-else-return": 1
}
}
]
}
}
19 changes: 17 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
![](screenshot.png)


## Highlights

- Pretty output.
- Sorts results by severity.
- Stylizes inline codeblocks in messages.
- Command-click a rule ID to open its docs.
- Command-click a header to reveal the first error in your editor. *(iTerm-only)*


## Install

```
Expand All @@ -14,6 +23,10 @@ $ npm install --save-dev eslint-formatter-pretty

## Usage

### [XO](https://github.com/xojs/xo)

Nothing to do. It's the default formatter.

### ESLint CLI

```
Expand Down Expand Up @@ -70,9 +83,11 @@ module.exports = {
```


## Tip
## Tips

In iTerm, <kbd>Command</kbd>-click the filename header to open the file in your editor.

In iTerm, <kbd>Cmd</kbd>+click the filename header to open the file in your editor.
In [terminals with support for hyperlinks](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#supporting-apps), <kbd>Command</kbd>-click the rule ID to open its docs.


## License
Expand Down

0 comments on commit 3f5cd27

Please sign in to comment.