Skip to content

Commit 146073f

Browse files
authored
(docs) discourage setting language defaults
1 parent 0d9e577 commit 146073f

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

docs/preprocessors/in-general.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,7 @@ It's also necessary to add a `type="text/language-name"` or `lang="language-name
3838

3939
#### Using language defaults
4040

41-
If you use `svelte-preprocess` and define the defaults inside `svelte.config.js`, you can in some cases omit the `type`/`lang` attributes. While these defaults get picked up by the language server, this may break your syntax highlighting and your code is no longer colored the right way, so use with caution - we recommend to always type the attributes. Reason: we have to tell VSCode which part of the Svelte file is written in which language through providing static regexes, which rely on the `type`/`lang` attribute.
42-
43-
```js
44-
const sveltePreprocess = require('svelte-preprocess');
45-
46-
module.exports = {
47-
preprocess: sveltePreprocess({
48-
defaults: {
49-
script: 'typescript' // <-- now you can just write <script>let typingsAllowed: string;</script>
50-
}
51-
})
52-
};
53-
```
41+
If you use `svelte-preprocess` and [define the defaults](https://github.com/sveltejs/svelte-preprocess/blob/main/docs/preprocessing.md#auto-preprocessing-options) inside `svelte.config.js`, you can in some cases omit the `type`/`lang` attributes. While these defaults get picked up by the language server, this may break your syntax highlighting and your code is no longer colored the right way, so use with caution - reason: we have to tell VSCode which part of the Svelte file is written in which language through providing static regexes, which rely on the `type`/`lang` attribute. It will also likely not work for other tooling in the ecosystem, for example `eslint-plugin-svelte3` or `prettier-plugin-svelte`. **We therefore recommend to always type the attributes.**
5442

5543
#### Deduplicating your configs
5644

0 commit comments

Comments
 (0)