Skip to content

Migrating to ESLint

Cyril Silverman edited this page Jun 28, 2016 · 23 revisions

Currently VexFlow is in the process of migrating to eslint. Using a much stricter config than the previous jshint config provided.

A PR is currently open which has started the process.

Basic Steps

  1. Run code through Lebab with lebab <filepath> -o <filepath>
  • Lebab is an ES5 to ES6 converter.
  • You can install it with npm.
  • It seems to work quite well, but be sure to review the result because some transforms are unsafe.
  1. Run eslint --fix
  • This will fix some pretty trivial things, but definitely saves time.
  1. Manual edits
  • Despite the automated bits, many errors will remain.
  • Sometimes minor refactoring will be required
  1. When finished add the file name to the ESLINT_SOURCES array in the Gruntfile

Config

Here's the current .eslintrc, acquaint yourself with the eslint rules and feel free to make suggestions. Note that we're extending the eslint-config-airbnb-base

{
  "extends": "airbnb-base",
  "root": true,
  "rules": {
    "max-len": [2, 100],
    "camelcase": [0],
    "no-case-declarations": [2],
    "no-confusing-arrow": [0],
    "new-cap": [0],
    "no-else-return": [0],
    "no-multi-spaces": [0],
    "no-param-reassign": [0],
    "no-shadow": [0],
    "no-use-before-define": [0],
    "prefer-template": [0],
    "space-before-function-paren": [2, "never"],
    "strict": [2, "global"]
  }
}