Skip to content

sindresorhus/eslint-formatter-pretty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

88f1088 · Jul 26, 2024

History

77 Commits
Dec 13, 2023
Oct 28, 2023
Sep 5, 2017
Nov 13, 2018
Sep 5, 2017
Sep 5, 2017
Oct 28, 2023
Jan 2, 2024
Oct 28, 2023
Jun 13, 2020
Jan 2, 2024
Jul 26, 2024
Apr 21, 2016

Repository files navigation

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

Please note that to use version 6 of this package you will HAVE to use ESLint v9+. If you're using ESLint v8 or below, install with npm install --save-dev eslint-formatter-pretty@5 instead.

Usage

Nothing to do. It's the default formatter.

ESLint CLI

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

grunt.loadNpmTasks('grunt-eslint');
grunt.registerTask('default', ['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.