From 50ac55db8ba8ef965fbc3a57bc1de45dbd90e3a4 Mon Sep 17 00:00:00 2001 From: Andrea Mocci Date: Mon, 11 May 2020 14:29:14 +0200 Subject: [PATCH 1/3] Issue #115: Add eslint configuration, commands, and pipeline config --- .gitlab-ci.yml | 7 ++--- smart-hut/.eslintrc | 60 ++++++++++++++++++++++++++++++++++++++++++ smart-hut/package.json | 6 ++++- 3 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 smart-hut/.eslintrc diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index daddd39..afa202c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,11 +27,12 @@ testing_testing: sonar-scanner: stage: code_quality - only: - - dev + # only: + # - dev script: - cd smart-hut - - yarn sonar-scanner -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN -Dsonar.projectName=$CI_PROJECT_PATH_SLUG -Dsonar.projectKey=$CI_PROJECT_PATH_SLUG -Dsonar.exclusion=cypress -Dsonar.sources=src -Dsonar.javascript.file.suffixes=.js,.jsx -Dsonar.sourceEncoding=UTF-8 -Dsonar.scm.disabled=True + - yarn eslint:report || true + - yarn sonar-scanner -Dsonar.host.url=$SONAR_URL -Dsonar.login=$SONAR_LOGIN -Dsonar.projectName=$CI_PROJECT_PATH_SLUG -Dsonar.projectKey=$CI_PROJECT_PATH_SLUG -Dsonar.exclusion=cypress -Dsonar.sources=src -Dsonar.javascript.file.suffixes=.js,.jsx -Dsonar.sourceEncoding=UTF-8 -Dsonar.scm.disabled=True -Dsonar.eslint.reportPaths=eslint-report.json smartHut_deploy: stage: deploy diff --git a/smart-hut/.eslintrc b/smart-hut/.eslintrc new file mode 100644 index 0000000..d1dbd6e --- /dev/null +++ b/smart-hut/.eslintrc @@ -0,0 +1,60 @@ +{ + "parser": "babel-eslint", + "parserOptions": { + "ecmaVersion": 2020, + "sourceType": "module", + "ecmaFeatures": { + "jsx": true + } + }, + "rules": { + "semi": "error", + "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], + "react/jsx-no-bind": [ + "error", + { + "allowArrowFunctions": true, + "allowBind": false, + "ignoreRefs": true + } + ], + "react/no-did-update-set-state": "error", + "react/no-unknown-property": "error", + "react/no-unused-prop-types": "error", + "react/prop-types": "error", + "react/react-in-jsx-scope": "error", + "cypress/no-assigning-return-values": "error", + "cypress/no-unnecessary-waiting": "error", + "cypress/assertion-before-screenshot": "warn", + "cypress/no-force": "warn", + "no-unused-expressions": 0, + "chai-friendly/no-unused-expressions": 2, + "indent": [0, 4] + }, + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:cypress/recommended", + "airbnb" + ], + "env": { + "node": true, + "browser": true, + "jest": true, + "cypress/globals": true + }, + + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + + "settings": { + "react": { + "version": "detect" + } + }, + + "plugins": ["react", "cypress", "chai-friendly"] +} + diff --git a/smart-hut/package.json b/smart-hut/package.json index 664eb89..f3140c7 100644 --- a/smart-hut/package.json +++ b/smart-hut/package.json @@ -36,6 +36,8 @@ "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", + "eslint": "eslint src", + "eslint:report": "eslint src -f json -o eslint-report.json", "eject": "react-scripts eject" }, "eslintConfig": { @@ -55,6 +57,8 @@ }, "devDependencies": { "prettier": "2.0.1", - "sonarqube-scanner": "^2.6.0" + "sonarqube-scanner": "^2.6.0", + "eslint-config-airbnb": "^18.1.0", + "eslint-plugin-chai-friendly": "^0.6.0" } } From 22d0ba078ab65a2045cd6a7b0319d7eae6dbe6fc Mon Sep 17 00:00:00 2001 From: Andrea Mocci Date: Mon, 11 May 2020 14:40:15 +0200 Subject: [PATCH 2/3] Issue #115: Remove cypress config for eslint --- smart-hut/.eslintrc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/smart-hut/.eslintrc b/smart-hut/.eslintrc index d1dbd6e..ed73165 100644 --- a/smart-hut/.eslintrc +++ b/smart-hut/.eslintrc @@ -23,10 +23,6 @@ "react/no-unused-prop-types": "error", "react/prop-types": "error", "react/react-in-jsx-scope": "error", - "cypress/no-assigning-return-values": "error", - "cypress/no-unnecessary-waiting": "error", - "cypress/assertion-before-screenshot": "warn", - "cypress/no-force": "warn", "no-unused-expressions": 0, "chai-friendly/no-unused-expressions": 2, "indent": [0, 4] @@ -34,14 +30,12 @@ "extends": [ "eslint:recommended", "plugin:react/recommended", - "plugin:cypress/recommended", "airbnb" ], "env": { "node": true, "browser": true, - "jest": true, - "cypress/globals": true + "jest": true }, "globals": { @@ -55,6 +49,6 @@ } }, - "plugins": ["react", "cypress", "chai-friendly"] + "plugins": ["react", "chai-friendly"] } From 19efeb22de2972d1242f003c2cc5dc1f1a52cba0 Mon Sep 17 00:00:00 2001 From: Andrea Mocci Date: Mon, 11 May 2020 14:54:34 +0200 Subject: [PATCH 3/3] Issue #115: Run code quality pipeline only on dev --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index afa202c..66e0666 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,8 +27,8 @@ testing_testing: sonar-scanner: stage: code_quality - # only: - # - dev + only: + - dev script: - cd smart-hut - yarn eslint:report || true