diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index daddd39..66e0666 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,7 +31,8 @@ sonar-scanner: - 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..ed73165 --- /dev/null +++ b/smart-hut/.eslintrc @@ -0,0 +1,54 @@ +{ + "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", + "no-unused-expressions": 0, + "chai-friendly/no-unused-expressions": 2, + "indent": [0, 4] + }, + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + "airbnb" + ], + "env": { + "node": true, + "browser": true, + "jest": true + }, + + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + + "settings": { + "react": { + "version": "detect" + } + }, + + "plugins": ["react", "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" } }