-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Introduce ESLint to svelte sources #2958
Conversation
I Just open an issue about this yesterday (#2958) 😄 |
alright so tonight i fixed the many thousands of lint errors. some by disabling rules (as svelte's conventions differ), some automatically ( any rules I disabled were either because we had a large enough amount of code that it clearly didn't match eslint's convention or because typescript conflicts with it.
Also, I left the lint fixes in their own commit in case we want to discard them and keep the setup/config. On a side note, I would highly recommend we simply turn off all of eslint's indentation rules and introduce a code formatter such as prettier/clang-format. It is better and more reliable IMO to auto-format the code than try lint it (clearly as you see in this PR it doesn't always get it 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.
thank you, this looks great! i just had a few questions as i was looking at the result, commented inline
@@ -14,13 +14,13 @@ export default class TitleWrapper extends Wrapper { | |||
block: Block, | |||
parent: Wrapper, | |||
node: Title, | |||
strip_whitespace: boolean, | |||
next_sibling: Wrapper | |||
_strip_whitespace: boolean, |
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 a rule for controlling whether unused variables need a leading underscore? I'm in two minds about it...
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.
ESLint's rule is configurable such that those matching the specified pattern are allowed.
I originally set it to ^_
, but actually later enabled typescript's built in (stricter) unused checks at compile time and turned the eslint rule off.
TypeScript has built in support for ignoring _
prefixed locals/parameters. I wouldn't go with another convention because this is built into typescript its self.
One other thing — a lot of the changes are reordering functions etc. Is that necessary? It renders the git history slightly less useful... |
I do realise that and it comes down to preference really. We can either turn the rule off and leave it as it was, or turn it on and reorder them. I noticed its pretty inconsistent, so wasn't sure which would be preferred. Many files have functions at the start, and at the end. Many have them at the end only and some have them at the start only. I don't mind discarding most of the fixes and redoing them at some point if we choose to leave the order intact. |
I'd vote for not changing the order that stuff is in the files. It might have been nice if there had been a more consistent ordering from the beginning, but I think this is actually of limited value given that editors have a 'jump to definition' command. |
thats fair enough. i agree. i reverted ordering changes and reverted whitespace changes in template expressions. i also changed the indent rule to a warning instead (as it will error on those still) |
i've rolled back some more unicode mess and i re-enabled the indent rule as
edit: the scissors unicode had gone walkies again.. tests fixed |
thank you! |
Fixes #2951.
Are you interested in this?
Interestingly the PR guidelines/template states to remember to run
npm run lint
, but there wasn't such a script before..Here's what I've done:
.eslintignore
as those files don't seem to exist anymoretest/
andsrc/
If you're interested in taking this PR on im happy to sort the mass of lint errors currently produced so we can get it merged. Most are just inconsistencies with whitespace or interface separator style (semicolon vs comma).