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

Fixes #1434 - adding Prettier #1468

Merged
merged 2 commits into from
Apr 3, 2017
Merged

Fixes #1434 - adding Prettier #1468

merged 2 commits into from
Apr 3, 2017

Conversation

magsout
Copy link
Member

@magsout magsout commented Mar 31, 2017

Closes #1434

r? @miketaylr you write all JS of webcompat.

Every commit, this recipe https://github.com/webcompat/webcompat.com/pull/1468/files#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R56 Is triggered.

if any JS is modified, it is automatically added after a git commit https://github.com/webcompat/webcompat.com/pull/1468/files#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R62 ? I'm not sure if it's a good idea.

The configuration is simple, I have modified only this option --trailing-com. (added a comma at the end of object)

@miketaylr
Copy link
Member

Would it be possible to split out the commit with all the changes to the code? Ideally there would be one commit for removing eslint, one for adding prettier, and one for transforming code.

Also, we'll need to update the .travis.yml config... right now it's exploding on npm run lint.

@miketaylr
Copy link
Member

I'd be interested to have @denschub take a look at this PR as well.

@miketaylr
Copy link
Member

There's still some eslint specific comments in the code, for example:

var issues = issues || {}; // eslint-disable-line no-use-before-define

So if we decide there's no more usage for eslint, we should remove those.

I wonder if we should document how this affects workflow in CONTRIBUTING.md as well.

@miketaylr
Copy link
Member

I wonder how people are using this w/ eslint though... with this change we lose out on all the recommended linting rules: http://eslint.org/docs/rules/ (and the few that we have added).

@magsout
Copy link
Member Author

magsout commented Mar 31, 2017

@miketaylr hum yes, I may have been a bit quick on this PR.

@miketaylr miketaylr changed the title Issue #1434 - adding Prettier Fixes #1434 - adding Prettier Mar 31, 2017
});
});
"Add a screenshot to a comment": function() {
return FunctionalHelpers.openPage(

This comment was marked as abuse.

This comment was marked as abuse.

@magsout
Copy link
Member Author

magsout commented Mar 31, 2017

I wonder how people are using this w/ eslint though... with this change we lose out on all the recommended linting rules: http://eslint.org/docs/rules/ (and the few that we have added).

@miketaylr Yes, it's Prettier's role, but maybe it's a bit too gross? You find that you lose what compared to eslint?

@miketaylr
Copy link
Member

Yes, it's Prettier's role, but maybe it's a bit too gross? You find that you lose what compared to eslint?

We lose the "safety" stuff that eslint was checking. eslint was also checking boring things like, do you have a space before a paren -- in my mind, this is what Prettier is good at. Don't think about style, let the machine do style. But it doesn't tell us if we accidentally introduced a new global variable, for example: https://github.com/webcompat/webcompat.com/blob/master/.eslintrc#L6

It should be possible to have both eslint and prettier -- just get rid of the code style rules from eslint, and run prettier after that?

I didn't study these yet, but I see:

https://github.com/prettier/eslint-config-prettier
https://github.com/prettier/prettier-eslint

@magsout
Copy link
Member Author

magsout commented Mar 31, 2017

But it doesn't tell us if we accidentally introduced a new global variable, for example: https://github.com/webcompat/webcompat.com/blob/master/.eslintrc#L6

@miketaylr right now, this recipe https://github.com/webcompat/webcompat.com/blob/master/package.json#L48 handle your comment above ?

@magsout
Copy link
Member Author

magsout commented Mar 31, 2017

@miketaylr

hum, let me rethink completely my PR.
Thanks for your feedback and your review.

@miketaylr
Copy link
Member

@miketaylr right now, this recipe https://github.com/webcompat/webcompat.com/blob/master/package.json#L48 handle your comment above ?

Yeah, I guess. (But I never use that...)

To be clear, I'm +1 on prettier, it does way more than eslint --fix. I just don't want us to lose linting non-style stuff.

@magsout
Copy link
Member Author

magsout commented Mar 31, 2017

To be clear, I'm +1 on prettier, it does way more than eslint --fix. I just don't want us to lose linting non-style stuff.

Yeah, and I agree with you.

@magsout
Copy link
Member Author

magsout commented Apr 1, 2017

@miketaylr another approch. Combined prettier with eslint. I have removed rules of eslint and have added prettier instead. We keep our lint/fix, with the Formatted Code by Prettier.

What do you think ?

@@ -9,7 +9,7 @@ module.exports = function(grunt) {
cssPath: "webcompat/static/css",
imgPath: "webcompat/static/img",
banner: "/*! <%= pkg.title %>\n" +
" * Copyright (c) <%= grunt.template.today(\"yyyy\") %> <%= pkg.author.name %>\n" +
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>\n' +

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@miketaylr
Copy link
Member

Interesting, while trying this locally I got the following error:

🐓 npm run lint

> webcompat@ lint /Users/miket/dev/compat/webcompat.com
> eslint ./Gruntfile.js ./tests ./grunt-tasks ./webcompat/static/js/lib


/Users/miket/dev/compat/webcompat.com/webcompat/static/js/lib/issues.js
  118:19  error  Follow `prettier` formatting (expected '\n' but found '"')  prettier/prettier

✖ 1 problem (1 error, 0 warnings)

Wonder why that didn't get picked up... (I can fix it up).

@miketaylr
Copy link
Member

Interesting, while trying this locally I got the following error:

(ah that's because that code got merged in before @magsout made this PR. forgive me, I'm v slow sometimes...)

@miketaylr
Copy link
Member

@magsout this looks good, we should probably update CONTRIBUTING.md as well. One question about workflow... for some imaginary scenario:

  1. write some code
  2. run npm run lint
  3. run npm run fix (if there were simple style errors...)
  4. commit, make PR, etc.

Does that seem like the best way?

@miketaylr
Copy link
Member

Actually, I think we can merge this and I'll file a follow up issue to document recommended workflow.

@miketaylr miketaylr merged commit 30cfdba into master Apr 3, 2017
@magsout
Copy link
Member Author

magsout commented Apr 3, 2017

@miketaylr yes, it does 👍

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

Successfully merging this pull request may close these issues.

2 participants