format-code: enable prettier
prettier is a formatter for YAML, JSON, Markdown, etc.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I7a47d02ef7382d811423b97a88132aa92b991eed
diff --git a/.prettierrc.yaml b/.prettierrc.yaml
new file mode 120000
index 0000000..b3e0aaf
--- /dev/null
+++ b/.prettierrc.yaml
@@ -0,0 +1 @@
+config/prettierrc.yaml
\ No newline at end of file
diff --git a/config/eslint-global-config.json b/config/eslint-global-config.json
index 4e3da2f..e5dd2bb 100644
--- a/config/eslint-global-config.json
+++ b/config/eslint-global-config.json
@@ -7,5 +7,5 @@
// We dont want to lint the json files in the suprojects, so
// ignoring the json files in the subprojects folder
- "ignorePatterns":["**/meson-*/*.json", "subprojects/**/*.json"]
+ "ignorePatterns": ["**/meson-*/*.json", "subprojects/**/*.json"]
}
diff --git a/config/prettierrc.yaml b/config/prettierrc.yaml
new file mode 100644
index 0000000..a69b879
--- /dev/null
+++ b/config/prettierrc.yaml
@@ -0,0 +1,7 @@
+tabWidth: 4
+printWidth: 80
+proseWrap: "always"
+overrides:
+ - files: "*.md"
+ options:
+ tabWidth: 2
diff --git a/jenkins/README.md b/jenkins/README.md
index b797f88..89be34d 100644
--- a/jenkins/README.md
+++ b/jenkins/README.md
@@ -1,8 +1,8 @@
-These are the top level scripts launched by the [OpenBMC Jenkins
-instance](https://jenkins.openbmc.org):
+These are the top level scripts launched by the
+[OpenBMC Jenkins instance](https://jenkins.openbmc.org):
| Job | Script | Notes |
-| -- | -- | -- |
+| --------------------------------- | ------------------------------- | ---------- |
| CI-MISC/ci-build-seed | jenkins/build-seed | |
| CI-MISC/ci-meta | jenkins/run-meta-ci | Deprecated |
| CI-MISC/ci-openbmc-build-scripts | jenkins/run-build-script-ci | |
diff --git a/scripts/build-unit-test-docker b/scripts/build-unit-test-docker
index fff4b25..1de8f8b 100755
--- a/scripts/build-unit-test-docker
+++ b/scripts/build-unit-test-docker
@@ -817,8 +817,6 @@
rsync \
libcryptsetup-dev
-RUN npm install -g eslint@latest eslint-plugin-json@latest
-
# Kinetic comes with GCC-12, so skip this.
#RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12 \
# --slave /usr/bin/g++ g++ /usr/bin/g++-12 \
@@ -855,6 +853,10 @@
RUN pip3 install meson==0.63.0
RUN pip3 install protobuf
RUN pip3 install requests
+
+RUN npm install -g \
+ eslint@latest eslint-plugin-json@latest \
+ prettier@latest
"""
# Build the base and stage docker images.
diff --git a/scripts/format-code.sh b/scripts/format-code.sh
index b0f56f3..77e8df0 100755
--- a/scripts/format-code.sh
+++ b/scripts/format-code.sh
@@ -30,6 +30,7 @@
clang_format \
eslint \
flake8 \
+ prettier \
shellcheck \
)
LINTERS_DISABLED=()
@@ -176,6 +177,13 @@
# disagree on best practices.
}
+LINTER_REQUIRE+=([prettier]="prettier;.prettierrc.yaml;${CONFIG_PATH}/prettierrc.yaml")
+LINTER_IGNORE+=([prettier]=".prettierignore")
+LINTER_TYPES+=([prettier]="json;markdown;yaml")
+function do_prettier() {
+ prettier --config "${LINTER_CONFIG[prettier]}" --write "$@"
+}
+
LINTER_REQUIRE+=([shellcheck]="shellcheck")
LINTER_IGNORE+=([shellcheck]=".shellcheck-ignore")
LINTER_TYPES+=([shellcheck]="bash;sh")