What is eslint-formatter-codeframe?
The eslint-formatter-codeframe package is an ESLint formatter that uses Babel's code frame to display linting errors and warnings in a visually appealing and easy-to-read format. It highlights the specific lines and columns where issues occur, making it easier for developers to identify and fix problems in their code.
What are eslint-formatter-codeframe's main functionalities?
Code Frame Formatting
This feature allows you to use the code frame formatter in your ESLint configuration. The code frame formatter highlights the specific lines and columns where linting issues occur, making it easier to identify and fix problems.
module.exports = {
"extends": "eslint:recommended",
"rules": {
"no-unused-vars": "warn"
},
"formatter": "codeframe"
};
Other packages similar to eslint-formatter-codeframe
eslint-formatter-pretty
eslint-formatter-pretty is another ESLint formatter that provides a visually appealing output for linting errors and warnings. It focuses on making the output more readable and user-friendly, similar to eslint-formatter-codeframe, but with a different visual style.
eslint-formatter-friendly
eslint-formatter-friendly is designed to provide a more human-readable output for ESLint results. It aims to make the linting output easier to understand for developers, similar to eslint-formatter-codeframe, but with a focus on simplicity and clarity.
eslint-formatter-table
eslint-formatter-table displays ESLint results in a table format. It organizes linting errors and warnings into a structured table, making it easy to scan and identify issues. This is different from eslint-formatter-codeframe, which uses a code frame format.
eslint-formatter-codeframe
ESLint’s official codeframe
formatter, extracted from ESLint 7
This formatter has been removed from ESLint 8 so it lives as a standalone module here.
Warning: This module is not maintained. If you're an ESLint contributor or dependable open-sourcerer, open an issue here and I'll pass you this repo and npm name. You can also ping me on Twitter @fregante
Install
npm install --save-dev eslint-formatter-codeframe
Usage
More information about formatters can be found on https://eslint.org/docs/user-guide/formatters/
eslint --format codeframe
Example output
error: 'addOne' is defined but never used (no-unused-vars) at fullOfProblems.js:1:10:
> 1 | function addOne(i) {
| ^
2 | if (i != NaN) {
3 | return i ++
4 | } else {
error: Use the isNaN function to compare with NaN (use-isnan) at fullOfProblems.js:2:9:
1 | function addOne(i) {
> 2 | if (i != NaN) {
| ^
3 | return i ++
4 | } else {
5 | return
error: Unexpected space before unary operator '++' (space-unary-ops) at fullOfProblems.js:3:16:
1 | function addOne(i) {
2 | if (i != NaN) {
> 3 | return i ++
| ^
4 | } else {
5 | return
6 | }
warning: Missing semicolon (semi) at fullOfProblems.js:3:20:
1 | function addOne(i) {
2 | if (i != NaN) {
> 3 | return i ++
| ^
4 | } else {
5 | return
6 | }
warning: Unnecessary 'else' after 'return' (no-else-return) at fullOfProblems.js:4:12:
2 | if (i != NaN) {
3 | return i ++
> 4 | } else {
| ^
5 | return
6 | }
7 | };
warning: Expected indentation of 8 spaces but found 6 (indent) at fullOfProblems.js:5:1:
3 | return i ++
4 | } else {
> 5 | return
| ^
6 | }
7 | };
error: Function 'addOne' expected a return value (consistent-return) at fullOfProblems.js:5:7:
3 | return i ++
4 | } else {
> 5 | return
| ^
6 | }
7 | };
warning: Missing semicolon (semi) at fullOfProblems.js:5:13:
3 | return i ++
4 | } else {
> 5 | return
| ^
6 | }
7 | };
error: Unnecessary semicolon (no-extra-semi) at fullOfProblems.js:7:2:
5 | return
6 | }
> 7 | };
| ^
5 errors and 4 warnings found.
2 errors and 4 warnings potentially fixable with the `--fix` option.
Links