Skip to content

Instantly share code, notes, and snippets.

@bossever
Created October 25, 2024 08:28
Show Gist options
  • Select an option

  • Save bossever/6ad8ad2e4e25ace03e796f9c5d9663f1 to your computer and use it in GitHub Desktop.

Select an option

Save bossever/6ad8ad2e4e25ace03e796f9c5d9663f1 to your computer and use it in GitHub Desktop.
ESLint Flat Config (fixed import/resolver & import/parser options)
import js from "@eslint/js";
import importPlugin from "eslint-plugin-import";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import globals from "globals";
import tseslint from "typescript-eslint";
export default tseslint.config(
{
ignores: [
"coverage",
"dist",
"eslint.config.js",
"vite.config.ts",
"vitest.config.ts",
"postcss.config.js",
"tailwind.config.js",
"deprecated-lintrc.cjs",
],
},
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
import: importPlugin,
react: react,
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"react/no-unstable-nested-components": "off",
"react/jsx-props-no-spreading": "off",
"react/jsx-no-useless-fragment": ["error", { allowExpressions: true }],
"react/require-default-props": "off",
"react/function-component-definition": "off",
"arrow-body-style": ["error", "as-needed"],
"@typescript-eslint/no-shadow": "off",
"@typescript-eslint/consistent-type-imports": [
"error",
{
prefer: "type-imports",
},
],
"import/prefer-default-export": "off",
"import/order": [
"error",
{
groups: [
"builtin",
"external",
"internal",
["parent", "sibling"],
"index",
"object",
"type",
],
alphabetize: {
order: "asc",
},
"newlines-between": "always",
warnOnUnassignedImports: false,
},
],
},
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment