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: prettier reset trailingComma: all #972

Closed
wants to merge 1 commit into from
Closed

Conversation

acao
Copy link
Member

@acao acao commented Oct 5, 2019

in the eslint upgrade and typescript conversion kerfuffle we accidentally reverted to es5 commas briefly. re-adding all those es2017 compatible commas!

@acao acao requested review from Neitsch and benjie October 5, 2019 20:33
@codecov
Copy link

codecov bot commented Oct 5, 2019

Codecov Report

Merging #972 into master will increase coverage by 0.01%.
The diff coverage is 37.03%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #972      +/-   ##
==========================================
+ Coverage   42.43%   42.45%   +0.01%     
==========================================
  Files          64       64              
  Lines        2922     2923       +1     
  Branches      633      633              
==========================================
+ Hits         1240     1241       +1     
  Misses       1411     1411              
  Partials      271      271
Impacted Files Coverage Δ
...ervice-interface/src/getAutocompleteSuggestions.ts 69.39% <ø> (ø) ⬆️
...hql-language-service-server/src/GraphQLWatchman.js 0% <ø> (ø) ⬆️
...s/graphiql/src/components/DocExplorer/SearchBox.js 58.33% <ø> (ø) ⬆️
packages/graphiql/src/utility/QueryStore.js 26.92% <ø> (ø) ⬆️
packages/graphiql/src/components/ToolbarSelect.js 6.45% <ø> (ø) ⬆️
...ages/graphql-language-service-server/src/Logger.js 5.55% <ø> (ø) ⬆️
packages/graphiql/src/utility/find.js 33.33% <ø> (ø) ⬆️
...kages/graphql-language-service-parser/src/Rules.ts 0% <ø> (ø) ⬆️
...ge-service-interface/src/GraphQLLanguageService.ts 44.94% <ø> (ø) ⬆️
packages/graphql-language-service/src/cli.js 0% <ø> (ø) ⬆️
... and 19 more

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 2da818b...64f1796. Read the comment docs.

@acao
Copy link
Member Author

acao commented Oct 6, 2019

Screen Shot 2019-10-06 at 5 23 17 PM
this is failing because it changes code coverage :/

Copy link
Contributor

@Neitsch Neitsch left a comment

Choose a reason for hiding this comment

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

Why is there a new file packages/examples/graphiql-cdn/graphiql.css?

Could you also point me to the config where you enabled the trailing comma? I can't find it amongst all those changes :/

@acao
Copy link
Member Author

acao commented Oct 7, 2019

@Neitsch this needs rebased but that new file will already exist as of the new master
The change is to .prettierrc. In this PR, we change from es5 trailingCommas (which is why some commas were just recently stripped, because we had recently applied this rule) back to all trailingCommas (since es2017 supports trailing commas in functions).

@acao
Copy link
Member Author

acao commented Oct 7, 2019

as you can see though, adding these extra commas somehow decreases coverage significantly

@acao
Copy link
Member Author

acao commented Oct 7, 2019

@Neitsch again, everything passes but codecov's test coverage comparison :/

/packages/graphiql/test/vendor

# Funky codemirror-graphql build pattern
/packages/codemirror-graphql/**
Copy link
Member

@benjie benjie Oct 7, 2019

Choose a reason for hiding this comment

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

You have to be very careful with this pattern; if this line matches a directory then files in that directory will not be re-included by the ! rule. ESLint uses the same algorithm as gitignore; which states:

An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined.

To fix you have to match JUST the files explicitly:

Suggested change
/packages/codemirror-graphql/**
/packages/codemirror-graphql/**/*.ts
/packages/codemirror-graphql/**/*.tsx
/packages/codemirror-graphql/**/*.js
/packages/codemirror-graphql/**/*.jsx

Maybe we should note this more strongly here:

# First: ignore FILES (not folders!)

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, the above suggestion works except it needs to ignore everything but src though. the whole issue with codemirror-graphql is that it builds to the root for easy resolutions, and the new eslintignore file doesnt ignore the built files anymore. the subpackage .gitignore honors this and we need the .eslinignore to do the same

Copy link
Member

Choose a reason for hiding this comment

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

Yes; that's why I left the !.../src/** line below :) It's only the actual /** line I changed to make more explicit to only match files and not folders. I believe this will achieve the outcome you desire.

Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

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

Couple notes 👍


# breaks prettier graphql parser
packages/graphql-language-service-server/src/__tests__/__queries__/test.graphql
packages/codemirror-graphql/src/__tests__/schema-kitchen-sink.graphql
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should ignore all the graphql files in __tests__; some of them might test whitespace?

Copy link
Member Author

Choose a reason for hiding this comment

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

good point... that reminds me of at least one test "fix" i had to make that was suspicious in this PR...

@@ -14,7 +14,7 @@ const INVERSE = '\x1b[7m';
const RESET = '\x1b[0m';
const YELLOW = '\x1b[33m';

const options = ['--trailing-comma=es5'];
const options = ['--config ../../.prettierrc'];
Copy link
Member

Choose a reason for hiding this comment

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

These options should be separate (for spawn), and we should pass a fixed path so that it doesn't matter where the script is called from.

Suggested change
const options = ['--config ../../.prettierrc'];
const options = ['--config', `${__dirname}/../.prettierrc`];

Copy link
Member Author

Choose a reason for hiding this comment

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

ah yes, absolute path is much better.

Copy link
Member Author

Choose a reason for hiding this comment

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

really, the script is so simple now, we could just invoke it directly

@acao
Copy link
Member Author

acao commented Oct 8, 2019

@benjie once we are done with this PR (it looks like we will have to add a fair amount of test coverage to make this one pass) and some of the other big ones, lets sit down with @IvanGoncharov, you and myself and do one last pass at auditing our eslint/prettier setup

@benjie
Copy link
Member

benjie commented Oct 10, 2019

Sounds like a plan. Fair warning: I am not a fan of YAML.

@Neitsch
Copy link
Contributor

Neitsch commented Oct 14, 2019

Thanks for fixing the trailing comma stuff! Let's ship it 👍
Then we can address @benjie improvement suggestions

@acao
Copy link
Member Author

acao commented Oct 14, 2019

@Neitsch @benjie i think we should scrap this PR personally. We already have es5 commas, so all object literals have trailing commas, etc. The commit you saw was where we enforced es5 commas, stripping out the extra es2018 commas downstream. This all option just adds them to function parameters. We are gonna need to add a bunch of test coverage to the LSP parser or server to get this to pass. So it could take a while, and its a huge cross cutting Pr so it will break other active ones. I know this is just the cost of making changes, but just for cosmetic ones? If we must...

@benjie
Copy link
Member

benjie commented Oct 15, 2019

I wouldn't worry about increasing code coverage when the changes are just formatting. It's okay to ignore that one status check :)

Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

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

@acao I'd like to see this PR done as two separate commits:

  • Commit 1: changes the configuration of ESLint/prettier/etc
  • Commit 2: autofix changes ONLY - no manual changes.

This will make it a lot easier to review.

I believe we can completely ignore codecov for this PR.

@acao
Copy link
Member Author

acao commented Oct 15, 2019 via email

@benjie
Copy link
Member

benjie commented Oct 16, 2019

It's certainly not a big priority. Let's close it and come back to it later.

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.

3 participants