Better Code Quality with ESLint
Linters go through your code and look for mistakes such as undefined variables or reassigned constants. They are more powerful though when combined with a style guide - a preset which dictates how code should be written (spacing, use of semicolons etc.). ESLint is a linter which uses the JavaScript standard style guide.
Visual Studio Code - https://code.visualstudio.com/docs/languages/javascript#_linters
Why you should always use a Linter - https://medium.com/dailyjs/why-you-should-always-use-a-linter-and-or-pretty-formatter-bb5471115a76
Setting up ESLint with Visual Studio Code:
- open a Terminal and enter the following:
npm install -g eslint - open VS Code, click the Extensions icon
- in the search box, enter ESLint and click Install and then click Reload
- add an .eslintrc file to the project root with the following contents:{"extends": "airbnb-base"}
- in the terminal for JavaScript without React:
(export PKG=eslint-config-airbnb-base;npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest")
JavaScript with React:
(export PKG=eslint-config-airbnb;npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest")
Visual Studio Code - https://code.visualstudio.com/docs/languages/javascript#_linters
Why you should always use a Linter - https://medium.com/dailyjs/why-you-should-always-use-a-linter-and-or-pretty-formatter-bb5471115a76