Eslint: Difference between revisions

From Bitpost wiki
Line 3: Line 3:
==== Installation ====
==== Installation ====
Do NOT USE APT, it is available and seems to work but this is a node module.  Don't be stupid, use npm.  Note the mind-bogglingly-insane number of dependencies.  Node world, you scare me...
Do NOT USE APT, it is available and seems to work but this is a node module.  Don't be stupid, use npm.  Note the mind-bogglingly-insane number of dependencies.  Node world, you scare me...
  npm install -g eslint
  npm install -g eslint eslint-config-google
 
==== Configuration ====
==== Configuration ====
If you have an existing .eslintrc.js that works well in another project, JUST COPY IT to the root of the new vscode folder-based project.  Otherwise, this will step you through it.  Use the google format as a baseline:
If you have an existing .eslintrc.js that works well in another project, JUST COPY IT to the root of the new vscode folder-based project.  Otherwise, this will step you through it.  Use the google format as a baseline:

Revision as of 17:21, 2 September 2020

Intro

eslint is a Javascript linter and format-enforcer. Love it or die. I'm following Google's rules, with allowance for longer lines. My job uses a very strict set of rules.

Installation

Do NOT USE APT, it is available and seems to work but this is a node module. Don't be stupid, use npm. Note the mind-bogglingly-insane number of dependencies. Node world, you scare me...

npm install -g eslint eslint-config-google

Configuration

If you have an existing .eslintrc.js that works well in another project, JUST COPY IT to the root of the new vscode folder-based project. Otherwise, this will step you through it. Use the google format as a baseline:

cd myproject
eslint --init

vscode integration

  • Get the eslint extension
  • Restart vscode and open a project with JS files.
  • An eslint dialog should pop up, click Allow. Should be all you need.