-
Notifications
You must be signed in to change notification settings - Fork 272
Conversation
90a9c6b
to
92e6c7d
Compare
Hi @williamboman, thanks a lot, that's big work!! However, take this time to try to convince me with ESLint :-) |
@astorije I've actually been using both They both achieve the same thing, and the configuration files themselves are really just touched once - or very seldom, so to me it really doesn't matter. |
What about strict mode? It's missing everywhere right now. |
@williamboman, thanks for giving your objective opinion. I will give a read to ESLint to take an informed decision. What I can see so far is that my JSCS configuration files seem much more rigorous in terms of style choices than your ESLint file. At first glance, I'd say that JSCS can better avoid confusion and set consistent style, but again, that might be because I don't know about it (in particular, the For strict mode (and other things), I fully agree with you, but let's set the minimal coding style rules as part of this PR to have the project comply with them, and then we can make the entire project stricter by adding relevant rules (including |
6cf7448
to
f548d57
Compare
What about using standard? (just my 2 cents) |
@olivierlambert The existing code in this repo does not adhere to standard, so no 😄. Personally, I don't like some of the standard rules (enough to never consider using it). |
That was just a suggestion ;) I fully understand some efforts and trade-off to comply to standard. |
@williamboman could you rebase on master ? there are conflicts. @astorije are you ok with the proposed changes as-is (after rebase of course) ? It would be good to merge such a PR soon cause it's quite conflicts-prone... I'm myself not very acustomed to js-style issues, so just looking at that from a distant point of view (but with great joy to see coding standards incoming !) |
@williamboman would'nt it be good to run those linters in before_script in .travis.yml ? |
Please leave me some more time on this. I will get to it for sure. |
f548d57
to
1393f79
Compare
Rebased edit: @astorije As I said before, if you feel unsure about eslint, feel free to provide a JSHint and JSCS configuration and I'll replace it 😄. |
1393f79
to
11c2698
Compare
Thanks @williamboman! I'm still reading ESLint docs, give me a few more days and I should be back on track for this. @JocelynDelalande, actually, it's even better to put it in the Stay tuned. |
What about using https://github.com/sindresorhus/xo? |
I personally feel pretty meh about xo. It's comfortable for small projects. |
9ed9a52
to
42fcb30
Compare
node: true | ||
|
||
rules: | ||
comma-dangle: 0 |
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 one should go, but I don't want to add extra delay to your PR. Could you add the comment # TODO Fix trailing commas and remove this line
at the end of this line please?
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.
Do you want it to be disallowed altogether? Having it enabled for objects that span multiple lines is pretty nice for diffing stuff.
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 don't have a super strong opinion at the moment, so disregard my comment for this PR. However, I think we'll have to remove this for compatibility reasons.
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.
Trailing commas already exist in the code base, all non-discontinued major browser (well, except IE8 which will be discontinued in January next year) supports it as well.
I really like trailing commas, as it makes cleaner diffs like these possible for adding/removing stuff;
diff --git a/foo.js b/foo.js
index 9c78d86..eb26d74 100644
--- a/foo.js
+++ b/foo.js
@@ -2,4 +2,5 @@ var foo = [
"foo",
"bar",
"quux",
+ "baz",
];
vs
diff --git a/foo.js b/foo.js
index 67d2cbd..2aada49 100644
--- a/foo.js
+++ b/foo.js
@@ -1,5 +1,6 @@
var foo = [
"foo",
"bar",
- "quux"
+ "quux",
+ "baz"
];
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.
The typical haskell style is to do:
myList :: [String]
mylist = [ "foo"
, "bar"
, "baz"
]
I have seen this repeated in many JS projects in the past and it works for them.
This also means that adding things to the list doesn't change more than one line of code and that it is impossible to end up with a 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.
@williamboman, that's fair comment. I should have specified that I had no strong opinion on the choice, but that I'd want one style to be enforced, either trailing commas everywhere, or nowhere (an alternative could be, everywhere on the server, nowhere on the client, until IE8 is not being used).
Let's keep comma-dangle: 0
and make a broader decision later, in a future PR (but I'd go in your direction now, I think).
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.
Yeah, @Xe, some are using that horrifying syntax indeed.
Thankfully, as all fashions kid like to wear, it is losing its popularity :-)
Let's not do that, and anyway the current codebase is not using crazyness like this, so even better.
"Closing" (virtually) this line of comments as decision was reached: we keep comma-dangle: 0
for the moment.
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.
Thankfully, as all fashions kid like to wear, it is losing its popularity :-)
Afaik, that convention is extremely ubiquitous in Haskell 😄.
42fcb30
to
3ebfaa6
Compare
@@ -6,6 +6,8 @@ node_js: | |||
- '4.1' | |||
- '4.2' | |||
sudo: false | |||
before_script: | |||
- npm run lint |
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.
Actually, this is very painful in practice. One cares more about failing tests than failing style rules.
Adding this in Travis's script
has the advantage of running all tasks, even in case of failure. But it means developers need to remember to run npm test
and npm run lint
. The former one is common practice by Node's users (npm run test
is aliased by npm test
, Travis CI runs npm test
automatically, ...).
Therefore, could you remove this line from .travis.yml
and update the test
task in package.json
accordingly:
"test": "HOME=test/fixtures mocha test/**/*.js && npm run lint",
Best of both worlds.
@williamboman, I finally found time to go through the entire PR. This is neat, thank you very much for your hard work!! I see plenty room for improvement, but let's get this merged quickly and the improvements will go in further PRs. 2 comments however before I can give my definite 👍:
Are you OK with these changes? :-) Thanks again! |
3ebfaa6
to
5306f13
Compare
Sorry, what do you mean? |
5306f13
to
10683f9
Compare
Sorry, I meant first commit, not first comment... |
10683f9
to
12ba15a
Compare
Done |
Great, thanks! Here is my 👍 then :-) @JocelynDelalande, still OK with this? Could you give yours please? |
Ok, that's really cool to read all this harmonized code, just finished reading your comments and the PR, 👍 Great work. Sorry for reviewing delay |
Closes #485.
To lint;
$ npm run lint
.