diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000000..ea807ab0cfa --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,31 @@ +repos: + - repo: https://github.com/ambv/black + rev: 21.12b0 + hooks: + - id: black + language_version: python3.8 + exclude: ingestion/src/metadata/generated + - repo: https://github.com/timothycrosley/isort + rev: 5.9.3 + hooks: + - id: isort + args: ["--profile", "black"] + exclude: ingestion/src/metadata/generated + - repo: local + hooks: + - id: google-style-java + name: Google Java Code Style for Java + description: Formats code in Google's Java codestyle with 120 line length. + entry: scripts/format-code.sh + language: script + files: \.java$ + require_serial: true + - repo: local + hooks: + - id: lint-staged + name: lint-staged + description: Formats TS and JS code. + entry: scripts/lint-staged.sh + language: script + files: \.(js|jsx|ts|tsx)$ + require_serial: true diff --git a/Makefile b/Makefile index eb92e050e94..5cc0e026df3 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ install_dev: precommit_install: @echo "Installing pre-commit hooks" @echo "Make sure to first run `make install_test`" - pre-commit install --config ingestion/.pre-commit-config.yaml + pre-commit install isort: isort $(PY_SOURCE) --skip $(PY_SOURCE)/metadata/generated --profile black --multi-line 3 diff --git a/ingestion/.pre-commit-config.yaml b/ingestion/.pre-commit-config.yaml deleted file mode 100644 index c453b2a3f9b..00000000000 --- a/ingestion/.pre-commit-config.yaml +++ /dev/null @@ -1,13 +0,0 @@ -repos: - - repo: https://github.com/ambv/black - rev: stable - hooks: - - id: black - language_version: python3.8 - exclude: ingestion/src/metadata/generated - - repo: https://github.com/timothycrosley/isort - rev: 5.9.3 - hooks: - - id: isort - args: ["--profile", "black"] - exclude: ingestion/src/metadata/generated diff --git a/openmetadata-ui/src/main/resources/ui/.huskyrc.json b/openmetadata-ui/src/main/resources/ui/.huskyrc.json deleted file mode 100644 index 8a3f53fd926..00000000000 --- a/openmetadata-ui/src/main/resources/ui/.huskyrc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "hooks": { - "pre-commit": "lint-staged --concurrent false" - } -} diff --git a/openmetadata-ui/src/main/resources/ui/package.json b/openmetadata-ui/src/main/resources/ui/package.json index 6da2f3543b2..23abc80f69e 100644 --- a/openmetadata-ui/src/main/resources/ui/package.json +++ b/openmetadata-ui/src/main/resources/ui/package.json @@ -140,7 +140,6 @@ "file-loader": "4.3.0", "fork-ts-checker-webpack-plugin": "^6.0.8", "html-webpack-plugin": "^4.5.1", - "husky": "^4.3.0", "jest": "^26.6.3", "jest-environment-jsdom-fourteen": "^1.0.1", "lint-staged": "^10.3.0", diff --git a/scripts/format-code.sh b/scripts/format-code.sh new file mode 100755 index 00000000000..c4604a16bdf --- /dev/null +++ b/scripts/format-code.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +mvn googleformatter:format@reformat-sources \ No newline at end of file diff --git a/scripts/lint-staged.sh b/scripts/lint-staged.sh new file mode 100755 index 00000000000..c9f6fb56aef --- /dev/null +++ b/scripts/lint-staged.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +cd openmetadata-ui/src/main/resources/ui +npx lint-staged --concurrent false \ No newline at end of file