turbo icon indicating copy to clipboard operation
turbo copied to clipboard

chore(linting): implement ESLint flat config compatibility for `eslin…

Open jeremy-code opened this issue 1 year ago • 4 comments

Description

  • Add "flat/recommended" config to eslint-plugin-turbo
  • Add meta property to plugin
  • Update README.md accordingly with information on using flat config
  • Add tests for flat config in __tests__/cwdFlat.test.ts

Testing Instructions

Run the following command:

pnpm run test --filter=eslint-plugin-turbo

jeremy-code avatar Jun 26 '24 04:06 jeremy-code

The latest updates on your projects. Learn more about Vercel for Git ↗︎

6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Nov 12, 2024 6:08pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Nov 12, 2024 6:08pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Nov 12, 2024 6:08pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Nov 12, 2024 6:08pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Nov 12, 2024 6:08pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Nov 12, 2024 6:08pm

vercel[bot] avatar Jun 26 '24 04:06 vercel[bot]

@jeremy-code is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jun 26 '24 04:06 vercel[bot]

Previous PR was #8054, @anthonyshew

jeremy-code avatar Jun 26 '24 04:06 jeremy-code

Really appreciate this! Do you have a repo I could test this out in? I haven't gotten to try out Flat Config yet.

anthonyshew avatar Jul 08 '24 15:07 anthonyshew

@jeremy-code We'd love to get this merged! Are you able to fix up the conflicts so we can try this out with a canary release?

anthonyshew avatar Nov 07 '24 04:11 anthonyshew

@anthonyshew Sorry, I didn't realize y'all were blocked on me. I have fixed any conflicts. Let me know if there's any issues. I ran the test suite again and saw no errors.

jeremy-code avatar Nov 08 '24 02:11 jeremy-code

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

🚮 Removed packages: npm/@types/[email protected]

View full report↗︎

socket-security[bot] avatar Nov 08 '24 02:11 socket-security[bot]

@jeremy-code No worries. I went on parental leave so I wasn't able to come back and review sooner - and I neglected to let anyone know to come review this one. Totally my fault!

I'm trying this out now in a create-next-app and it doesn't appear to be picking up issues. CleanShot 2024-11-10 at 09 18 15@2x

However, I'm not sure that I'm configuring things right. I haven't had a chance to work with the new ESLint configuration format, so it might be silently failing. Do you have an example repo where I can hand test this?

anthonyshew avatar Nov 10 '24 16:11 anthonyshew

image

Oh so that's what you meant by example repo -- I thought you just meant the ESLint config file.

The above is a quick and (very) dirty proof of concept to show it works with the the environmental variable rule. The corresponding repo is here: jeremy-code/turborepo-test.

If you're wondering why it's not underlining in VSCode, you have to enable "eslint.useFlatConfig" to true or have the ENV variable "ESLINT_USE_FLAT_CONFIG" for the ESLint extension.

EDIT:

I made some changes to try to make it a bit cleaner than it was previously. The corresponding repo is here: jeremy-code/turborepo-test. Here's a more thorough testing of it:

image

The ENV variables error or don't error correctly with the exception of process.env.TEST_ENV_IN_DOT_ENV (I think this is a recent change so not sure whether this is expected?). Also, apps/docs uses the flat config and doesn't error.

jeremy-code avatar Nov 10 '24 23:11 jeremy-code

I'm getting Error: Cannot find package '/Users/anthonyshew/projects/debugs/turborepo-test/packages/eslint-config/node_modules/eslint-plugin-turbo/package.json' imported from /Users/anthonyshew/projects/debugs/turborepo-test/packages/eslint-config/index.mjs in that repo. Do you know why that is?

anthonyshew avatar Nov 12 '24 17:11 anthonyshew

Did you run pnpm run build beforehand (or more specifically tsup in packages/eslint-plugin-turbo)? I just straight up copied-pasted all the code necessary for the ESLint plugin just for a quick sanity check.

On Tue, Nov 12, 2024 at 9:10 AM Anthony Shew @.***> wrote:

I'm getting Error: Cannot find package '/Users/anthonyshew/projects/debugs/turborepo-test/packages/eslint-config/node_modules/eslint-plugin-turbo/package.json' imported from /Users/anthonyshew/projects/debugs/turborepo-test/packages/eslint-config/index.mjs in that repo. Do you know why that is?

— Reply to this email directly, view it on GitHub https://github.com/vercel/turborepo/pull/8606#issuecomment-2471112835, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKKBKOXZQOJMA4OQRYPS44T2AIY6RAVCNFSM6AAAAABJ5CJDAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZRGEYTEOBTGU . You are receiving this because you were mentioned.Message ID: @.***>

jeremy-code avatar Nov 12 '24 17:11 jeremy-code

Oops, I thought I had done that but apparently not. This looks great!

anthonyshew avatar Nov 12 '24 17:11 anthonyshew

Sorry about my commits above. I messed up history and am getting back on track.

anthonyshew avatar Nov 12 '24 18:11 anthonyshew

Nono I am pretty certain it's my fault I thought (hoped?) I fixed these merge issues since the original commit was a bit of time ago. Let me see if I can make a new PR with a different branch

jeremy-code avatar Nov 12 '24 18:11 jeremy-code