0.1.0 • Published 4 years ago

eslint-plugin-catch-call-function v0.1.0

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

eslint-plugin-catch-call-function

enforce call specified function or rethrow inside catch clause.

eslint-plugin-catch-call-function 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

catch-call-function/catch-call-function

Options

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