@javalce/prettier-config 2.0.0 → 2.1.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/README.md +15 -32
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@ This is my personal Prettier configuration.
|
|
|
6
6
|
- [Features](#features)
|
|
7
7
|
- [Installation](#installation)
|
|
8
8
|
- [Usage](#usage)
|
|
9
|
+
- [Extending the shared configuration](#extending-the-shared-configuration)
|
|
9
10
|
|
|
10
11
|
## Features
|
|
11
12
|
|
|
@@ -21,7 +22,7 @@ This is my personal Prettier configuration.
|
|
|
21
22
|
- `arrowParens`: 'always'
|
|
22
23
|
- `plugins`: ['prettier-plugin-packagejson']
|
|
23
24
|
|
|
24
|
-
The `prettier-plugin-packagejson` plugin is used to sort the keys
|
|
25
|
+
The `prettier-plugin-packagejson` plugin is used to sort the keys of a `package.json` file to keep them in a consistent order and make it easier to read.
|
|
25
26
|
|
|
26
27
|
## Installation
|
|
27
28
|
|
|
@@ -43,50 +44,32 @@ yarn add --dev prettier @javalce/prettier-config
|
|
|
43
44
|
|
|
44
45
|
## Usage
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
This shared configuration is exported as a function that receives an optional object with the configuration to be merged with the shared configuration.
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
{
|
|
50
|
-
"prettier": "@javalce/prettier-config"
|
|
51
|
-
}
|
|
52
|
-
```
|
|
49
|
+
The following example to configure Prettier with this shared configuration is using the `prettier.config.js` file using ES Modules, because recently, packages, like eslint, are moving its configuration files from `rc` files to `*.config.js` files.
|
|
53
50
|
|
|
54
|
-
|
|
51
|
+
But you can still use the `.prettierrc.js` file if you prefer. Also, you can use CommonJS if you prefer.
|
|
55
52
|
|
|
56
53
|
```js
|
|
57
|
-
|
|
54
|
+
import { defineConfig } from '@javalce/prettier-config';
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
prettierConfig,
|
|
61
|
-
};
|
|
56
|
+
export default defineConfig();
|
|
62
57
|
```
|
|
63
58
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
```js
|
|
67
|
-
const prettierConfig = require('@javalce/prettier-config');
|
|
59
|
+
### Extending the shared configuration
|
|
68
60
|
|
|
69
|
-
|
|
70
|
-
...prettierConfig,
|
|
71
|
-
// ...yourPrettierConfig
|
|
72
|
-
plugins: [
|
|
73
|
-
...prettierConfig.plugins,
|
|
74
|
-
// ...yourPlugins
|
|
75
|
-
],
|
|
76
|
-
};
|
|
77
|
-
```
|
|
61
|
+
If you want to extend the shared config or override some of its properties, you can pass an object to the `defineConfig` function.
|
|
78
62
|
|
|
79
|
-
|
|
63
|
+
> [!IMPORTANT]
|
|
64
|
+
> The `plugins` property is merged with the shared configuration, not replaced, so it will use the plugins from the shared configuration and the plugins you pass.
|
|
80
65
|
|
|
81
66
|
```js
|
|
82
|
-
import
|
|
67
|
+
import { defineConfig } from '@javalce/prettier-config';
|
|
83
68
|
|
|
84
|
-
export default {
|
|
85
|
-
|
|
86
|
-
// ...yourPrettierConfig
|
|
69
|
+
export default defineConfig({
|
|
70
|
+
semi: false,
|
|
87
71
|
plugins: [
|
|
88
|
-
...prettierConfig.plugins,
|
|
89
72
|
// ...yourPlugins
|
|
90
73
|
],
|
|
91
|
-
};
|
|
74
|
+
});
|
|
92
75
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@javalce/prettier-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Javier's Prettier configuration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prettier"
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
"lint-staged": {
|
|
36
36
|
"*": "prettier -w --ignore-unknown"
|
|
37
37
|
},
|
|
38
|
-
"prettier": "./dist/index.js",
|
|
39
38
|
"dependencies": {
|
|
40
39
|
"prettier-plugin-packagejson": "^2.5.7"
|
|
41
40
|
},
|