From 7d82d90ea31689b7235a9282ccd5a2439483bc9f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 10 Oct 2022 08:33:39 +0200 Subject: [PATCH] Add eslint report to sonar MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .eslintrc.js | 1 + .github/workflows/ci.yml | 1 + .gitignore | 3 ++- .prettierignore | 1 + benchmarks/internal/benchmark-utils.js | 19 +++++++++++++++++-- package.json | 1 + sonar-project.properties | 1 + tests/test-utils.js | 8 ++++---- 8 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3e37aad4..11fb2803 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -49,6 +49,7 @@ module.exports = defineConfig({ 'readonly', 'serializable', 'sinon', + 'tsconfig', 'unregister', 'workerpool' ], diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebd5d409..776fa1ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,7 @@ jobs: run: | npm run test npm run coverage + npm run lint:report env: CI: true diff --git a/.gitignore b/.gitignore index edec4c70..99b9a2c2 100644 --- a/.gitignore +++ b/.gitignore @@ -71,5 +71,6 @@ build/config.gypi .eslintcache .history/ .scannerwork -lib *.bak +lib +reports diff --git a/.prettierignore b/.prettierignore index 9ba2f434..99d9d1f9 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,6 @@ .nyc_output/ coverage/ +reports/ docs/ outputs/ lib/ diff --git a/benchmarks/internal/benchmark-utils.js b/benchmarks/internal/benchmark-utils.js index 6c9e23aa..7cb4e54f 100644 --- a/benchmarks/internal/benchmark-utils.js +++ b/benchmarks/internal/benchmark-utils.js @@ -40,14 +40,28 @@ function generateRandomInteger (max, min = 0) { /** * Intentionally inefficient implementation. * - * @param {number} n - * @returns {number} + * @param {number} n - The number of fibonacci numbers to generate. + * @returns {number} - The nth fibonacci number. */ function fibonacci (n) { if (n <= 1) return 1 return fibonacci(n - 1) + fibonacci(n - 2) } +/** + * Intentionally inefficient implementation. + * + * @param {number} n - The number to calculate the factorial of. + * @returns {number} - The factorial of n. + */ +function factorial (n) { + if (n === 0) { + return 1 + } else { + return factorial(n - 1) * n + } +} + const LIST_FORMATTER = new Intl.ListFormat('en-US', { style: 'long', type: 'conjunction' @@ -58,5 +72,6 @@ module.exports = { jsonIntegerSerialization, generateRandomInteger, fibonacci, + factorial, LIST_FORMATTER } diff --git a/package.json b/package.json index 65d18ef1..9280e8e2 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "format": "prettier --loglevel silent --write .; prettierx --write .", "lint": "eslint . --cache", "lint:fix": "eslint . --cache --fix", + "lint:report": "eslint . --cache --format json --output-file reports/eslint.json", "typedoc": "typedoc", "sonar:properties": "./updateSonarProps.sh", "prepublishOnly": "npm run build:prod" diff --git a/sonar-project.properties b/sonar-project.properties index 57349f64..b0039990 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,7 @@ sonar.projectKey=pioardi_poolifier sonar.organization=pioardi sonar.javascript.lcov.reportPaths=coverage/lcov.info +sonar.eslint.reportPaths=reports/eslint.json sonar.projectName=poolifier sonar.projectVersion=2.2.2 sonar.host.url=https://sonarcloud.io diff --git a/tests/test-utils.js b/tests/test-utils.js index e63e14f2..4dace47e 100644 --- a/tests/test-utils.js +++ b/tests/test-utils.js @@ -46,8 +46,8 @@ class TestUtils { /** * Intentionally inefficient implementation. * - * @param {number} n - * @returns {number} + * @param {number} n - The number of fibonacci numbers to generate. + * @returns {number} - The nth fibonacci number. */ static fibonacci (n) { if (n <= 1) return 1 @@ -57,8 +57,8 @@ class TestUtils { /** * Intentionally inefficient implementation. * - * @param {number} n - * @returns {number} + * @param {number} n - The number to calculate the factorial of. + * @returns {number} - The factorial of n. */ static factorial (n) { if (n === 0) { -- 2.34.1