From d83e7302306302871c3070d1395a0c6dd7c323d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9lio=20Rocha?= Date: Wed, 23 Oct 2024 15:25:18 +0100 Subject: [PATCH 1/2] add running-eslint.md file --- .../local-analysis/running-eslint.md | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 docs/repositories-configure/local-analysis/running-eslint.md diff --git a/docs/repositories-configure/local-analysis/running-eslint.md b/docs/repositories-configure/local-analysis/running-eslint.md new file mode 100644 index 0000000000..c2f19d792d --- /dev/null +++ b/docs/repositories-configure/local-analysis/running-eslint.md @@ -0,0 +1,71 @@ +--- +description: Instructions on how to run ESLint as a client-side tool on Codacy. +tool_name: ESLint +--- + +# Running ESLint + +To run ESLint as a [client-side tool](client-side-tools.md): + + + +{% + include "../../assets/includes/client-side-tool-instructions.md" + start="" + end="" +%} + +## Important Concepts + +- **`.codacy/codacy.yaml`**: Configuration file to specify `node` and `eslint` versions for the CLI. + ```yaml + runtimes: + - node@22.2.0 + tools: + - eslint@9.3.0 + +## Manual configuration + +```bash +codacy-cli install +codacy-cli analyze -t eslint -o eslint.sarif +codacy-cli upload -s eslint.sarif -c $COMMIT_SHA -t CODACY_PROJECT_TOKEN + +``` + + **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: + + ```bash +codacy-cli install +codacy-cli analyze -t eslint -o eslint.sarif +codacy-cli analyze -t eslint -o eslint.sarif -c $COMMIT_SHA -a CODACY_API_TOKEN -p provider (gh|gl|bb) -o ORGANIZATION -r REPOSITORY + ``` + +## GitHub Action + + + ### Using a project token +```yml +- name: Run Codacy CLI + uses: codacy/codacy-cli-v2-action@main + with: + project-token: CODACY_PROJECT_TOKEN + tool: eslint + upload_report: true +``` + +### Using an account API token + +```yml +- name: Run Codacy CLI + uses: codacy/codacy-cli-v2-action@main + with: + api_token: CODACY_API_TOKEN + tool: eslint + upload_report: true + provider: gh + owner: codacy-acme + repository: sample-javascript-project + +``` From f8e57bfdb5676b0b51ee97b4837eb0344f802419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9lio=20Rocha?= Date: Wed, 23 Oct 2024 15:36:56 +0100 Subject: [PATCH 2/2] add navigation --- .../local-analysis/running-eslint.md | 22 ++++++++++--------- mkdocs.yml | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/repositories-configure/local-analysis/running-eslint.md b/docs/repositories-configure/local-analysis/running-eslint.md index c2f19d792d..072b857e3b 100644 --- a/docs/repositories-configure/local-analysis/running-eslint.md +++ b/docs/repositories-configure/local-analysis/running-eslint.md @@ -19,33 +19,33 @@ To run ESLint as a [client-side tool](client-side-tools.md): ## Important Concepts - **`.codacy/codacy.yaml`**: Configuration file to specify `node` and `eslint` versions for the CLI. - ```yaml - runtimes: - - node@22.2.0 - tools: - - eslint@9.3.0 +```yaml +runtimes: + - node@22.2.0 +tools: + - eslint@9.3.0 +``` ## Manual configuration ```bash codacy-cli install codacy-cli analyze -t eslint -o eslint.sarif codacy-cli upload -s eslint.sarif -c $COMMIT_SHA -t CODACY_PROJECT_TOKEN - ``` **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: - ```bash +```bash codacy-cli install codacy-cli analyze -t eslint -o eslint.sarif codacy-cli analyze -t eslint -o eslint.sarif -c $COMMIT_SHA -a CODACY_API_TOKEN -p provider (gh|gl|bb) -o ORGANIZATION -r REPOSITORY - ``` +``` ## GitHub Action - ### Using a project token +### Using a project token ```yml - name: Run Codacy CLI uses: codacy/codacy-cli-v2-action@main @@ -67,5 +67,7 @@ codacy-cli analyze -t eslint -o eslint.sarif -c $COMMIT_SHA -a CODACY_API_TOKEN provider: gh owner: codacy-acme repository: sample-javascript-project - ``` + +!!! warning "Tokens should be stored in the repository secrets." + diff --git a/mkdocs.yml b/mkdocs.yml index 7066b8ffb6..22c4b1d8b0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -591,6 +591,7 @@ nav: - repositories-configure/local-analysis/running-aligncheck.md - repositories-configure/local-analysis/running-deadcode.md - repositories-configure/local-analysis/running-spotbugs.md + - repositories-configure/local-analysis/running-eslint.md - repositories-configure/using-submodules.md - repositories-configure/codacy-configuration-file.md - repositories-configure/removing-your-repository.md