ci: add eslint and prettier check
authorPetr Štetiar <ynezz@true.cz>
Thu, 6 Aug 2020 11:55:04 +0000 (13:55 +0200)
committerPetr Štetiar <ynezz@true.cz>
Thu, 6 Aug 2020 12:57:56 +0000 (14:57 +0200)
Use opinionated code formatter `prettier` and `eslint` for static code
analysis of JavaScript code.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
.eslintrc.json [new file with mode: 0644]
.gitlab-ci.yml
package.json [new file with mode: 0644]

diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644 (file)
index 0000000..f9bef65
--- /dev/null
@@ -0,0 +1,10 @@
+{
+    "env": {
+        "browser": true,
+        "es2020": true
+    },
+    "extends": [
+           "eslint:recommended",
+           "prettier"
+    ]
+}
index 5a01f2290d7233138ed2ca0b6a725f324604f5a7..f1761b59832f5ac02480fccf3de2e2f9a7c1ab8e 100644 (file)
@@ -6,6 +6,17 @@ stages:
   - pre-build
   - test
 
+check HTML, JS, CSS with eslint and prettier:
+  stage: pre-build
+  image: node
+  cache:
+    paths:
+      - node_modules/
+  script:
+    - yarn install
+    - yarn prettier --check www/
+    - yarn eslint www/
+
 check HTML, CSS and SVG with html5validator:
   stage: pre-build
   image: cyb3rjak3/html5validator:latest
diff --git a/package.json b/package.json
new file mode 100644 (file)
index 0000000..a4bece5
--- /dev/null
@@ -0,0 +1,8 @@
+{
+  "devDependencies": {
+    "eslint": "^7.6.0",
+    "eslint-config-prettier": "^6.11.0",
+    "eslint-plugin-prettier": "^3.1.4",
+    "prettier": "^2.0.5"
+  }
+}