hubble-contracts icon indicating copy to clipboard operation
hubble-contracts copied to clipboard

Add eslint with mocha rules

Open jacque006 opened this issue 3 years ago • 1 comments

What's Wrong

Per https://github.com/thehubbleproject/hubble-contracts/pull/552#discussion_r616244448 , there are a number of gotcha's such as describe/it.onlys being committed unknowingly. There are likely other code issues we could scan for as well.

How to fix it

  • Implement eslint for typescript https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md
  • Add default mocha rules and also enable https://github.com/lo1tuma/eslint-plugin-mocha/blob/master/docs/rules/no-exclusive-tests.md
  • (optional) Consider integrating prettier and solhint into eslint
  • Make sure eslint checks do not add too much overhead to the local development experience.

jacque006 avatar Apr 20 '21 13:04 jacque006

Consider: Add check to ensure all equality checks are strict equality. See https://stackoverflow.com/questions/359494/which-equals-operator-vs-should-be-used-in-javascript-comparisons/359509#359509 for a good opinion on why strict equality is preferable.

tl;dr use ===, !==, enforce via linting

jacque006 avatar Apr 30 '21 16:04 jacque006