-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Lint with standardjs #950
Comments
Strong choice! See also: standard-format Edit: ah, never mind. Seems like |
I believe plotly.js should remain a ES5-only repository for the foreseeable future. I also believe that Eslint is configured with ES5-only parser by default (ref), but standard now uses an ES8 parser 😲 (ref) meaning that running the stock So, I propose using {
"standard-own": {
"eslintConfig": {
"parserOptions": {
"ecmaVersion": 5
}
}
}
} to the package.json should do the trick. Alternatively, we could publish an es5 version of |
Interesting. Agreed on keeping it ES5 for the sake of consistency. (though es2020 hits the nail on the head, IMO.) Related discussion: standard/standard#159 |
Though I'm mostly trying to understand the consequences of the parser vs. the set of rules and what that means for simply enforcing style. |
Good point here. Perhaps we could just use |
Testing out |
To enforce ES5, we could use |
Ah, looks like that maybe just sets the parser version of eslint. Separate steps seem nice since they're two different things, but if it's really as simple as setting the parser version, maybe it's not worthwhile to separate it. |
As far as I know, I don't think one can set the parser version within |
FWIW @etpinard and I had a slack chat about styles a few weeks ago... we talked about how I'm freaked out by the restrictions imposed by no
So let me generalize that statement: if we change styles, it had better be because the community is truly coalescing around a style AND we're convinced it's going to last many years that way. My gut reaction is that we shouldn't switch styles at all unless and until we move to ES6+ (but please don't open that can of worms here!) Also for the record I completely agree with the outcome of #1629 - while enforcing completely automated style has its advantages, if it stops you from doing things that - rules be damned - make your code more readable (extra parens, d3 half-indents, etc etc) - then it's going too far. And of course @rreusser 's #1629 (comment) is spot on:
So there's really no point arguing about what's superior on the merits. Unless you can start the discussion with "all the major active projects (in ES5) are using this style so it'll be easier for new people to adapt to our project," lets leave our style as it is now. |
Entering the room, realizing that I missed the bikeshedding :-) Please therefore ignore my self-healing attempt :-) I started liking no-semicolons with ES2015, as its streamlined syntax made the semicolons stick out, indeed it's subjective. I admittedly haven't considered majority share due to switching back and forth anyway eg. between plotly.js and gl-vis. Looks like standard.js is the most starred style but semi still leads in large libs. Maybe everybody is waiting for some other large libs to switch 😆 The sample list is neat and there are non-standardjs libs which omit semis eg. regl or bootstrap. Standard.js announced recently to audacity/ridicule, and revisiting now, I'm impressed to see a lot of libraries, A couple times I've run into a superficial and immediately obvious issue with an iife in ES5. With ES2015 there's hardly ever a need for an iife because of the block scoping of Re the |
To add an example for overbearing format rules, we already have some constraints that feel a bit arbitrary, compare this, what I think would be nice but not allowed:
with this, as allowed by our current linter:
Aside from nice vertical alignment, I like important things to not be at the line end if they can be at the beginning, as it shows intent and structure faster. I know most shops put their ternary operators to the end like this, and we have no intention to revisit it:
but this shows the ternary nature more directly:
|
Have to agree with @alexcjohnson. I still prefer some of the standard/semistandard conventions, but short of something drastic like prettier that I think does have merits beyond the aesthetic, I think bikeshedding is best avoided, especially if it involves hundreds of manual variable declaration reworkings just to get it off the ground. Oh, and let's not forget the extra steps required to sort out git blame history as soon as you change the linting. |
Note the changes to the indent rule. Running |
Could just disable…
{
rules: {
indent: "off",
"indent-legacy": "error" // replace this with your previous `indent` configuration
}
} |
Probably won't happen anytime soon, closing. |
The standard set of linting rules are becoming the standard 😆 for open-source JS libraries.
We should follow suit.
The text was updated successfully, but these errors were encountered: