Skip to content

sindresorhus/eslint-formatter-pretty

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
October 29, 2023 01:34
October 29, 2023 01:17
September 5, 2017 10:22
November 13, 2018 12:03
September 5, 2017 10:22
September 5, 2017 10:22
October 29, 2023 01:17
October 29, 2023 01:17
October 29, 2023 01:17
June 13, 2020 16:32
October 29, 2023 01:21
April 21, 2016 19:05

eslint-formatter-pretty

Pretty formatter for ESLint

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

npm install --save-dev eslint-formatter-pretty@5

To use this with ESLint, use version 5. Version 6 is not compatible with ESLint.

Usage

XO

Nothing to do. It's the default formatter.

ESLint CLI

eslint --format=pretty file.js

grunt-eslint

grunt.initConfig({
	eslint: {
		target: ['file.js'].
		options: {
			format: 'pretty'
		}
	}
});

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

gulp-eslint

import gulp from 'gulp';
import eslint from 'gulp-eslint';

export const lint = (
	gulp.src('file.js')
		.pipe(eslint())
		.pipe(eslint.format('pretty'))
);

eslint-loader (webpack)

import eslintFormatterPretty from 'eslint-formatter-pretty';

export default {
	entry: ['file.js'],
	module: {
		rules: [
			{
				test: /\.js$/,
				exclude: /node_modules/,
				loader: 'eslint-loader',
				options: {
					formatter: eslintFormatterPretty
				}
			}
		]
	}
};

Tips

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

In terminals with support for hyperlinks, Command-click the rule ID to open its docs.