Skip to content

Commit 9aa19cf

Browse files
committed
migration
1 parent dbcea90 commit 9aa19cf

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

Migrating-to-v2.0.0.md

+16-21
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ module.exports = {
8585
8686
```
8787

88-
## Language Options
88+
## 语言配置项
8989

90-
Prior to 2.0.0, the way to enable language options was by using `ecmaFeatures` in your configuration. In 2.0.0:
90+
在2.0.0版本之前,启动语言配置项是通过在配置文件中添加`ecmaFeatures`配置项来实现的。而在2.0.0版本,发生了如下变化:
9191

92-
- The `ecmaFeatures` property is now under a top-level `parserOptions` property.
93-
- All ECMAScript 6 `ecmaFeatures` flags have been removed in favor of a `ecmaVersion` property under `parserOptions` that can be set to 3, 5 (default), or 6.
94-
- The `ecmaFeatures.modules` flag has been replaced by a `sourceType` property under `parserOptions` which can be set to `"script"` (default) or`"module"` for ES6 modules.
92+
- `ecmaFeatures` 配置项现从属于`parserOptions`配置属性下面。
93+
- 所有的ECMAScript 6 标记的`ecmaFeatures` 都被移除,并被一个`parserOptions` 下面的`ecmaVersion`配置项所替代,该配置项可以被设置为如下值:3, 5(默认值)或者 6.
94+
- `ecmaFeatures.modules`标记被`parserOptions`配置项下面的`sourceType`属性所替代,该属性可能的取值包括`"script"`(默认值)和`"module"` 用于启动ES6中的modules特性。
9595

96-
**To address:** If you are using any ECMAScript 6 feature flags in `ecmaFeatures`, you'll need to use `ecmaVersion: 6` instead. The ECMAScript 6 feature flags are:
96+
**解决方案:** 如果你在`ecmaFeatures`中使用了ECMAScript 6 特性标签,那么你需要使用`ecmaVersion: 6` 来替换之前配置,ECMAScript 6特性标签列表如下:
9797

9898
- `arrowFunctions` - enable [arrow functions](https://leanpub.com/understandinges6/read#leanpub-auto-arrow-functions)
9999
- `binaryLiterals` - enable [binary literals](https://leanpub.com/understandinges6/read#leanpub-auto-octal-and-binary-literals)
@@ -117,29 +117,27 @@ Prior to 2.0.0, the way to enable language options was by using `ecmaFeatures`
117117
- `templateStrings` - enable [template strings](https://leanpub.com/understandinges6/read/#leanpub-auto-template-strings)
118118
- `unicodeCodePointEscapes` - enable [code point escapes](https://leanpub.com/understandinges6/read/#leanpub-auto-escaping-non-bmp-characters)
119119

120-
If you're using any of these flags, such as:
120+
如果你使用了以上标签,如下:
121121

122122
```
123123
{
124124
ecmaFeatures: {
125125
arrowFunctions: true
126126
}
127127
}
128-
129128
```
130129

131-
Then you should enable ES6 using `ecmaVersion`:
130+
那么为了使用ES 6,你需要设置 `ecmaVersion`:
132131

133132
```
134133
{
135134
parserOptions: {
136135
ecmaVersion: 6
137136
}
138137
}
139-
140138
```
141139

142-
If you're using any non-ES6 flags in `ecmaFeatures`, you need to move those inside of `parserOptions`. For instance:
140+
如果你在`ecmaFeatures`中使用了非ES6标签,那么你需要把这些标签迁移到`parserOptions`配置项中,例如:
143141

144142
```
145143
{
@@ -150,7 +148,7 @@ If you're using any non-ES6 flags in `ecmaFeatures`, you need to move those ins
150148
151149
```
152150

153-
Then you should move `ecmaFeatures` under `parserOptions`:
151+
然后你需要把 `ecmaFeatures` 迁移到 `parserOptions`配置项之下:
154152

155153
```
156154
{
@@ -160,10 +158,9 @@ Then you should move `ecmaFeatures` under `parserOptions`:
160158
}
161159
}
162160
}
163-
164161
```
165162

166-
If you were using `ecmaFeatures.modules` to enable ES6 module support like this:
163+
若果你使用了 `ecmaFeatures.modules` 来启动ES6 module,那么需要做如下修改:
167164

168165
```
169166
{
@@ -177,27 +174,25 @@ If you were using `ecmaFeatures.modules` to enable ES6 module support like thi
177174
sourceType: "module"
178175
}
179176
}
180-
181177
```
182178

183-
Additionally, if you are using `context.ecmaFeatures` inside of your rules, then you'll need to update your code in the following ways:
179+
除此之外,如果你在规则中使用了 `context.ecmaFeatures` ,那么你需要对你的代码做如下升级:
184180

185181
1. If you're using an ES6 feature flag such as `context.ecmaFeatures.blockBindings`, rewrite to check for`context.parserOptions.ecmaVersion > 5`.
186182
2. If you're using `context.ecmaFeatures.modules`, rewrite to check that the `sourceType` property of the Program node is `"module"`.
187183
3. If you're using a non-ES6 feature flag such as `context.ecmaFeatures.jsx`, rewrite to check for `context.parserOptions.ecmaFeatures.jsx`.
188184

189185
If you're not using `ecmaFeatures` in your configuration, then no change is needed.
190186

191-
## New Rules in `"eslint:recommended"`
187+
##  `"eslint:recommended"`中新增规则
192188

193189
```
194190
{
195191
"extends": "eslint:recommended"
196192
}
197-
198193
```
199194

200-
In 2.0.0, the following 11 rules were added to `"eslint:recommended"`.
195+
在2.0.0中, `"eslint:recommended"`新增11条规则。
201196

202197
- [constructor-super](http://eslint.org/docs/rules/constructor-super)
203198
- [no-case-declarations](http://eslint.org/docs/rules/no-case-declarations)
@@ -211,7 +206,7 @@ In 2.0.0, the following 11 rules were added to `"eslint:recommended"`.
211206
- [no-unexpected-multiline](http://eslint.org/docs/rules/no-unexpected-multiline)
212207
- [no-unused-labels](http://eslint.org/docs/rules/no-unused-labels)
213208

214-
**To address:** If you don't want to be notified by those rules, you can simply disable those rules.
209+
解决方案:如果你不想使用这些规则,只需要将这些规则警告级别设置为0,如下:
215210

216211
```
217212
{
@@ -233,7 +228,7 @@ In 2.0.0, the following 11 rules were added to `"eslint:recommended"`.
233228
234229
```
235230

236-
## Scope Analysis Changes
231+
## 作用域解析的变化
237232

238233
We found some bugs in our scope analysis that needed to be addressed. Specifically, we were not properly accounting for global variables in all the ways they are defined.
239234

0 commit comments

Comments
 (0)