@javalce/prettier-config 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Javier Valero Cejudo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # My Prettier Configuration
2
+
3
+ This is my personal Prettier configuration.
4
+
5
+ - [My Prettier Configuration](#my-prettier-configuration)
6
+ - [Features](#features)
7
+ - [Installation](#installation)
8
+ - [Usage](#usage)
9
+
10
+ ## Features
11
+
12
+ - `printWidth`: 100
13
+ - `tabWidth`: 2
14
+ - `useTabs`: false
15
+ - `endOfLine`: 'lf'
16
+ - `trailingComma`: 'all'
17
+ - `semi`: true
18
+ - `singleQuote`: true
19
+ - `jsxSingleQuote`: true
20
+ - `bracketSpacing`: true
21
+ - `arrowParens`: 'always'
22
+ - `plugins`: ['prettier-plugin-packagejson']
23
+
24
+ The `prettier-plugin-packagejson` plugin is used to sort the keys ofm a `package.json` file to keep them in a consistent order and make it easier to read.
25
+
26
+ ## Installation
27
+
28
+ > [!IMPORTANT]
29
+ > Prettier is a peer-dependency of this package, and should be installed at the root of your project.
30
+ >
31
+ > See: https://prettier.io/docs/en/install.html
32
+
33
+ ```sh
34
+ # If you use npm
35
+ npm install --save-dev prettier @javalce/prettier-config
36
+
37
+ # If you use pnpm
38
+ pnpm add --save-dev prettier @javalce/prettier-config
39
+
40
+ # If you use yarn
41
+ yarn add --dev prettier @javalce/prettier-config
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ To use this config, set the following in `package.json`.
47
+
48
+ ```json
49
+ {
50
+ "prettier": "@javalce/prettier-config"
51
+ }
52
+ ```
53
+
54
+ or create a `.prettierrc.cjs` file with the following content:
55
+
56
+ ```js
57
+ const prettierConfig = require('@javalce/prettier-config');
58
+
59
+ module.exports = {
60
+ prettierConfig,
61
+ };
62
+ ```
63
+
64
+ If you want to extend the shared config, you can do so by creating a `.prettierrc.cjs` file with the following content:
65
+
66
+ ```js
67
+ const prettierConfig = require('@javalce/prettier-config');
68
+
69
+ module.exports = {
70
+ ...prettierConfig,
71
+ // ...yourPrettierConfig
72
+ plugins: [
73
+ ...prettierConfig.plugins,
74
+ // ...yourPlugins
75
+ ],
76
+ };
77
+ ```
78
+
79
+ or by using ESM (`.prettierrc.mjs` or `prettierrc.js` if the `package.json` has `"type": "module"`):
80
+
81
+ ```js
82
+ import prettierConfig from '@javalce/prettier-config';
83
+
84
+ export default {
85
+ ...prettierConfig,
86
+ // ...yourPrettierConfig
87
+ plugins: [
88
+ ...prettierConfig.plugins,
89
+ // ...yourPlugins
90
+ ],
91
+ };
92
+ ```
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@javalce/prettier-config",
3
+ "version": "1.0.0",
4
+ "description": "Javier's Prettier configuration",
5
+ "keywords": [
6
+ "prettier"
7
+ ],
8
+ "homepage": "https://github.com/javalce/prettier-config#readme",
9
+ "bugs": {
10
+ "url": "https://github.com/javalce/prettier-config/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/javalce/prettier-config.git"
15
+ },
16
+ "license": "MIT",
17
+ "author": "Javier Valero <javalce29@gmail.com>",
18
+ "main": "./src/index.js",
19
+ "files": [
20
+ "src"
21
+ ],
22
+ "lint-staged": {
23
+ "*": "prettier -w --ignore-unknown"
24
+ },
25
+ "prettier": "./src/index.js",
26
+ "dependencies": {
27
+ "prettier-plugin-packagejson": "^2.5.0"
28
+ },
29
+ "devDependencies": {
30
+ "@commitlint/cli": "^19.3.0",
31
+ "@commitlint/config-conventional": "^19.2.2",
32
+ "bumpp": "^9.4.1",
33
+ "husky": "^9.0.11",
34
+ "lint-staged": "^15.2.7",
35
+ "prettier": "^3.3.2"
36
+ },
37
+ "peerDependencies": {
38
+ "prettier": ">=3.0.0 <4"
39
+ },
40
+ "peerDependenciesMeta": {
41
+ "prettier": {
42
+ "optional": true
43
+ }
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "scripts": {
49
+ "format": "prettier --write .",
50
+ "format:check": "prettier --check .",
51
+ "release": "bumpp && pnpm publish"
52
+ }
53
+ }
package/src/index.js ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Some of Prettier's defaults can be overridden by an EditorConfig file. We
3
+ * define those here to ensure that doesn't happen.
4
+ *
5
+ * See: https://github.com/prettier/prettier/blob/main/docs/configuration.md#editorconfig
6
+ */
7
+ const overridableDefaults = {
8
+ printWidth: 100,
9
+ tabWidth: 2,
10
+ useTabs: false,
11
+ endOfLine: 'lf',
12
+ };
13
+
14
+ /** @type {import('prettier').Config} */
15
+ module.exports = {
16
+ ...overridableDefaults,
17
+ trailingComma: 'all',
18
+ semi: true,
19
+ singleQuote: true,
20
+ jsxSingleQuote: true,
21
+ bracketSpacing: true,
22
+ arrowParens: 'always',
23
+ plugins: ['prettier-plugin-packagejson'],
24
+ };