Skip to content

Commit 00e3fe7

Browse files
committed
docs(plugin-eslint): add formatter docs
1 parent a559959 commit 00e3fe7

File tree

3 files changed

+105
-241
lines changed

3 files changed

+105
-241
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# ESLint Multi-Format Formatter
2+
3+
The ESLint plugin uses a custom formatter that supports multiple output formats and destinations simultaneously.
4+
5+
## Configuration
6+
7+
Use the `ESLINT_FORMATTER_CONFIG` environment variable to configure the formatter with JSON.
8+
9+
### Configuration Schema
10+
11+
```json
12+
{
13+
"outputDir": "./reports", // Optional: Output directory (default: cwd/.eslint)
14+
"filename": "eslint-report", // Optional: Base filename without extension (default: 'eslint-report')
15+
"formats": ["json", "html"], // Optional: Array of format names for file output (default: ['json'])
16+
"terminal": "stylish", // Optional: Format for terminal output (default: 'stylish')
17+
"verbose": true // Optional: Enable verbose logging (default: false)
18+
}
19+
```
20+
21+
### Supported Formats
22+
23+
All standard ESLint formatters are supported:
24+
25+
- `stylish` (default terminal output)
26+
- `json` (default file output)
27+
- `json-with-metadata`
28+
- `html`
29+
- `xml`
30+
- `checkstyle`
31+
- `junit`
32+
- `tap`
33+
- `unix`
34+
- `compact`
35+
- `codeframe`
36+
- `table`
37+
- Custom formatters (any string)
38+
39+
## Usage Examples
40+
41+
### Basic Usage
42+
43+
```bash
44+
# Default behavior - JSON file output + stylish console output
45+
npx eslint .
46+
47+
# Custom output directory and filename
48+
ESLINT_FORMATTER_CONFIG='{"outputDir":"./ci-reports","filename":"lint-results"}' npx eslint .
49+
# Creates: ci-reports/lint-results.json + terminal output
50+
```
51+
52+
### Multiple Output Formats
53+
54+
```bash
55+
# Generate multiple file formats
56+
ESLINT_FORMATTER_CONFIG='{"formats":["json","html","xml"],"terminal":"stylish"}' npx eslint .
57+
# Creates: .eslint/eslint-report.json, .eslint/eslint-report.html, .eslint/eslint-report.xml + terminal output
58+
59+
# Custom directory with multiple formats
60+
ESLINT_FORMATTER_CONFIG='{"outputDir":"./reports","filename":"eslint-results","formats":["json","html","checkstyle"]}' npx eslint .
61+
# Creates: reports/eslint-results.json, reports/eslint-results.html, reports/eslint-results.xml
62+
```
63+
64+
### Terminal Output Only
65+
66+
```bash
67+
# Only show terminal output, no files
68+
ESLINT_FORMATTER_CONFIG='{"formats":[],"terminal":"compact"}' npx eslint .
69+
70+
# Different terminal format
71+
ESLINT_FORMATTER_CONFIG='{"formats":[],"terminal":"unix"}' npx eslint .
72+
```
73+
74+
### Configuration from File
75+
76+
```bash
77+
# Create a configuration file
78+
cat > eslint-config.json << 'EOF'
79+
{
80+
"outputDir": "./ci-reports",
81+
"filename": "eslint-report",
82+
"formats": ["json", "junit"],
83+
"terminal": "stylish",
84+
"verbose": true
85+
}
86+
EOF
87+
88+
# Use the configuration file
89+
ESLINT_FORMATTER_CONFIG="$(cat eslint-config.json)" npx eslint .
90+
```
91+
92+
## Default Behavior
93+
94+
When no `ESLINT_FORMATTER_CONFIG` is provided, the formatter uses these defaults:
95+
96+
- **outputDir**: `./.eslint` (relative to current working directory)
97+
- **filename**: `eslint-report`
98+
- **formats**: `["json"]`
99+
- **terminal**: `stylish`
100+
- **verbose**: `false`
101+
102+
This means by default you get:
103+
104+
- A JSON file at `./.eslint/eslint-report.json`
105+
- Stylish terminal output

tools/eslint-config-examples.md

Lines changed: 0 additions & 107 deletions
This file was deleted.

tools/eslint-programmatic-formatter.cjs

Lines changed: 0 additions & 134 deletions
This file was deleted.

0 commit comments

Comments
 (0)