Skip to content

Instantly share code, notes, and snippets.

@euxn23
Last active February 16, 2024 00:28
Show Gist options
  • Select an option

  • Save euxn23/0e637ebfdd51a795259f7ff3f2235155 to your computer and use it in GitHub Desktop.

Select an option

Save euxn23/0e637ebfdd51a795259f7ff3f2235155 to your computer and use it in GitHub Desktop.
pnpm i -DE eslint typescript-eslint eslint-plugin-import eslint-plugin-unused-imports eslint-plugin-react eslint-plugin-react-hooks esint-plugin-jsx-a11y
// @ts-check
import typescript from 'typescript-eslint'
import reactPlugin from 'eslint-plugin-react'
import reactHooksPlugin from 'eslint-plugin-react-hooks'
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y'
import importPlugin from 'eslint-plugin-import'
import unusedImportsPlugin from 'eslint-plugin-unused-imports'
import js from '@eslint/js'
import globals from 'globals'
export default [
{
files: ['**/*.js', '**/*.ts', '**/*.tsx'],
languageOptions: {
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
globals: {
...globals.browser,
},
},
plugins: {
import: importPlugin,
'unused-imports': unusedImportsPlugin,
},
rules: {
...js.configs.recommended.rules,
'import/no-duplicates': 'error',
'import/order': [
'error',
{
'newlines-between': 'never',
pathGroups: [
{
pattern: '@/**',
group: 'external',
position: 'after',
},
],
},
],
'import/no-named-as-default': 'off',
'import/no-restricted-paths': ['error'],
'import/extensions': [
'error',
'never',
{ ignorePackages: true, pattern: { css: 'always' } },
],
'import/no-internal-modules': [
'error',
{
allow: [
'@*/**',
'firebase/**',
'react-dom/**',
],
},
],
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
},
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: typescript.parser,
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
},
},
settings: {
react: {
version: 'detect',
},
},
plugins: {
'@typescript-eslint': typescript.plugin,
react: reactPlugin,
'react-hooks': reactHooksPlugin,
'jsx-a11y': jsxA11yPlugin,
},
rules: {
...typescript.configs.eslintRecommended.rules,
...typescript.configs.strict.rules,
...typescript.configs.strictTypeChecked.rules,
...reactPlugin.configs.recommended.rules,
...reactHooksPlugin.configs.recommended.rules,
...jsxA11yPlugin.configs.recommended.rules,
'require-await': 'error',
'no-undef': 'warn',
'no-redeclare': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/no-unused-vars': 'off', // for unuser-imports
'react/react-in-jsx-scope': 'off',
'react/jsx-filename-extension': ['error', { extensions: ['.tsx'] }],
'react/jsx-curly-brace-presence': [
'error',
{ props: 'never', children: 'never', propElementValues: 'always' },
],
'react/jsx-no-useless-fragment': 'error',
'react/no-unknown-property': 'error',
'react/jsx-boolean-value': 'error',
'react-hooks/exhaustive-deps': 'error',
'jsx-a11y/alt-text': 'off',
'jsx-a11y/anchor-has-content': 'warn',
'jsx-a11y/anchor-is-valid': 'warn',
'jsx-a11y/click-events-have-key-events': 'warn',
'jsx-a11y/no-static-element-interactions': 'warn',
},
},
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment