Issue #115: Add eslint configuration, commands, and pipeline config

This commit is contained in:
Andrea Mocci 2020-05-11 14:29:14 +02:00
parent a576632ef7
commit 50ac55db8b
3 changed files with 69 additions and 4 deletions

View File

@ -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

60
smart-hut/.eslintrc Normal file
View File

@ -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"]
}

View File

@ -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"
}
}