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

fix: configs in plugin declaration file #428

Merged
merged 2 commits into from Apr 14, 2024

Conversation

henrist
Copy link
Contributor

@henrist henrist commented Apr 14, 2024

Fixes #427

This also fixes the globals values of env config. It was previously writeable but the correct is writable (all though I don't understand why it's specified as writable in the first place). This was not type checked previously since there are no type constraints with Object.assign.

Side note: I'm noticing that the CI pipeline don't typecheck the code. pnpm tsc fails on main for me.

Copy link
Owner

@veritem veritem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

There is a lot of issues with type checking but I do not have enough time to fix them. Will look into it when I get time.

@veritem veritem merged commit a554dd2 into veritem:main Apr 14, 2024
@Sparticuz
Copy link

If I'm not mistaken, this means we can now do this?

  {
    extends: [vitest.configs.recommended],
    files: ["tests/**", "test/**"],
    languageOptions: {
      globals: {
        ...vitest.environments.env.globals,
      },
    },
  },

instead of

  {
    files: ["tests/**", "test/**"],
    languageOptions: {
      globals: {
        ...vitest.environments.env.globals,
      },
    },
    plugins: {
      vitest,
    },
    rules: {
      ...vitest.configs.recommended.rules,
    },
  },

@henrist
Copy link
Contributor Author

henrist commented Apr 16, 2024

@Sparticuz I think I would have done this for something like that:

export default tseslint.config(
  // ...
  {
    ...vitest.configs.recommended,
    ...vitest.configs.env,
    files: ["tests/**", "test/**"],
  },
)

The extends property doesn't behave the way you think (I believe), and it's actually no longer part of core ESLint. See the comment here: https://github.com/typescript-eslint/typescript-eslint/blob/e44a1a280f08f9fd0d29f74e5c3e73b7b64a9606/packages/typescript-eslint/src/config-helper.ts#L22-L62

If you don't depend on the files filter it can even be top level.

export default tseslint.config(
  // ...
  vitest.configs.recommended,
  vitest.configs.env,
)

I'm new to the flat config myself though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Declaration file missing plugin configs
3 participants