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

Upgrade ESLint to 6 #236

Merged
merged 7 commits into from May 21, 2020
Merged

Conversation

kylemh
Copy link
Collaborator

@kylemh kylemh commented Aug 19, 2019

Resolves #222

Summary

For those uninterested in seeing the conversation below, we simply upgraded the dependency and removed an assertion regarding the number of times fs.readFileSync is called, as it is an integration detail that ESLint controls - not this library.

Original Post

So... logging the calls of fsMock.readFileSync yields:

an array of 5 calls, 4 of which relate to .eslintignore

The following test logs error if it cannot read the file... sets and resets the mock at the test-level, instead of the test lifecycle; however, when I attempt this workaround...

test('reads text from fs if filePath is provided but not text', () => {
  const originalMock = fsMock.readFileSync;
  fsMock.readFileSync = jest.fn();

  const filePath = '/blah-blah/some-file.js';
  format({ filePath });

  expect(fsMock.readFileSync).toHaveBeenCalledWith(filePath, 'utf8');

  // one hit to get the file and one for the eslintignore
  expect(fsMock.readFileSync).toHaveBeenCalledTimes(2);

  fsMock.readFileSync = originalMock;
});

I'm met with many other broken tests:

Screen Shot 2019-08-19 at 3 10 05 PM
Screen Shot 2019-08-19 at 3 09 55 PM
Screen Shot 2019-08-19 at 3 09 33 PM

I skimmed the changelog for ESLint since v5, but couldn't find a reasoning for the increased calls; so I'm left to imagine that

a) It is invalid and the way the tests are written currently need a massive overhaul to avoid leaking into other . tests.

OR

b) It is valid, but I'm unsure how to document the extra calls.

@kylemh kylemh changed the title Upgrade eslint to 6 Upgrade ESLint to 6 Aug 19, 2019
@codecov-io
Copy link

codecov-io commented Aug 19, 2019

Codecov Report

Merging #236 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #236   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines         208    208           
  Branches       42     42           
=====================================
  Hits          208    208

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c87b69b...acaa3b5. Read the comment docs.

@kylemh
Copy link
Collaborator Author

kylemh commented Sep 20, 2019

@robertpaul01 I feel like you didn’t read anything.

No it can’t be merged.

@jakeleventhal
Copy link

@kylemh lmfao

@kylemh
Copy link
Collaborator Author

kylemh commented Sep 22, 2019

Hell yeah, well why didn't you say so!?

Also, you debugged the test incorrectly. You need to do this to not crash all the test like you did because you stubbed the readFileSync to an empty function.

This is totally correct - didn't realize fs was mocked separately as part of the Jest setup, so I needed to pass it the mock implementation, or - better yet - I'll just spy on the original mock fn implementation.

Unfortunately, even with the corrections, I am still seeing 5 function calls versus 2. To be clear: I tried both the done fn implementation you showed and the spy method I tried.

The janky tests should be turned off or updated.

Doesn't seem like the safest strategy, which is why I tried opening up this issue for discussion. I agree with you and think these tests are "janky", but the library main contributors should be the one to see in finality.

@numso
Copy link

numso commented Sep 24, 2019

@kylemh: Based on what @robertpaul01 wrote, the way prettier-eslint interacts with eslint@6 causes .eslintignore to be read multiple times during the test. That test should now assert that readFileSync was called 5 times.

IMHO The test in question is testing more of the internal details of eslint than it should. That test is just trying to ensure that format, given a filePath, reads and uses the file at that filePath. That being the case, I believe the call count assertion (expect(readFileSyncMockSpy).toHaveBeenCalledTimes(5);) is unneeded and should be removed.

@kylemh
Copy link
Collaborator Author

kylemh commented Sep 24, 2019

Thank you all for making it a discussion y'all ❤️
I agree that the most important assertion is that readFileSync is called and with the right parameters, but not necessarily the number of calls.

@zimme if you feel asserting the number of calls is necessary let me know, and I'll add a comment to this pull request as contextual information. Otherwise, this PR should be ready.

@zimme
Copy link
Member

zimme commented Sep 24, 2019

I'll make sure to carve out some time this week for this so we can get a new major version out with support for eslint 6

@JSanchezIO
Copy link

Has any progress been made on this?

@zimme
Copy link
Member

zimme commented Sep 30, 2019

I started to look at this today, however family life intervened and here we are me hoping to get a few hours available this week to look at this and hopefully merge

@kylemh
Copy link
Collaborator Author

kylemh commented Sep 30, 2019

Clearly zimme will get to it when he can. No need to request for more updates.

@tweet
Copy link

tweet commented Oct 24, 2019

