Skip to content

Instantly share code, notes, and snippets.

@matthijsgroen
Created June 27, 2024 06:40
Show Gist options
  • Save matthijsgroen/fa422d8ecf17b502abc7feb97699fc9c to your computer and use it in GitHub Desktop.
Save matthijsgroen/fa422d8ecf17b502abc7feb97699fc9c to your computer and use it in GitHub Desktop.
Eslint Config
import { fixupConfigRules } from "@eslint/compat";
import pluginJs from "@eslint/js";
import eslintConfigPrettier from "eslint-config-prettier";
import pluginReactConfig from "eslint-plugin-react/configs/recommended.js";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import globals from "globals";
import tseslint from "typescript-eslint";
export default [
{ languageOptions: { globals: globals.browser } },
{
...pluginJs.configs.recommended,
settings: {
react: {
version: "detect",
},
},
},
...tseslint.configs.recommended,
...fixupConfigRules(pluginReactConfig),
eslintConfigPrettier,
{
plugins: {
"simple-import-sort": simpleImportSort,
},
rules: {
"react/prop-types": "off", // Does not work nicely with React.FC TS declarations
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_" },
],
"simple-import-sort/exports": "error",
"simple-import-sort/imports": [
"error",
{
groups: [
// Packages `react` related packages come first.
["^react", "^@?\\w"],
// Internal packages.
["^(@|components)(/.*|$)"],
// Side effect imports.
["^\\u0000"],
// Parent imports. Put `..` last.
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
// Other relative imports. Put same-folder imports and `.` last.
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
// Style imports.
["^.+\\.?(css)$"],
],
},
],
},
},
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment