简体   繁体   中英

How to make build failed in React Native project when ESLint emit error

As i see now, when eslint show error on console window. App keep continue update new code. I want to force it stop update latest code until no error appear and i dont want use VS Code Extension apply on project. Really appriciate when any one provide some clues. Regard

There is no supported eslint parameter to treat warnings as errors, but you can do something like this:

// .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"],
  },
  // ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM