DEV Community

Cover image for Creating vite vue ts template: Configure Eslint for Jest
Sardorbek Imomaliev
Sardorbek Imomaliev

Posted on • Edited on

Creating vite vue ts template: Configure Eslint for Jest

Enable linting for tests

  1. Update .eslintrc.js

    @@ -16,4 +16,15 @@ module.exports = {
         'plugin:vue/vue3-recommended',
         'prettier',
       ],
    +  overrides: [
    +    {
    +      files: [
    +        '**/__tests__/*.{j,t}s?(x)',
    +        '**/tests/unit/**/*.spec.{j,t}s?(x)',
    +      ],
    +      env: {
    +        jest: true,
    +      },
    +    },
    +  ],
     }
    
  2. git add -u

  3. git commit -m 'enable jest tests linting'

  4. Install eslint-plugin-jest

    $ npm install --save-dev eslint-plugin-jest
    
  5. Update .eslintrc.js

    -  plugins: ['@typescript-eslint'],
    +  plugins: ['@typescript-eslint', 'jest'],
       extends: [
         'eslint:recommended',
         'plugin:@typescript-eslint/recommended',
         'plugin:vue/vue3-recommended',
    +    'plugin:jest/recommended',
         'prettier',
       ],
       overrides: [
    
  6. Add eslint-plugin-jest to .pre-commit-config.yaml

               - vue-eslint-parser@7.9.0
    +          - jest@27.0.6
    +          - eslint-plugin-jest@24.4.0
    
  7. git add -u

  8. git commit -m 'install eslint-plugin-jest'

Links

Project

GitHub logo imomaliev / vue-ts

Vite + Vue + TypeScript template

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay