node.js - Travis CI 中的 eslint 失败,但不是本地的

标签 node.js meteor github travis-ci eslint

我有一个 GitHub project已通过 Travis CI。创建 pull request对于新功能,Travis CI fails pr 和 push 由于两个 eslint 错误:

/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 中的版本相同。

Travis CI配置如下:

{
  "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
  }
}

这之前在另一个文件中发生过,我通过让 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.

我会尝试设置这些规则之一并再次运行测试。

如果这不能解决您的问题,请告诉我!

关于node.js - Travis CI 中的 eslint 失败,但不是本地的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40901653/

相关文章:

node.js - 如何让 window.onload 函数在 Jade 模板语言中工作

javascript - 递归解析对象数组并根据 id 过滤对象

git - 使用 git 维护多子模块项目

firebase - 无法通过 `CompileOptions.compilerArgs` 指定 -processorpath 或 --processor-path。请改用 `CompileOptions.annotationProcessorPath` 属性

javascript - 在 ES6 Node.js 中导入 '.json' 扩展会引发错误

node.js - 当数据库位于服务器文件夹之外时如何启动 Mongoose 连接?

meteor - 我可以使用哪些 Mongo GUI 工具连接到我部署的 Meteor 应用程序?

mongodb - cursor.observe 如何工作以及如何避免运行多个实例?

javascript - meteor 模板中的简单数据反射

GitHub Branch Source Plugin --> 仅扫描 Pull Request