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

chore: bump eslint and its plugins #13412

Merged
merged 4 commits into from
Jun 4, 2021
Merged

chore: bump eslint and its plugins #13412

merged 4 commits into from
Jun 4, 2021

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Jun 2, 2021

Q                       A
License MIT
yarn up eslint "eslint-*"
yarn dedupe

This PR also fixes the following lint errors reported by new eslint-plugin-jest:

  • jest/valide-title: If the title is a variable, suppress this rule when the test title comes from the fixture, otherwise improves the text. If the title is text, fixes is straightforward.
  • jest/no-done-callback: Wrap the test routine in a Promise constructor.
  • jest/no-conditional-expect: Hoist conditions to the it level, or split to two loop calls. expect() is allowed in loop.

"eslint-plugin-flowtype": "^5.7.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^24.3.6",
"eslint-plugin-prettier": "^3.4.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the root package, it is fine to bump major versions since we build on latest node.

@babel-bot
Copy link
Collaborator

babel-bot commented Jun 2, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/46672/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 2, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 66b73c7:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@JLHwung JLHwung marked this pull request as draft June 2, 2021 18:18
@JLHwung JLHwung marked this pull request as ready for review June 2, 2021 19:40
for (let i = 0; i < options1.plugins.length; i++) {
if (i === 0 || i === 1 || i === 4 || i === 5 || i === 6) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The linter helps catching a bug: "i === 6" is unreachable.

expect(options2.plugins[i]).not.toBe(options1.plugins[i]);
} else {
expect(options2.plugins[i]).toBe(options1.plugins[i]);
continue;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is sort-of cheating. The expect is still implicitly guarded. However I can't figure out a better way except constructing a list of valid i, which seems to be overkills here.

/cc @SimenB

Copy link
Contributor

@SimenB SimenB Jun 2, 2021

Choose a reason for hiding this comment

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

Personal preference is mostly ignore comments even if I generally agree with the lint rule.

@G-Rath thoughts on this one?

Copy link

@G-Rath G-Rath Jun 2, 2021

Choose a reason for hiding this comment

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

I think I like how it looks here - but that could also be because I'm bias against else 😅

Another alternative would be to do the comparison yourself and compare to true:

const plugin1 = options1.plugins[i];
const plugin2 = options2.plugins[i];

expect(Object.is(plugin2, plugin1).toBe(i !== 2);

I'm pretty sure we don't have any rules that'll complain on that (tho maybe we should?) - but one of the big downsides of course is that jest won't be as helpful with it's error messages if the test failed, since it'll always just complain "expected value to be true"

Comment on lines +769 to +770
return new Promise(resolve => {
transformFile(
Copy link
Member

Choose a reason for hiding this comment

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

In all these tests we could use transformFileAsync which returns a promise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test is focused on the behaviour of transformFile so I don't think we should replace here. I have added a new test case on transformFileAsync.

packages/babel-core/test/config-loading.js Outdated Show resolved Hide resolved
packages/babel-core/test/config-loading.js Outdated Show resolved Hide resolved
packages/babel-core/test/config-loading.js Outdated Show resolved Hide resolved
packages/babel-generator/test/index.js Outdated Show resolved Hide resolved
packages/babel-register/test/index.js Outdated Show resolved Hide resolved
const bundler = browserify(
path.join(
path.dirname(fileURLToPath(import.meta.url)),
"fixtures/browserify/register.js",
),
);
return new Promise((resolve, reject) => {
bundler.bundle(function (err, bundle) {
if (err) return reject(err);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The promise will be rejected when bundler fails.

@JLHwung JLHwung merged commit 4eda1c8 into babel:main Jun 4, 2021
@JLHwung JLHwung deleted the bump-eslint branch June 4, 2021 03:42
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 3, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: eslint outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Dependency ⬆️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants