-
Notifications
You must be signed in to change notification settings - Fork 34
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
Add linting & formatting #7
Comments
I have started some work here: https://github.com/manuel3108/svelte-add-linting I think it's pretty hard, because the svelte template and prettier are both opinionated. I'm quite happy with the results of prettier now, as it only modifies 4 now, instead of nearly every file when i was starting. Eslint is currently giving me this error: /mnt/files/dev/web/sveltekit/src/routes/index.svelte
2:22 error Unable to resolve path to module '$components/Counter.svelte' import/no-unresolved If you have an idea, please let me know. Also I'm unsure for the scripts added. For the my past projects I added them like this: "lint": "eslint .",
"format": "prettier --write .",
"format-check": "prettier --check .",
"check": "npm run lint && npm run format-check" Any opinion on this? |
I do not. Problems like this are why I was personally afraid of being responsible for the linting adder. Leaving it to solve later is fine by me.
I agree with combining linting and format checking into one script ( "format": "prettier --write .",
"format:check": "prettier --check .",
"eslint": "eslint .",
"lint": "run-p format:check eslint", and only tell people to use What are your thoughts on that? Do you also know if it's always going to be the case that Prettier formats code in a way that ESLint accepts, or can people get caught on errors from that? I personally have only used ESLint's formatter to prevent such a thing from ever occurring. |
I'm excited about this one. I played around with the no-unresolved issue and I don't see a way to get eslint or eslint-plugin-import to resolve those imports. It's expecting to use a resolver package, and the config is just a Vite alias. You can ignore those imports like this, in .eslintrc.json:
I set it up that way instead of $components because SvelteKit changed the components path to lib now. It could be more specific if that feels off: |
Ahhh, you where there a bit too early 😄 I found another way to remove this error: https://github.com/manuel3108/svelte-add-linting/commit/61e1a6ea200a54b65ff9e60f6e27e734d18f3941 Essentially I am using eslint-import-resolver-alias and adding a bit of config to the The tricky thing is the
I agree mainly, but I don't think we should use
Updated the readme
That's why we are using |
The default |
In my opinion, this should be in charge of implementing #6 or #5 depending on which works best.
That is to say, there should ideally only be
svelte-add/linting
and notsvelte-add/eslint
norsvelte-add/prettier
The text was updated successfully, but these errors were encountered: