语言选项
指定环境
环境提供预定义的全局变量。可用的环境有:
browser
- 浏览器全局变量。node
- Node.js 全局变量和 Node.js 范围。commonjs
- CommonJS 全局变量和 CommonJS 范围(将其用于使用 Browserify/WebPack 的仅浏览器代码)。shared-node-browser
- Node.js 和浏览器通用的全局变量。es6
- 启用除模块之外的所有 ECMAScript 6 功能(这会自动将ecmaVersion
解析器选项设置为 6)。es2016
- 添加所有 ECMAScript 2016 全局变量并自动将ecmaVersion
解析器选项设置为 7。es2017
- 添加所有 ECMAScript 2017 全局变量并自动将ecmaVersion
解析器选项设置为 8。es2018
- 添加所有 ECMAScript 2018 全局变量并自动将ecmaVersion
解析器选项设置为 9。es2019
- 添加所有 ECMAScript 2019 全局变量并自动将ecmaVersion
解析器选项设置为 10。es2020
- 添加所有 ECMAScript 2020 全局变量并自动将ecmaVersion
解析器选项设置为 11。es2021
- 添加所有 ECMAScript 2021 全局变量并自动将ecmaVersion
解析器选项设置为 12。es2022
- 添加所有 ECMAScript 2022 全局变量并自动将ecmaVersion
解析器选项设置为 13。worker
- 网络工作者全局变量。amd
- 根据 amd 规范将require()
和define()
定义为全局变量。mocha
- 添加所有 Mocha 测试全局变量。jasmine
- 为版本 1.3 和 2.0 添加所有 Jasmine 测试全局变量。jest
- Jest 全局变量。phantomjs
- PhantomJS 全局变量。protractor
- 量角器全局变量。qunit
- QUnit 全局变量。jquery
- jQuery 全局变量。prototypejs
- Prototype.js 全局变量。shelljs
- ShellJS 全局变量。meteor
- Meteor 全局变量。mongo
- MongoDB 全局变量。applescript
- AppleScript 全局变量。nashorn
- Java 8 Nashorn 全局变量。serviceworker
- Service Worker 全局变量。atomtest
- Atom 测试助手全局变量。embertest
- Ember 测试助手全局变量。webextensions
- WebExtensions 全局变量。greasemonkey
- GreaseMonkey 全局变量。
这些环境不是相互排斥的,因此您可以一次定义多个环境。
环境可以在文件内、配置文件中或使用 --env
命令行 标志指定。
使用配置注释
要使用 JavaScript 文件中的注释指定环境,请使用以下格式:
/* eslint-env node, mocha */
CCGr3/+PKYs29UN3h8PLaH2zkHH/uG9XWFVcaOieHFzSmn2MM3J61aYhruHIin8R
使用配置文件
itue6446rLriIAbJzRANMnrvf6HYWZaLjQQyaw8OKtbz6U8RuT3KP3nX3s2eUpjoOiWBFFdXCamDtWd7d7VacjwpHI0A8s7SOCKCUMvinXo180sD0FkGdtm2kic6lL2Hwj7iDFw8funhJHw9a+xew2pvi7Rtv5dbEmPiJXXe12mtem9K9cGnDe/isrXdzLrehL33yzEJ4Q1xOqJ4GAJN/6Wrcbt8tSuetFhZDLVwGYJC0gVqLxZsnZXDWJRiFAHeZmXLVSR0y+z6Ei5b30xibA==
{
"env": {
"browser": true,
"node": true
}
}
CkALPFjpmFQ6nAZ9crQt62sUrIiOfSZNQik05NWH/Md7xPdtPM4OeWN1LjiA0jrQ
{
"name": "mypackage",
"version": "0.0.1",
"eslintConfig": {
"env": {
"browser": true,
"node": true
}
}
}
uQLtHzVJ6t8tamhBejzGSg==
---
env:
browser: true
node: true
使用插件
yzEFErRXzy4KgSXztnOiDCNOxP0dQG1zGmVBRvNFRvoLafeDoTi4PdC2fcK5MOWD8SyJG44kzyy0epe13z32+7kvt6GFugrW4ufIjXvjbTO4beogEPtPYmSbD1pTgFbK49Saryy9BEV0/8MiSvJuYVaSMyGGPASG0EEiuWLL7Ax5rNg3yhxc62DZQC/yd6KCHOQcyqhFfVB2UxS6H7oZ4wtEV8YLiLgMU0/xcm6lrR7ZsKkDnOMo7PqrgbnkTzdb
{
"plugins": ["example"],
"env": {
"example/custom": true
}
}
CkALPFjpmFQ6nAZ9crQt62sUrIiOfSZNQik05NWH/Md7xPdtPM4OeWN1LjiA0jrQ
{
"name": "mypackage",
"version": "0.0.1",
"eslintConfig": {
"plugins": ["example"],
"env": {
"example/custom": true
}
}
}
指定全局变量
DVehnLOqS0eMvKG7OIFixDEABqVcbSvh+IQhb67r/I1V7E2rdVPNShqc69tUOWouDbZvLqkkmM79L3Yx57rVq2gc7CxcBnLsQ9O/+BmJ/X04dOkQGXRVkWo4ZWIzpiCE0MudH7GhlH2cQICQ8xYm0IaqibCHgnUavNIgE/KFp6UR09nIFqALdkJy3+pgN3GMBmjLjEEeXassZOsi/yLrPip7AIAs0gHjH15N3g3qoKyPXcz2641aAIu+COQmz70xbJD32rdGny609xrajVJMq71Yz9r2b6feDg5xhxTofvwdPwQq0e+JAeixmdtZ0/fJFzHo/kaTr8OEPOzAqhQgPvIxA6lOPjZRt+pukBs8RldpAqk0muCrAVwy2YbqB0DrxRPigTO/VNdsDMlekEN0cybczLfC3YdzM8rM7bVtL2yh5lKYlFGv4zbFPNDlkD5+ufPzmBAEwpni4IROm8HwDvuKcqwk+mbDkBTM0nw6Y5BcCcazCM65wDOl64CVEurBYAWkAR+y6pao+2HnNVGBDHVakiM5weW4CUqB8GpYmRTLeI4/9Zb3C/Bc7Y6sPq96
使用配置注释
Oat6ORreTAHneit/NBRwBODOQjYic0QTHlr/wHRnfrOYudmzu8rk/hhyjrmdbtOoIjXM9l458pFgotzEeeNV+2l9DYGxqGwdeUBYKpSRkwso49ggrSYFuxCkB4i3h0BH
/* global var1, var2 */
Nfh/k3wHXMad9ACe7mow6tKRUZZuJqyZQwICzMVAWZf3kyQI75RWfDThz68X9VnjxATuI2iWuktoM0KQo3KyYl5+dGVItxvREDh/aDL/DkUTO5400/UGIwCHbjJ0RS35Nt1b4lGGDi9ma4PSdGWzIZ9tvLipcFeBRHeys1UONSX4BhSvRE6arX7kcYzdzgQ13m/nbZh2Gq3wTh26krPJmdZEjgrTv55y1HihIumRq6QsQ07Q6SCzA3b1zW567YFfHNArLsxCFN0Y+rto4usNOtyI1kpUvE9qtGvhMaLOQH6LMzWMoV7kBIOg4NRAOUY286mqEY9ZTpAmCB4dcKa6EA==
/* global var1:writable, var2:writable */
使用配置文件
itue6446rLriIAbJzRANMiXU69nshPo1O7ehCREhH6XZTy4m2hDWbmmYGFiMPtNT4A8m3vF9OFjk7uJfVOBtGZBIAiqZoAREC4Iv7DETqmxYh1iKCm3sssZq/UnAwmzes41pWkStPJCTFtdtyHNeewGziKGLKjE8BbogafR7OJd0D/D4Pp/uPxLmt+MGw4ZPFvFE7bMc7LrDXbYlEBAkOHz9JH/ogfvCU32PC26H3xRvyHZ8jpkqLCiMpa6la6TeOVdYTO77fr6nI5HHefoB0wuiI2Vuv4B7yRYpXjhZRiXNWSUNbM7XNPVD62gQXCT0TBJlGvTQFZRCLnJmAdAgFqo4ahzd9RnGhSaNOWOQhjvN9Gsvz+/gf6sSKlg88yJFhRauVyygj3ki2vZgWLQ6mpscV/qSAxFbtYaFk2hbG4A=
{
"globals": {
"var1": "writable",
"var2": "readonly"
}
}
uQLtHzVJ6t8tamhBejzGSg==
---
globals:
var1: writable
var2: readonly
BrfutrSrWmPo+NZTdDEQtiHafnWpgAzYyV3W6vETJThpXdgTJ7bW9zdoZFPd9iRvTbLSCQ4B6MYc2G+J3e5y0k9bsXO76r1MBwkhOegWCb2CQnHukK1yw5HsAtpCexbkQoCtRk6XHrTL27NDKoqFlxnDouY6SvHXPk01kXllmH0=
zKOcDRaekO5iFIYG5dcc3T/WQCXf/V4PYN4dAG17Ev6mwkY+u7491QG6B7gjQA0ahayEyd+k5StSUcNrjoPJnNYMuXtkGMVBXb+YFjM3YV3AVaNu07sZ3JrSWExQE+HJHqHSFpUYLUPdVvNemHZciTL4iYdGdetPVugOyEjI8oZ0xZtJ32R00CAe/zw5/V2f8NXb4MoL2D04w0DZEoGsUtJ+f3VhJ6yd228TpppGD8Qezk1E6cSJ8llnIXYfKw1k
{
"env": {
"es6": true
},
"globals": {
"Promise": "off"
}
}
jMb7CSVtJzkPQjPJkrmEB8ClxoFhTUd00Zn/mAmfaHXsptWyszWCkjd+GZ85xKuTEmWaRvAljUch6iRTButO9k7N/sGRnnup5XTD8uXMijMF6v5xfwnR//QY22HEYBrPTKcYdlBKIo0aLzu69VjjPP7qY9q3LLmuw7RT2DC0ncUaPd09J4h6Wf95aXhx6qB7Bw5NQiuS6YX4SwwmlH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