ESLint

Lightning Talk

Custom Rules

About Me

  • Senior Software Engineer at Iteris
  • twitter: @bchirgwin
  • Organizer of CODE Norman

ESLint

  • Linting Tool [JSLint, JSHint]
    • Potential Errors
      • if (a = b)
    • Best Practices
      • require === conditions
    • Style Guidelines
      • comma location

ESLint Installation

  • npm install -g eslint
  • eslint --init
    • answer questions

Warnings/Errors

  • Rules can be set as warning while code is changed
  • Set rule to error once all code refactored & CI system can fail on error.

Demo

Style Guideline Rules

  • "max-statements": [2, 2, {"ignoreTopLevelFunctions": true}]

  • "max-depth: [2, {"maximum": 2} ]

  • "max-len": [2, {"code": 80, "tabWidth": 4, "ignoreUrls": true}]

  • "max-params": [2, {"maximum": 2}]

  • "complexity": [2, { "maximum": 2 }]

  • "max-nested-callbacks": [2, {"maximum": 3}]

Custom Rules

  • Write rules to enforce team style guide.
  • Optional Fix routine to automatically follow rule.

Code Norman

  • Saturday, March 19, 2 - 4 at Norman Public Library
  • ESLint

ESLint Lightning Talk

By Brian Chirgwin

ESLint Lightning Talk

  • 597