@dyb-dev/prettier-config 0.0.1

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 dyb-dev
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,51 @@
1
+ # @dyb-dev/prettier-config
2
+
3
+ `@dyb-dev/prettier-config` 是一个全面的 Prettier 配置包,支持 JavaScript、TypeScript、Vue、Jsonc、JsDoc格式化检查,且额外支持 Html、Markdown、.d.ts格式化检查。此包旨在为你的项目提供统一和一致的编码风格。
4
+
5
+ ## 安装
6
+
7
+ 使用以下命令安装此包,具体取决于你使用的包管理器:
8
+
9
+ ```shell
10
+ # 使用 npm
11
+ npm install @dyb-dev/prettier-config -D
12
+
13
+ # 使用 pnpm
14
+ pnpm add @dyb-dev/prettier-config -D
15
+
16
+ # 使用 yarn
17
+ yarn add @dyb-dev/prettier-config -D
18
+ ```
19
+
20
+ ## 使用方法
21
+
22
+ 在你的 Prettier 配置文件中扩展此配置。你可以在 `.prettierrc.js` 或 `.prettierrc.mjs` 或 `.prettierrc.cjs` 文件中进行配置:
23
+
24
+ `.prettierrc.js` 或 `.prettierrc.mjs` 文件示例
25
+
26
+ ```js
27
+ import prettierConfig from "@dyb-dev/prettier-config"
28
+ export default prettierConfig
29
+ ```
30
+
31
+ `.prettierrc.cjs` 文件示例
32
+
33
+ ```js
34
+ const prettierConfig = require("@dyb-dev/prettier-config")
35
+ module.exports = prettierConfig
36
+ ```
37
+
38
+ ## 功能支持
39
+
40
+ - **JavaScript 格式化**: 支持对普通 JavaScript 文件的代码规范检查。
41
+ - **TypeScript 格式化检查**: 确保你的 TypeScript 代码符合规范,但请注意,你需要额外安装 `typescript` 依赖(`npm install typescript -D`)。
42
+ - **Vue 文件格式化**: 内置对 Vue 文件的支持,确保你的 Vue 组件代码风格统一。
43
+ - **Jsonc 文件格式化**: 支持 JSON with Comments 格式的文件格式化。
44
+ - **JsDoc 格式化**: 确保你的代码注释符合规范,提升代码可读性。
45
+ - **Html 文件格式化**: 支持 HTML 文件的格式化,确保网页结构清晰规范。
46
+ - **Markdown 文件格式化**: 提供对 Markdown 文件的格式化支持,确保文档内容易读且统一。
47
+ - **.d.ts 文件格式化**: 针对 TypeScript 的类型声明文件进行格式化,确保类型定义清晰一致。
48
+
49
+ ### 安装包后无法使用格式化
50
+
51
+ 如果在安装 @dyb-dev/prettier-config 后无法使用格式化功能,可能是因为编辑器尚未加载新的配置。解决方法是 重启 编辑器,然后重新尝试格式化操作。
package/index.cjs ADDED
@@ -0,0 +1,55 @@
1
+ /*
2
+ * @Author: dyb-dev
3
+ * @Date: 2024-08-27 20:52:09
4
+ * @LastEditors: dyb-dev
5
+ * @LastEditTime: 2024-08-27 22:50:43
6
+ * @FilePath: /base-lib/packages/prettier-config/index.cjs
7
+ * @Description: Prettier 配置
8
+ */
9
+
10
+ module.exports = {
11
+ // 指定换行的行长
12
+ printWidth: 130,
13
+ // 指定每个缩进级别的空格数
14
+ tabWidth: 4,
15
+ // 用空格而不是制表符缩进
16
+ useTabs: false,
17
+ // 在语句末尾打印分号
18
+ semi: false,
19
+ // Vue 文件中 <script> 和 <style> 标签内的代码是否缩进
20
+ vueIndentScriptAndStyle: false,
21
+ // 使用双引号而不是单引号
22
+ singleQuote: false,
23
+ // 引用对象中的属性时更改
24
+ quoteProps: "as-needed",
25
+ // 打印对象字面量中括号之间的空格
26
+ bracketSpacing: true,
27
+ // 将多行 HTML(HTML、JSX、Vue、Angular)元素的 > 放在最后一行的末尾,而不是单独放在下一行(不适用于自关闭元素)。
28
+ bracketSameLine: false,
29
+ // 格式化开始位置:从文件顶部开始
30
+ rangeStart: 0,
31
+ // 格式化结束位置:无穷大
32
+ rangeEnd: Infinity,
33
+ // 尾随逗号
34
+ trailingComma: "none",
35
+ // 在 JSX 中使用单引号而不是双引号
36
+ jsxSingleQuote: false,
37
+ // 在唯一的箭头函数参数周围包含括号
38
+ arrowParens: "avoid",
39
+ // Prettier 可以在文件顶部插入一个特殊的 @format 标记,指定该文件已使用 Prettier 格式化
40
+ insertPragma: false,
41
+ // Prettier 可以限制自己只格式化在文件顶部包含特殊注释(称为 pragma)的文件
42
+ requirePragma: false,
43
+ // Prettier 不会更改 Markdown 文本 例如:README.md
44
+ proseWrap: "preserve",
45
+ // 指定 HTML、Vue、Angular 和 Handlebars 的全局空白敏感度,如果行标签可能会改变间距,保留空格,如果是块标签无法影响布局,则去除空格
46
+ htmlWhitespaceSensitivity:
47
+ "css",
48
+ // 维护现有的行结尾(一个文件中的混合值通过查看第一行之后使用的内容来规范化)
49
+ endOfLine: "auto",
50
+ // 控制 Prettier 是否格式化嵌入在文件中的引用代码
51
+ embeddedLanguageFormatting:
52
+ "auto",
53
+ // 不要强制每行使用一个属性
54
+ singleAttributePerLine: false
55
+ }
package/index.mjs ADDED
@@ -0,0 +1,53 @@
1
+ /*
2
+ * @Author: dyb-dev
3
+ * @Date: 2024-08-27 19:36:32
4
+ * @LastEditors: dyb-dev
5
+ * @LastEditTime: 2024-08-27 22:49:34
6
+ * @FilePath: /base-lib/packages/prettier-config/index.mjs
7
+ * @Description: Prettier 配置
8
+ */
9
+
10
+ export default {
11
+ // 指定换行的行长
12
+ printWidth: 130,
13
+ // 指定每个缩进级别的空格数
14
+ tabWidth: 4,
15
+ // 用空格而不是制表符缩进
16
+ useTabs: false,
17
+ // 在语句末尾打印分号
18
+ semi: false,
19
+ // Vue 文件中 <script> 和 <style> 标签内的代码是否缩进
20
+ vueIndentScriptAndStyle: false,
21
+ // 使用双引号而不是单引号
22
+ singleQuote: false,
23
+ // 引用对象中的属性时更改
24
+ quoteProps: "as-needed",
25
+ // 打印对象字面量中括号之间的空格
26
+ bracketSpacing: true,
27
+ // 将多行 HTML(HTML、JSX、Vue、Angular)元素的 > 放在最后一行的末尾,而不是单独放在下一行(不适用于自关闭元素)。
28
+ bracketSameLine: false,
29
+ // 格式化开始位置:从文件顶部开始
30
+ rangeStart: 0,
31
+ // 格式化结束位置:无穷大
32
+ rangeEnd: Infinity,
33
+ // 尾随逗号
34
+ trailingComma: "none",
35
+ // 在 JSX 中使用单引号而不是双引号
36
+ jsxSingleQuote: false,
37
+ // 在唯一的箭头函数参数周围包含括号
38
+ arrowParens: "avoid",
39
+ // Prettier 可以在文件顶部插入一个特殊的 @format 标记,指定该文件已使用 Prettier 格式化
40
+ insertPragma: false,
41
+ // Prettier 可以限制自己只格式化在文件顶部包含特殊注释(称为 pragma)的文件
42
+ requirePragma: false,
43
+ // Prettier 不会更改 Markdown 文本 例如:README.md
44
+ proseWrap: "preserve",
45
+ // 指定 HTML、Vue、Angular 和 Handlebars 的全局空白敏感度,如果行标签可能会改变间距,保留空格,如果是块标签无法影响布局,则去除空格
46
+ htmlWhitespaceSensitivity: "css",
47
+ // 维护现有的行结尾(一个文件中的混合值通过查看第一行之后使用的内容来规范化)
48
+ endOfLine: "auto",
49
+ // 控制 Prettier 是否格式化嵌入在文件中的引用代码
50
+ embeddedLanguageFormatting: "auto",
51
+ // 不要强制每行使用一个属性
52
+ singleAttributePerLine: false
53
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@dyb-dev/prettier-config",
3
+ "version": "0.0.1",
4
+ "description": "Prettier 配置",
5
+ "author": "dyb-dev",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "private": false,
9
+ "main": "./index.cjs",
10
+ "module": "./index.mjs",
11
+ "exports": {
12
+ ".": {
13
+ "require": "./index.cjs",
14
+ "import": "./index.mjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "index.cjs",
19
+ "index.mjs",
20
+ "package.json",
21
+ "README.md"
22
+ ],
23
+ "engines": {
24
+ "node": ">=18.0.0",
25
+ "pnpm": ">=8.15.5"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public",
29
+ "registry": "https://registry.npmjs.org/"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/dyb-dev/base-lib"
34
+ },
35
+ "homepage": "https://github.com/dyb-dev/base-lib/tree/main/packages/prettier-config",
36
+ "bugs": {
37
+ "url": "https://github.com/dyb-dev/base-lib/issues",
38
+ "directory": "https://github.com/dyb-dev/base-lib/tree/main/packages/prettier-config"
39
+ },
40
+ "keywords": [
41
+ "prettier",
42
+ "prettier-config"
43
+ ],
44
+ "devDependencies": {
45
+ "prettier": "^3.3.2"
46
+ },
47
+ "peerDependencies": {
48
+ "prettier": "^3.3.2"
49
+ }
50
+ }