From 34e4df5902a721717506428112680c104883850d Mon Sep 17 00:00:00 2001 From: Stephen Edgar Date: Tue, 4 Feb 2020 20:37:06 +1100 Subject: [PATCH 1/4] Add Prettier shared config package --- packages/prettier-config/README.md | 28 +++++++++++++++++ .../__tests__/prettier-config.test.js | 15 +++++++++ .../prettier-config/lib/prettier-config.js | 12 +++++++ packages/prettier-config/package.json | 31 +++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 packages/prettier-config/README.md create mode 100644 packages/prettier-config/__tests__/prettier-config.test.js create mode 100644 packages/prettier-config/lib/prettier-config.js create mode 100644 packages/prettier-config/package.json diff --git a/packages/prettier-config/README.md b/packages/prettier-config/README.md new file mode 100644 index 0000000000000..d5f20d5f775be --- /dev/null +++ b/packages/prettier-config/README.md @@ -0,0 +1,28 @@ +# Prettier Config + +WordPress Prettier shareable config for [Prettier](https://prettier.io). + +## Installation + +Install the module + +```shell +$ npm install @wordpress/Prettier-config --save-dev +``` + +## Usage + +Add this to your `package.json` file: + +```json +prettier": "@wordpress/prettier-config" +] +``` + +Alternatively, add this to `.prettierrc` file: + +``` +extends @wordpress/prettier-config +``` + +

Code is Poetry.

