An Interest In:
Web News this Week
- April 28, 2024
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
April 5, 2023 09:51 pm GMT
Original Link: https://dev.to/zsevic/linting-with-eslint-1ae7
Linting with Eslint
Linting represents static code analysis based on specified rules. Please include it in the CI pipeline.
Setup
Run the following commands to generate the linter configuration using the eslint
package.
npm init -ynpm init @eslint/config
Below is an example of the configuration. Some rules can be ignored or suppressed as warnings.
// .eslintrc.jsmodule.exports = { env: { commonjs: true, es2021: true, node: true, jest: true, }, extends: 'airbnb-base', overrides: [ ], parserOptions: { ecmaVersion: 'latest', }, rules: { 'import/no-extraneous-dependencies': 'warn', 'import/prefer-default-export': 'off', },};
Ignore the files with the .eslintignore
file.
dist
Linting
Configure and run the script with the npm run lint
command. Some errors can be fixed automatically with the --fix
option.
// package.json{ "scripts": { // ... "lint": "eslint src", "lint:fix": "npm run lint -- --fix" }}
Original Link: https://dev.to/zsevic/linting-with-eslint-1ae7
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To