diff options
author | Kristóf Marussy <kristof@marussy.com> | 2021-10-05 21:27:30 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2021-10-05 21:47:45 +0200 |
commit | 5032e0c67792838d6754d172301e2373cf68deb7 (patch) | |
tree | 6ec80e200e15f45659b5be1af4da65729f26d888 /language-web | |
parent | docs: fix typo (diff) | |
download | refinery-5032e0c67792838d6754d172301e2373cf68deb7.tar.gz refinery-5032e0c67792838d6754d172301e2373cf68deb7.tar.zst refinery-5032e0c67792838d6754d172301e2373cf68deb7.zip |
ci(web): add eslint and stylelint to sonar
Diffstat (limited to 'language-web')
-rw-r--r-- | language-web/.eslintrc.ci.js | 33 | ||||
-rw-r--r-- | language-web/.eslintrc.js | 32 | ||||
-rw-r--r-- | language-web/build.gradle | 33 | ||||
-rw-r--r-- | language-web/package.json | 8 | ||||
-rw-r--r-- | language-web/yarn.lock | 5 |
5 files changed, 65 insertions, 46 deletions
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 | ||
3 | module.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 | ||
3 | module.exports = { | 1 | module.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' | |||
27 | apply plugin: 'org.siouan.frontend-jdk11' | 27 | apply plugin: 'org.siouan.frontend-jdk11' |
28 | import org.siouan.frontendgradleplugin.infrastructure.gradle.RunNpmYarn | 28 | import org.siouan.frontendgradleplugin.infrastructure.gradle.RunNpmYarn |
29 | 29 | ||
30 | def nodeDirectory = "${rootDir}/.gradle/node" | ||
31 | |||
30 | frontend { | 32 | frontend { |
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 | ||
52 | tasks.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 | |||
64 | def eslint = tasks.register('eslint', RunNpmYarn) { | 54 | def 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 | ||
3138 | eslint-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 | |||
3138 | eslint-scope@5.1.1, eslint-scope@^5.1.1: | 3143 | eslint-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" |