diff --git a/packages/prettier-config/__tests__/prettier-config.test.js b/packages/prettier-config/__tests__/prettier-config.test.js new file mode 100644 index 0000000000000..49ef7fe31c8ad --- /dev/null +++ b/packages/prettier-config/__tests__/prettier-config.test.js @@ -0,0 +1,15 @@ +/** + * External dependencies + */ +import { isPlainObject } from 'lodash'; + +/** + * Internal dependencies + */ +import config from '../lib/prettier-config.js'; + +describe( 'prettier config tests', () => { + it( 'should be an object', () => { + expect( isPlainObject( config ) ).toBeTruthy(); + } ); +} ); diff --git a/packages/prettier-config/lib/prettier-config.js b/packages/prettier-config/lib/prettier-config.js new file mode 100644 index 0000000000000..17308856dce9d --- /dev/null +++ b/packages/prettier-config/lib/prettier-config.js @@ -0,0 +1,12 @@ +module.exports = { + useTabs: true, + tabWidth: 4, + printWidth: 80, + singleQuote: true, + trailingComma: 'es5', + bracketSpacing: true, + parenSpacing: true, + jsxBracketSameLine: false, + semi: true, + arrowParens: 'always', +}; diff --git a/packages/prettier-config/package.json b/packages/prettier-config/package.json new file mode 100644 index 0000000000000..371d0f5d02bed --- /dev/null +++ b/packages/prettier-config/package.json @@ -0,0 +1,31 @@ +{ + "name": "@wordpress/prettier-config", + "version": "0.0.1", + "description": "WordPress Prettier shared configuration.", + "author": "The WordPress Contributors", + "license": "GPL-2.0-or-later", + "keywords": [ + "wordpress", + "prettier", + "prettier-config" + ], + "homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/prettier-config/README.md", + "repository": { + "type": "git", + "url": "https://github.com/WordPress/gutenberg.git", + "directory": "packages/prettier-config" + }, + "bugs": { + "url": "https://github.com/WordPress/gutenberg/issues" + }, + "engines": { + "node": ">=10" + }, + "files": [ + "lib/prettier-config.js" + ], + "main": "lib/prettier-config.js", + "publishConfig": { + "access": "public" + } +} From eea3bc78cc18bb6128309857a334d9e1eb239f5a Mon Sep 17 00:00:00 2001 From: Stephen Edgar Date: Tue, 4 Feb 2020 20:51:19 +1100 Subject: [PATCH 2/4] Update packages/prettier-config/README.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Grzegorz (Greg) Ziółkowski --- packages/prettier-config/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/prettier-config/README.md b/packages/prettier-config/README.md index d5f20d5f775be..13738d27d591e 100644 --- a/packages/prettier-config/README.md +++ b/packages/prettier-config/README.md @@ -7,7 +7,7 @@ WordPress Prettier shareable config for [Prettier](https://prettier.io). Install the module ```shell -$ npm install @wordpress/Prettier-config --save-dev +$ npm install @wordpress/prettier-config --save-dev ``` ## Usage From f0a47329f8f56fe06dc357c5d1b06ac262a5dbb9 Mon Sep 17 00:00:00 2001 From: Stephen Edgar Date: Tue, 4 Feb 2020 20:52:36 +1100 Subject: [PATCH 3/4] Update README.md --- packages/prettier-config/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/prettier-config/README.md b/packages/prettier-config/README.md index 13738d27d591e..f90ae7f0d11a4 100644 --- a/packages/prettier-config/README.md +++ b/packages/prettier-config/README.md @@ -16,7 +16,6 @@ Add this to your `package.json` file: ```json prettier": "@wordpress/prettier-config" -] ``` Alternatively, add this to `.prettierrc` file: From 7539155864f5b9b3a7fa616d7552d94fe10c9cb4 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Fri, 13 Mar 2020 09:40:01 +0100 Subject: [PATCH 4/4] Use @wordpres/prettier-config with @wordpress/scripts --- docs/manifest.json | 6 ++++++ package-lock.json | 9 +++++++-- package.json | 1 + packages/prettier-config/.npmrc | 1 + packages/prettier-config/CHANGELOG.md | 5 +++++ .../lib/{prettier-config.js => index.js} | 0 packages/prettier-config/package.json | 4 ++-- .../prettier-config.test.js => test/index.js} | 2 +- packages/scripts/CHANGELOG.md | 4 ++++ packages/scripts/config/.prettierrc.js | 13 +------------ packages/scripts/package.json | 1 + 11 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 packages/prettier-config/.npmrc create mode 100644 packages/prettier-config/CHANGELOG.md rename packages/prettier-config/lib/{prettier-config.js => index.js} (100%) rename packages/prettier-config/{__tests__/prettier-config.test.js => test/index.js} (83%) diff --git a/docs/manifest.json b/docs/manifest.json index 50fdc3673e7d7..e97610daf02c4 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -1445,6 +1445,12 @@ "markdown_source": "../packages/postcss-themes/README.md", "parent": "packages" }, + { + "title": "@wordpress/prettier-config", + "slug": "packages-prettier-config", + "markdown_source": "../packages/prettier-config/README.md", + "parent": "packages" + }, { "title": "@wordpress/primitives", "slug": "packages-primitives", diff --git a/package-lock.json b/package-lock.json index b906c9019f78e..3f9e70df1bfff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10953,6 +10953,10 @@ "postcss-color-function": "^4.0.1" } }, + "@wordpress/prettier-config": { + "version": "file:packages/prettier-config", + "dev": true + }, "@wordpress/primitives": { "version": "file:packages/primitives", "requires": { @@ -11003,6 +11007,7 @@ "@wordpress/eslint-plugin": "file:packages/eslint-plugin", "@wordpress/jest-preset-default": "file:packages/jest-preset-default", "@wordpress/npm-package-json-lint-config": "file:packages/npm-package-json-lint-config", + "@wordpress/prettier-config": "file:packages/prettier-config", "babel-jest": "^24.9.0", "babel-loader": "^8.0.6", "chalk": "^2.4.2", @@ -19770,7 +19775,7 @@ }, "node-pre-gyp": { "version": "0.12.0", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.12.0.tgz", + "resolved": false, "integrity": "sha512-4KghwV8vH5k+g2ylT+sLTjy5wmUOb9vPhnM8NHvRf9dHmnW/CndrFXy2aRPaPST6dugXSdHXfeaHQm77PIz/1A==", "dev": true, "optional": true, @@ -19789,7 +19794,7 @@ }, "nopt": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "resolved": false, "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", "dev": true, "optional": true, diff --git a/package.json b/package.json index 96271ef7f816b..1e08e1aa9c03e 100644 --- a/package.json +++ b/package.json @@ -105,6 +105,7 @@ "@wordpress/library-export-default-webpack-plugin": "file:packages/library-export-default-webpack-plugin", "@wordpress/npm-package-json-lint-config": "file:packages/npm-package-json-lint-config", "@wordpress/postcss-themes": "file:packages/postcss-themes", + "@wordpress/prettier-config": "file:packages/prettier-config", "@wordpress/scripts": "file:packages/scripts", "babel-loader": "8.0.6", "babel-plugin-emotion": "10.0.27", diff --git a/packages/prettier-config/.npmrc b/packages/prettier-config/.npmrc new file mode 100644 index 0000000000000..43c97e719a5a8 --- /dev/null +++ b/packages/prettier-config/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/packages/prettier-config/CHANGELOG.md b/packages/prettier-config/CHANGELOG.md new file mode 100644 index 0000000000000..6d73529eee219 --- /dev/null +++ b/packages/prettier-config/CHANGELOG.md @@ -0,0 +1,5 @@ +## Master + +### Initial Release + +- The config was extracted from `@wordpress/scripts` package ([#20026](https://github.com/WordPress/gutenberg/pull/20026)). diff --git a/packages/prettier-config/lib/prettier-config.js b/packages/prettier-config/lib/index.js similarity index 100% rename from packages/prettier-config/lib/prettier-config.js rename to packages/prettier-config/lib/index.js diff --git a/packages/prettier-config/package.json b/packages/prettier-config/package.json index 371d0f5d02bed..681c28ea6110c 100644 --- a/packages/prettier-config/package.json +++ b/packages/prettier-config/package.json @@ -22,9 +22,9 @@ "node": ">=10" }, "files": [ - "lib/prettier-config.js" + "lib/index.js" ], - "main": "lib/prettier-config.js", + "main": "lib/index.js", "publishConfig": { "access": "public" } diff --git a/packages/prettier-config/__tests__/prettier-config.test.js b/packages/prettier-config/test/index.js similarity index 83% rename from packages/prettier-config/__tests__/prettier-config.test.js rename to packages/prettier-config/test/index.js index 49ef7fe31c8ad..bebedab8802d8 100644 --- a/packages/prettier-config/__tests__/prettier-config.test.js +++ b/packages/prettier-config/test/index.js @@ -6,7 +6,7 @@ import { isPlainObject } from 'lodash'; /** * Internal dependencies */ -import config from '../lib/prettier-config.js'; +import config from '../lib/'; describe( 'prettier config tests', () => { it( 'should be an object', () => { diff --git a/packages/scripts/CHANGELOG.md b/packages/scripts/CHANGELOG.md index 2d15b6edd3455..9a68b9aad9e32 100644 --- a/packages/scripts/CHANGELOG.md +++ b/packages/scripts/CHANGELOG.md @@ -1,5 +1,9 @@ ## Master +## Internal + +- Package depends now on the shared Prettier config exposed in `@wordpress/prettier-config` dependency ([#20026](https://github.com/WordPress/gutenberg/pull/20026)). + ## 7.1.2 (2020-02-25) ### Bug Fixes diff --git a/packages/scripts/config/.prettierrc.js b/packages/scripts/config/.prettierrc.js index 17308856dce9d..ca2665d67f1b2 100644 --- a/packages/scripts/config/.prettierrc.js +++ b/packages/scripts/config/.prettierrc.js @@ -1,12 +1 @@ -module.exports = { - useTabs: true, - tabWidth: 4, - printWidth: 80, - singleQuote: true, - trailingComma: 'es5', - bracketSpacing: true, - parenSpacing: true, - jsxBracketSameLine: false, - semi: true, - arrowParens: 'always', -}; +module.exports = require( '@wordpress/prettier-config' ); diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 753ba80ed431a..74e202412d508 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -39,6 +39,7 @@ "@wordpress/eslint-plugin": "file:../eslint-plugin", "@wordpress/jest-preset-default": "file:../jest-preset-default", "@wordpress/npm-package-json-lint-config": "file:../npm-package-json-lint-config", + "@wordpress/prettier-config": "file:../prettier-config", "babel-jest": "^24.9.0", "babel-loader": "^8.0.6", "chalk": "^2.4.2",