当ESLint发出错误时如何在React Native项目中使构建失败

时间:2019-01-20 04:35:14

标签: android ios reactjs react-native eslint

正如我现在看到的,当eslint在控制台窗口上显示错误时。应用程序保持继续更新新代码。我想强迫它停止更新最新代码,直到没有错误出现并且我不想在项目上使用VS Code Extension。 任何人提供一些线索时都非常适合。 问候

1 个答案:

答案 0 :(得分:0)

没有支持的eslint参数将警告视为错误,但是您可以执行以下操作:

// .eslintrc.js
function isTruthy(value) {
  if (!value) return false;
  return ['1', 'true'].indexOf(value.toLowerCase()) >= 0;
}

// Warnings are errors in CI
var OFF = 'off';
var ERROR = 'error';
var WARNING = isTruthy(process.env.CI) ? ERROR : 'warn';

module.exports = {
  // ...
  "rules": {
    "comma-dangle": OFF,
    "eqeqeq": [WARNING, "allow-null"],
    "import/imports-first": OFF,
    "indent": [WARNING, 2, {"SwitchCase": 1}],
    "max-len": [WARNING, 100, 2],
    "no-console": [WARNING, {"allow": ["warn", "error"]}],
    "no-debugger": WARNING,
    "no-fallthrough": WARNING,
    "no-unreachable": WARNING,
    "no-unused-vars": [WARNING, {"vars": "all", "args": "none"}],
    "no-var": ERROR,
    "prefer-const": WARNING,
    "react/prop-types": [WARNING, {"ignore": ["className"]}],
    "semi": [WARNING, "never"],
  },
  // ...
}