Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to utilise the new ESLint flat file config. #1955

Open
maclong9 opened this issue Aug 4, 2024 · 7 comments
Open

feat: update to utilise the new ESLint flat file config. #1955

maclong9 opened this issue Aug 4, 2024 · 7 comments
Labels
📌 area: t3-app Relates to the generated T3 App 🔰 good first issue Good for newcomers 🌟 enhancement New feature or request

Comments

@maclong9
Copy link

maclong9 commented Aug 4, 2024

Is your feature request related to a problem? Please describe.

This cli tool is great for setting up a project with a good base stack really quickly, only snag in productivity at the moment is requiring the conversion of .eslintrc.json to the new eslint.config.{m|c}js format.

Describe the solution you'd like to see

Update the standard configuration to utilise the new flat file configuration.

Describe alternate solutions

Write a codemod script that can be run by developers who want to use the new format.

Additional information

No response

@maclong9 maclong9 added the 🌟 enhancement New feature or request label Aug 4, 2024
@juliusmarminge
Copy link
Member

only snag in productivity at the moment is requiring the conversion of .eslintrc.json to the new eslint.config.{m|c}js format.

This is a bit of a stretch given a lot (probably a large majority actually) still doesn't support FlatConfig natively

@juliusmarminge
Copy link
Member

juliusmarminge commented Oct 16, 2024

Reviving this now that v8 has reached EOL.

Next 15 has official support for v9 (https://nextjs.org/blog/next-15-rc2#eslint-9-support) and also flat config (https://x.com/feedthejim/status/1846502242590802180)

If we assume Next 15 will be marked stable next week at NextConf we could start preparing a PR with the necessary bumps

@TheCukitoDev
Copy link

Now Next.js 15 is stable...

@dmurvihill
Copy link

Getting deprecation warnings from eslint 8 now.

npm warn deprecated [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.

@MGSimard
Copy link

Any news on this? Doing manual migrations to eslint.config.mjs is getting bothersome

@juliusmarminge
Copy link
Member

Any news on this? Doing manual migrations to eslint.config.mjs is getting bothersome

Feel free to submit a PR !

@MGSimard
Copy link

MGSimard commented Jan 14, 2025

Any news on this? Doing manual migrations to eslint.config.mjs is getting bothersome

Feel free to submit a PR !

Spent a couple hours catching up on all this stuff today, first time looking at monorepos. On CLI build I'm running into "tty" dynamic requires errors when adding imports to extras/config/_eslint.js necessary for the flat config (such as FlatCompat and plugin imports), so it's a bit annoying. Also is it me or the upgrade workspace is behind base/latest? Maybe it's just that I'm not familiar with monorepos/turborepos.

Anyways, for the time being if anyone is looking for a resource to convert manually, this is more or less the output from this codemod: https://eslint.org/blog/2024/05/eslint-configuration-migrator/. Seems to work fine? Made sure to also update tsconfig.json's eslint config file include to "eslint.config.mjs".

/** @ts-expect-error - @eslint/eslintrc is untyped */
import { FlatCompat } from "@eslint/eslintrc";
import tsEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
/** @ts-expect-error - eslint-plugin-drizzle is untyped */
import drizzle from "eslint-plugin-drizzle";

const compat = new FlatCompat({
  baseDirectory: import.meta.dirname,
});

/** @type {import("eslint").Linter.Config[]} */
export default [
  ...compat.extends(
    "next/core-web-vitals",
    "plugin:@typescript-eslint/recommended-type-checked",
    "plugin:@typescript-eslint/stylistic-type-checked"
  ),
  {
    plugins: {
      "@typescript-eslint": tsEslint,
      drizzle,
    },
    languageOptions: {
      parser: tsParser,
      ecmaVersion: "latest",
      sourceType: "module",
      parserOptions: {
        project: true,
      },
    },
    rules: {
      "@typescript-eslint/array-type": "off",
      "@typescript-eslint/consistent-type-definitions": "off",
      "@typescript-eslint/consistent-type-imports": [
        "warn",
        {
          prefer: "type-imports",
          fixStyle: "inline-type-imports",
        },
      ],
      "@typescript-eslint/no-unused-vars": [
        "warn",
        {
          argsIgnorePattern: "^_",
        },
      ],
      "@typescript-eslint/require-await": "off",
      "@typescript-eslint/no-misused-promises": [
        "error",
        {
          checksVoidReturn: {
            attributes: false,
          },
        },
      ],
      "drizzle/enforce-delete-with-where": [
        "error",
        {
          drizzleObjectName: ["db", "ctx.db"],
        },
      ],
      "drizzle/enforce-update-with-where": [
        "error",
        {
          drizzleObjectName: ["db", "ctx.db"],
        },
      ],
    },
  },
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📌 area: t3-app Relates to the generated T3 App 🔰 good first issue Good for newcomers 🌟 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants