From 56e8cca025671276ce9863f249b6d93e164e892d Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 1 Jul 2020 12:20:07 -0700 Subject: [PATCH] lint: Add Prettier as a linter for YAML files. Signed-off-by: Anders Kaseorg --- package.json | 1 + tools/lint | 5 +++++ version.py | 2 +- yarn.lock | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e6ff35c5dd..5d806daa65 100644 --- a/package.json +++ b/package.json @@ -96,6 +96,7 @@ "jsdom": "^16.1.0", "nyc": "^15.0.0", "phantomjs-prebuilt": "^2.1.16", + "prettier": "^2.0.5", "puppeteer": "^3.0.0", "source-map": "^0.6.1", "stylelint": "^13.0.0", diff --git a/tools/lint b/tools/lint index f80fb754c1..7d7753cd2a 100755 --- a/tools/lint +++ b/tools/lint @@ -93,6 +93,11 @@ def run() -> None: linter_config.external_linter('isort', ['isort'], ['py'], description="Sorts Python import statements", check_arg=['--check-only', '--diff']) + linter_config.external_linter('prettier', ['node_modules/.bin/prettier'], ['yaml', 'yml'], + check_arg=['--check'], fix_arg=['--write'], + description="Formats YAML files", + # https://github.com/prettier/prettier/pull/8703 + suppress_line=lambda line: line in ["Checking formatting...\n", "All matched files use Prettier code style!\n"]) semgrep_command = ["semgrep", "--config=./tools/semgrep.yml", "--error", # This option is dangerous in the context of running diff --git a/version.py b/version.py index bc735ba09a..215ea56247 100644 --- a/version.py +++ b/version.py @@ -44,4 +44,4 @@ API_FEATURE_LEVEL = 24 # historical commits sharing the same major version, in which case a # minor version bump suffices. -PROVISION_VERSION = '89.3' +PROVISION_VERSION = '89.4' diff --git a/yarn.lock b/yarn.lock index 727aaa5c01..5921615afb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9669,6 +9669,11 @@ prepend-http@^1.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= +prettier@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4" + integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg== + pretty-error@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3"