Skip to content

Instantly share code, notes, and snippets.

@freeatnet
Last active July 6, 2025 17:15
Show Gist options
  • Save freeatnet/112084e603b5dc4943e4e8ab7ccfba04 to your computer and use it in GitHub Desktop.
Save freeatnet/112084e603b5dc4943e4e8ab7ccfba04 to your computer and use it in GitHub Desktop.
/*eslint sort-keys: "error"*/
import { dirname } from "path";
import { fileURLToPath } from "url";
import { FlatCompat } from "@eslint/eslintrc";
import eslint from "@eslint/js";
import pluginQuery from "@tanstack/eslint-plugin-query";
import tsParser from "@typescript-eslint/parser";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import tailwind from "eslint-plugin-tailwindcss";
import tseslint from "typescript-eslint";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
});
const eslintConfig = tseslint.config(
{
ignores: [
// gel generated query files
"src/**/*.query.ts",
],
},
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
tseslint.configs.stylisticTypeChecked,
...compat.extends("next/core-web-vitals"),
...pluginQuery.configs["flat/recommended"],
...tailwind.configs["flat/recommended"],
eslintPluginPrettierRecommended,
{
languageOptions: {
parser: tsParser,
parserOptions: {
projectService: true,
sourceType: "module",
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
"@typescript-eslint/consistent-type-assertions": [
"error",
{ assertionStyle: "never" },
],
"@typescript-eslint/consistent-type-definitions": "off", // No preference on type vs interface
"@typescript-eslint/consistent-type-exports": [
"warn",
{ fixMixedExportsWithInlineTypeSpecifier: true },
],
"@typescript-eslint/consistent-type-imports": [
"warn",
{
fixStyle: "inline-type-imports",
prefer: "type-imports",
},
],
"@typescript-eslint/no-deprecated": "error",
"@typescript-eslint/no-misused-promises": [
"error",
{
checksVoidReturn: { attributes: false },
},
],
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-unnecessary-condition": [
"error",
{ allowConstantLoopConditions: true },
],
"@typescript-eslint/no-unsafe-assignment": ["warn"],
"@typescript-eslint/no-unused-expressions": [
"error",
{ allowShortCircuit: true, allowTernary: true },
],
"@typescript-eslint/no-unused-vars": [
"warn",
{ argsIgnorePattern: "^_", caughtErrors: "none" },
],
"@typescript-eslint/restrict-template-expressions": [
"error",
{
allowAny: false,
allowBoolean: false,
allowNever: false,
allowNullish: false,
allowRegExp: false,
},
],
"import/first": "error",
"import/no-cycle": "error",
"import/no-duplicates": "error",
"import/order": [
"error",
{
alphabetize: {
caseInsensitive: true,
order: "asc",
},
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
],
"newlines-between": "always",
pathGroups: [
{
group: "internal",
pattern: "~/**",
position: "after",
},
],
},
],
"no-console": [
"warn",
{
allow: ["warn", "error"],
},
],
"no-empty": ["error", { allowEmptyCatch: true }],
"react/jsx-curly-brace-presence": "warn",
},
},
{
files: ["*.cjs"],
rules: {
"@typescript-eslint/no-require-imports": "off",
},
},
);
export default eslintConfig;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment