An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
July 27, 2021 04:47 pm GMT
Fix
Links for
Original Link: https://dev.to/imomaliev/install-eslint-2m24
Install eslint
Install eslint and setup default config files
Install eslint with typescript
$ npm install --save-dev eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin
Create eslint config file
touch .eslintrc.js
Edit
.eslintrc.js
to look like thismodule.exports = { root: true, parser: '@typescript-eslint/parser', plugins: [ '@typescript-eslint', ], extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended', ],}
Create eslint ignore file
touch .eslintignore
Edit
.eslintignore
to look like this# don't ever lint node_modulesnode_modules# don't lint build output (make sure it's set to your correct build folder name)dist# don't lint nyc coverage outputcoverage
Add
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
to"scripts"
section in package.json{ ..., "scripts": { ..., "lint": "eslint . --ext .js,.jsx,.ts,.tsx" }, ...}
Run
npm run lint
$ npm run lint> [email protected] lint> eslint . --ext .js,.jsx,.ts,.tsx/Users/batiskaf/Development/personal/vue-ts-tailwind/.eslintrc.js 1:1 error 'module' is not defined no-undef 1 problem (1 error, 0 warnings)
First let's commit what we already've done
git add .
git commit -m 'install eslint with typescript
Fix error 'module' is not defined no-undef
From docs https://eslint.org/docs/rules/no-undef#environments
For convenience, ESLint provides shortcuts that pre-define global variables exposed by popular libraries and runtime environments.
Fix previous error by editing
.eslintrc.js
to look like thismodule.exports = { root: true, // https://eslint.org/docs/rules/no-undef#nodejs env: { node: true, }, ...}
Run
npm run lint
git add -u
git commit -m "fix: error 'module' is not defined no-undef"
Links
- https://vueschool.io/articles/vuejs-tutorials/eslint-and-prettier-with-vite-and-vue-js-3/
- https://eslint.org/docs/user-guide/getting-started
- https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md
Links for error 'module' is not defined no-undef
- https://eslint.org/docs/user-guide/configuring/language-options#specifying-environments
- https://eslint.org/docs/rules/no-undef#nodejs
- https://stackoverflow.com/a/62335842/3627387
- https://stackoverflow.com/a/63512242/3627387
Project
Original Link: https://dev.to/imomaliev/install-eslint-2m24
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