@wordpress/prettier-config 1.2.0-next.e230fbab09.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.2.0 (2022-04-21)
6
+
7
+ ### Enhancement
8
+
9
+ - Add additional configuration for CSS styles to better align with [CSS Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/css/) ([#40479](https://github.com/WordPress/gutenberg/pull/40479)).
10
+
11
+ ### Bug Fix
12
+
13
+ - Ensure that the config can work with both `prettier` and `wp-prettier` without reporting warnings ([#40479](https://github.com/WordPress/gutenberg/pull/40479)).
14
+
5
15
  ## 1.0.0 (2021-01-21)
6
16
 
7
17
  ### Breaking Changes
package/lib/index.js CHANGED
@@ -1,4 +1,9 @@
1
- /** @typedef {import('prettier').Options} PrettierOptions */
1
+ /**
2
+ * External dependencies
3
+ */
4
+ const prettierPackage = require( require.resolve( 'prettier/package.json' ) );
5
+
6
+ /** @typedef {import('prettier').Config} PrettierConfig */
2
7
 
3
8
  /**
4
9
  * @typedef WPPrettierOptions
@@ -6,10 +11,15 @@
6
11
  * @property {boolean} [parenSpacing=true] Insert spaces inside parentheses.
7
12
  */
8
13
 
14
+ const isWPPrettier = prettierPackage.name === 'wp-prettier';
15
+ const customOptions = isWPPrettier
16
+ ? { parenSpacing: true, jsxBracketSameLine: false }
17
+ : { bracketSameLine: false };
18
+ const customStyleOptions = isWPPrettier ? { parenSpacing: false } : {};
19
+
9
20
  // Disable reason: The current JSDoc tooling does not yet understand TypeScript
10
21
  // union types.
11
-
12
- /** @type {PrettierOptions & WPPrettierOptions} */
22
+ /** @type {PrettierConfig & WPPrettierOptions} */
13
23
  const config = {
14
24
  useTabs: true,
15
25
  tabWidth: 4,
@@ -17,10 +27,18 @@ const config = {
17
27
  singleQuote: true,
18
28
  trailingComma: 'es5',
19
29
  bracketSpacing: true,
20
- parenSpacing: true,
21
- jsxBracketSameLine: false,
22
30
  semi: true,
23
31
  arrowParens: 'always',
32
+ ...customOptions,
33
+ overrides: [
34
+ {
35
+ files: '*.{css,sass,scss}',
36
+ options: {
37
+ singleQuote: false,
38
+ ...customStyleOptions,
39
+ },
40
+ },
41
+ ],
24
42
  };
25
43
 
26
44
  module.exports = config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/prettier-config",
3
- "version": "1.2.0-next.e230fbab09.0",
3
+ "version": "1.2.0",
4
4
  "description": "WordPress Prettier shared configuration.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,8 +27,11 @@
27
27
  ],
28
28
  "main": "lib/index.js",
29
29
  "types": "build-types",
30
+ "peerDependencies": {
31
+ "prettier": ">=2"
32
+ },
30
33
  "publishConfig": {
31
34
  "access": "public"
32
35
  },
33
- "gitHead": "308df03e6a96ded732f9c4e32471b1b4f8dea54a"
36
+ "gitHead": "1ba52312b56db563df2d8d4fba5b00613fb46d8c"
34
37
  }