I use mocha/chai and my .eslint file is in YAML.

What eslint settings could I apply to most projects, i.e. use as a template ?


This example works:

  commonjs: true
  es6: true
  node: true
  - 'plugin:mocha/recommended'
  Atomics: readonly
  SharedArrayBuffer: readonly
  ecmaVersion: 2018
  prefer-const: error
  eqeqeq: error
  no-var: error
  semi: error
  - "mocha"

It has 4 simple rules and allows for the describe and it statements in Mocha while applying the 'prefer-const', 'eqeqeq' (use === over ==), etc. rules.

Also if you modify package.json to have:

  "scripts": {
    "pretest": "eslint .",
    "test": "mocha **/*.spec.js"

then linting will automatically run before your tests when you issue

npm test

to make it seamless and easy and the tests won't run until the linting parses which effectively means that format is tested and enforced. No more code review arguments on formats! once you agree on the rules in the settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.