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/README.md b/packages/prettier-config/README.md new file mode 100644 index 0000000000000..f90ae7f0d11a4 --- /dev/null +++ b/packages/prettier-config/README.md @@ -0,0 +1,27 @@ +# 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/lib/index.js b/packages/prettier-config/lib/index.js new file mode 100644 index 0000000000000..17308856dce9d --- /dev/null +++ b/packages/prettier-config/lib/index.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..681c28ea6110c --- /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/index.js" + ], + "main": "lib/index.js", + "publishConfig": { + "access": "public" + } +} diff --git a/packages/prettier-config/test/index.js b/packages/prettier-config/test/index.js new file mode 100644 index 0000000000000..bebedab8802d8 --- /dev/null +++ b/packages/prettier-config/test/index.js @@ -0,0 +1,15 @@ +/** + * External dependencies + */ +import { isPlainObject } from 'lodash'; + +/** + * Internal dependencies + */ +import config from '../lib/'; + +describe( 'prettier config tests', () => { + it( 'should be an object', () => { + expect( isPlainObject( config ) ).toBeTruthy(); + } ); +} ); 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",