如何修复“仅在ES6中可用”的过滤器错误
How to fix “only available in ES6” linter errors?
我试图在我的Express应用程序中添加一个过滤器,并且我得到了关于ES6的几个过滤器错误,即‘export’ is only available in ES6 (use esnext option)
, ’const’ is only available in JavaScript 1.7
和’arrow function syntax’ is only available in Javascript 1.7
。我不知道如何消除这些错误,希望得到任何帮助。我目前已经尝试安装了几个东西,包括Sublime Text 2 linter和babel-eslint,但可能是错误的。
From relevant package.json:
{
"dependencies": {
"babel-cli": "^6.10.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-2": "^6.5.0",
"bcrypt-nodejs": "0.0.3",
"botkit-sms": "^1.1.0",
"dotenv": "^2.0.0",
"express": "^4.14.0",
"jwt-simple": "^0.5.0",
"mongoose": "^4.6.3",
"passport": "^0.3.2",
"passport-jwt": "^2.2.1",
"passport-local": "^1.0.0",
"request": "^2.76.0",
"routific": "0.0.2"
},
"devDependencies": {
"babel-eslint": "^6.1.2",
"eslint": "^2.13.1",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.16.0",
"eslint-plugin-jsx-a11y": "^1.4.2",
"eslint-plugin-react": "^5.1.1",
"nodemon": "^1.9.2"
}
}
.babelrc:
{
"presets": ["es2015", "stage-2"]
}
.eslintrc:
{
extends: ["airbnb", "esnext"],
parser: "babel-eslint",
env: {
browser: false,
node: true,
es6: true
},
rules: {
strict: 0,
quotes: [2, "single"],
no-else-return: 0,
new-cap: ["error", {"capIsNewExceptions": ["Router"]}],
no-console: 0,
import/no-unresolved: [2, { commonjs: true}],
no-unused-vars: ["error", { "vars": "all", "args": "none" }],
no-underscore-dangle: 0,
arrow-body-style: ["error", "always"],
no-shadow: ["error", { "allow": ["done", "res", "cb", "err", "resolve", "reject"] }],
no-use-before-define: ["error", { "functions": false }],
max-len: 0
},
plugins: [
'import'
],
ecmaFeatures: {
jsx: true,
modules: true
}
}
在Preferences -> Package Settings-> sublime -> Settings- user worked for me中将esnext设置为true
{
"jshint_options":
{
"esnext": true
}
}
我认为你必须摆脱下一个这是我的节点。eslintrc:
{
"extends" : "airbnb",
"rules": {
// disable requiring trailing commas because it might be nice to revert to
// being JSON at some point, and I don t want to make big changes now.
"comma-dangle": 0,
// we can use escape and template strings
"quotes": [1, "single", {"avoidEscape": true, "allowTemplateLiterals": true}],
"max-len": [0],
"no-console": 0,
"no-param-reassign": 0
},
"globals": { "ENV": true },
"env": {
"browser": true,
"node": true,
"jasmine": true
}
}
这些是我的devDependencies
"devDependencies": {
"babel-cli": "^6.9.0",
"babel-core": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-0": "^6.5.0",
"eslint": "^3.1.1",
"eslint-config-airbnb": "^12.0.0",
"eslint-plugin-import": "1.16.0",
"eslint-plugin-jsx-a11y": "2.2.3",
"eslint-plugin-react": "6.4.1",
"nodemon": "^1.9.2"
}
ecmaFeatures
配置设置在parserOptions
下。
...
plugins: [
'import'
],
parserOptions: {
ecmaFeatures: {
jsx: true
},
ecmaVersion: 6,
sourceType: 'module'
},
...
您应该使用sourceType: 'module'
而不是modules: true
。
相关文章:
- ui网格日期单元格过滤器,过滤日期格式导致显示错误的日期
- 角度过滤器可以工作,但将输入视为未定义并抛出错误
- 带有过滤器的jQuery标记引发错误
- 游戏关闭 - 过滤器错误
- CORS 过滤器错误 - 需要帮助来修复相同的错误
- 过滤器 AngularJS REST JSON 数据:错误:badcfg 响应与配置的参数不匹配
- 将“按$index跟踪”与过滤器一起使用时,出现错误.如何解决这个问题
- Gettin 交叉过滤器.js错误“太多递归”
- 过滤器会导致错误
- AngularJS日期过滤器显示错误的日期
- 错误:text.replace不是angularjs过滤器中的函数,如何解决此问题
- 如何修复“仅在ES6中可用”的过滤器错误
- 使用wordpress the_content过滤器注入javascript会导致javascript语法错误
- Stocktwits符号过滤器标志抛出错误
- Angular分页过滤器错误
- ExtJS过滤器的错误与组合框
- AngularJS 1.X:空列上的过滤器错误(?)
- 单元测试过滤器错误:预期null等于[object]
- 角度ng重复和过滤器错误(版本1.1.5有效,1.2.15有错误)
- Angularjs过滤器错误:";错误:未知提供程序:textProvider"