Currently there are three places where I should configure ignores for svelte's a11y warnings:
lua
lspconfig.svelte.setup{
cmd = { "yarn", "svelteserver", "--stdio" };
on_attach = on_attach;
settings = {
svelte = {
plugin = {
svelte = {
compilerWarnings = {
["a11y-no-onchange"] = "ignore"
}
}
}
}
}
}
svelte-check, which makes package.json
look ugly when configured and this is only place to configure it
{
"val": "svelte-check --compiler-warnings a11y-no-onchange:ignore",
"validate": "yarn val --threshold warning && yarn tsc --noEmit"
}
eslint
settings: {
'svelte3/ignore-warnings': ({ code }) => code === 'a11y-no-onchange',
// ...
},
I would love to configure it in one place: svelte.config.js
. It can't be avoided because of svelte-preprocess
and also these tools are reading it anyway for svelte-preprocess
, why not use it for onwarn
?
Also in the current situation I can't make per-project configurations for language server.
Ideally, I would like to use svelte.config.js
both in language tools and bundler and configure everything svelte-related there.
This stuff too: https://github.com/sveltejs/language-tools/tree/master/packages/svelte-vscode#settings
Males sense to me. I imagine the hard part will be agreeing on naming / how exactly it should be specified
It makes sense for things like warnings. I disagree that all language server settings should be read from it, that should be the responsibility of the IDE to provide those and integrate with the language server.
So using onwarn in it's current form is acceptable direction to go ?
To be compatible with existing configs, we could implement similar onwarn callback interface for intercepting warnings like it is done currently in svelte plugins for bundlers.
The reason for having maybe not all, but some configuration for language server in svelte.config.js
is that at least format options are usually configured on per-project basis. :thinking:
Formatting options should be put into a .prettierrc
file as the extension makes use of prettier in combination with a prettier plugin to accomplish formatting. https://www.npmjs.com/package/prettier-plugin-svelte
I have prettier as a pre-commit hook. Configuration is in package.json
.
{
"prettier": {
"singleQuote": true,
"printWidth": 80,
"plugins": [
"prettier-plugin-svelte"
]
}
}
Is there something special in prettier invocation from the LS? Or it should load this configuration like it usually does? :thinking:
This will work, too. My point was that the formatting options should not be the concern of svelte.config.js
.
I agree, now I don't see anything else other than onwarn
to reasonably move to the svelte.config.js
.
There's not much to decide left.
Do making onwarn
callback in every tool sounds like a good solution?
Unified configuration compatible with current one in the bundlers.
I'm rather concerned about adding svelte.config.js
support to things that already have well established mechanisms for configuration. In ESLint, for example, plugins are just passed the configuration object that ESLint has already loaded. This could be the result of the merging of several hierarchical .eslintrc.js
files (or JSON files, or YAML files, or the contents of the eslintConfig
keys in package.json
files), and I don't think ESLint tells the plugin where any of these files were, so I don't know where the plugin ought to look for svelte.config.js
. There's a single unified way for configuration to be handled, and ESLint core wants to be responsible for it.
So the solution is:
svelte-vscode
does.svelte.config.js
and use it in .eslintrc.js
somehow. Make a list with ignores and use it in both functions or something.svelte-check
to load configuration from workspace.Looks like the only thing worth modifying is svelte-check
then ?
Other than svelte-check
, it feels like it is doable in the userland. :thinking:
Candidates for harmonization of onwarn in my opinion are: language-server, svelte-check, rollup plugin, webpack plugin.
Most helpful comment
Candidates for harmonization of onwarn in my opinion are: language-server, svelte-check, rollup plugin, webpack plugin.