yiminghe / eslint-plugin-catch-call-function

enforce call function inside catch clause

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

eslint-plugin-catch-call-function

enforce call specified function or rethrow inside catch clause.

NPM version NPM downloads Build Status

usage

.eslintrc.js

module.exports = {
  plugins: ['eslint-plugin-catch-call-function'],
  rules:{
    // must call reportError function or re throw
    'catch-call-function/catch-call-function':['error', ['reportError','throw']],
  }
};

rules

correct:

/*eslint catch-call-function/catch-call-function: ["error", ["reportError","throw"]]*/

try {
  console.log(1);
} catch (e) {
  reportError(e);
  // throw e;
}

wrong:

/*eslint catch-call-function/catch-call-function: ["error", ["reportError"]]*/

try {
  console.log(1);
} catch (e) {
  console.log(e);
}
  3:3  error  Must call function inside catch: reportError  catch-call-function/catch-call-function

About

enforce call function inside catch clause

License:MIT License


Languages

Language:JavaScript 100.0%