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(eslint): restructuring + vitest support + docs and mocha deprecation #723

Merged
merged 6 commits into from
Aug 10, 2023

Conversation

erunion
Copy link
Member

@erunion erunion commented Aug 9, 2023

🧰 Changes

I've been immediately impressed with Vitest that I want to move as much of our libraries off Jest and over to it. This starts that process by adding a new ESLint standards config for it with eslint-plugin-vitest.

  • Breaks up @readme/eslint-config/testing into four different configs:
    • @readme/eslint-config/testing/jest-dom - These configs were a part of our stock @readme/eslint-config/testing but as most projects we've got don't use jest-dom it doesn't make sense to include it in the base config.
    • @readme/eslint-config/testing/jest
    • @readme/eslint-config/testing/react
    • @readme/eslint-config/testing/vitest
  • Deprecates and removes @readme/eslint-config/testing-mocha. We only use Mocha, and this config, in two of our open source packages but I plan on moving them over to Vitest whenever I get a chance.
  • Deprecates and removes @readme/eslint-config/docs. We only used this in oas and I had most rules from it disabled there as it's very annoying and doesn't really fit in a TS codebase, which that is.
  • Moves spectral-config and stylelint-config from using Jest to run their tests to using Vitest. Doing this allows us to remove the experimental flag from Node as Vitest supports ESM projects by default. Vitest kinda slaps??

@erunion erunion requested review from dannobytes and kanadgupta and removed request for kanadgupta August 9, 2023 23:32
@erunion erunion changed the title feat(eslint): restructuring + vitest support + docs deprecation feat(eslint): restructuring + vitest support + docs and mocha deprecation Aug 9, 2023
@erunion erunion added enhancement New feature or request refactor Issues about tackling technical debt labels Aug 9, 2023
packages/eslint-config/package.json Show resolved Hide resolved
Comment on lines +43 to +44
"eslint-plugin-you-dont-need-lodash-underscore": "^6.12.0",
"lodash.merge": "^4.6.2"
Copy link
Member

Choose a reason for hiding this comment

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

also dying at the fact that these are right next to each other

packages/eslint-config/testing/react.js Outdated Show resolved Hide resolved
@@ -1,9 +1,10 @@
const fs = require('fs');
Copy link
Member

Choose a reason for hiding this comment

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

Oh damn so wait are tests ESM now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah though vitest ships a CJS file for tests that use only require() it's actually empty1 so if you do const { it, expect } = require('vitest') you'll get a "it is not a function" error because the export from vitest that's being loaded there is just an empty object.

Kinda annoying but cool that all of these tests can use import without any TS or Babel configs.

Footnotes

  1. https://github.com/vitest-dev/vitest/blob/main/packages/vitest/index.cjs

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha! I prefer this pattern of importing these rather than the mysterious jest global shit

@@ -9,7 +9,7 @@
},
"scripts": {
"lint": "eslint .",
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
"test": "vitest run"
Copy link
Member

Choose a reason for hiding this comment

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

Hell yeah

Copy link
Member

@kanadgupta kanadgupta left a comment

Choose a reason for hiding this comment

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

yayyyy eat shit meta

@erunion erunion merged commit dd69897 into main Aug 10, 2023
3 checks passed
@erunion erunion deleted the feat/eslint-restructuring branch August 10, 2023 05:30
@dannobytes
Copy link
Contributor

Moves spectral-config and stylelint-config from using Jest to run their tests to using Vitest. Doing this allows us to remove the experimental flag from Node as Vitest supports ESM projects by default. Vitest kinda slaps??

This alone makes me sold on Vitest, which I've never used before but looks pretty amazing 😍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor Issues about tackling technical debt
Development

Successfully merging this pull request may close these issues.

None yet

3 participants