@zjutjh/eslint-config 0.5.1 → 0.5.2
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 +8 -8
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,14 +82,14 @@ $ npm run lint
|
|
|
82
82
|
|
|
83
83
|
很多人在意代码的格式化,这里单独拿出一章讲。
|
|
84
84
|
|
|
85
|
-
支持使用 `@stylistic/eslint-plugin` (lint 工具对格式的检查) 或者传统的 formatter
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
支持使用 `@stylistic/eslint-plugin` (lint 工具对格式的检查) 或者传统的 formatter 工具
|
|
86
|
+
(Prettier) 来对代码进行格式化。具体配置放在 `options.codeStyle` 下面。codeStyle 默认开启,以
|
|
87
|
+
`@stylistic/eslint-plugin` 做为默认的风格规范工具。如果要使用 formatter,需要手动开启。
|
|
88
88
|
|
|
89
|
-
> [!
|
|
90
|
-
>
|
|
89
|
+
> [!IMPORTANT]
|
|
90
|
+
> stylistic 和 formatter 在配置上互斥,选择其中之一即可,我们会保证两者在大部分场景下代码风格的一致性。一般来说,formatter 对格式的要求比 stylistic 更严格。
|
|
91
91
|
|
|
92
|
-
```
|
|
92
|
+
```ts
|
|
93
93
|
// 启用 formatter,可选传入 prettier 的相关配置
|
|
94
94
|
export default [
|
|
95
95
|
...(await zjutjh({
|
|
@@ -101,7 +101,7 @@ export default [
|
|
|
101
101
|
];
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
stylistic 只对 js(x) 和 ts(x) 进行格式化,而 formatter 还对其他文件,如 css,
|
|
104
|
+
stylistic 只对 js(x) 和 ts(x) 进行格式化,而 formatter 还对其他文件,如 css,vue template 等配置了格式化。
|
|
105
105
|
如果你要格式化这些文件,需要配置编辑器来允许 eslint 校验这些类型的文件。
|
|
106
106
|
|
|
107
107
|
```jsonc
|
|
@@ -118,7 +118,7 @@ stylistic 只对 js(x) 和 ts(x) 进行格式化,而 formatter 还对其他文
|
|
|
118
118
|
}
|
|
119
119
|
```
|
|
120
120
|
> [!WARNING]
|
|
121
|
-
> 我们使用 eslint 调用 prettier 可执行文件来进行代码格式化,所以你的编辑器不需要安装 prettier 插件,有 eslint 插件就行。prettier
|
|
121
|
+
> 我们使用 eslint 调用 prettier 可执行文件来进行代码格式化,所以你的编辑器不需要安装 prettier 插件,有 eslint 插件就行。prettier 的格式化配置声明在配置源码内部,如果启用了 prettier 插件,他读取不到内部的配置,会按照默认的配置来格式化,这会导致代码风格不一致。
|
|
122
122
|
|
|
123
123
|
## 开发指南
|
|
124
124
|
|
package/dist/index.js
CHANGED
|
@@ -356,7 +356,7 @@ async function vue(options) {
|
|
|
356
356
|
...pluginVue.configs["flat/recommended"].map((c) => c.rules).reduce((prev, curr) => ({ ...prev, ...curr }), {}),
|
|
357
357
|
...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((prev, curr) => ({ ...prev, ...curr }), {}),
|
|
358
358
|
...pluginVue.configs["flat/strongly-recommended"].map((c) => c.rules).reduce((prev, curr) => ({ ...prev, ...curr }), {}),
|
|
359
|
-
"vue/multi-word-component-names": ["warn", {
|
|
359
|
+
"vue/multi-word-component-names": ["warn", { ignores: ["index"] }],
|
|
360
360
|
"vue/component-name-in-template-casing": ["error", "kebab-case", { "registeredComponentsOnly": true }],
|
|
361
361
|
"vue/max-attributes-per-line": ["error", { "singleline": { "max": 3 } }],
|
|
362
362
|
"vue/prefer-true-attribute-shorthand": ["warn", options?.taro ? "never" : "always"],
|