-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[tests] Unify linting and autoformatting #2914
Conversation
Codecov Report
@@ Coverage Diff @@
## canary #2914 +/- ##
==========================================
- Coverage 11.06% 11.04% -0.02%
==========================================
Files 267 267
Lines 10133 10133
Branches 1264 1266 +2
==========================================
- Hits 1121 1119 -2
- Misses 8922 8924 +2
Partials 90 90
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lucleray Running yarn lint
in the root of the repo with this results in
✖ 1516 problems (1193 errors, 323 warnings)
107 errors and 0 warnings potentially fixable with the `--fix` option.
🤔
@rdev Improved eslint configuration and fixed some errors:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work!
Could we publish an eslint plugin that uses the prettier plugin and add instructions for a standard ZEIT linting setup? |
}; | ||
|
||
// Static builders are special cased in `@now/static-build` | ||
function getBuilders(): Map<string, Builder> { | ||
return new Map<string, Builder>([ | ||
['next', { src, use: '@now/next', config }], | ||
['next', { src, use: '@now/next', config }] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we continue using trailing commas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was no trailing comma in now-cli
so I went for no trailing comma.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lucleray Tbh I prefer trailing commas because of the cleaner diffs 🤔
But it's not a strong stance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally think trailing commas give cleaner diffs, what do you think @styfle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I like trailing commas because they're less noise when reviewing PRs.
In this case, however, let's try to keep now-cli
consistent because that was the original repo and has all the history here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also because of prettier
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prettier
allows you to configure trailing commas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any command that we need to run to get the pre-commit hook working properly?
@lucleray What do you think about unifying the |
* add prettier and eslint on root * remove eslint from now-cli * adjust root package.json * adjust eslintignore * adjust now-cli rules * remove @zeit/git-hooks in packages * adjust now-client eslint config * add lint-staged and hook on pre-commit * add pre-commit script * replace @zeit/git-hooks with husky * remove unnecessary script * fix eslint errors * trigger tests * fix fixable errors * fix fixable errors (bis) * revert two changes
This PR adds:
prettier
to autoformateslint
on the root folder to unify it across the repositorylint-staged
to improve our code incrementally (only files that are touched in the commit are linted/prettified)husky
to add a hook on pre-commitThere are still many lint errors across the code base (
yarn run lint
to list them). Because of that, onlynow-client
andnow-cli
are currently part of the CI step, but please add others packages when they pass lint!To add a package to the CI step, simply add a script to the package:
Eventually, we'll have all packages linted and we can simply run
eslint
from the root package.Remarks:
.eslintrc.json
if a rule is not appropriate or causing too much problems. Please tweak the rule only for the specific package and not for the whole monorepo (unless necessary). The goal is to unify linting so please don't add too many rules 😅eslint-config-airbnb
because it is bloated with confusing rules and i believe we are smart programmers 🤓)Todo:
now-cli
now-cli
now-client
Fixes #2912