Skip to content

Instantly share code, notes, and snippets.

@Leland
Created October 30, 2025 15:35
Show Gist options
  • Select an option

  • Save Leland/043d73224fb957b1aac24cf275ff0535 to your computer and use it in GitHub Desktop.

Select an option

Save Leland/043d73224fb957b1aac24cf275ff0535 to your computer and use it in GitHub Desktop.
ESLint 9 flat config file for TypeScript React with StoryBook and Prettier
// ⚠️ note! you'll want jiti to use TS eslint configs
// https://eslint.org/docs/latest/use/configure/configuration-files#typescript-configuration-files
import { defineConfig, globalIgnores } from "eslint/config";
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import reactPlugin from "eslint-plugin-react";
import reactHooksPlugin from "eslint-plugin-react-hooks";
// @ts-expect-error - JSX a11y plugin doesn't export types properly, see https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/1010
import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
import storybookPlugin from "eslint-plugin-storybook";
import eslintConfigPrettier from "eslint-config-prettier/flat";
const ignoredFiles = ["**/node_modules/**", "**/dist/**"];
const relaxedFiles = [
"**/*.test.{ts,tsx}",
"**/*.stories.{ts,tsx}",
"**/__mocks__/**",
];
// @see https://typescript-eslint.io/rules/no-unused-vars/#what-benefits-does-this-rule-have-over-typescript
const unusedVarsExceptUnderscored = {
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
};
export default defineConfig(
globalIgnores(ignoredFiles),
eslint.configs.recommended,
tseslint.configs.recommended,
tseslint.configs.strict,
tseslint.configs.stylistic,
// @ts-expect-error - React plugin flat configs have type issues, see https://github.com/jsx-eslint/eslint-plugin-react/issues/3956
reactPlugin.configs.flat.recommended,
reactPlugin.configs.flat["jsx-runtime"],
reactHooksPlugin.configs.flat.recommended,
jsxA11yPlugin.flatConfigs.recommended,
...storybookPlugin.configs["flat/recommended"],
eslintConfigPrettier,
{
settings: { react: { version: "detect" } },
rules: {
"@typescript-eslint/no-unused-vars": [
"error",
unusedVarsExceptUnderscored,
],
},
},
{ files: relaxedFiles, rules: { "no-console": "off" } },
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment