Skip to content

chore: use swc for tests instead of Babel #4584

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

Merged
merged 10 commits into from
Mar 2, 2022

Conversation

JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Feb 22, 2022

PR Checklist

Overview

Uses @swc/jest instead of Babel for transpiling during tests. Roughly the same approach as typescript-eslint/tslint-to-eslint-config#1367.

Performance runs

  • Execution: hyperfine 'yarn jest' -m 25 -p 'yarn jest --clearCache' --show-output within the below packages. Terminal was in focus and no actions taken on open programs during test runs.
  • Hardware: Surface Laptop 4, 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz.
  • Software: WSL 2.0 in an Ubuntu drive via a VS Code terminal.
Package Babel Time SWC Time (old - new) / old x 100%
eslint-plugin 206.237 s ± 3.049 s 199.548 s ± 3.271 s 3% faster
eslint-plugin-internal 6.057 s ± 0.366 s 5.200 s ± 0.254 s 14% faster
Raw data

Babel in packages/eslint-plugin pre-#4599:

  Time (mean ± σ):     206.237 s ±  3.049 s    [User: 1156.814 s, System: 40.173 s]
  Range (min … max):   201.867 s … 212.914 s    25 runs

SWC in packages/eslint-plugin pre-#4599:

  Time (mean ± σ):     199.548 s ±  3.271 s    [User: 1093.411 s, System: 40.435 s]
  Range (min … max):   190.621 s … 206.566 s    25 runs

Babel in packages/eslint-plugin-internal:

  Time (mean ± σ):      6.057 s ±  0.366 s    [User: 22.428 s, System: 1.324 s]
  Range (min … max):    5.176 s …  7.015 s    25 runs

SWC in packages/eslint-plugin-internal:

  Time (mean ± σ):      5.200 s ±  0.254 s    [User: 19.014 s, System: 1.256 s]
  Range (min … max):    4.851 s …  5.725 s    25 runs

@nx-cloud
Copy link

nx-cloud bot commented Feb 22, 2022

☁️ Nx Cloud Report

CI ran the following commands for commit 9216077. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 48 targets

Sent with 💌 from NxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@netlify
Copy link

netlify bot commented Feb 22, 2022

❌ Deploy Preview for typescript-eslint failed.

🔨 Explore the source changes: 9216077

🔍 Inspect the deploy log: https://app.netlify.com/sites/typescript-eslint/deploys/621fbd8d0070c70008e82308

@JoshuaKGoldberg JoshuaKGoldberg added the DO NOT MERGE PRs which should not be merged yet label Feb 22, 2022
@JoshuaKGoldberg
Copy link
Member Author

swc-project/swc#3672 was discovered as part of this PR.

https://github.com/typescript-eslint/typescript-eslint/runs/5292666530?check_suite_focus=true

 FAIL  tests/rules/index.test.ts
  ● Test suite failed to run

    error: Expected ',', got ':'
      
       |
    97 |               : (fixer): TSESLint.RuleFix[] => {
       |                        ^

@codecov
Copy link

codecov bot commented Feb 22, 2022

Codecov Report

Merging #4584 (9216077) into main (fabfc2b) will increase coverage by 1.82%.
The diff coverage is 98.64%.

@@            Coverage Diff             @@
##             main    #4584      +/-   ##
==========================================
+ Coverage   92.41%   94.23%   +1.82%     
==========================================
  Files         350      151     -199     
  Lines       12059     7933    -4126     
  Branches     3430     2560     -870     
==========================================
- Hits        11144     7476    -3668     
+ Misses        642      262     -380     
+ Partials      273      195      -78     
Flag Coverage Δ
unittest 94.23% <98.64%> (+1.82%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...nt-plugin/src/rules/consistent-type-definitions.ts 97.14% <92.85%> (-0.16%) ⬇️
...gin/src/rules/naming-convention-utils/validator.ts 94.96% <100.00%> (-0.55%) ⬇️
...ges/eslint-plugin/src/rules/no-misused-promises.ts 98.71% <100.00%> (+0.07%) ⬆️
...es/eslint-plugin/src/rules/prefer-function-type.ts 97.14% <100.00%> (-0.05%) ⬇️
...es/eslint-plugin/src/util/getOperatorPrecedence.ts 31.42% <0.00%> (-28.58%) ⬇️
.../src/rules/sort-type-union-intersection-members.ts 90.74% <0.00%> (-1.80%) ⬇️
...ackages/eslint-plugin/src/rules/no-invalid-this.ts 78.26% <0.00%> (-1.74%) ⬇️
...ckages/eslint-plugin/src/rules/no-magic-numbers.ts 81.25% <0.00%> (-1.45%) ⬇️
...s/eslint-plugin/src/rules/no-implicit-any-catch.ts 83.33% <0.00%> (-1.29%) ⬇️
.../eslint-plugin/src/rules/method-signature-style.ts 87.65% <0.00%> (-1.24%) ⬇️
... and 301 more

@@ -85,57 +85,54 @@ export default util.createRule({
}),
...(option === 'type' && {
TSInterfaceDeclaration(node): void {
const fix = isCurrentlyTraversedNodeWithinModuleDeclaration()
Copy link
Member Author

Choose a reason for hiding this comment

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

These changes don't do anything other than get us around swc-project/swc#3672

@JoshuaKGoldberg JoshuaKGoldberg added tests anything to do with testing and removed DO NOT MERGE PRs which should not be merged yet labels Mar 1, 2022
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review March 1, 2022 17:54
@JoshuaKGoldberg JoshuaKGoldberg merged commit fa381f3 into typescript-eslint:main Mar 2, 2022
@JoshuaKGoldberg JoshuaKGoldberg deleted the swc branch March 2, 2022 19:10
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tests anything to do with testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Experiment with SWC instead of Babel for Jest tests
2 participants