@zimme Any update for this PR?

@zimme
Copy link
Member

zimme commented Oct 24, 2019

I will try my best to test and merge this within a week.

@dimitropoulos
Copy link

@zimme is there any way I can help?

@blueandhack
Copy link

blueandhack commented Nov 2, 2019

I will try my best to test and merge this within a week.

@zimme Hi Simon, first I want to say, thank you! we are still waiting for you. I know this is hard that maintainers to maintain a popular public repository, but you know, a lot of people and repository waiting for this merge. Thank you again!

@tomkel
Copy link

tomkel commented Nov 4, 2019

Feel free to put up a donation link so everyone who wants it done can chip in to help

@JSanchezIO
Copy link

I'm willing to donate, but I don't think that should be the motivation for @zimme to pull the trigger on this. My frustration is that this PR is ready to be merged, and there isn't anything I can do to help. Is there no other course of action? Is someone else eligible to review and merge this?

@kylemh
Copy link
Collaborator Author

kylemh commented Nov 6, 2019

Just because it's ready to be merged doesn't mean it's ready to be used in everybody's application.

We had a discussion at the top of the PR on a point that we think we have a good understanding of now, but - as an author of a popular open source library - the hesitation becomes around not wanting to bump versions before they're as certain as possible.

If this ships and actually leads to bugs, now the author has created their own stress to correct everything ASAP. If they don't, issues increase and notifications blow up increasing more stress.

Please stop bumping this thread. They'll release it when they release it.

@pelotom
Copy link

pelotom commented Nov 6, 2019

Why not just release under a beta tag and let early adopters find the bugs for you? Seems like everyone's happy then...

@kylemh
Copy link
Collaborator Author

kylemh commented Jan 5, 2020

@zimme care to release a beta tag with this merged? I can subscribe to the repo and pay attention to issues. If we get any from the beta, I can make the reversion PR and ping you.

@jamesblack
Copy link

Clearly zimme will get to it when he can. No need to request for more updates.

rk-for-zulip added a commit to rk-for-zulip/zulip-mobile that referenced this pull request Jan 14, 2020
Unfortnately, React Native 0.60.0 specifies this version of ESLint as
a requirement. (0.62.0-rc1 removes the requirement.)

Note that `prettier-eslint` is not yet fully compatible with ESLint 6,
although an open PR exists which should remedy this:
prettier/prettier-eslint#236
@DarkMikey
Copy link

Sorry to ask, but what is the workaround to get prettier to work with eslint 6?

@kylemh
Copy link
Collaborator Author

kylemh commented Mar 27, 2020

Assuming you install the relevant dependencies, you’ll want a lint config like this:

module.exports = {
  env: {
    browser: true,
    commonjs: true,
    es6: true,
    node: true,
  },

  extends: [
    'prettier',
    'prettier/react',
  ],

  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 2018,
    sourceType: 'module',
  },

  plugins: [
    'prettier',
  ],

  rules: {
    // Prettier Plugin Rules
    'prettier/prettier': 'error',
  },
};

@codecov-commenter
Copy link

codecov-commenter commented May 21, 2020

Codecov Report

Merging #236 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #236   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          208       208           
  Branches        42        42           
=========================================
  Hits           208       208           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 71f8d84...62f85fb. Read the comment docs.

@kylemh
Copy link
Collaborator Author

kylemh commented May 21, 2020

Ready to merge and tag at your discretion @hamzahamidi

@hamzahamidi
Copy link
Collaborator

@kylemh it appears the pr no longer passes. I'll take a look

@hamzahamidi
Copy link
Collaborator

@kylemh The checks pass now

@hamzahamidi
Copy link
Collaborator

hamzahamidi commented May 21, 2020

I'll merge this branch as a breakingChange: Eslint 6+

@hamzahamidi hamzahamidi merged commit b2ae087 into prettier:master May 21, 2020
@kylemh kylemh deleted the upgrade-eslint-to-6 branch May 21, 2020 20:30
@zimme
Copy link
Member

zimme commented May 21, 2020

🎉 This PR is included in version 10.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@zimme zimme added the released label May 21, 2020
@numso
Copy link

numso commented May 21, 2020

@hamzahamidi FYI looks like things may have gotten lost in between PRs getting merged and reverted. It looks like master is still pointing to eslint@5

"eslint": "^5.0.0",

@kylemh
Copy link
Collaborator Author

kylemh commented May 21, 2020

Strange. It was here: 95169c5

@hamzahamidi
Copy link
Collaborator

Ok I'll ready another pr.

@hamzahamidi
Copy link
Collaborator

#337

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

Successfully merging this pull request may close these issues.

Not working properly width eslint 6