From a3b7912c623cff32acfe51c1256146f3b91b4b0b Mon Sep 17 00:00:00 2001 From: MSK Date: Sat, 8 Feb 2020 13:18:10 +0000 Subject: [PATCH] style: format JSON, Markdown and YAML files with Prettier --- .gitignore | 3 +++ .pre-commit-config.yaml | 30 +++++++++++++++++++++--------- .prettierrc.yaml | 14 ++++++++++++++ .vscode/.prettierrc.yaml | 14 ++++++++++++++ 4 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 .prettierrc.yaml create mode 100644 .vscode/.prettierrc.yaml diff --git a/.gitignore b/.gitignore index d977b75..17a70fb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ ansible.cfg # IDEs .vscode/* !.vscode/cSpell.json +!.vscode/extensions.json # pyenv .python-version + +!.prettierrc.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fecad66..d5871b0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,6 @@ # -*- mode: yaml -*- # vim:ts=2:sw=2:ai:si:syntax=yaml --- - minimum_pre_commit_version: 1.16.1 repos: @@ -13,13 +12,26 @@ repos: - id: check-case-conflict - id: check-merge-conflict - id: trailing-whitespace - args: ['--markdown-linebreak-ext=md'] + args: ["--markdown-linebreak-ext=md"] - id: end-of-file-fixer - id: mixed-line-ending - args: ['--fix=lf'] + args: ["--fix=lf"] - id: check-yaml - - id: pretty-format-json - args: ['--autofix', '--indent=2', '--no-sort-keys'] + + # Format JSON, Markdown and YAML files with Prettier. + - repo: https://github.com/prettier/prettier + rev: "1.19.1" + hooks: + - id: prettier + name: Format JSON, Markdown and YAML files + files: "\\.(\ + json\ + |md|markdown|mdown|mkdn\ + |yaml|yml\ + )$" + # Do not run on Git push + stages: [commit] + verbose: false - repo: https://github.com/adrienverge/yamllint.git rev: v1.16.0 @@ -37,10 +49,10 @@ repos: hooks: - id: shellcheck - id: shfmt - args: ['-l', '-i', '4', '-ci', '-w'] + args: ["-l", "-i", "4", "-ci", "-w"] - repo: https://github.com/openstack-dev/bashate.git - rev: '0.6.0' + rev: "0.6.0" hooks: - id: bashate verbose: false @@ -51,9 +63,9 @@ repos: - id: markdownlint - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook.git - rev: '2.0.0' + rev: "2.0.0" hooks: - id: commitlint stages: [commit-msg] - additional_dependencies: ['@commitlint/config-conventional'] + additional_dependencies: ["@commitlint/config-conventional"] verbose: false diff --git a/.prettierrc.yaml b/.prettierrc.yaml new file mode 100644 index 0000000..9c83565 --- /dev/null +++ b/.prettierrc.yaml @@ -0,0 +1,14 @@ +# -*- mode: yaml -*- +# vim:ts=2:sw=2:ai:si:syntax=yaml +# +# Prettier configuration options: +# https://prettier.io/docs/en/options.html +--- +printWidth: 80 +tabWidth: 2 +semi: true +singleQuote: false +useTabs: false +trailingComma: none +endOfLine: lf +proseWrap: preserve diff --git a/.vscode/.prettierrc.yaml b/.vscode/.prettierrc.yaml new file mode 100644 index 0000000..08b1c74 --- /dev/null +++ b/.vscode/.prettierrc.yaml @@ -0,0 +1,14 @@ +# -*- mode: yaml -*- +# vim:ts=2:sw=2:ai:si:syntax=yaml +# +# Prettier configuration options: +# https://prettier.io/docs/en/options.html +--- +printWidth: 80 +tabWidth: 4 +semi: true +singleQuote: false +useTabs: false +trailingComma: none +endOfLine: lf +proseWrap: always