├── .npmrc
├── .gitignore
├── packages
├── eslint-formatter-unix
│ ├── examples
│ │ ├── no-errors.log
│ │ ├── multiple-files.log
│ │ ├── single-file.log
│ │ └── with-fixable.log
│ ├── index.d.ts
│ ├── readme.md
│ ├── package.json
│ ├── license
│ └── index.js
├── eslint-formatter-compact
│ ├── examples
│ │ ├── no-errors.log
│ │ ├── multiple-files.log
│ │ ├── single-file.log
│ │ └── with-fixable.log
│ ├── index.d.ts
│ ├── readme.md
│ ├── package.json
│ ├── license
│ └── index.js
├── eslint-formatter-json
│ ├── examples
│ │ ├── no-errors.json
│ │ ├── single-file.json
│ │ ├── with-fixable.json
│ │ └── multiple-files.json
│ ├── index.d.ts
│ ├── index.js
│ ├── package.json
│ ├── readme.md
│ └── license
├── eslint-formatter-stylish
│ ├── examples
│ │ ├── no-errors.log
│ │ ├── multiple-files.log
│ │ ├── single-file.log
│ │ └── with-fixable.log
│ ├── index.d.ts
│ ├── readme.md
│ ├── package.json
│ ├── license
│ └── index.js
├── eslint-formatter-visualstudio
│ ├── examples
│ │ ├── no-errors.log
│ │ ├── multiple-files.log
│ │ ├── single-file.log
│ │ └── with-fixable.log
│ ├── index.d.ts
│ ├── readme.md
│ ├── package.json
│ ├── license
│ └── index.js
├── eslint-formatter-json-with-metadata
│ ├── examples
│ │ ├── no-errors.json
│ │ ├── single-file.json
│ │ ├── with-fixable.json
│ │ └── multiple-files.json
│ ├── index.d.ts
│ ├── index.js
│ ├── package.json
│ ├── readme.md
│ └── license
├── eslint-formatter-tap
│ ├── examples
│ │ ├── no-errors.log
│ │ ├── single-file.log
│ │ ├── multiple-files.log
│ │ └── with-fixable.log
│ ├── index.d.ts
│ ├── package.json
│ ├── readme.md
│ ├── license
│ └── index.js
├── eslint-formatter-junit
│ ├── index.d.ts
│ ├── examples
│ │ ├── no-errors.xml
│ │ ├── single-file.xml
│ │ ├── with-fixable.xml
│ │ └── multiple-files.xml
│ ├── package.json
│ ├── xml-escape.js
│ ├── readme.md
│ ├── license
│ └── index.js
├── eslint-formatter-checkstyle
│ ├── index.d.ts
│ ├── examples
│ │ ├── no-errors.xml
│ │ ├── single-file.xml
│ │ ├── multiple-files.xml
│ │ └── with-fixable.xml
│ ├── readme.md
│ ├── package.json
│ ├── xml-escape.js
│ ├── license
│ └── index.js
├── eslint-formatter-jslint-xml
│ ├── index.d.ts
│ ├── examples
│ │ ├── no-errors.xml
│ │ ├── single-file.xml
│ │ ├── with-fixable.xml
│ │ └── multiple-files.xml
│ ├── readme.md
│ ├── package.json
│ ├── xml-escape.js
│ ├── index.js
│ └── license
├── eslint-formatter-table
│ └── readme.md
└── eslint-formatter-codeframe
│ └── readme.md
├── .prettierignore
├── package.json
├── .github
└── workflows
│ ├── auto-update.yml
│ ├── is-dist-up-to-date.yml
│ └── ci.yml
├── readme.md
└── formatters.test.js
/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | eslint
3 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-unix/examples/no-errors.log:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-compact/examples/no-errors.log:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-json/examples/no-errors.json:
--------------------------------------------------------------------------------
1 | []
--------------------------------------------------------------------------------
/packages/eslint-formatter-stylish/examples/no-errors.log:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-visualstudio/examples/no-errors.log:
--------------------------------------------------------------------------------
1 | no problems
--------------------------------------------------------------------------------
/packages/eslint-formatter-json-with-metadata/examples/no-errors.json:
--------------------------------------------------------------------------------
1 | {"results":[]}
--------------------------------------------------------------------------------
/packages/eslint-formatter-tap/examples/no-errors.log:
--------------------------------------------------------------------------------
1 | TAP version 13
2 | 1..0
3 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | eslint
2 | packages/*/index.js
3 | expected-output
4 | packages/*/examples
5 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-json/index.d.ts:
--------------------------------------------------------------------------------
1 | declare function formatter(): string;
2 | export = formatter;
3 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-junit/index.d.ts:
--------------------------------------------------------------------------------
1 | declare function formatter(): string;
2 | export = formatter;
3 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-tap/index.d.ts:
--------------------------------------------------------------------------------
1 | declare function formatter(): string;
2 | export = formatter;
3 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-unix/index.d.ts:
--------------------------------------------------------------------------------
1 | declare function formatter(): string;
2 | export = formatter;
3 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-checkstyle/index.d.ts:
--------------------------------------------------------------------------------
1 | declare function formatter(): string;
2 | export = formatter;
3 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-compact/index.d.ts:
--------------------------------------------------------------------------------
1 | declare function formatter(): string;
2 | export = formatter;
3 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-jslint-xml/index.d.ts:
--------------------------------------------------------------------------------
1 | declare function formatter(): string;
2 | export = formatter;
3 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-stylish/index.d.ts:
--------------------------------------------------------------------------------
1 | declare function formatter(): string;
2 | export = formatter;
3 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-jslint-xml/examples/no-errors.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-visualstudio/index.d.ts:
--------------------------------------------------------------------------------
1 | declare function formatter(): string;
2 | export = formatter;
3 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-json-with-metadata/index.d.ts:
--------------------------------------------------------------------------------
1 | declare function formatter(): string;
2 | export = formatter;
3 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-junit/examples/no-errors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-checkstyle/examples/no-errors.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-table/readme.md:
--------------------------------------------------------------------------------
1 | # eslint-formatter-table
2 |
3 | Extracted to own repository: https://github.com/fregante/eslint-formatter-table
4 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-codeframe/readme.md:
--------------------------------------------------------------------------------
1 | # eslint-formatter-codeframe
2 |
3 | Extracted to own repository: https://github.com/fregante/eslint-formatter-codeframe
4 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-unix/examples/multiple-files.log:
--------------------------------------------------------------------------------
1 | foo.js:5:10: Unexpected foo. [Error/foo]
2 | bar.js:6:11: Unexpected bar. [Warning/bar]
3 | baz.js:1:1: Fatal error parsing file. [Error]
4 |
5 | 3 problems
--------------------------------------------------------------------------------
/packages/eslint-formatter-unix/examples/single-file.log:
--------------------------------------------------------------------------------
1 | foo.js:5:10: Unexpected foo. [Error/foo]
2 | foo.js:10:15: Missing semicolon. [Error/semi]
3 | foo.js:3:8: Unused variable. [Warning/no-unused-vars]
4 |
5 | 3 problems
--------------------------------------------------------------------------------
/packages/eslint-formatter-visualstudio/examples/multiple-files.log:
--------------------------------------------------------------------------------
1 | foo.js(5,10): error foo : Unexpected foo.
2 | bar.js(6,11): warning bar : Unexpected bar.
3 | baz.js(1,1): error : Fatal error parsing file.
4 |
5 | 3 problems
--------------------------------------------------------------------------------
/packages/eslint-formatter-visualstudio/examples/single-file.log:
--------------------------------------------------------------------------------
1 | foo.js(5,10): error foo : Unexpected foo.
2 | foo.js(10,15): error semi : Missing semicolon.
3 | foo.js(3,8): warning no-unused-vars : Unused variable.
4 |
5 | 3 problems
--------------------------------------------------------------------------------
/packages/eslint-formatter-compact/examples/multiple-files.log:
--------------------------------------------------------------------------------
1 | foo.js: line 5, col 10, Error - Unexpected foo. (foo)
2 | bar.js: line 6, col 11, Warning - Unexpected bar. (bar)
3 | baz.js: line 1, col 1, Error - Fatal error parsing file.
4 |
5 | 3 problems
--------------------------------------------------------------------------------
/packages/eslint-formatter-unix/examples/with-fixable.log:
--------------------------------------------------------------------------------
1 | fixable.js:5:20: Missing semicolon. [Error/semi]
2 | fixable.js:8:15: Unexpected trailing comma. [Error/comma-dangle]
3 | fixable.js:3:1: Prefer const over let. [Warning/prefer-const]
4 |
5 | 3 problems
--------------------------------------------------------------------------------
/packages/eslint-formatter-compact/examples/single-file.log:
--------------------------------------------------------------------------------
1 | foo.js: line 5, col 10, Error - Unexpected foo. (foo)
2 | foo.js: line 10, col 15, Error - Missing semicolon. (semi)
3 | foo.js: line 3, col 8, Warning - Unused variable. (no-unused-vars)
4 |
5 | 3 problems
--------------------------------------------------------------------------------
/packages/eslint-formatter-visualstudio/examples/with-fixable.log:
--------------------------------------------------------------------------------
1 | fixable.js(5,20): error semi : Missing semicolon.
2 | fixable.js(8,15): error comma-dangle : Unexpected trailing comma.
3 | fixable.js(3,1): warning prefer-const : Prefer const over let.
4 |
5 | 3 problems
--------------------------------------------------------------------------------
/packages/eslint-formatter-stylish/examples/multiple-files.log:
--------------------------------------------------------------------------------
1 |
2 | foo.js
3 | 5:10 error Unexpected foo foo
4 |
5 | bar.js
6 | 6:11 warning Unexpected bar bar
7 |
8 | baz.js
9 | 1:1 error Fatal error parsing file
10 |
11 | ✖ 3 problems (2 errors, 1 warning)
12 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-compact/examples/with-fixable.log:
--------------------------------------------------------------------------------
1 | fixable.js: line 5, col 20, Error - Missing semicolon. (semi)
2 | fixable.js: line 8, col 15, Error - Unexpected trailing comma. (comma-dangle)
3 | fixable.js: line 3, col 1, Warning - Prefer const over let. (prefer-const)
4 |
5 | 3 problems
--------------------------------------------------------------------------------
/packages/eslint-formatter-stylish/examples/single-file.log:
--------------------------------------------------------------------------------
1 |
2 | foo.js
3 | 5:10 error Unexpected foo foo
4 | 10:15 error Missing semicolon semi
5 | 3:8 warning Unused variable no-unused-vars
6 |
7 | ✖ 3 problems (2 errors, 1 warning)
8 | 1 error and 0 warnings potentially fixable with the `--fix` option.
9 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-unix/readme.md:
--------------------------------------------------------------------------------
1 | # eslint-formatter-unix
2 |
3 | > ESLint's `unix` formatter as a standalone package
4 |
5 | ## Demo
6 |
7 | ```
8 | foo.js:5:10: Unexpected foo. [Error/foo]
9 | bar.js:6:11: Unexpected bar. [Warning/bar]
10 | baz.js:1:1: Fatal error parsing file. [Error]
11 |
12 | 3 problems
13 | ```
14 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-jslint-xml/examples/single-file.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-stylish/examples/with-fixable.log:
--------------------------------------------------------------------------------
1 |
2 | fixable.js
3 | 5:20 error Missing semicolon semi
4 | 8:15 error Unexpected trailing comma comma-dangle
5 | 3:1 warning Prefer const over let prefer-const
6 |
7 | ✖ 3 problems (2 errors, 1 warning)
8 | 2 errors and 1 warning potentially fixable with the `--fix` option.
9 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-visualstudio/readme.md:
--------------------------------------------------------------------------------
1 | # eslint-formatter-visualstudio
2 |
3 | > ESLint's `visualstudio` formatter as a standalone package
4 |
5 | ## Demo
6 |
7 | ```
8 | foo.js(5,10): error foo : Unexpected foo.
9 | bar.js(6,11): warning bar : Unexpected bar.
10 | baz.js(1,1): error : Fatal error parsing file.
11 |
12 | 3 problems
13 | ```
14 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-compact/readme.md:
--------------------------------------------------------------------------------
1 | # eslint-formatter-compact
2 |
3 | > ESLint's `compact` formatter as a standalone package
4 |
5 | ## Demo
6 |
7 | ```
8 | foo.js: line 5, col 10, Error - Unexpected foo. (foo)
9 | bar.js: line 6, col 11, Warning - Unexpected bar. (bar)
10 | baz.js: line 1, col 1, Error - Fatal error parsing file.
11 |
12 | 3 problems
13 | ```
14 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-jslint-xml/examples/with-fixable.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-stylish/readme.md:
--------------------------------------------------------------------------------
1 | # eslint-formatter-stylish
2 |
3 | > ESLint's `stylish` formatter as a standalone package
4 |
5 | ## Demo
6 |
7 | ```
8 | foo.js
9 | 5:10 error Unexpected foo foo
10 |
11 | bar.js
12 | 6:11 warning Unexpected bar bar
13 |
14 | baz.js
15 | 1:1 error Fatal error parsing file
16 |
17 | ✖ 3 problems (2 errors, 1 warning)
18 | ```
19 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-jslint-xml/examples/multiple-files.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-json/examples/single-file.json:
--------------------------------------------------------------------------------
1 | [{"filePath":"foo.js","messages":[{"message":"Unexpected foo.","severity":2,"line":5,"column":10,"ruleId":"foo"},{"message":"Missing semicolon.","severity":2,"line":10,"column":15,"ruleId":"semi"},{"message":"Unused variable.","severity":1,"line":3,"column":8,"ruleId":"no-unused-vars"}],"errorCount":2,"warningCount":1,"fixableErrorCount":1,"fixableWarningCount":0}]
--------------------------------------------------------------------------------
/packages/eslint-formatter-json/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview JSON reporter
3 | * @author Burak Yigit Kaya aka BYK
4 | */
5 |
6 | //------------------------------------------------------------------------------
7 | // Public Interface
8 | //------------------------------------------------------------------------------
9 |
10 | module.exports = function (results) {
11 | return JSON.stringify(results);
12 | };
--------------------------------------------------------------------------------
/packages/eslint-formatter-json-with-metadata/examples/single-file.json:
--------------------------------------------------------------------------------
1 | {"results":[{"filePath":"foo.js","messages":[{"message":"Unexpected foo.","severity":2,"line":5,"column":10,"ruleId":"foo"},{"message":"Missing semicolon.","severity":2,"line":10,"column":15,"ruleId":"semi"},{"message":"Unused variable.","severity":1,"line":3,"column":8,"ruleId":"no-unused-vars"}],"errorCount":2,"warningCount":1,"fixableErrorCount":1,"fixableWarningCount":0}]}
--------------------------------------------------------------------------------
/packages/eslint-formatter-json/examples/with-fixable.json:
--------------------------------------------------------------------------------
1 | [{"filePath":"fixable.js","messages":[{"message":"Missing semicolon.","severity":2,"line":5,"column":20,"ruleId":"semi"},{"message":"Unexpected trailing comma.","severity":2,"line":8,"column":15,"ruleId":"comma-dangle"},{"message":"Prefer const over let.","severity":1,"line":3,"column":1,"ruleId":"prefer-const"}],"errorCount":2,"warningCount":1,"fixableErrorCount":2,"fixableWarningCount":1}]
--------------------------------------------------------------------------------
/packages/eslint-formatter-json-with-metadata/examples/with-fixable.json:
--------------------------------------------------------------------------------
1 | {"results":[{"filePath":"fixable.js","messages":[{"message":"Missing semicolon.","severity":2,"line":5,"column":20,"ruleId":"semi"},{"message":"Unexpected trailing comma.","severity":2,"line":8,"column":15,"ruleId":"comma-dangle"},{"message":"Prefer const over let.","severity":1,"line":3,"column":1,"ruleId":"prefer-const"}],"errorCount":2,"warningCount":1,"fixableErrorCount":2,"fixableWarningCount":1}]}
--------------------------------------------------------------------------------
/packages/eslint-formatter-json-with-metadata/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview JSON reporter, including rules metadata
3 | * @author Chris Meyer
4 | */
5 |
6 | //------------------------------------------------------------------------------
7 | // Public Interface
8 | //------------------------------------------------------------------------------
9 |
10 | module.exports = function (results, data) {
11 | return JSON.stringify({
12 | results,
13 | metadata: data,
14 | });
15 | };
--------------------------------------------------------------------------------
/packages/eslint-formatter-checkstyle/examples/single-file.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "prettier": "prettier . --single-quote --use-tabs --no-bracket-spacing --arrow-parens avoid --print-width 150 --prose-wrap never",
5 | "format": "npm run prettier -- --write",
6 | "test": "vitest run",
7 | "test:watch": "vitest"
8 | },
9 | "dependencies": {
10 | "prettier": "^2.8.8"
11 | },
12 | "engines": {
13 | "node": ">=15",
14 | "npm": ">=7"
15 | },
16 | "devDependencies": {
17 | "vitest": "^3.2.4"
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-checkstyle/examples/multiple-files.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-checkstyle/examples/with-fixable.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-jslint-xml/readme.md:
--------------------------------------------------------------------------------
1 | # eslint-formatter-jslint-xml
2 |
3 | > ESLint's `jslint-xml` formatter as a standalone package
4 |
5 | ## Demo
6 |
7 | ```xml
8 |
9 | ```
10 |
--------------------------------------------------------------------------------
/.github/workflows/auto-update.yml:
--------------------------------------------------------------------------------
1 | name: Update
2 |
3 | on:
4 | workflow_dispatch:
5 | schedule:
6 | - cron: '10 11 12 * *'
7 |
8 | jobs:
9 | check-and-update:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v3
13 | - uses: fregante/setup-git-user@v2
14 | - name: Try updating the version
15 | run: |
16 | npm install
17 | npm config set '//registry.npmjs.org/:_authToken' "${{ secrets.NPM_TOKEN }}"
18 | npm run publish
19 | git push --follow-tags
20 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-tap/examples/single-file.log:
--------------------------------------------------------------------------------
1 | TAP version 13
2 | 1..1
3 | not ok 1 - foo.js
4 | ---
5 | message: Unexpected foo.
6 | severity: error
7 | data:
8 | line: 5
9 | column: 10
10 | ruleId: foo
11 | messages:
12 | - message: Missing semicolon.
13 | severity: error
14 | data:
15 | line: 10
16 | column: 15
17 | ruleId: semi
18 | - message: Unused variable.
19 | severity: warning
20 | data:
21 | line: 3
22 | column: 8
23 | ruleId: no-unused-vars
24 | ...
25 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-tap/examples/multiple-files.log:
--------------------------------------------------------------------------------
1 | TAP version 13
2 | 1..3
3 | not ok 1 - foo.js
4 | ---
5 | message: Unexpected foo.
6 | severity: error
7 | data:
8 | line: 5
9 | column: 10
10 | ruleId: foo
11 | ...
12 | ok 2 - bar.js
13 | ---
14 | message: Unexpected bar.
15 | severity: warning
16 | data:
17 | line: 6
18 | column: 11
19 | ruleId: bar
20 | ...
21 | not ok 3 - baz.js
22 | ---
23 | message: Fatal error parsing file.
24 | severity: error
25 | data:
26 | line: 1
27 | column: 1
28 | ruleId: ''
29 | ...
30 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-tap/examples/with-fixable.log:
--------------------------------------------------------------------------------
1 | TAP version 13
2 | 1..1
3 | not ok 1 - fixable.js
4 | ---
5 | message: Missing semicolon.
6 | severity: error
7 | data:
8 | line: 5
9 | column: 20
10 | ruleId: semi
11 | messages:
12 | - message: Unexpected trailing comma.
13 | severity: error
14 | data:
15 | line: 8
16 | column: 15
17 | ruleId: comma-dangle
18 | - message: Prefer const over let.
19 | severity: warning
20 | data:
21 | line: 3
22 | column: 1
23 | ruleId: prefer-const
24 | ...
25 |
--------------------------------------------------------------------------------
/.github/workflows/is-dist-up-to-date.yml:
--------------------------------------------------------------------------------
1 | env:
2 | SCRIPT_NAME: format
3 |
4 | # FILE GENERATED WITH: npx ghat fregante/ghatemplates/is-dist-up-to-date
5 | # SOURCE: https://github.com/fregante/ghatemplates
6 |
7 | name: Verify Built Files
8 | on:
9 | - pull_request
10 | - push
11 | jobs:
12 | Verify:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v3
16 | - name: install
17 | run: npm ci || npm install
18 | - run: npm run ${{ env.SCRIPT_NAME }}
19 | - name: verify that built files are up to date
20 | run: git diff --exit-code
21 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-json/examples/multiple-files.json:
--------------------------------------------------------------------------------
1 | [{"filePath":"foo.js","messages":[{"message":"Unexpected foo.","severity":2,"line":5,"column":10,"ruleId":"foo"}],"errorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"bar.js","messages":[{"message":"Unexpected bar.","severity":1,"line":6,"column":11,"ruleId":"bar"}],"errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"baz.js","messages":[{"message":"Fatal error parsing file.","severity":2,"fatal":true,"line":1,"column":1,"ruleId":null}],"errorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0}]
--------------------------------------------------------------------------------
/packages/eslint-formatter-checkstyle/readme.md:
--------------------------------------------------------------------------------
1 | # eslint-formatter-checkstyle
2 |
3 | > ESLint's `checkstyle` formatter as a standalone package
4 |
5 | ## Demo
6 |
7 | ```xml
8 |
9 | ```
10 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-json/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-formatter-json",
3 | "version": "9.0.1",
4 | "description": "ESLint’s official `json` formatter, unofficially published as a standalone module",
5 | "keywords": [
6 | "lint",
7 | "javascript",
8 | "ecmascript"
9 | ],
10 | "homepage": "https://github.com/fregante/eslint-formatters/tree/main/packages/eslint-formatter-json",
11 | "repository": "fregante/eslint-formatters",
12 | "license": "MIT",
13 | "author": "Nicholas C. Zakas ",
14 | "dependencies": {},
15 | "engines": {
16 | "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-unix/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-formatter-unix",
3 | "version": "9.0.1",
4 | "description": "ESLint’s official `unix` formatter, unofficially published as a standalone module",
5 | "keywords": [
6 | "lint",
7 | "javascript",
8 | "ecmascript"
9 | ],
10 | "homepage": "https://github.com/fregante/eslint-formatters/tree/main/packages/eslint-formatter-unix",
11 | "repository": "fregante/eslint-formatters",
12 | "license": "MIT",
13 | "author": "Nicholas C. Zakas ",
14 | "dependencies": {},
15 | "engines": {
16 | "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-junit/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-formatter-junit",
3 | "version": "9.0.1",
4 | "description": "ESLint’s official `junit` formatter, unofficially published as a standalone module",
5 | "keywords": [
6 | "lint",
7 | "javascript",
8 | "ecmascript"
9 | ],
10 | "homepage": "https://github.com/fregante/eslint-formatters/tree/main/packages/eslint-formatter-junit",
11 | "repository": "fregante/eslint-formatters",
12 | "license": "MIT",
13 | "author": "Nicholas C. Zakas ",
14 | "dependencies": {},
15 | "engines": {
16 | "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-compact/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-formatter-compact",
3 | "version": "9.0.1",
4 | "description": "ESLint’s official `compact` formatter, unofficially published as a standalone module",
5 | "keywords": [
6 | "lint",
7 | "javascript",
8 | "ecmascript"
9 | ],
10 | "homepage": "https://github.com/fregante/eslint-formatters/tree/main/packages/eslint-formatter-compact",
11 | "repository": "fregante/eslint-formatters",
12 | "license": "MIT",
13 | "author": "Nicholas C. Zakas ",
14 | "dependencies": {},
15 | "engines": {
16 | "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-json-with-metadata/examples/multiple-files.json:
--------------------------------------------------------------------------------
1 | {"results":[{"filePath":"foo.js","messages":[{"message":"Unexpected foo.","severity":2,"line":5,"column":10,"ruleId":"foo"}],"errorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"bar.js","messages":[{"message":"Unexpected bar.","severity":1,"line":6,"column":11,"ruleId":"bar"}],"errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"baz.js","messages":[{"message":"Fatal error parsing file.","severity":2,"fatal":true,"line":1,"column":1,"ruleId":null}],"errorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0}]}
--------------------------------------------------------------------------------
/packages/eslint-formatter-checkstyle/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-formatter-checkstyle",
3 | "version": "9.0.1",
4 | "description": "ESLint’s official `checkstyle` formatter, unofficially published as a standalone module",
5 | "keywords": [
6 | "lint",
7 | "javascript",
8 | "ecmascript"
9 | ],
10 | "homepage": "https://github.com/fregante/eslint-formatters/tree/main/packages/eslint-formatter-checkstyle",
11 | "repository": "fregante/eslint-formatters",
12 | "license": "MIT",
13 | "author": "Nicholas C. Zakas ",
14 | "dependencies": {},
15 | "engines": {
16 | "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-jslint-xml/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-formatter-jslint-xml",
3 | "version": "9.0.1",
4 | "description": "ESLint’s official `jslint-xml` formatter, unofficially published as a standalone module",
5 | "keywords": [
6 | "lint",
7 | "javascript",
8 | "ecmascript"
9 | ],
10 | "homepage": "https://github.com/fregante/eslint-formatters/tree/main/packages/eslint-formatter-jslint-xml",
11 | "repository": "fregante/eslint-formatters",
12 | "license": "MIT",
13 | "author": "Nicholas C. Zakas ",
14 | "dependencies": {},
15 | "engines": {
16 | "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-tap/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-formatter-tap",
3 | "version": "9.0.1",
4 | "description": "ESLint’s official `tap` formatter, unofficially published as a standalone module",
5 | "keywords": [
6 | "lint",
7 | "javascript",
8 | "ecmascript"
9 | ],
10 | "homepage": "https://github.com/fregante/eslint-formatters/tree/main/packages/eslint-formatter-tap",
11 | "repository": "fregante/eslint-formatters",
12 | "license": "MIT",
13 | "author": "Nicholas C. Zakas ",
14 | "dependencies": {
15 | "js-yaml": "^4.1.0"
16 | },
17 | "engines": {
18 | "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-visualstudio/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-formatter-visualstudio",
3 | "version": "9.0.1",
4 | "description": "ESLint’s official `visualstudio` formatter, unofficially published as a standalone module",
5 | "keywords": [
6 | "lint",
7 | "javascript",
8 | "ecmascript"
9 | ],
10 | "homepage": "https://github.com/fregante/eslint-formatters/tree/main/packages/eslint-formatter-visualstudio",
11 | "repository": "fregante/eslint-formatters",
12 | "license": "MIT",
13 | "author": "Nicholas C. Zakas ",
14 | "dependencies": {},
15 | "engines": {
16 | "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-tap/readme.md:
--------------------------------------------------------------------------------
1 | # eslint-formatter-tap
2 |
3 | > ESLint's `tap` formatter as a standalone package
4 |
5 | ## Demo
6 |
7 | ```
8 | TAP version 13
9 | 1..3
10 | not ok 1 - foo.js
11 | ---
12 | message: Unexpected foo.
13 | severity: error
14 | data:
15 | line: 5
16 | column: 10
17 | ruleId: foo
18 | ...
19 | ok 2 - bar.js
20 | ---
21 | message: Unexpected bar.
22 | severity: warning
23 | data:
24 | line: 6
25 | column: 11
26 | ruleId: bar
27 | ...
28 | not ok 3 - baz.js
29 | ---
30 | message: Fatal error parsing file.
31 | severity: error
32 | data:
33 | line: 1
34 | column: 1
35 | ruleId: ''
36 | ...
37 | ```
38 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-json-with-metadata/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-formatter-json-with-metadata",
3 | "version": "9.0.1",
4 | "description": "ESLint’s official `json-with-metadata` formatter, unofficially published as a standalone module",
5 | "keywords": [
6 | "lint",
7 | "javascript",
8 | "ecmascript"
9 | ],
10 | "homepage": "https://github.com/fregante/eslint-formatters/tree/main/packages/eslint-formatter-json-with-metadata",
11 | "repository": "fregante/eslint-formatters",
12 | "license": "MIT",
13 | "author": "Nicholas C. Zakas ",
14 | "dependencies": {},
15 | "engines": {
16 | "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-stylish/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eslint-formatter-stylish",
3 | "version": "9.0.1",
4 | "description": "ESLint’s official `stylish` formatter, unofficially published as a standalone module",
5 | "keywords": [
6 | "lint",
7 | "javascript",
8 | "ecmascript"
9 | ],
10 | "homepage": "https://github.com/fregante/eslint-formatters/tree/main/packages/eslint-formatter-stylish",
11 | "repository": "fregante/eslint-formatters",
12 | "license": "MIT",
13 | "author": "Nicholas C. Zakas ",
14 | "dependencies": {
15 | "chalk": "^4.0.0",
16 | "strip-ansi": "^6.0.1",
17 | "text-table": "^0.2.0"
18 | },
19 | "engines": {
20 | "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-junit/examples/single-file.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-junit/examples/with-fixable.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | pull_request:
8 | workflow_dispatch:
9 |
10 | jobs:
11 | test:
12 | runs-on: ubuntu-latest
13 | permissions:
14 | contents: read
15 | strategy:
16 | matrix:
17 | node-version: ['18.18.0', '20.9.0', '21']
18 | steps:
19 | - uses: actions/checkout@v3
20 | - name: Setup Node.js
21 | uses: actions/setup-node@v3
22 | with:
23 | node-version: ${{ matrix.node-version }}
24 | - name: Install root dependencies
25 | run: npm install
26 | - name: Install formatter dependencies
27 | run: |
28 | cd packages/eslint-formatter-stylish && npm install
29 | cd ../../packages/eslint-formatter-tap && npm install
30 | - name: Run tests
31 | run: npm test
32 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-junit/examples/multiple-files.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-json/readme.md:
--------------------------------------------------------------------------------
1 | # eslint-formatter-json
2 |
3 | > ESLint's `json` formatter as a standalone package
4 |
5 | ## Demo
6 |
7 | ```json
8 | [
9 | {
10 | "filePath": "foo.js",
11 | "messages": [{"message": "Unexpected foo.", "severity": 2, "line": 5, "column": 10, "ruleId": "foo"}],
12 | "errorCount": 1,
13 | "warningCount": 0,
14 | "fixableErrorCount": 0,
15 | "fixableWarningCount": 0
16 | },
17 | {
18 | "filePath": "bar.js",
19 | "messages": [{"message": "Unexpected bar.", "severity": 1, "line": 6, "column": 11, "ruleId": "bar"}],
20 | "errorCount": 0,
21 | "warningCount": 1,
22 | "fixableErrorCount": 0,
23 | "fixableWarningCount": 0
24 | },
25 | {
26 | "filePath": "baz.js",
27 | "messages": [{"message": "Fatal error parsing file.", "severity": 2, "fatal": true, "line": 1, "column": 1, "ruleId": null}],
28 | "errorCount": 1,
29 | "warningCount": 0,
30 | "fixableErrorCount": 0,
31 | "fixableWarningCount": 0
32 | }
33 | ]
34 | ```
35 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-junit/xml-escape.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview XML character escaper
3 | * @author George Chung
4 | */
5 |
6 | //------------------------------------------------------------------------------
7 | // Public Interface
8 | //------------------------------------------------------------------------------
9 |
10 | /**
11 | * Returns the escaped value for a character
12 | * @param {string} s string to examine
13 | * @returns {string} severity level
14 | * @private
15 | */
16 | module.exports = function (s) {
17 | return `${s}`.replace(/[<>&"'\x00-\x1F\x7F\u0080-\uFFFF]/gu, c => {
18 | // eslint-disable-line no-control-regex -- Converting controls to entities
19 | switch (c) {
20 | case '<':
21 | return '<';
22 | case '>':
23 | return '>';
24 | case '&':
25 | return '&';
26 | case '"':
27 | return '"';
28 | case "'":
29 | return ''';
30 | default:
31 | return `${c.charCodeAt(0)};`;
32 | }
33 | });
34 | };
35 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-checkstyle/xml-escape.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview XML character escaper
3 | * @author George Chung
4 | */
5 |
6 | //------------------------------------------------------------------------------
7 | // Public Interface
8 | //------------------------------------------------------------------------------
9 |
10 | /**
11 | * Returns the escaped value for a character
12 | * @param {string} s string to examine
13 | * @returns {string} severity level
14 | * @private
15 | */
16 | module.exports = function (s) {
17 | return `${s}`.replace(/[<>&"'\x00-\x1F\x7F\u0080-\uFFFF]/gu, c => {
18 | // eslint-disable-line no-control-regex -- Converting controls to entities
19 | switch (c) {
20 | case '<':
21 | return '<';
22 | case '>':
23 | return '>';
24 | case '&':
25 | return '&';
26 | case '"':
27 | return '"';
28 | case "'":
29 | return ''';
30 | default:
31 | return `${c.charCodeAt(0)};`;
32 | }
33 | });
34 | };
35 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-jslint-xml/xml-escape.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview XML character escaper
3 | * @author George Chung
4 | */
5 |
6 | //------------------------------------------------------------------------------
7 | // Public Interface
8 | //------------------------------------------------------------------------------
9 |
10 | /**
11 | * Returns the escaped value for a character
12 | * @param {string} s string to examine
13 | * @returns {string} severity level
14 | * @private
15 | */
16 | module.exports = function (s) {
17 | return `${s}`.replace(/[<>&"'\x00-\x1F\x7F\u0080-\uFFFF]/gu, c => {
18 | // eslint-disable-line no-control-regex -- Converting controls to entities
19 | switch (c) {
20 | case '<':
21 | return '<';
22 | case '>':
23 | return '>';
24 | case '&':
25 | return '&';
26 | case '"':
27 | return '"';
28 | case "'":
29 | return ''';
30 | default:
31 | return `${c.charCodeAt(0)};`;
32 | }
33 | });
34 | };
35 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-junit/readme.md:
--------------------------------------------------------------------------------
1 | # eslint-formatter-junit
2 |
3 | > ESLint's `junit` formatter as a standalone package
4 |
5 | ## Demo
6 |
7 | ```xml
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | ```
21 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-json-with-metadata/readme.md:
--------------------------------------------------------------------------------
1 | # eslint-formatter-json-with-metadata
2 |
3 | > ESLint's `json-with-metadata` formatter as a standalone package
4 |
5 | ## Demo
6 |
7 | ```json
8 | {
9 | "results": [
10 | {
11 | "filePath": "foo.js",
12 | "messages": [{"message": "Unexpected foo.", "severity": 2, "line": 5, "column": 10, "ruleId": "foo"}],
13 | "errorCount": 1,
14 | "warningCount": 0,
15 | "fixableErrorCount": 0,
16 | "fixableWarningCount": 0
17 | },
18 | {
19 | "filePath": "bar.js",
20 | "messages": [{"message": "Unexpected bar.", "severity": 1, "line": 6, "column": 11, "ruleId": "bar"}],
21 | "errorCount": 0,
22 | "warningCount": 1,
23 | "fixableErrorCount": 0,
24 | "fixableWarningCount": 0
25 | },
26 | {
27 | "filePath": "baz.js",
28 | "messages": [{"message": "Fatal error parsing file.", "severity": 2, "fatal": true, "line": 1, "column": 1, "ruleId": null}],
29 | "errorCount": 1,
30 | "warningCount": 0,
31 | "fixableErrorCount": 0,
32 | "fixableWarningCount": 0
33 | }
34 | ]
35 | }
36 | ```
37 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-jslint-xml/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview JSLint XML reporter
3 | * @author Ian Christian Myers
4 | */
5 |
6 | const xmlEscape = require('./xml-escape');
7 |
8 | //------------------------------------------------------------------------------
9 | // Public Interface
10 | //------------------------------------------------------------------------------
11 |
12 | module.exports = function (results) {
13 | let output = '';
14 |
15 | output += '';
16 | output += '';
17 |
18 | results.forEach(result => {
19 | const messages = result.messages;
20 |
21 | output += ``;
22 |
23 | messages.forEach(message => {
24 | output += [
25 | ``,
29 | ].join(' ');
30 | });
31 |
32 | output += '';
33 | });
34 |
35 | output += '';
36 |
37 | return output;
38 | };
--------------------------------------------------------------------------------
/packages/eslint-formatter-tap/license:
--------------------------------------------------------------------------------
1 | eslint
2 | MIT
3 | Copyright OpenJS Foundation and other contributors,
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-compact/license:
--------------------------------------------------------------------------------
1 | eslint
2 | MIT
3 | Copyright OpenJS Foundation and other contributors,
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-json/license:
--------------------------------------------------------------------------------
1 | eslint
2 | MIT
3 | Copyright OpenJS Foundation and other contributors,
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-junit/license:
--------------------------------------------------------------------------------
1 | eslint
2 | MIT
3 | Copyright OpenJS Foundation and other contributors,
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-stylish/license:
--------------------------------------------------------------------------------
1 | eslint
2 | MIT
3 | Copyright OpenJS Foundation and other contributors,
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-unix/license:
--------------------------------------------------------------------------------
1 | eslint
2 | MIT
3 | Copyright OpenJS Foundation and other contributors,
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-checkstyle/license:
--------------------------------------------------------------------------------
1 | eslint
2 | MIT
3 | Copyright OpenJS Foundation and other contributors,
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-jslint-xml/license:
--------------------------------------------------------------------------------
1 | eslint
2 | MIT
3 | Copyright OpenJS Foundation and other contributors,
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-visualstudio/license:
--------------------------------------------------------------------------------
1 | eslint
2 | MIT
3 | Copyright OpenJS Foundation and other contributors,
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-json-with-metadata/license:
--------------------------------------------------------------------------------
1 | eslint
2 | MIT
3 | Copyright OpenJS Foundation and other contributors,
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # eslint-formatters
2 |
3 | > ESLint formatters published as standalone packages
4 |
5 | - [eslint-formatter-stylish](packages/eslint-formatter-stylish)
6 | - [eslint-formatter-json](packages/eslint-formatter-json)
7 | - [eslint-formatter-json-with-metadata](packages/eslint-formatter-json-with-metadata)
8 | - ~~eslint-formatter-html~~ _unfortunately already exists, so it's not published_
9 |
10 | ESLint 8 dropped 2 formatters and they're now available as their own projects:
11 |
12 | - [eslint-community/eslint-formatter-codeframe](https://github.com/eslint-community/eslint-formatter-codeframe)
13 | - [eslint-community/eslint-formatter-table](https://github.com/eslint-community/eslint-formatter-table)
14 |
15 | ESLint 9 dropped more formatters, but they're [not yet maintained independently](https://github.com/eslint/eslint/issues/17524). You can still find them here:
16 |
17 | - [eslint-formatter-checkstyle](packages/eslint-formatter-checkstyle)
18 | - [eslint-formatter-compact](packages/eslint-formatter-compact)
19 | - [eslint-formatter-jslint-xml](packages/eslint-formatter-jslint-xml)
20 | - [eslint-formatter-junit](packages/eslint-formatter-junit)
21 | - [eslint-formatter-tap](packages/eslint-formatter-tap)
22 | - [eslint-formatter-unix](packages/eslint-formatter-unix)
23 | - [eslint-formatter-visualstudio](packages/eslint-formatter-visualstudio)
24 |
--------------------------------------------------------------------------------
/packages/eslint-formatter-compact/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview Compact reporter
3 | * @author Nicholas C. Zakas
4 | */
5 |
6 | //------------------------------------------------------------------------------
7 | // Helper Functions
8 | //------------------------------------------------------------------------------
9 |
10 | /**
11 | * Returns the severity of warning or error
12 | * @param {Object} message message object to examine
13 | * @returns {string} severity level
14 | * @private
15 | */
16 | function getMessageType(message) {
17 | if (message.fatal || message.severity === 2) {
18 | return 'Error';
19 | }
20 | return 'Warning';
21 | }
22 |
23 | //------------------------------------------------------------------------------
24 | // Public Interface
25 | //------------------------------------------------------------------------------
26 |
27 | module.exports = function (results) {
28 | let output = '',
29 | total = 0;
30 |
31 | results.forEach(result => {
32 | const messages = result.messages;
33 |
34 | total += messages.length;
35 |
36 | messages.forEach(message => {
37 | output += `${result.filePath}: `;
38 | output += `line ${message.line || 0}`;
39 | output += `, col ${message.column || 0}`;
40 | output += `, ${getMessageType(message)}`;
41 | output += ` - ${message.message}`;
42 | output += message.ruleId ? ` (${message.ruleId})` : '';
43 | output += '\n';
44 | });
45 | });
46 |
47 | if (total > 0) {
48 | output += `\n${total} problem${total !== 1 ? 's' : ''}`;
49 | }
50 |
51 | return output;
52 | };
--------------------------------------------------------------------------------
/packages/eslint-formatter-unix/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview unix-style formatter.
3 | * @author oshi-shinobu
4 | */
5 |
6 | //------------------------------------------------------------------------------
7 | // Helper Functions
8 | //------------------------------------------------------------------------------
9 |
10 | /**
11 | * Returns a canonical error level string based upon the error message passed in.
12 | * @param {Object} message Individual error message provided by eslint
13 | * @returns {string} Error level string
14 | */
15 | function getMessageType(message) {
16 | if (message.fatal || message.severity === 2) {
17 | return 'Error';
18 | }
19 | return 'Warning';
20 | }
21 |
22 | //------------------------------------------------------------------------------
23 | // Public Interface
24 | //------------------------------------------------------------------------------
25 |
26 | module.exports = function (results) {
27 | let output = '',
28 | total = 0;
29 |
30 | results.forEach(result => {
31 | const messages = result.messages;
32 |
33 | total += messages.length;
34 |
35 | messages.forEach(message => {
36 | output += `${result.filePath}:`;
37 | output += `${message.line || 0}:`;
38 | output += `${message.column || 0}:`;
39 | output += ` ${message.message} `;
40 | output += `[${getMessageType(message)}${message.ruleId ? `/${message.ruleId}` : ''}]`;
41 | output += '\n';
42 | });
43 | });
44 |
45 | if (total > 0) {
46 | output += `\n${total} problem${total !== 1 ? 's' : ''}`;
47 | }
48 |
49 | return output;
50 | };
--------------------------------------------------------------------------------
/packages/eslint-formatter-visualstudio/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview Visual Studio compatible formatter
3 | * @author Ronald Pijnacker
4 | */
5 |
6 | //------------------------------------------------------------------------------
7 | // Helper Functions
8 | //------------------------------------------------------------------------------
9 |
10 | /**
11 | * Returns the severity of warning or error
12 | * @param {Object} message message object to examine
13 | * @returns {string} severity level
14 | * @private
15 | */
16 | function getMessageType(message) {
17 | if (message.fatal || message.severity === 2) {
18 | return 'error';
19 | }
20 | return 'warning';
21 | }
22 |
23 | //------------------------------------------------------------------------------
24 | // Public Interface
25 | //------------------------------------------------------------------------------
26 |
27 | module.exports = function (results) {
28 | let output = '',
29 | total = 0;
30 |
31 | results.forEach(result => {
32 | const messages = result.messages;
33 |
34 | total += messages.length;
35 |
36 | messages.forEach(message => {
37 | output += result.filePath;
38 | output += `(${message.line || 0}`;
39 | output += message.column ? `,${message.column}` : '';
40 | output += `): ${getMessageType(message)}`;
41 | output += message.ruleId ? ` ${message.ruleId}` : '';
42 | output += ` : ${message.message}`;
43 | output += '\n';
44 | });
45 | });
46 |
47 | if (total === 0) {
48 | output += 'no problems';
49 | } else {
50 | output += `\n${total} problem${total !== 1 ? 's' : ''}`;
51 | }
52 |
53 | return output;
54 | };
--------------------------------------------------------------------------------
/packages/eslint-formatter-checkstyle/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview CheckStyle XML reporter
3 | * @author Ian Christian Myers
4 | */
5 |
6 | const xmlEscape = require('./xml-escape');
7 |
8 | //------------------------------------------------------------------------------
9 | // Helper Functions
10 | //------------------------------------------------------------------------------
11 |
12 | /**
13 | * Returns the severity of warning or error
14 | * @param {Object} message message object to examine
15 | * @returns {string} severity level
16 | * @private
17 | */
18 | function getMessageType(message) {
19 | if (message.fatal || message.severity === 2) {
20 | return 'error';
21 | }
22 | return 'warning';
23 | }
24 |
25 | //------------------------------------------------------------------------------
26 | // Public Interface
27 | //------------------------------------------------------------------------------
28 |
29 | module.exports = function (results) {
30 | let output = '';
31 |
32 | output += '';
33 | output += '';
34 |
35 | results.forEach(result => {
36 | const messages = result.messages;
37 |
38 | output += ``;
39 |
40 | messages.forEach(message => {
41 | output += [
42 | ``,
47 | ].join(' ');
48 | });
49 |
50 | output += '';
51 | });
52 |
53 | output += '';
54 |
55 | return output;
56 | };
--------------------------------------------------------------------------------
/packages/eslint-formatter-junit/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview jUnit Reporter
3 | * @author Jamund Ferguson
4 | */
5 |
6 | const xmlEscape = require('./xml-escape');
7 | const path = require('path');
8 |
9 | //------------------------------------------------------------------------------
10 | // Helper Functions
11 | //------------------------------------------------------------------------------
12 |
13 | /**
14 | * Returns the severity of warning or error
15 | * @param {Object} message message object to examine
16 | * @returns {string} severity level
17 | * @private
18 | */
19 | function getMessageType(message) {
20 | if (message.fatal || message.severity === 2) {
21 | return 'Error';
22 | }
23 | return 'Warning';
24 | }
25 |
26 | /**
27 | * Returns a full file path without extension
28 | * @param {string} filePath input file path
29 | * @returns {string} file path without extension
30 | * @private
31 | */
32 | function pathWithoutExt(filePath) {
33 | return path.join(path.dirname(filePath), path.basename(filePath, path.extname(filePath)));
34 | }
35 |
36 | //------------------------------------------------------------------------------
37 | // Public Interface
38 | //------------------------------------------------------------------------------
39 |
40 | module.exports = function (results) {
41 | let output = '';
42 |
43 | output += '\n';
44 | output += '\n';
45 |
46 | results.forEach(result => {
47 | const messages = result.messages;
48 | const classname = pathWithoutExt(result.filePath);
49 |
50 | if (messages.length > 0) {
51 | output += `\n`;
52 | messages.forEach(message => {
53 | const type = message.fatal ? 'error' : 'failure';
54 |
55 | output += ``;
56 | output += `<${type} message="${xmlEscape(message.message || '')}">`;
57 | output += '';
63 | output += `${type}>`;
64 | output += '\n';
65 | });
66 | output += '\n';
67 | } else {
68 | output += `\n`;
69 | output += `\n`;
70 | output += '\n';
71 | }
72 | });
73 |
74 | output += '\n';
75 |
76 | return output;
77 | };
--------------------------------------------------------------------------------
/packages/eslint-formatter-tap/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview TAP reporter
3 | * @author Jonathan Kingston
4 | */
5 |
6 | const yaml = require('js-yaml');
7 |
8 | //------------------------------------------------------------------------------
9 | // Helper Functions
10 | //------------------------------------------------------------------------------
11 |
12 | /**
13 | * Returns a canonical error level string based upon the error message passed in.
14 | * @param {Object} message Individual error message provided by eslint
15 | * @returns {string} Error level string
16 | */
17 | function getMessageType(message) {
18 | if (message.fatal || message.severity === 2) {
19 | return 'error';
20 | }
21 | return 'warning';
22 | }
23 |
24 | /**
25 | * Takes in a JavaScript object and outputs a TAP diagnostics string
26 | * @param {Object} diagnostic JavaScript object to be embedded as YAML into output.
27 | * @returns {string} diagnostics string with YAML embedded - TAP version 13 compliant
28 | */
29 | function outputDiagnostics(diagnostic) {
30 | const prefix = ' ';
31 | let output = `${prefix}---\n`;
32 |
33 | output += prefix + yaml.dump(diagnostic).split('\n').join(`\n${prefix}`);
34 | output += '...\n';
35 | return output;
36 | }
37 |
38 | //------------------------------------------------------------------------------
39 | // Public Interface
40 | //------------------------------------------------------------------------------
41 |
42 | module.exports = function (results) {
43 | let output = `TAP version 13\n1..${results.length}\n`;
44 |
45 | results.forEach((result, id) => {
46 | const messages = result.messages;
47 | let testResult = 'ok';
48 | let diagnostics = {};
49 |
50 | if (messages.length > 0) {
51 | messages.forEach(message => {
52 | const severity = getMessageType(message);
53 | const diagnostic = {
54 | message: message.message,
55 | severity,
56 | data: {
57 | line: message.line || 0,
58 | column: message.column || 0,
59 | ruleId: message.ruleId || '',
60 | },
61 | };
62 |
63 | // This ensures a warning message is not flagged as error
64 | if (severity === 'error') {
65 | testResult = 'not ok';
66 | }
67 |
68 | /*
69 | * If we have multiple messages place them under a messages key
70 | * The first error will be logged as message key
71 | * This is to adhere to TAP 13 loosely defined specification of having a message key
72 | */
73 | if ('message' in diagnostics) {
74 | if (typeof diagnostics.messages === 'undefined') {
75 | diagnostics.messages = [];
76 | }
77 | diagnostics.messages.push(diagnostic);
78 | } else {
79 | diagnostics = diagnostic;
80 | }
81 | });
82 | }
83 |
84 | output += `${testResult} ${id + 1} - ${result.filePath}\n`;
85 |
86 | // If we have an error include diagnostics
87 | if (messages.length > 0) {
88 | output += outputDiagnostics(diagnostics);
89 | }
90 | });
91 |
92 | return output;
93 | };
--------------------------------------------------------------------------------
/packages/eslint-formatter-stylish/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview Stylish reporter
3 | * @author Sindre Sorhus
4 | */
5 |
6 | const chalk = require('chalk'),
7 | stripAnsi = require('strip-ansi'),
8 | table = require('text-table');
9 |
10 | //------------------------------------------------------------------------------
11 | // Helpers
12 | //------------------------------------------------------------------------------
13 |
14 | /**
15 | * Given a word and a count, append an s if count is not one.
16 | * @param {string} word A word in its singular form.
17 | * @param {int} count A number controlling whether word should be pluralized.
18 | * @returns {string} The original word with an s on the end if count is not one.
19 | */
20 | function pluralize(word, count) {
21 | return count === 1 ? word : `${word}s`;
22 | }
23 |
24 | //------------------------------------------------------------------------------
25 | // Public Interface
26 | //------------------------------------------------------------------------------
27 |
28 | module.exports = function (results) {
29 | let output = '\n',
30 | errorCount = 0,
31 | warningCount = 0,
32 | fixableErrorCount = 0,
33 | fixableWarningCount = 0,
34 | summaryColor = 'yellow';
35 |
36 | results.forEach(result => {
37 | const messages = result.messages;
38 |
39 | if (messages.length === 0) {
40 | return;
41 | }
42 |
43 | errorCount += result.errorCount;
44 | warningCount += result.warningCount;
45 | fixableErrorCount += result.fixableErrorCount;
46 | fixableWarningCount += result.fixableWarningCount;
47 |
48 | output += `${chalk.underline(result.filePath)}\n`;
49 |
50 | output += `${table(
51 | messages.map(message => {
52 | let messageType;
53 |
54 | if (message.fatal || message.severity === 2) {
55 | messageType = chalk.red('error');
56 | summaryColor = 'red';
57 | } else {
58 | messageType = chalk.yellow('warning');
59 | }
60 |
61 | return ['', message.line || 0, message.column || 0, messageType, message.message.replace(/([^ ])\.$/u, '$1'), chalk.dim(message.ruleId || '')];
62 | }),
63 | {
64 | align: ['', 'r', 'l'],
65 | stringLength(str) {
66 | return stripAnsi(str).length;
67 | },
68 | },
69 | )
70 | .split('\n')
71 | .map(el => el.replace(/(\d+)\s+(\d+)/u, (m, p1, p2) => chalk.dim(`${p1}:${p2}`)))
72 | .join('\n')}\n\n`;
73 | });
74 |
75 | const total = errorCount + warningCount;
76 |
77 | if (total > 0) {
78 | output += chalk[summaryColor].bold(['\u2716 ', total, pluralize(' problem', total), ' (', errorCount, pluralize(' error', errorCount), ', ', warningCount, pluralize(' warning', warningCount), ')\n'].join(''));
79 |
80 | if (fixableErrorCount > 0 || fixableWarningCount > 0) {
81 | output += chalk[summaryColor].bold([' ', fixableErrorCount, pluralize(' error', fixableErrorCount), ' and ', fixableWarningCount, pluralize(' warning', fixableWarningCount), ' potentially fixable with the `--fix` option.\n'].join(''));
82 | }
83 | }
84 |
85 | // Resets output color, for prevent change on top level
86 | return total > 0 ? chalk.reset(output) : '';
87 | };
--------------------------------------------------------------------------------
/formatters.test.js:
--------------------------------------------------------------------------------
1 | import {describe, it, expect} from 'vitest';
2 | import {readdirSync} from 'node:fs';
3 | import {join, dirname} from 'node:path';
4 | import {fileURLToPath} from 'node:url';
5 |
6 | const __dirname = dirname(fileURLToPath(import.meta.url));
7 | const packagesDir = join(__dirname, 'packages');
8 |
9 | // Get all packages that have an index.js file
10 | const packages = readdirSync(packagesDir, {withFileTypes: true})
11 | .filter(dirent => dirent.isDirectory())
12 | .map(dirent => dirent.name)
13 | .filter(name => {
14 | try {
15 | return readdirSync(join(packagesDir, name)).includes('index.js');
16 | } catch {
17 | return false;
18 | }
19 | });
20 |
21 | // Test fixtures
22 | const noErrors = [];
23 |
24 | const singleFile = [
25 | {
26 | filePath: 'foo.js',
27 | messages: [
28 | {
29 | message: 'Unexpected foo.',
30 | severity: 2,
31 | line: 5,
32 | column: 10,
33 | ruleId: 'foo',
34 | },
35 | {
36 | message: 'Missing semicolon.',
37 | severity: 2,
38 | line: 10,
39 | column: 15,
40 | ruleId: 'semi',
41 | },
42 | {
43 | message: 'Unused variable.',
44 | severity: 1,
45 | line: 3,
46 | column: 8,
47 | ruleId: 'no-unused-vars',
48 | },
49 | ],
50 | errorCount: 2,
51 | warningCount: 1,
52 | fixableErrorCount: 1,
53 | fixableWarningCount: 0,
54 | },
55 | ];
56 |
57 | const multipleFiles = [
58 | {
59 | filePath: 'foo.js',
60 | messages: [
61 | {
62 | message: 'Unexpected foo.',
63 | severity: 2,
64 | line: 5,
65 | column: 10,
66 | ruleId: 'foo',
67 | },
68 | ],
69 | errorCount: 1,
70 | warningCount: 0,
71 | fixableErrorCount: 0,
72 | fixableWarningCount: 0,
73 | },
74 | {
75 | filePath: 'bar.js',
76 | messages: [
77 | {
78 | message: 'Unexpected bar.',
79 | severity: 1,
80 | line: 6,
81 | column: 11,
82 | ruleId: 'bar',
83 | },
84 | ],
85 | errorCount: 0,
86 | warningCount: 1,
87 | fixableErrorCount: 0,
88 | fixableWarningCount: 0,
89 | },
90 | {
91 | filePath: 'baz.js',
92 | messages: [
93 | {
94 | message: 'Fatal error parsing file.',
95 | severity: 2,
96 | fatal: true,
97 | line: 1,
98 | column: 1,
99 | ruleId: null,
100 | },
101 | ],
102 | errorCount: 1,
103 | warningCount: 0,
104 | fixableErrorCount: 0,
105 | fixableWarningCount: 0,
106 | },
107 | ];
108 |
109 | const withFixableIssues = [
110 | {
111 | filePath: 'fixable.js',
112 | messages: [
113 | {
114 | message: 'Missing semicolon.',
115 | severity: 2,
116 | line: 5,
117 | column: 20,
118 | ruleId: 'semi',
119 | },
120 | {
121 | message: 'Unexpected trailing comma.',
122 | severity: 2,
123 | line: 8,
124 | column: 15,
125 | ruleId: 'comma-dangle',
126 | },
127 | {
128 | message: 'Prefer const over let.',
129 | severity: 1,
130 | line: 3,
131 | column: 1,
132 | ruleId: 'prefer-const',
133 | },
134 | ],
135 | errorCount: 2,
136 | warningCount: 1,
137 | fixableErrorCount: 2,
138 | fixableWarningCount: 1,
139 | },
140 | ];
141 |
142 | const testCases = [
143 | {name: 'no-errors', fixture: noErrors},
144 | {name: 'single-file', fixture: singleFile},
145 | {name: 'multiple-files', fixture: multipleFiles},
146 | {name: 'with-fixable', fixture: withFixableIssues},
147 | ];
148 |
149 | // Map packages to their appropriate file extensions
150 | const extensionMap = {
151 | 'eslint-formatter-json': '.json',
152 | 'eslint-formatter-json-with-metadata': '.json',
153 | 'eslint-formatter-checkstyle': '.xml',
154 | 'eslint-formatter-jslint-xml': '.xml',
155 | 'eslint-formatter-junit': '.xml',
156 | };
157 |
158 | // Run tests for each package
159 | for (const pkg of packages) {
160 | describe(pkg, async () => {
161 | const formatter = (await import(`./packages/${pkg}/index.js`)).default;
162 | const ext = extensionMap[pkg] || '.log';
163 |
164 | for (const {name, fixture} of testCases) {
165 | it(name, async () => {
166 | const output = formatter(fixture);
167 | await expect(output).toMatchFileSnapshot(`./packages/${pkg}/examples/${name}${ext}`);
168 | });
169 | }
170 | });
171 | }
172 |
--------------------------------------------------------------------------------