Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Prettier shared config package #20026

Merged
merged 4 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 7 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/prettier-config/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
5 changes: 5 additions & 0 deletions packages/prettier-config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Master

### Initial Release

- The config was extracted from `@wordpress/scripts` package ([#20026](https://github.com/WordPress/gutenberg/pull/20026)).
27 changes: 27 additions & 0 deletions packages/prettier-config/README.md
Original file line number Diff line number Diff line change
@@ -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
```

<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
12 changes: 12 additions & 0 deletions packages/prettier-config/lib/index.js
Original file line number Diff line number Diff line change
@@ -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',
};
31 changes: 31 additions & 0 deletions packages/prettier-config/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
15 changes: 15 additions & 0 deletions packages/prettier-config/test/index.js
Original file line number Diff line number Diff line change
@@ -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();
} );
} );
4 changes: 4 additions & 0 deletions packages/scripts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 1 addition & 12 deletions packages/scripts/config/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -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' );
1 change: 1 addition & 0 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down