aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2021-10-05 21:27:30 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2021-10-05 21:47:45 +0200
commit5032e0c67792838d6754d172301e2373cf68deb7 (patch)
tree6ec80e200e15f45659b5be1af4da65729f26d888
parentdocs: fix typo (diff)
downloadrefinery-5032e0c67792838d6754d172301e2373cf68deb7.tar.gz
refinery-5032e0c67792838d6754d172301e2373cf68deb7.tar.zst
refinery-5032e0c67792838d6754d172301e2373cf68deb7.zip
ci(web): add eslint and stylelint to sonar
-rw-r--r--.github/workflows/build.yml2
-rw-r--r--language-web/.eslintrc.ci.js33
-rw-r--r--language-web/.eslintrc.js32
-rw-r--r--language-web/build.gradle33
-rw-r--r--language-web/package.json8
-rw-r--r--language-web/yarn.lock5
6 files changed, 66 insertions, 47 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index bb6b26cb..bc82ed7f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -44,4 +44,4 @@ jobs:
44 env: 44 env:
45 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed by Sonar to get PR information, if any 45 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed by Sonar to get PR information, if any
46 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 46 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
47 run: ./gradlew build sonarqube --info 47 run: ./gradlew build sonarqube -Pci --info
diff --git a/language-web/.eslintrc.ci.js b/language-web/.eslintrc.ci.js
new file mode 100644
index 00000000..b4c83bb8
--- /dev/null
+++ b/language-web/.eslintrc.ci.js
@@ -0,0 +1,33 @@
1// Loosely based on
2// https://github.com/iamturns/create-exposed-app/blob/f14e435b8ce179c89cce3eea89e56202153a53da/.eslintrc.js
3module.exports = {
4 plugins: [
5 '@typescript-eslint',
6 ],
7 extends: [
8 'airbnb',
9 'airbnb-typescript',
10 'airbnb/hooks',
11 'plugin:@typescript-eslint/recommended',
12 'plugin:@typescript-eslint/recommended-requiring-type-checking',
13 ],
14 parserOptions: {
15 project: './tsconfig.json',
16 },
17 rules: {
18 // https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
19 'import/prefer-default-export': 'off',
20 'import/no-default-export': 'error',
21 // propTypes are for runtime validation, but we rely on TypeScript for build-time validation:
22 // https://github.com/yannickcr/eslint-plugin-react/issues/2275#issuecomment-492003857
23 'react/prop-types': 'off',
24 // Make sure switches are exhaustive: https://stackoverflow.com/a/60166264
25 'default-case': 'off',
26 '@typescript-eslint/switch-exhaustiveness-check': 'error',
27 },
28 ignorePatterns: [
29 '*.js',
30 'build/**/*',
31 'src/main/js/xtext/**/*',
32 ],
33};
diff --git a/language-web/.eslintrc.js b/language-web/.eslintrc.js
index b4c83bb8..810a5ccd 100644
--- a/language-web/.eslintrc.js
+++ b/language-web/.eslintrc.js
@@ -1,33 +1,9 @@
1// Loosely based on
2// https://github.com/iamturns/create-exposed-app/blob/f14e435b8ce179c89cce3eea89e56202153a53da/.eslintrc.js
3module.exports = { 1module.exports = {
4 plugins: [ 2 plugins: [
5 '@typescript-eslint', 3 'sonarjs',
6 ], 4 ],
7 extends: [ 5 extends: [
8 'airbnb', 6 './.eslintrc.ci.js',
9 'airbnb-typescript', 7 'plugin:sonarjs/recommended',
10 'airbnb/hooks',
11 'plugin:@typescript-eslint/recommended',
12 'plugin:@typescript-eslint/recommended-requiring-type-checking',
13 ], 8 ],
14 parserOptions: { 9}
15 project: './tsconfig.json',
16 },
17 rules: {
18 // https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
19 'import/prefer-default-export': 'off',
20 'import/no-default-export': 'error',
21 // propTypes are for runtime validation, but we rely on TypeScript for build-time validation:
22 // https://github.com/yannickcr/eslint-plugin-react/issues/2275#issuecomment-492003857
23 'react/prop-types': 'off',
24 // Make sure switches are exhaustive: https://stackoverflow.com/a/60166264
25 'default-case': 'off',
26 '@typescript-eslint/switch-exhaustiveness-check': 'error',
27 },
28 ignorePatterns: [
29 '*.js',
30 'build/**/*',
31 'src/main/js/xtext/**/*',
32 ],
33};
diff --git a/language-web/build.gradle b/language-web/build.gradle
index 0403bb3d..526ba2da 100644
--- a/language-web/build.gradle
+++ b/language-web/build.gradle
@@ -27,9 +27,11 @@ def serverMainClass = 'tools.refinery.language.web.ServerLauncher'
27apply plugin: 'org.siouan.frontend-jdk11' 27apply plugin: 'org.siouan.frontend-jdk11'
28import org.siouan.frontendgradleplugin.infrastructure.gradle.RunNpmYarn 28import org.siouan.frontendgradleplugin.infrastructure.gradle.RunNpmYarn
29 29
30def nodeDirectory = "${rootDir}/.gradle/node"
31
30frontend { 32frontend {
31 nodeVersion = project.ext.nodeVersion 33 nodeVersion = project.ext.nodeVersion
32 nodeInstallDirectory = file("${rootDir}/.gradle/node") 34 nodeInstallDirectory = file(nodeDirectory)
33 yarnEnabled = true 35 yarnEnabled = true
34 yarnVersion = project.ext.yarnVersion 36 yarnVersion = project.ext.yarnVersion
35 yarnInstallDirectory = file("${rootDir}/.gradle/yarn") 37 yarnInstallDirectory = file("${rootDir}/.gradle/yarn")
@@ -49,23 +51,16 @@ assembleFrontend.configure {
49 outputs.dir productionResources 51 outputs.dir productionResources
50} 52}
51 53
52tasks.register('webpackStats', RunNpmYarn) {
53 dependsOn installFrontend
54 dependsOn generateXtextLanguage
55 inputs.dir 'src/main/css'
56 inputs.dir 'src/main/html'
57 inputs.dir 'src/main/js'
58 inputs.dir "${buildDir}/generated/sources/xtext/js"
59 inputs.files('package.json', 'yarn.lock', 'webpack.config.js')
60 outputs.file "${buildDir}/webpack/stats.json"
61 script = 'run stats'
62}
63
64def eslint = tasks.register('eslint', RunNpmYarn) { 54def eslint = tasks.register('eslint', RunNpmYarn) {
65 dependsOn installFrontend 55 dependsOn installFrontend
66 inputs.dir 'src/main/js' 56 inputs.dir 'src/main/js'
67 inputs.files('.eslintrc.js', 'tsconfig.json') 57 inputs.files('.eslintrc.js', 'tsconfig.json')
68 script = 'run check:eslint' 58 if (project.hasProperty('ci')) {
59 outputs.file "${buildDir}/eslint.json"
60 script = 'run check:eslint:ci'
61 } else {
62 script = 'run check:eslint'
63 }
69 group = 'verification' 64 group = 'verification'
70 description = 'Check for TypeScript errors.' 65 description = 'Check for TypeScript errors.'
71} 66}
@@ -74,7 +69,12 @@ def stylelint = tasks.register('stylelint', RunNpmYarn) {
74 dependsOn installFrontend 69 dependsOn installFrontend
75 inputs.dir 'src/main/css' 70 inputs.dir 'src/main/css'
76 inputs.file '.stylelintrc.js' 71 inputs.file '.stylelintrc.js'
77 script = 'run check:stylelint' 72 if (project.hasProperty('ci')) {
73 outputs.file "${buildDir}/stylelint.json"
74 script = 'run check:stylelint:ci'
75 } else {
76 script = 'run check:stylelint'
77 }
78 group = 'verification' 78 group = 'verification'
79 description = 'Check for Sass errors.' 79 description = 'Check for Sass errors.'
80} 80}
@@ -142,4 +142,7 @@ sonarqube.properties {
142 'src/main/css/xtext/**', 142 'src/main/css/xtext/**',
143 'src/main/js/xtext/**', 143 'src/main/js/xtext/**',
144 ] 144 ]
145 property 'sonar.nodejs.executable', "${nodeDirectory}/bin/node"
146 property 'sonar.eslint.reportPaths', "${buildDir}/eslint.json"
147 property 'sonar.css.stylelint.reportPaths', "${buildDir}/stylelint.json"
145} 148}
diff --git a/language-web/package.json b/language-web/package.json
index 2dfc6325..7a931d95 100644
--- a/language-web/package.json
+++ b/language-web/package.json
@@ -5,11 +5,12 @@
5 "main": "index.js", 5 "main": "index.js",
6 "scripts": { 6 "scripts": {
7 "assemble": "webpack --node-env production", 7 "assemble": "webpack --node-env production",
8 "stats": "webpack --node-env production --json > build/webpack/stats.json",
9 "serve": "webpack serve --node-env development --hot", 8 "serve": "webpack serve --node-env development --hot",
10 "check": "yarn run check:eslint && yarn run check:stylelint", 9 "check": "yarn run check:eslint && yarn run check:stylelint",
11 "check:eslint": "eslint .", 10 "check:eslint": "eslint .",
12 "check:stylelint": "stylelint src/main/css/**/*.scss" 11 "check:eslint:ci": "eslint -c ./.eslintrc.ci.js -f json -o build/eslint.json .",
12 "check:stylelint": "stylelint src/main/css/**/*.scss",
13 "check:stylelint:ci": "stylelint -f json src/main/css/**/*.scss > build/stylelint.json"
13 }, 14 },
14 "repository": { 15 "repository": {
15 "type": "git", 16 "type": "git",
@@ -33,9 +34,10 @@
33 "eslint-config-airbnb": "^18.2.1", 34 "eslint-config-airbnb": "^18.2.1",
34 "eslint-config-airbnb-typescript": "^14.0.0", 35 "eslint-config-airbnb-typescript": "^14.0.0",
35 "eslint-plugin-import": "^2.24.2", 36 "eslint-plugin-import": "^2.24.2",
37 "eslint-plugin-jsx-a11y": "^6.4.1",
36 "eslint-plugin-react": "^7.26.1", 38 "eslint-plugin-react": "^7.26.1",
37 "eslint-plugin-react-hooks": "^4.2.0", 39 "eslint-plugin-react-hooks": "^4.2.0",
38 "eslint-plugin-jsx-a11y": "^6.4.1", 40 "eslint-plugin-sonarjs": "^0.10.0",
39 "html-webpack-plugin": "^5.3.2", 41 "html-webpack-plugin": "^5.3.2",
40 "image-webpack-loader": "^8.0.1", 42 "image-webpack-loader": "^8.0.1",
41 "magic-comments-loader": "^1.4.1", 43 "magic-comments-loader": "^1.4.1",
diff --git a/language-web/yarn.lock b/language-web/yarn.lock
index 6caa3106..e87bc6ee 100644
--- a/language-web/yarn.lock
+++ b/language-web/yarn.lock
@@ -3135,6 +3135,11 @@ eslint-plugin-react@^7.26.1:
3135 semver "^6.3.0" 3135 semver "^6.3.0"
3136 string.prototype.matchall "^4.0.5" 3136 string.prototype.matchall "^4.0.5"
3137 3137
3138eslint-plugin-sonarjs@^0.10.0:
3139 version "0.10.0"
3140 resolved "https://registry.yarnpkg.com/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.10.0.tgz#2b520c6d0dbdecbea98cd82f5cb84fc5c3d2b954"
3141 integrity sha512-FBRIBmWQh2UAfuLSnuYEfmle33jIup9hfkR0X8pkfjeCKNpHUG8qyZI63ahs3aw8CJrv47QJ9ccdK3ZxKH016A==
3142
3138eslint-scope@5.1.1, eslint-scope@^5.1.1: 3143eslint-scope@5.1.1, eslint-scope@^5.1.1:
3139 version "5.1.1" 3144 version "5.1.1"
3140 resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" 3145 resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"