Skip to content

Commit 6235a94

Browse files
committed
调整 en eslint-js和eslint-vue
1 parent a48f722 commit 6235a94

File tree

3 files changed

+71
-68
lines changed

3 files changed

+71
-68
lines changed

en/Tutorial/extension/eslint-js.md

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,62 +16,65 @@ Click the menu [Tools] [Settings -> Plugin] [eslint-js], you can see the eslint-
1616

1717
<img src="/static/snapshots/tutorial/plugins/settings_eslint_en.png" class="hd-img"/>
1818

19-
**实时校验、自动修复**
19+
**Real-time verification and automatically fixable**
2020

21-
> HBuilderX 2.6.8+版本起,新增eslint 实时校验、自动修复错误的功能。注意:此功能不适用于2.6.8之前的版本
21+
> Only supports HBuilderX 2.6.8+ version
2222
23-
1. 使用此功能,必须安装[eslint-js](https://ext.dcloud.net.cn/plugin?id=2037)插件
24-
2. `vue-cli`项目,需要安装eslint库,并配置eslint规则.
25-
3. 若满足上述条件,当编写完代码,保存时,若代码中存在错误,自动修复;
26-
4. 实时校验功能,默认未开启,需要手动开启此功能
23+
1. To use this function, you must install the [eslint-js](https://ext.dcloud.net.cn/plugin?id=2037) plugin
24+
2. The `vue-cli` project needs to install the eslint library and configure the eslint rules.
25+
3. If the above conditions are met, when the code is written and saved, if there is an error in the code, it will be automatically repaired;
26+
4. Real-time verification function, not enabled by default, you need to manually enable this function
2727

2828

29-
## eslint-js config file
29+
## HBuilderX eslint-js configuration files
3030

31-
eslint-js的配置文件为.eslintrc.js。
32-
点击菜单工具 -> 插件配置 -> eslint-js -> .eslintrc.js,即可打开.eslintrc.js文件。
31+
The configuration file of eslint-js is `.eslintrc.js`.
3332

34-
选项对应说明如下:
33+
Click on the menu Tools -> Plugins -> eslint-js -> .eslintrc.js to open the `.eslintrc.js` file.
34+
35+
The configuration file is as follows:
3536

3637
```js
3738
module.exports = {
38-
"plugins": [], //插件
39+
"plugins": [],
3940
"env": {
4041
"browser": true,
4142
"node": true
4243
},
43-
"parser": "esprima", //指定解析器
44+
"parser": "esprima",
4445
"parserOptions": {},
45-
"rules": {} //规则
46+
"rules": {}
4647
}
4748
```
4849

49-
更多配置说明可以参考[options](https://cn.eslint.org/docs/user-guide/configuring)
50+
More configuration instructions can refer to [options](https://eslint.org/docs/rules/)
5051

5152
## How to add rules?
5253

5354
[rules list: https://cn.eslint.org/docs/rules/](https://cn.eslint.org/docs/rules/)
5455

55-
规则设置:
56-
- "off" 或 0 - 关闭规则
57-
- "warn" 或 1 - 开启规则,使用警告级别的错误:warn (不会导致程序退出)
58-
- "error" 或 2 - 开启规则,使用错误级别的错误:error (当被触发的时候,程序会退出)
56+
ESLint comes with a large number of built-in rules and you can add more rules through plugins. You can modify which rules your project uses either using configuration comments or configuration files. To change a rule setting, you must set the rule ID equal to one of these values:
57+
58+
- "off" or 0 - turn the rule off
59+
- "warn" or 1 - turn the rule on as a warning (doesn't affect exit code)
60+
- "error" or 2 - turn the rule on as an error (exit code is 1 when triggered)
61+
62+
Example:
5963

60-
规则示例
6164
```js
6265
"rules": {
63-
"camelcase": 2, //强制驼峰法命名,
64-
"indent": [2, 4], //缩进风格
65-
"id-match": 0, //命名检测
66-
"init-declarations": 1, //声明时必须赋初值
67-
"no-undef": 1, //不能有未定义的变量
66+
"camelcase": 2, //enforce camelcase naming convention,
67+
"indent": [2, 4], //enforce consistent indentation
68+
"id-match": 0, //require identifiers to match a specified regular expression
69+
"init-declarations": 1, //require or disallow initialization in variable declarations
70+
"no-undef": 1, //disallow the use of undeclared variables unless mentioned in /*global */ comments
6871
}
6972
```
7073

7174

7275
## Exampl:Html Project
7376

74-
使用eslint, 校验多余的空格,并自动修复
77+
Use eslint to check extra spaces and fix them automatically.
7578

7679
<img src="/static/snapshots/tutorial/eslint-html-example.gif" style="zoom: 90%; border: 1px solid #eee;" />
7780

@@ -100,30 +103,28 @@ module.exports = {
100103

101104
## Example:uni-app project
102105

103-
特别说明:
104-
- vue文件,校验vue语法,需要安装`eslint-vue`插件,[插件地址](https://ext.dcloud.net.cn/plugin?id=2005)
105-
- vue文件, 校验规则,需要从`eslint-vue`插件中配置。
106-
- 菜单【工具】->【设置 -> 插件配置 -> eslint-vue -> .eslintrc.js】,编辑`.eslintrc.js`文件
106+
- vue file, verify vue syntax, need to install `eslint-vue` plugin, [plugin address](https://ext.dcloud.net.cn/plugin?id=2005)
107+
- The vue file, the verification rules, need to be configured from the `eslint-vue` plugin.
108+
- Menu [Tools] [Settings] [Plugins] [eslint-vue] [.eslintrc.js], edit the `.eslintrc.js` file
107109

108-
【示例】eslint自动修复双引号为单引号,如下:
110+
111+
Example: eslint automatically fixes double quotes to single quotes
109112

110113
<img src="/static/snapshots/tutorial/eslint-uniapp-example.gif" style="zoom: 90%; border: 1px solid #eee;" />
111114

112115

113116
## Example:vue-cli project
114117

115-
vue-cli项目,如果使用项目下的配置规则,需要安装相关库、并在项目根目录创建`.eslintrc.js`文件
116-
117-
备注:
118-
1. 注意:项目下`eslint规则`会覆盖HBuilderX编辑器`eslint插件中的规则`
119-
2. 校验vue语法,需要安装`eslint-vue`插件,[插件地址](https://ext.dcloud.net.cn/plugin?id=2005)
118+
1. For the vue-cli project, if you use the configuration rules under the project, you need to install the relevant libraries and create the `.eslintrc.js` file in the project root directory
119+
2. The `eslint rules` under the project will override the rules in the HBuilderX editor `eslint plugin`
120+
3. vue file, verify vue syntax, need to install `eslint-vue` plugin, [plugin address](https://ext.dcloud.net.cn/plugin?id=2005)
120121

121122
```shell
122123
npm install --save eslint eslint-plugin-vue eslint-plugin-html eslint-config-standard eslint-plugin-import eslint-plugin-node eslint-plugin-promise eslint-plugin-standard
123124
```
124125

125126

126-
**.eslintrc.js example**
127+
**.eslintrc.js configuration files**
127128

128129
```js
129130
module.exports = {
@@ -132,13 +133,13 @@ module.exports = {
132133
],
133134
rules: {
134135
"no-alert": 0,
135-
"no-multi-spaces": "error", // 禁止多个空格
136-
"semi": [2, "always"] ,// 自动补充分号
137-
"quotes": ["error", "single"] // 使用单引号
136+
"no-multi-spaces": "error", // disallow multiple spaces
137+
"semi": [2, "always"] , // equire or disallow semicolons instead of ASI
138+
"quotes": ["error", "single"] // enforce the consistent use of either backticks, double, or single quotes
138139
}
139140
}
140141
```
141142

142-
示例:使用eslint, 自动补充分号
143+
**Example: Use eslint to automatically add semicolons**
143144

144145
![](https://img-cdn-qiniu.dcloud.net.cn/uploads/article/20200317/911ea4cac9f2c4d80ec502b1384e7a58.gif)

en/Tutorial/extension/eslint-vue.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ Click the menu [Tools] [Settings -> Plugin] [eslint-vue], you can see the eslint
1616

1717
<img src="/static/snapshots/tutorial/plugins/settings_eslint_en.png" class="hd-img"/>
1818

19-
**实时校验、自动修复**
19+
**Real-time verification and automatically fixable**
2020

21-
> HBuilderX 2.6.8+版本起,新增eslint 实时校验、自动修复错误的功能。注意:此功能不适用于2.6.8之前的版本
21+
> Only supports HBuilderX 2.6.8+ version
2222
23-
1. 使用此功能,必须安装[eslint-js](https://ext.dcloud.net.cn/plugin?id=2037)[eslint-vue](https://ext.dcloud.net.cn/plugin?id=2005)插件
24-
2. `vue-cli`项目,需要安装eslint库,并配置eslint规则.
25-
3. 若满足上述条件,当编写完代码,保存时,若代码中存在错误,自动修复;
26-
4. 实时校验功能,默认未开启,需要手动开启此功能
23+
1. To use this function, you must install [eslint-js](https://ext.dcloud.net.cn/plugin?id=2037) and [eslint-vue](https://ext.dcloud.net.cn /plugin?id=2005) plugin
24+
2. The `vue-cli` project needs to install the eslint library and configure the eslint rules.
25+
3. If the above conditions are met, when the code is written and saved, if there is an error in the code, it will be automatically repaired;
26+
4. Real-time verification function, not enabled by default, you need to manually enable this function
2727

28-
## eslint-vue config file
28+
## HBuilderX eslint-vue configuration files
2929

3030
The configuration file of eslint-vue is `.eslintrc.js`.
3131

@@ -48,10 +48,12 @@ More configuration instructions can refer to [options](http://eslint.org/docs/us
4848

4949
[rules list](https://github.com/vuejs/eslint-plugin-vue#gear-configs)
5050

51-
Rule setting:
52-
- "off" or 0 - close rules
53-
- "warn" or 1 - open rules,使用警告级别的错误:warn (不会导致程序退出)
54-
- "error" or 2 - open rules,使用错误级别的错误:error (当被触发的时候,程序会退出)
51+
ESLint comes with a large number of built-in rules and you can add more rules through plugins. You can modify which rules your project uses either using configuration comments or configuration files. To change a rule setting, you must set the rule ID equal to one of these values:
52+
53+
- "off" or 0 - turn the rule off
54+
- "warn" or 1 - turn the rule on as a warning (doesn't affect exit code)
55+
- "error" or 2 - turn the rule on as an error (exit code is 1 when triggered)
56+
5557

5658
Modify the .eslintrc.js file and add rules, such as:
5759

@@ -122,33 +124,31 @@ Modify the .eslintrc.js file and add rules, such as:
122124
```
123125

124126

125-
## Exampleuni-app project
127+
## Example: uni-app project
126128

127-
特别说明:
128-
- vue文件,校验vue语法,需要安装`eslint-vue`插件,[插件地址](https://ext.dcloud.net.cn/plugin?id=2005)
129-
- vue文件, 校验规则,需要从`eslint-vue`插件中配置。
130-
- 菜单【工具】【设置】【插件配置】【eslint-vue】【.eslintrc.js】,编辑`.eslintrc.js`文件
131129

130+
- vue file, verify vue syntax, need to install `eslint-vue` plugin, [plugin address](https://ext.dcloud.net.cn/plugin?id=2005)
131+
- The vue file, the verification rules, need to be configured from the `eslint-vue` plugin.
132+
- Menu [Tools] [Settings] [Plugins] [eslint-vue] [.eslintrc.js], edit the `.eslintrc.js` file
132133

133-
【示例】eslint自动修复双引号为单引号,如下:
134134

135-
<img src="/static/snapshots/tutorial/eslint-uniapp-example.gif" style="zoom: 90%; border: 1px solid #eee;" />
135+
Example: eslint automatically fixes double quotes to single quotes
136136

137+
<img src="/static/snapshots/tutorial/eslint-uniapp-example.gif" style="zoom: 90%; border: 1px solid #eee;" />
137138

138-
## Example:vue-cli project
139139

140-
vue-cli项目,如果使用项目下的配置规则,需要安装相关库、并在项目根目录创建`.eslintrc.js`文件
140+
## Example: vue-cli project
141141

142-
备注:
143-
1. 注意:项目下`eslint规则`会覆盖HBuilderX编辑器`eslint插件中的规则`
144-
2. 校验vue语法,需要安装`eslint-vue`插件,[插件地址](https://ext.dcloud.net.cn/plugin?id=2005)
142+
1. For the vue-cli project, if you use the configuration rules under the project, you need to install the relevant libraries and create the `.eslintrc.js` file in the project root directory
143+
2.The `eslint rules` under the project will override the rules in the HBuilderX editor `eslint plugin`
144+
3. vue file, verify vue syntax, need to install `eslint-vue` plugin, [plugin address](https://ext.dcloud.net.cn/plugin?id=2005)
145145

146146
```shell
147147
npm install --save eslint eslint-plugin-vue eslint-plugin-html eslint-config-standard eslint-plugin-import eslint-plugin-node eslint-plugin-promise eslint-plugin-standard
148148
```
149149

150150

151-
.eslintrc.js配置文件示例
151+
**.eslintrc.js configuration files**
152152

153153
```js
154154
module.exports = {
@@ -157,13 +157,13 @@ module.exports = {
157157
],
158158
rules: {
159159
"no-alert": 0,
160-
"no-multi-spaces": "error", // 禁止多个空格
161-
"semi": [2, "always"] ,// 自动补充分号
162-
"quotes": ["error", "single"] // 使用单引号
160+
"no-multi-spaces": "error",
161+
"semi": [2, "always"] ,
162+
"quotes": ["error", "single"] //enforce the consistent use of either backticks, double, or single quotes
163163
}
164164
}
165165
```
166166

167-
示例:使用eslint, 自动补充分号
167+
**Example: Use eslint to automatically add semicolons**
168168

169169
![](https://img-cdn-qiniu.dcloud.net.cn/uploads/article/20200317/911ea4cac9f2c4d80ec502b1384e7a58.gif)

en/_sidebar.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
* Extension
4646
* [validate-html](/Tutorial/extension/validate-html.md)
4747
* [validate-stylelint](/Tutorial/extension/validate-stylelint.md)
48+
* [eslint-js](/Tutorial/extension/eslint-js.md)
49+
* [eslint-vue](/Tutorial/extension/eslint-vue.md)
4850
* [sass](/Tutorial/extension/sass.md)
4951
* [Formator Prettier](/Tutorial/extension/prettier.md)
5052
* Other

0 commit comments

Comments
 (0)