Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
July 27, 2021 04:47 pm GMT

Install eslint

Install eslint and setup default config files

  1. Install eslint with typescript

    $ npm install --save-dev eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin
  2. Create eslint config file touch .eslintrc.js

  3. Edit .eslintrc.js to look like this

    module.exports = {  root: true,  parser: '@typescript-eslint/parser',  plugins: [    '@typescript-eslint',  ],  extends: [    'eslint:recommended',    'plugin:@typescript-eslint/recommended',  ],}
  4. Create eslint ignore file touch .eslintignore

  5. 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
  6. Add "lint": "eslint . --ext .js,.jsx,.ts,.tsx" to "scripts" section in package.json

    {  ...,  "scripts": {    ...,    "lint": "eslint . --ext .js,.jsx,.ts,.tsx"  },  ...}
  7. 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)
  8. First let's commit what we already've done git add .

  9. git commit -m 'install eslint with typescript

Fix error 'module' is not defined no-undef

  1. 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.

  2. Fix previous error by editing .eslintrc.js to look like this

    module.exports = {  root: true,  // https://eslint.org/docs/rules/no-undef#nodejs  env: {    node: true,  },  ...}
  3. Run npm run lint

  4. git add -u

  5. git commit -m "fix: error 'module' is not defined no-undef"

Links

Links for error 'module' is not defined no-undef

Project

vue-ts-tailwind


Original Link: https://dev.to/imomaliev/install-eslint-2m24

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To