@javalce/prettier-config 2.0.0 → 2.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/README.md +28 -26
- package/dist/index.cjs +1 -47
- package/dist/index.d.cts +14 -4
- package/dist/index.d.ts +14 -4
- package/dist/index.js +1 -22
- package/package.json +10 -11
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ 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)
|
|
10
|
+
- [TypeScript users:](#typescript-users)
|
|
9
11
|
|
|
10
12
|
## Features
|
|
11
13
|
|
|
@@ -21,12 +23,12 @@ This is my personal Prettier configuration.
|
|
|
21
23
|
- `arrowParens`: 'always'
|
|
22
24
|
- `plugins`: ['prettier-plugin-packagejson']
|
|
23
25
|
|
|
24
|
-
The `prettier-plugin-packagejson` plugin is used to sort the keys
|
|
26
|
+
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
27
|
|
|
26
28
|
## Installation
|
|
27
29
|
|
|
28
30
|
> [!IMPORTANT]
|
|
29
|
-
> Prettier is a peer-dependency of this package
|
|
31
|
+
> Prettier is a peer-dependency of this package and should be installed at the root of your project.
|
|
30
32
|
>
|
|
31
33
|
> See: https://prettier.io/docs/en/install.html
|
|
32
34
|
|
|
@@ -39,54 +41,54 @@ pnpm add --save-dev prettier @javalce/prettier-config
|
|
|
39
41
|
|
|
40
42
|
# If you use yarn
|
|
41
43
|
yarn add --dev prettier @javalce/prettier-config
|
|
44
|
+
|
|
45
|
+
# If you use bun
|
|
46
|
+
bun add --dev prettier @javalce/prettier-config
|
|
42
47
|
```
|
|
43
48
|
|
|
44
49
|
## Usage
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
Since version 2.0.0, the configuration is implemented in TypeScript and the package exports both ESM and CommonJS formats.
|
|
52
|
+
|
|
53
|
+
It is recommended to use a `prettier.config.js` file with ESM syntax, as many tools (like ESLint) are moving from legacy `rc` files to `*.config.js` files for configuration. Example:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import prettierConfig from '@javalce/prettier-config';
|
|
47
57
|
|
|
48
|
-
|
|
49
|
-
{
|
|
50
|
-
"prettier": "@javalce/prettier-config"
|
|
51
|
-
}
|
|
58
|
+
export default prettierConfig;
|
|
52
59
|
```
|
|
53
60
|
|
|
54
|
-
|
|
61
|
+
You can also use `.prettierrc.js` or CommonJS if you prefer:
|
|
55
62
|
|
|
56
63
|
```js
|
|
57
64
|
const prettierConfig = require('@javalce/prettier-config');
|
|
58
|
-
|
|
59
|
-
module.exports = {
|
|
60
|
-
prettierConfig,
|
|
61
|
-
};
|
|
65
|
+
module.exports = prettierConfig;
|
|
62
66
|
```
|
|
63
67
|
|
|
64
|
-
|
|
68
|
+
### Extending the shared configuration
|
|
69
|
+
|
|
70
|
+
If you want to extend the shared config or override some of its properties, you can import and modify the exported object:
|
|
65
71
|
|
|
66
72
|
```js
|
|
67
|
-
|
|
73
|
+
import prettierConfig from '@javalce/prettier-config';
|
|
68
74
|
|
|
69
|
-
|
|
75
|
+
export default {
|
|
70
76
|
...prettierConfig,
|
|
71
|
-
|
|
77
|
+
semi: false,
|
|
72
78
|
plugins: [
|
|
73
79
|
...prettierConfig.plugins,
|
|
74
|
-
// ...
|
|
80
|
+
// ...your plugins
|
|
75
81
|
],
|
|
76
82
|
};
|
|
77
83
|
```
|
|
78
84
|
|
|
79
|
-
|
|
85
|
+
## TypeScript users:
|
|
80
86
|
|
|
81
|
-
|
|
82
|
-
import prettierConfig from '@javalce/prettier-config';
|
|
87
|
+
This package provides type definitions for the configuration. You can import the `Config` type from Prettier for full type safety in your custom config:
|
|
83
88
|
|
|
89
|
+
```js
|
|
90
|
+
/** @type {import('prettier').Config} */
|
|
84
91
|
export default {
|
|
85
|
-
...
|
|
86
|
-
// ...yourPrettierConfig
|
|
87
|
-
plugins: [
|
|
88
|
-
...prettierConfig.plugins,
|
|
89
|
-
// ...yourPlugins
|
|
90
|
-
],
|
|
92
|
+
// ...your config
|
|
91
93
|
};
|
|
92
94
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -1,47 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
defineConfig: () => defineConfig
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(index_exports);
|
|
26
|
-
function defineConfig(config) {
|
|
27
|
-
const { plugins = [], overrides = [], ...customConfig } = config ?? {};
|
|
28
|
-
return {
|
|
29
|
-
printWidth: 100,
|
|
30
|
-
tabWidth: 2,
|
|
31
|
-
useTabs: false,
|
|
32
|
-
endOfLine: "lf",
|
|
33
|
-
trailingComma: "all",
|
|
34
|
-
semi: true,
|
|
35
|
-
singleQuote: true,
|
|
36
|
-
jsxSingleQuote: true,
|
|
37
|
-
bracketSpacing: true,
|
|
38
|
-
arrowParens: "always",
|
|
39
|
-
...customConfig,
|
|
40
|
-
plugins: ["prettier-plugin-packagejson", ...plugins],
|
|
41
|
-
overrides
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
-
0 && (module.exports = {
|
|
46
|
-
defineConfig
|
|
47
|
-
});
|
|
1
|
+
"use strict";var a=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var p=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},u=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of l(e))!o.call(t,i)&&i!==r&&a(t,i,{get:()=>e[i],enumerable:!(n=s(e,i))||n.enumerable});return t};var g=t=>u(a({},"__esModule",{value:!0}),t);var m={};p(m,{default:()=>f});module.exports=g(m);var f={printWidth:100,tabWidth:2,useTabs:!1,endOfLine:"lf",trailingComma:"all",semi:!0,singleQuote:!0,jsxSingleQuote:!0,bracketSpacing:!0,arrowParens:"always",plugins:["prettier-plugin-packagejson"]};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
declare const _default: {
|
|
2
|
+
printWidth: number;
|
|
3
|
+
tabWidth: number;
|
|
4
|
+
useTabs: false;
|
|
5
|
+
endOfLine: "lf";
|
|
6
|
+
trailingComma: "all";
|
|
7
|
+
semi: true;
|
|
8
|
+
singleQuote: true;
|
|
9
|
+
jsxSingleQuote: true;
|
|
10
|
+
bracketSpacing: true;
|
|
11
|
+
arrowParens: "always";
|
|
12
|
+
plugins: string[];
|
|
13
|
+
};
|
|
2
14
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { defineConfig };
|
|
15
|
+
export = _default;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
declare const _default: {
|
|
2
|
+
printWidth: number;
|
|
3
|
+
tabWidth: number;
|
|
4
|
+
useTabs: false;
|
|
5
|
+
endOfLine: "lf";
|
|
6
|
+
trailingComma: "all";
|
|
7
|
+
semi: true;
|
|
8
|
+
singleQuote: true;
|
|
9
|
+
jsxSingleQuote: true;
|
|
10
|
+
bracketSpacing: true;
|
|
11
|
+
arrowParens: "always";
|
|
12
|
+
plugins: string[];
|
|
13
|
+
};
|
|
2
14
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { defineConfig };
|
|
15
|
+
export { _default as default };
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1 @@
|
|
|
1
|
-
|
|
2
|
-
function defineConfig(config) {
|
|
3
|
-
const { plugins = [], overrides = [], ...customConfig } = config ?? {};
|
|
4
|
-
return {
|
|
5
|
-
printWidth: 100,
|
|
6
|
-
tabWidth: 2,
|
|
7
|
-
useTabs: false,
|
|
8
|
-
endOfLine: "lf",
|
|
9
|
-
trailingComma: "all",
|
|
10
|
-
semi: true,
|
|
11
|
-
singleQuote: true,
|
|
12
|
-
jsxSingleQuote: true,
|
|
13
|
-
bracketSpacing: true,
|
|
14
|
-
arrowParens: "always",
|
|
15
|
-
...customConfig,
|
|
16
|
-
plugins: ["prettier-plugin-packagejson", ...plugins],
|
|
17
|
-
overrides
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
defineConfig
|
|
22
|
-
};
|
|
1
|
+
var i={printWidth:100,tabWidth:2,useTabs:!1,endOfLine:"lf",trailingComma:"all",semi:!0,singleQuote:!0,jsxSingleQuote:!0,bracketSpacing:!0,arrowParens:"always",plugins:["prettier-plugin-packagejson"]};export{i as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@javalce/prettier-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Javier's Prettier configuration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prettier"
|
|
@@ -35,21 +35,20 @@
|
|
|
35
35
|
"lint-staged": {
|
|
36
36
|
"*": "prettier -w --ignore-unknown"
|
|
37
37
|
},
|
|
38
|
-
"prettier": "./dist/index.js",
|
|
39
38
|
"dependencies": {
|
|
40
|
-
"prettier-plugin-packagejson": "^2.5.
|
|
39
|
+
"prettier-plugin-packagejson": "^2.5.14"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
43
|
-
"@arethetypeswrong/cli": "^0.
|
|
44
|
-
"@commitlint/cli": "^19.
|
|
45
|
-
"@commitlint/config-conventional": "^19.
|
|
46
|
-
"bumpp": "^
|
|
42
|
+
"@arethetypeswrong/cli": "^0.18.1",
|
|
43
|
+
"@commitlint/cli": "^19.8.1",
|
|
44
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
45
|
+
"bumpp": "^10.1.1",
|
|
47
46
|
"conventional-changelog-cli": "^5.0.0",
|
|
48
47
|
"husky": "^9.1.7",
|
|
49
|
-
"lint-staged": "^
|
|
50
|
-
"prettier": "^3.
|
|
51
|
-
"tsup": "^8.
|
|
52
|
-
"typescript": "^5.
|
|
48
|
+
"lint-staged": "^16.1.0",
|
|
49
|
+
"prettier": "^3.5.3",
|
|
50
|
+
"tsup": "^8.5.0",
|
|
51
|
+
"typescript": "^5.8.3"
|
|
53
52
|
},
|
|
54
53
|
"peerDependencies": {
|
|
55
54
|
"prettier": ">=3.0.0 <4"
|