Skip to content

Instantly share code, notes, and snippets.

@joeyjiron06
Last active June 27, 2024 20:24
Show Gist options
  • Save joeyjiron06/9fe2c5cc8c97f48424377c4808d3e489 to your computer and use it in GitHub Desktop.
Save joeyjiron06/9fe2c5cc8c97f48424377c4808d3e489 to your computer and use it in GitHub Desktop.
VITE + ESLINT

Adding ESLint to Vite

Adds typescript support for ESLint, prettier integration for better code formatting and eslint-plugin-jsx-a11y for accesibility errors.

pnpm i --save-dev eslint @typescript-eslint/parser eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-config-prettier

ESLint config

module.exports = {
  root: true,
  env: { browser: true, es2020: true },
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:jsx-a11y/recommended',
    'plugin:react-hooks/recommended',
    // This disables the formatting rules in ESLint that Prettier is going to be responsible for handling.
    // Make sure it's always the last config, so it gets the chance to override other configs.
    "plugin:prettier/recommended",
  ],
  ignorePatterns: ['dist', '.eslintrc.cjs'],
  parser: '@typescript-eslint/parser',
  plugins: ['react-refresh'],
  rules: {
    'react-refresh/only-export-components': [
      'warn',
      { allowConstantExport: true },
    ],
  },
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment