vogler / free-games-claimer

Automatically claims free games on the Epic Games Store, Amazon Prime Gaming and GOG.
GNU Affero General Public License v3.0
2.46k stars 149 forks source link

Sonarqube support with ESLint #228

Closed 4n4n4s closed 11 months ago

4n4n4s commented 1 year ago

Added sonarqube analysis.

To enable you: 1) need to create an organization on sonarcloud with your github user and setup a project for free-games-claimer github project 2) create a token at https://sonarcloud.io/account/security and add it as "SONAR_TOKEN" to the projects secrets 3) https://sonarcloud.io/project/analysis_method?id=vogler_free-games-claimer change analysis to not use "Automatic Analysis"

In the .eslintrc.cjs we can also add new rules like I added for now 'semi': 'error' so we enforce to have semicolons at the end of each line.

You can also use the ESLint addon in VSCode/Coduim and it also uses the .eslintrc.cjs

We can later also add test coverage and status icons to the README.md about project status.

sonarcloud[bot] commented 11 months ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

vogler commented 11 months ago

Thanks! Signing up and adding the repo on sonarcloud was enough for its automatic analysis. However, this has the following limitations:

This PR adds a GitHub Action for sonarcloud as shown here: https://github.com/SonarSource/sonarcloud-github-action

This allows to integrate eslint into the sonarcloud results: https://docs.sonarsource.com/sonarcloud/enriching/external-analyzer-reports/#javascript

.eslintrc.cjs is close to what npm init @eslint/config would generate, but extends a minimal eslint:recommended instead of something like https://github.com/airbnb/javascript which would cause lots of warnings.

Tried the airbnb style guide for epic-games.js but ended up disabling a lot of rules:

/* eslint-disable no-restricted-syntax */
/* eslint-disable arrow-parens */
/* eslint-disable no-mixed-operators */
/* eslint-disable eqeqeq */
/* eslint-disable no-await-in-loop */
/* eslint-disable no-console */
/* eslint-disable max-len */

So, extending eslint:recommended seems like the better idea. Only thing I had to adjust was 'no-unused-vars': ["error", { "argsIgnorePattern": "^_" }] to not have it warn about _ as unused arg. - https://eslint.org/docs/latest/rules/no-unused-vars#argsignorepattern Also, no-undef needs to be disabled for JS evaluated in the browser context for it to not complain about undef. window etc.

vogler commented 11 months ago

2eaf6f059855187200d60bbf2876ec0d6638acf3 e4e4f2eafa2a186bf25942bac5b06e9053435910 efe4faab3e3027fb347b39f6ac349fcd55ff3a4d