- Harry Stephens
Then, install eslint-config with npm
npm install --save-dev eslint-config-murmuration-frontend
From wherever you installed eslint-config-murmuration-frontend
, run:
sh node_modules/eslint-config-murmuration-frontend/setup.sh
Ensure that your IDE has the ESLint plugin installed, turned on, using automatic settings in either VS Code or WebStorm.
Verify that ESLint is running by navigating to the Preferences: Open Settings (UI)
and make sure the following settings are as follows:
-
Editor: Default Formatter
is set to ESLint -
Editor: Format On Save
box is ticked -
Eslint: Enable
box is ticked -
Eslint > Format: Enable
box is ticked
Open Preferences and navigate to Languages & Frameworks | JavaScript | Code Quality Tools | ESLint
, then set ESLint to Automatic ESLint Configuration
.
Make sure the Run eslint --fix on save
box is ticked.
eslint ./DIRECTORY_TO_LINT --ext .ts --config .eslintrc.js --fix
Double check that ESLint is working as expected by creating a new TypeScript file and pasting the following function in it:
// You should get all sorts of errors here.
let myTestFunction = (myTestString) => {
myTestString = [
"ESLint should be very upset",
"about every aspect of this function"
]
return myTestString
}
// If you replace the above code with:
const myTestFunction = (myTestString: Array<string>): string => {
myTestString = [
'ESLint should be very upset',
'about every aspect of this function',
];
return myTestString[0];
};
myTestFunction(['This should make', 'ESLint happy']);
// All warnings and errors should disappear
Lint your little heart out.