Skip to content

Commit 72489d3

Browse files
authored
Add eslint as client side tool docs (#2241)
* add running-eslint.md file * add navigation
1 parent 5d539ee commit 72489d3

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
description: Instructions on how to run ESLint as a client-side tool on Codacy.
3+
tool_name: ESLint
4+
---
5+
6+
# Running ESLint
7+
8+
To run ESLint as a [client-side tool](client-side-tools.md):
9+
10+
11+
<!-- NOTE
12+
include-markdown breaks the final list in two, use include instead. -->
13+
{%
14+
include "../../assets/includes/client-side-tool-instructions.md"
15+
start="<!--instructions-start-->"
16+
end="<!--instructions-end-->"
17+
%}
18+
19+
## Important Concepts
20+
21+
- **`.codacy/codacy.yaml`**: Configuration file to specify `node` and `eslint` versions for the CLI.
22+
23+
```yaml
24+
runtimes:
25+
- node@22.2.0
26+
tools:
27+
- eslint@9.3.0
28+
```
29+
## Manual configuration
30+
31+
```bash
32+
codacy-cli install
33+
codacy-cli analyze -t eslint -o eslint.sarif
34+
codacy-cli upload -s eslint.sarif -c $COMMIT_SHA -t CODACY_PROJECT_TOKEN
35+
```
36+
37+
**If you're using an account API token**, you must also provide the flags `-p`, `-o`, and `-r`. You can obtain the values for these flags from the URL of your repository dashboard on Codacy:
38+
39+
```bash
40+
codacy-cli install
41+
codacy-cli analyze -t eslint -o eslint.sarif
42+
codacy-cli analyze -t eslint -o eslint.sarif -c $COMMIT_SHA -a CODACY_API_TOKEN -p provider (gh|gl|bb) -o ORGANIZATION -r REPOSITORY
43+
```
44+
45+
## GitHub Action
46+
47+
48+
### Using a project token
49+
```yml
50+
- name: Run Codacy CLI
51+
uses: codacy/codacy-cli-v2-action@main
52+
with:
53+
project-token: CODACY_PROJECT_TOKEN
54+
tool: eslint
55+
upload_report: true
56+
```
57+
58+
### Using an account API token
59+
60+
```yml
61+
- name: Run Codacy CLI
62+
uses: codacy/codacy-cli-v2-action@main
63+
with:
64+
api_token: CODACY_API_TOKEN
65+
tool: eslint
66+
upload_report: true
67+
provider: gh
68+
owner: codacy-acme
69+
repository: sample-javascript-project
70+
```
71+
72+
!!! warning "Tokens should be stored in the repository secrets."
73+

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ nav:
591591
- repositories-configure/local-analysis/running-aligncheck.md
592592
- repositories-configure/local-analysis/running-deadcode.md
593593
- repositories-configure/local-analysis/running-spotbugs.md
594+
- repositories-configure/local-analysis/running-eslint.md
594595
- repositories-configure/using-submodules.md
595596
- repositories-configure/codacy-configuration-file.md
596597
- repositories-configure/removing-your-repository.md

0 commit comments

Comments
 (0)