Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upDifferent settings for different JS versions #159
Comments
This comment has been minimized.
This comment has been minimized.
|
I think |
This comment has been minimized.
This comment has been minimized.
|
No opinions on this? |
This comment has been minimized.
This comment has been minimized.
|
I can see wanting to use no-var and object-shorthand on ES6 codebases -- those seem useful. Personally, I don't think always using Not a fan of comma dangle. Currently, we actively disallow it. Enabling it would cause almost every single dependent to start failing -- can't do that. The question is how do get no-var and object-shorthand for people on ES6 codebases. Are these things always going to require options? |
This comment has been minimized.
This comment has been minimized.
|
I think this is a very good idea. Would it also make sense to enable specific features? I currently compile my javascript as below and would love to have babel src -s --optional es7.functionBind --out-dir lib
I'm on the fence about comma dangle but to be fair it does make it easier to move lines up and down. Often when I do that there will be a line in the middle without comma which makes for a syntax error. @feross What do you mean with this?
As long as we specify somehow that the code is ECMAScript 6 it shouldn't require any more options. There is no reason to use |
This comment has been minimized.
This comment has been minimized.
|
I disagree: declaring vars with I agree forcing comma dangle is not viable solution as it would break compatibility but allowing it for ES>3 would not create any issues and allow cleaner diffs. |
This comment has been minimized.
This comment has been minimized.
|
I really think that we should either enforce it or forbid it. Letting the user decide for themselves just creates more bike-sheding? |
This comment has been minimized.
This comment has been minimized.
|
Remember, you can always "fork" standard if you care a ton about a single rule. Add your own rule with {
"extends": ["standard", "standard-react"],
"rules": {
"comma-dangle": [2, "always"]
}
} |
This comment has been minimized.
This comment has been minimized.
|
Defaulting to I also agree with @julien-f that using |
This comment has been minimized.
This comment has been minimized.
Agreed.
Although I am usually a massive proponent for This is not so in JS, as the So, while it pains me to say it, I think
@yoshuawuyts maybe I'm just being short sighted, but can you elaborate on this?
@julien-f this is the one positive I can see. Immutability rules. But IMHO, it is almost always better to be enforced through libraries like immutable.js then it is at the scope level.
We should ask eslint if we we can add an option That way we can solve a multitude of issues simultaneously! (e.g #167) |
This comment has been minimized.
This comment has been minimized.
|
@dcousens I was leading a refactoring effort at a previous job where ~1k-2k LOC files weren't uncommon. At that point it was impossible to remember all variables available in scope, and accidentally redeclaring variables happened. Actually I'm curious what the reasons against pro const
con(st) const
Does that sound about right? Let me know if I missed anything. |
This comment has been minimized.
This comment has been minimized.
|
Looks right to me. |
This comment has been minimized.
This comment has been minimized.
|
Here's a concrete problem I have with 'use strict'
const http = require('http')
function fetchGoogle (cb) {
let options = {
hostname: 'www.google.com',
port: 80,
path: '/'
}
if (Math.random() > 0.5) options.headers = { DNT: 1 }
http.get(options, cb)
}
fetchGoogle(function (res) {
console.log('got ' + res.statusCode)
})With
My problems with
|
feross
added
the
question
label
Jun 25, 2015
This comment has been minimized.
This comment has been minimized.
|
@feross It's because the semantic of If, in Node, |
This comment has been minimized.
This comment has been minimized.
|
@julien-f I think that's a pretty weak guarantee and it's not worth forcing users to use it in every possible situation where it could conceivably be used. Rules have to be worth the pain they cause, and I'm not yet convinced this rule is worth it. |
This comment has been minimized.
This comment has been minimized.
|
I can understand your arguments against the semantic of |
This comment has been minimized.
This comment has been minimized.
|
This is very subjective and personal but I don't really like the look of function complicatedStuff () {
let i = 0
const len = a.length
let futureKey = 'next'
let lastKey
const firstKey = futureKey
// ...
}But what do you guys think about enforcing const ENCODING = 'utf-8'
const OP_WRITE = 0x00
const OP_READ = 0x10 |
This comment has been minimized.
This comment has been minimized.
|
@LinusU Since |
This comment has been minimized.
This comment has been minimized.
Yup, non-transitive const is pants on head retarded IMHO.
I think that seems fair. |
This comment has been minimized.
This comment has been minimized.
|
Btw, in the last version of These rules are nice because they don't affect non-ES6 code. We can continue to enable these types of rules with no issues :) |
This comment has been minimized.
This comment has been minimized.
hax
commented
Nov 13, 2015
|
@feross It's not weak guarantee, it just only guarantee the value (or reference in object case) can not be modified. In C++, you should also use two In JS, we could use Notice it's far more ugly in Java than JS (in Java To be honest, Anyway, it's impossible to change the bad names now, what we can do is educating the js programmers to familiar the usage of |
This comment has been minimized.
This comment has been minimized.
|
@hax Thank you very much for this extremely clear argument :) |
This comment has been minimized.
This comment has been minimized.
hax
commented
Nov 13, 2015
|
And FYI, airbnb already enable |
This comment has been minimized.
This comment has been minimized.
|
If we ever switch to ES6 only, reference standard/eslint-config-standard-react#7 might be worth including. |
This comment has been minimized.
This comment has been minimized.
justmoon
commented
Jan 19, 2016
|
One more thought that I didn't see mentioned yet: |
This comment has been minimized.
This comment has been minimized.
haadcode
commented
Nov 21, 2016
|
I would also like to see |
This comment has been minimized.
This comment has been minimized.
|
I reckon opinions on dangling commas are divided, and thus that the best resolution in such a case is to not break backwards compatibility. I propose we don't break codebases. In that spirit I also dislike the prefer-const rule as forcing ES6 onto people is a bad thing. And yeah let's also not add options to enable different modes of standard because not having options is kind of the point of standard hah. |
This comment has been minimized.
This comment has been minimized.
|
Oh I also don't like option b: loosening rules as it makes a codebase more inconsistent which like also goes against the point of having a linter. I think we shouldn't force everyone to suddenly use dangling commas |
This comment has been minimized.
This comment has been minimized.
It does not break any code and people can keep using standard 8 if they don't want to use this feature.
|
This comment has been minimized.
This comment has been minimized.
haadcode
commented
Nov 21, 2016
•
I would also propose to look at the reasons behind the decisions and not judge purely on opinions or consensus of opinions. For |
This comment has been minimized.
This comment has been minimized.
omeid
commented
Jan 7, 2017
|
At the cost of beating the dead horse, I would also like to see I am not sure what woudl be the implications of making |
This comment has been minimized.
This comment has been minimized.
stale
bot
commented
May 10, 2018
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
stale
bot
added
the
stale
label
May 10, 2018
This comment has been minimized.
This comment has been minimized.
|
Hey, I believe this issue is still relevant |
stale
bot
removed
the
stale
label
May 10, 2018
This comment has been minimized.
This comment has been minimized.
kyeotic
commented
Jun 12, 2018
|
I would like to side against prefer |
This comment has been minimized.
This comment has been minimized.
|
@tyrsius It's probably pretty rare, maybe it would be preferable to simply opt-out ( |
This comment has been minimized.
This comment has been minimized.
kyeotic
commented
Jun 12, 2018
|
@julien-f I already have a way to opt-out of that behavior: use |
This comment has been minimized.
This comment has been minimized.
|
Let's agree to disagree of the meaning of these signals: for me |
This comment has been minimized.
This comment has been minimized.
kyeotic
commented
Jun 12, 2018
|
I agree with you on the meaning of those signals. Our disagreement seems to be that I want to consider potential futures, where as you only want to consider the current state of the code. |
This comment has been minimized.
This comment has been minimized.
sara0871
commented
Jul 4, 2018
|
|
This comment has been minimized.
This comment has been minimized.
stale
bot
commented
Oct 2, 2018
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
stale
bot
added
the
stale
label
Oct 2, 2018
stale
bot
closed this
Oct 9, 2018
This comment has been minimized.
This comment has been minimized.
|
FYI, I've started using more and more ESLint instead of Standard exactly for this reason (being able to target a specific version of ES, like ES5). |
This comment has been minimized.
This comment has been minimized.
|
@julien-f which rules is it that you enable on top of standard? Maybe it's time to just include them |
This comment has been minimized.
This comment has been minimized.
|
I've listed the main one in the first message ( |
This comment has been minimized.
This comment has been minimized.
|
Ah, right, sorry didn't look at the top comment Oh, how I would love to have comma-dangle I don't see a problem with adding Personally, I would like to see |
This comment has been minimized.
This comment has been minimized.
|
@julien-f put up a PR for |
This comment has been minimized.
This comment has been minimized.
|
Hmmm,
Hmm, I would like to do some more research and see how many of those are actually targeting older environments |
julien-f commentedJun 15, 2015
•
edited
I think it would make sense for some settings to differ based on which JS version is targeted:
functionsoptionOf course it would be the best if compatibility is kept (a JS3 code is compatible with JS3 up to JS6 config).
I don't know what would be the best way to implement that, maybe via an options in
package.json:{ "standard": { "compatibility": "es2015" } }