From fc70c6ecb59013d93d00da6a3d5dfb565bfb2c83 Mon Sep 17 00:00:00 2001 From: Arctic Ice Studio Date: Sat, 22 Jun 2019 21:09:29 +0200 Subject: [PATCH 1/3] Install `prettier` Installed the main `prettier` (1) NPM package. References: (1) npmjs.com/package/prettier Epic: GH-33 Depends on GH-47 GH-49 GH-37 --- package-lock.json | 6 ++++++ package.json | 1 + 2 files changed, 7 insertions(+) diff --git a/package-lock.json b/package-lock.json index 0c27e8a..52b4121 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2178,6 +2178,12 @@ "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", "dev": true }, + "prettier": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz", + "integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==", + "dev": true + }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", diff --git a/package.json b/package.json index 0a0b830..2c58eaa 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ }, "devDependencies": { "npm-run-all": "4.1.5", + "prettier": "1.18.2", "remark-cli": "6.0.1", "remark-preset-lint-arcticicestudio": ">=0.3.0 <1.0.0" }, From d8eefc02ec53f66c2e67bc65d5a8952f44d5a079 Mon Sep 17 00:00:00 2001 From: Arctic Ice Studio Date: Sat, 22 Jun 2019 21:11:44 +0200 Subject: [PATCH 2/3] Implement Prettier configuration and ignore pattern file This is one of the main features of Prettier: It already provides the best and recommended style configurations of-out-the-box. The only option that has been changed is the print width (1). It is set to `80` by default which not up-to-date for modern screens (might only be relevant when working in terminals only like e.g. with Vim). It is now set to `120` used by all of Arctic Ice Studio's style guides. The `prettier.config.js` configuration file is placed in the project root as well as the `.prettierignore` file that defines ignore pattern. References: (1) prettier.io/docs/en/options.html#print-width Epic: GH-33 Depends on GH-47 GH-49 GH-37 --- .prettierignore | 8 ++++++++ prettier.config.js | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .prettierignore create mode 100644 prettier.config.js diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..79a2ddf --- /dev/null +++ b/.prettierignore @@ -0,0 +1,8 @@ +# Copyright (C) 2017-present Arctic Ice Studio +# Copyright (C) 2017-present Sven Greb +# +# Project: snowsaw +# Repository: https://github.com/arcticicestudio/snowsaw +# License: MIT + +**/node_modules/* diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 0000000..ad35a6f --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2017-present Arctic Ice Studio + * Copyright (C) 2017-present Sven Greb + * + * Project: snowsaw + * Repository: https://github.com/arcticicestudio/snowsaw + * License: MIT + * References: + * https://prettier.io/docs/en/configuration.html + * https://prettier.io/docs/en/options.html + */ + +/** + * @file The Prettier configuration. + * @author Arctic Ice Studio + * @author Sven Greb + * @see https://prettier.io/docs/en/configuration.html + */ + +module.exports = { + printWidth: 120 +}; From 87bfb7d7d25451f448a257821b66fa4f11177b6b Mon Sep 17 00:00:00 2001 From: Arctic Ice Studio Date: Sat, 22 Jun 2019 21:14:54 +0200 Subject: [PATCH 3/3] Implement NPM `format:pretty` script/task for Prettier To allow to format all sources the `format:pretty` NPM script/task has been added as well as the `format` script/task to run all tasks of the formatting workflow. Epic: GH-33 Depends on GH-47 GH-49 Resolves GH-37 --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2c58eaa..2723ec3 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,10 @@ "arcticicestudio" ], "scripts": { - "lint": "npm-run-all lint:*", - "lint:md": "remark --no-stdout . \".github/**/*.md\"" + "format:pretty": "prettier --write \"./**/*.{js,json,md,yml}\"", + "format": "npm-run-all format:pretty", + "lint:md": "remark --no-stdout . \".github/**/*.md\"", + "lint": "npm-run-all lint:*" }, "devDependencies": { "npm-run-all": "4.1.5",