Next we install and configure ESLint. Let’s go into the root folder of our WordPress project and install eslint
and eslint-config-prettier
. Eslint-config-prettier is the one that is going to disable all the conflicting formatting from ESLint to give Prettier room to do it’s thing. You can install both with this command:
npm install --save-dev eslint eslint-config-prettier
Then add a file to the same root folder called .eslintrc.js
with these contents:
"use strict";
module.exports = {
env: {
es6: true
},
extends: ["prettier"]
};
This enables ES6 syntax, ES6 global variables and starts using modern JavaScript settings that works nicely with Prettier.