Eslint Setup

We'll cover the following

Eslint

In the case of Eslint, our Docker job looks like the following:

Docker Job

widget

Here the only difference is we use Build Script to build any npm modules in case the package.json file is updated by the user.

Then the code is run in the Run Script

We set the directory to /usercode as that is where we are placing all our user code in, so we install and modules needed in that directory.

Run the below code to see eslint in action:

Press + to interact
file1.js
package.json
.eslintrc
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "latest",
"eslint": "^6.1.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-jasmine": "^2.10.1",
"prettier": "^1.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.3",
"eslint-plugin-react-hooks": "^1.7.0"
},
"devDependencies": {
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.3"
}
"peerDependencies": {
"eslint-plugin-import": "^2.18.2"
}
}

Note: In case of an execution time out for the above code, change time limit settings to a higher value in the code widget in your own course.

The configuration file selected is eslint-config-airbnb

You can change this by updating the package.json file and add any associated dependencies there.

Then update .eslintrc file accordingly.


In the next lesson, we’ll set up Jest.

Press + to interact
echo $NODE_ENV