From 7539155864f5b9b3a7fa616d7552d94fe10c9cb4 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Fri, 13 Mar 2020 09:40:01 +0100 Subject: [PATCH] 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",