You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2022/12/21 09:20:11 UTC

[streampipes] 01/03: feat: [apache/streampipes#771] add husky pre commit hook for linting

This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit 5fb5c11c5ccab584c83da5585369955c3a097ce8
Author: Samuel Abt <gi...@samuelabt.de>
AuthorDate: Tue Dec 20 17:59:45 2022 +0100

    feat: [apache/streampipes#771] add husky pre commit hook for linting
---
 ui/.husky/pre-commit  |  4 ++++
 ui/.lintstagedrc.json |  4 ++++
 ui/package.json       | 16 ++++++++++++----
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/ui/.husky/pre-commit b/ui/.husky/pre-commit
new file mode 100755
index 000000000..a0951ea80
--- /dev/null
+++ b/ui/.husky/pre-commit
@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+. "$(dirname -- "$0")/_/husky.sh"
+
+cd ui && npm run lint-staged
diff --git a/ui/.lintstagedrc.json b/ui/.lintstagedrc.json
new file mode 100644
index 000000000..ca7497c49
--- /dev/null
+++ b/ui/.lintstagedrc.json
@@ -0,0 +1,4 @@
+{
+  "*.*": "prettier --check",
+  "src/**/*.ts": ["ng-lint-staged lint --"]
+}
diff --git a/ui/package.json b/ui/package.json
index 9c7934c00..c424637cc 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -18,11 +18,16 @@
     "run-prebuild-script": "node ./deployment/prebuild.js",
     "build": "node ./deployment/prebuild.js && set NODE_OPTIONS=--max-old-space-size=8192 && npm run build-libraries && ng build --configuration production",
     "build-dev": "node ./deployment/prebuild.js && set NODE_OPTIONS=--max-old-space-size=8192 && npm run build-libraries && ng build",
-    "lint": "prettier --check . && ng lint",
+    "lint": "ng lint",
+    "lint:fix": "ng lint --fix",
+    "format": "prettier --check .",
+    "format:fix": "prettier --fix .",
+    "lint-staged": "lint-staged",
     "analyze": "webpack-bundle-analyzer dist/stats.json",
     "test-cypress-open": "cypress open",
     "test-cypress-smoke": "npx cypress run --spec 'cypress/tests/**/*.smoke.spec.ts'",
-    "test-cypress-all": "npx cypress run --spec 'cypress/tests/**/*.spec.ts'"
+    "test-cypress-all": "npx cypress run --spec 'cypress/tests/**/*.spec.ts'",
+    "prepare": "cd ../ && husky install ./ui/.husky"
   },
   "peerDependencies": {
     "@streampipes/platform-services": "0.0.1",
@@ -120,9 +125,10 @@
     "csv-string": "^4.1.0",
     "cypress": "^10.9.0",
     "cypress-file-upload": "^5.0.8",
-    "eslint": "8.22.0",
+    "eslint": "8.28.0",
     "eslint-config-prettier": "^8.5.0",
     "html-webpack-plugin": "^5.5.0",
+    "husky": "^8.0.2",
     "jasmine-core": "^3.6.0",
     "js-yaml": "^3.14.0",
     "karma": "~6.3.4",
@@ -132,10 +138,12 @@
     "karma-jasmine": "~4.0.0",
     "karma-jasmine-html-reporter": "^1.5.0",
     "karma-verbose-reporter": "0.0.6",
+    "lint-staged": "^13.1.0",
     "mustache": "^2.3.0",
+    "ng-lint-staged": "^12.0.4",
     "ng-packagr": "^14.2.2",
     "path": "^0.12.7",
-    "prettier": "1.14.2",
+    "prettier": "2.8.0",
     "raw-loader": "^4.0.2",
     "resize-observer-polyfill": "^1.5.1",
     "to-string-loader": "^1.1.5",