-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
feat(lint): add Airbnb and Unicorn eslint packages #2596
Conversation
This PR (part 1 of #2589) is complete. |
tasks/docs/serve.js
Outdated
@@ -27,7 +28,8 @@ var | |||
|
|||
module.exports = function () { | |||
// use a different config | |||
config = configSetup.addDerivedValues(config); | |||
const config = extend(true, {}, configDocs); |
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.
This is still a confusing change. Please revert. addDerivedValues returns config and config is declared via let, so what's the purpose of creating a temporary const which extends the previous config.... This is confusing.
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.
addDerivedValues()
was written quite complited. When no/empty config was given, it created it. Why? When such fallback is removed, no need for return.
By the function name I would expect a void method that adds some config values. This is how it is coded now, is that ok?
The change also fixes the mutation of a config returned from an imported module, previously, it was not extended/cloned. IMHO it is a good practise to never mutate anything imported.
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.
It is still confusing: Why is configDocs now declared outiside of the exports scope? For nothing else than being extended for the const once.... Why not move the let config = require('../config/docs'),
into the module.exports block and keep the functionality as it was before?
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.
because it is a good practise to keep imports at the top (and never mutate them) - otherwise eslint with recommended config will warn - otherwise we will need eslint-disable-line
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.
ok, understood, but then it should be kept as var instead of let if we get into scope issues otherwise ;)
[Edit]"and never mutated them" -> yes, right, so this case really needs a refactoring, but lets do it clean instead of the const fix ;)
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.
If imported on top (with var/let/const), then it is visible to the whole script scope.
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.
Then i am still/again confused again why you renamed that into configDocs and did the additional const stuff in module.exports? Because of the undesired mutation? As said this needs a better refactoring. Maybe we are talking too much about a code which is not even used many times (its about serving docs)
Lets get this PR to some point where we can merge it, as said, i would have already merged lots of other rules if they werent bound altogether in combined PRs 😉
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.
Don't get me wrong, i highly appreciate what you are doing here 👍🏼 But you are preparing lots of similiar PRs always containing several rules and if only one of them turns into discussion we never get close into getting most of them included :) I actually dont want to rewrite ancient (but working) code just because airbnb rules now tell us we should code different. That said, i am totally fine with many other rules which do not need code structure changes , but please keep the whole var/let/const changes in a separate PR which does nothing else. Thanks.I am fine with a lot of PRs having a single lint rule. This makes approvement/review much easier and we can concentrate on one topic and merging gets faster as we won't loose time (or me investigating what code, i never touched before, is doing and why the linter thinks it has to be changed). You are doing a great job these days, thanks a lot! 🙂 |
c781915
to
e359b44
Compare
e359b44
to
91ec658
Compare
I have a "master" PR #2589 which I split and split :) The older PRs are to be merged later, they hold changes not compatible with Node 12/ (and E11). Thankfully, I made the changes quite strictly rule by rule so I can reduce the PR size easily. This PR now adds the linter packages only. |
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.
LGTM :)
@mvorisek
|
nevermind.... found the issue 😉 |
@mvorisek Another "issue".
If this is a default rule in airbnb-ruleset, how can we override that? my git config is configured to use LF only when pushing but CRLF when checking out on windows (standard git setting under windows "core.autolcrlf=true"). Of course i dont want to see every code line now being an error, so we should override that rule. Not everybody is using a mac or linux for web development :) |
This seems to be a reliable override ?
|
If possible and you are in doubt, somebody could accidently push CRLF: Could we restrict the rule to LF inside CI only? |
LF must be used in all source text files if there is any text file stored as CRLF, please fix if you have LF locally, I advise to reconfigure your IDE to LF which is used by 99% projects across many programming languages if you have locally CRLF, it might come from git and I will take care of enforcing LF for JS and LESS as well |
Modernize code using eslint advisory introduced in GH-2596. This PR focuses on fixing no-var rule. For src/* files it cannot be fixed (now) because of limited support in IE11.
Modernize code using eslint advisory introduced in GH-2596. This PR focuses on fixing multiple rare rules, done in one PR, as otherwise there will be only a few LOC changed per separate PR.
Modernize code using eslint advisory introduced in GH-2596. This PR focuses on fixing unicorn/no-typeof-undefined rule with some related changes done manually
Modernize code using eslint advisory introduced in GH-2596. This PR focuses on unified regex and .length check usage, also removes useless escapes.
Modernize code using eslint advisory introduced in GH-2596. This PR focuses on fixing unicorn/prefer-date-now rule.
Modernize code using eslint advisory introduced in GH-2596. This PR focuses on fixing rules like no-else-return and other ternary operator related.
Modernize code using eslint advisory introduced in GH-2596. This PR fixes several smaller rules not worth a separate PRs.
Modernize code using eslint advisory introduced in GH-2596. This PR updates ternary operator formatting for better readability and and removes unneeded parentheses around expressions.
Modernize code using eslint advisory introduced in GH-2596. This PR focuses on fixing no-extra-parens rule with a help or a custom rule output filter.
Add eslint plugin packages with recommended rules to be fixed in separate PRs.