Travis CI 中的 eslint 失败,但不是本地的
eslint Failures in Travis CI, but not locally
由于两个 eslint 错误,我有一个 GitHub project that has passed Travis CI. Upon creating a pull request for a new feature, Travis CI fails pr 和 push:
/home/travis/build/enove/Thriver/packages/thriver-accounts/lib/accounts.js
121:5 error Strings must use singlequote quotes
122:5 error Strings must use singlequote quotes
accounts.js
的第 119 行到第 122 行如下:
119: return `Hello ${user.profile.firstname}!\n\n` +
120: `To verify your account email, simply click the link below.\n\n${url}\n\n` +
121: `If you weren't expecting this email, simply delete it.\n\n` +
122: `Thanks!\n\nAll of us at WCASA`;
提交甚至没有更改 accounts.js
,并且本地 eslint 没有错误地通过了。我检查并验证了 node、npm 和 meteor 的版本在本地与它们在 Travis 中的版本相同 CI.
TravisCI配置如下:
{
"sudo": "required",
"language": "node_js",
"node_js": "4.1.1",
"before_install": [
"curl -L https://git.io/ejPSng | /bin/sh"
],
"env": "CXX=g++-4.8",
"addons": {
"apt": {
"sources": [
"ubuntu-toolchain-r-test"
],
"packages": [
"g++-4.8"
]
}
},
"services": "mongodb",
"script": [
"meteor npm run lint"
],
"group": "stable",
"dist": "precise",
"os": "linux"
}
.eslintrc
如下:
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"impliedStrict": true
}
},
"env": {
"browser": true,
"node": true,
"mongo": true,
"meteor": true
},
"extends": [
"airbnb"
//"plugin:meteor/recommended"
],
"globals": {
"Thriver": true,
"SimpleSchema": true,
"Marked": true,
"SHA256": true,
"google": true,
"geoXML3": true,
"AutoForm": true,
"details_shim": true
},
"rules": {
"no-underscore-dangle": 0,
"new-cap": 0
}
}
之前在另一个文件中发生过这种情况,我 "resolved" 通过让 eslint 忽略该行来解决这个问题。但我不能对每个神秘问题都这样做。有什么建议吗?
http://eslint.org/docs/rules/quotes
这很可能是您问题的解决方法。
JavaScript allows you to define strings in one of three ways: double quotes, single quotes, and backticks (as of ECMAScript 6). For example:
/*eslint-env es6*/
var double = "double";
var single = 'single';
var backtick = `backtick`; // ES6 only
The choice of how to define strings in a codebase is a stylistic one outside of template literals (which allow embedded of expressions to be interpreted). Many codebases require strings to be defined in a consistent manner.
我会尝试设置这些规则之一,然后 运行 再次测试。
如果这不能解决您的问题,请告诉我!
我仍然不知道 eslint 在本地是如何通过的。也许我在 eslint 或 airbnb 版本上落后了。但是,我意识到这些线条确实需要更正。底部两行代码不应使用反引号,因为这些字符串中没有任何变量。
119: return `Hello ${user.profile.firstname}!\n\n` +
120: `To verify your account email, simply click the link below.\n\n${url}\n\n` +
121: 'If you weren\'t expecting this email, simply delete it.\n\n' +
122: 'Thanks!\n\nAll of us at WCASA';
与不是每个段都包含变量的一致字符串相比,Eslint 更喜欢不同样式的串联字符串。
由于两个 eslint 错误,我有一个 GitHub project that has passed Travis CI. Upon creating a pull request for a new feature, Travis CI fails pr 和 push:
/home/travis/build/enove/Thriver/packages/thriver-accounts/lib/accounts.js
121:5 error Strings must use singlequote quotes
122:5 error Strings must use singlequote quotes
accounts.js
的第 119 行到第 122 行如下:
119: return `Hello ${user.profile.firstname}!\n\n` +
120: `To verify your account email, simply click the link below.\n\n${url}\n\n` +
121: `If you weren't expecting this email, simply delete it.\n\n` +
122: `Thanks!\n\nAll of us at WCASA`;
提交甚至没有更改 accounts.js
,并且本地 eslint 没有错误地通过了。我检查并验证了 node、npm 和 meteor 的版本在本地与它们在 Travis 中的版本相同 CI.
TravisCI配置如下:
{
"sudo": "required",
"language": "node_js",
"node_js": "4.1.1",
"before_install": [
"curl -L https://git.io/ejPSng | /bin/sh"
],
"env": "CXX=g++-4.8",
"addons": {
"apt": {
"sources": [
"ubuntu-toolchain-r-test"
],
"packages": [
"g++-4.8"
]
}
},
"services": "mongodb",
"script": [
"meteor npm run lint"
],
"group": "stable",
"dist": "precise",
"os": "linux"
}
.eslintrc
如下:
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"impliedStrict": true
}
},
"env": {
"browser": true,
"node": true,
"mongo": true,
"meteor": true
},
"extends": [
"airbnb"
//"plugin:meteor/recommended"
],
"globals": {
"Thriver": true,
"SimpleSchema": true,
"Marked": true,
"SHA256": true,
"google": true,
"geoXML3": true,
"AutoForm": true,
"details_shim": true
},
"rules": {
"no-underscore-dangle": 0,
"new-cap": 0
}
}
之前在另一个文件中发生过这种情况,我 "resolved" 通过让 eslint 忽略该行来解决这个问题。但我不能对每个神秘问题都这样做。有什么建议吗?
http://eslint.org/docs/rules/quotes
这很可能是您问题的解决方法。
JavaScript allows you to define strings in one of three ways: double quotes, single quotes, and backticks (as of ECMAScript 6). For example:
/*eslint-env es6*/
var double = "double";
var single = 'single';
var backtick = `backtick`; // ES6 only
The choice of how to define strings in a codebase is a stylistic one outside of template literals (which allow embedded of expressions to be interpreted). Many codebases require strings to be defined in a consistent manner.
我会尝试设置这些规则之一,然后 运行 再次测试。
如果这不能解决您的问题,请告诉我!
我仍然不知道 eslint 在本地是如何通过的。也许我在 eslint 或 airbnb 版本上落后了。但是,我意识到这些线条确实需要更正。底部两行代码不应使用反引号,因为这些字符串中没有任何变量。
119: return `Hello ${user.profile.firstname}!\n\n` +
120: `To verify your account email, simply click the link below.\n\n${url}\n\n` +
121: 'If you weren\'t expecting this email, simply delete it.\n\n' +
122: 'Thanks!\n\nAll of us at WCASA';
与不是每个段都包含变量的一致字符串相比,Eslint 更喜欢不同样式的串联字符串。