format-code: enable black/isort
* black is a widely used python formatting tool.
* isort is used to order python imports in a consistent way.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I1918421120ce2942f04b9110a2c0f1bd820d21c7
diff --git a/scripts/format-code.sh b/scripts/format-code.sh
index 17a6d1e..f6eaacc 100755
--- a/scripts/format-code.sh
+++ b/scripts/format-code.sh
@@ -29,9 +29,11 @@
commit_spelling \
beautysh \
beautysh_sh \
+ black \
clang_format \
eslint \
flake8 \
+ isort \
prettier \
shellcheck \
)
@@ -176,6 +178,12 @@
beautysh --force-function-style paronly "$@"
}
+LINTER_REQUIRE+=([black]="black")
+LINTER_TYPES+=([black]="python")
+function do_black() {
+ black -l 79 --preview "$@"
+}
+
LINTER_REQUIRE+=([eslint]="eslint;.eslintrc.json;${CONFIG_PATH}/eslint-global-config.json")
LINTER_IGNORE+=([eslint]=".eslintignore")
LINTER_TYPES+=([eslint]="json")
@@ -195,6 +203,12 @@
# disagree on best practices.
}
+LINTER_REQUIRE+=([isort]="isort")
+LINTER_TYPES+=([isort]="python")
+function do_isort() {
+ isort --profile black "$@"
+}
+
LINTER_REQUIRE+=([prettier]="prettier;.prettierrc.yaml;${CONFIG_PATH}/prettierrc.yaml")
LINTER_IGNORE+=([prettier]=".prettierignore")
LINTER_TYPES+=([prettier]="json;markdown;yaml")