Skip to content

Commit 8abeb0f

Browse files
authored
(chore) prettier --check (#768)
- add prettier --check - Formatting everything Note: If you use windows you might get a warning checking the first time. That's because git may do lf/crlf normalization. Just stage the files and they should magically disappear (because git recognizes that it's only lf/crlf differences)
1 parent 73707aa commit 8abeb0f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+900
-952
lines changed

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ packages/svelte2tsx/test/*/samples/*/*sx
33
packages/svelte2tsx/test/*/samples/*/*.svelte
44
packages/svelte2tsx/test/sourcemaps/*.html
55
packages/language-server/test/**/*.svelte
6+
packages/language-server/test/**/testfiles/**/*.ts
67
packages/svelte-vscode/syntaxes/*.yaml
8+
**/dist
79
.github/**
10+
.history/**

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"typescript.preferences.quoteStyle": "single",
2+
"typescript.preferences.quoteStyle": "single"
33
}

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ A `.svelte` file would look something like this:
3333
}
3434
</script>
3535

36-
<button on:click="{handleClick}">
37-
Count: {count}
38-
</button>
36+
<button on:click="{handleClick}">Count: {count}</button>
3937

4038
<p>{count} * 2 = {doubled}</p>
4139
<p>{doubled} * 2 = {quadrupled}</p>
@@ -128,7 +126,7 @@ For tricker issues, you can run the tests with a debugger in VSCode by setting a
128126

129127
Svelte is an MIT-licensed open source project with its ongoing development made possible entirely by the support of awesome volunteers. If you'd like to support their efforts, please consider:
130128

131-
- [Becoming a backer on Open Collective](https://opencollective.com/svelte).
129+
- [Becoming a backer on Open Collective](https://opencollective.com/svelte).
132130

133131
Funds donated via Open Collective will be used for compensating expenses related to Svelte's development such as hosting costs. If sufficient donations are received, funds may also be used to support Svelte's development more directly.
134132

docs/README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ LSP-compatible editors, you can use an HTML comment with the `@component` tag:
3939
<!-- @component But only the last documentation comment will be used -->
4040

4141
<main>
42-
<h1>
43-
Hello world
44-
</h1>
42+
<h1>Hello world</h1>
4543
</main>
4644
```
4745

@@ -66,7 +64,7 @@ The VS Code extension comes with its own syntax highlighting grammar which defin
6664
}
6765
```
6866

69-
To find out the scope of the things you want to highlight differently, you can use the scope inspector by entering the command "Developer: Inspect Editor Tokens and Scopes". The scope at the top of the section "textmate scopes" is what you are looking for. The current color is in the section "foreground" - you can use this to look up colors of other scopes if you want them to be the same color but don't know the color-code.
67+
To find out the scope of the things you want to highlight differently, you can use the scope inspector by entering the command "Developer: Inspect Editor Tokens and Scopes". The scope at the top of the section "textmate scopes" is what you are looking for. The current color is in the section "foreground" - you can use this to look up colors of other scopes if you want them to be the same color but don't know the color-code.
7068

7169
For more info on customizing your theme, [see the VS Code docs](https://code.visualstudio.com/docs/getstarted/themes#_customizing-a-color-theme).
7270

@@ -95,8 +93,9 @@ If you have the `Babel Javascript` plugin installed, this may be the cause. Disa
9593
#### My Code does not get formatted
9694

9795
Your default formatter for Svelte files may be wrong.
98-
- Mabye it's set to the old Svelte extension, if so, remove the setting
99-
- Maybe you set all files to be formatted by the prettier extension. Then you have two options: Either install `prettier-plugin-svelte` from npm, or tell VSCode to format the code with the `Svelte for VSCode extension`:
96+
97+
- Mabye it's set to the old Svelte extension, if so, remove the setting
98+
- Maybe you set all files to be formatted by the prettier extension. Then you have two options: Either install `prettier-plugin-svelte` from npm, or tell VSCode to format the code with the `Svelte for VSCode extension`:
10099

101100
```json
102101
"[svelte]": {

docs/internal/deployment.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
The [publisher is Svelte](https://marketplace.visualstudio.com/manage/publishers/svelte)
44

5-
- Extension builds with the account signed up via GitHub from orta
5+
- Extension builds with the account signed up via GitHub from orta
66

77
### npm deployments
88

9-
- Deployments come from a bot: `svelte-language-tools-deploy`
9+
- Deployments come from a bot: `svelte-language-tools-deploy`
1010

1111
### When Deployments happen
1212

13-
- Nightly builds are triggered through a scheduled GitHub workflow every night at 04:00 UTC.
14-
- Production builds are triggered by creating a new tag, which is best done through the "do a release" on Github. The tag name equals the version that is then shown on the marketplace, so each tag should have a higher version than the previous.
13+
- Nightly builds are triggered through a scheduled GitHub workflow every night at 04:00 UTC.
14+
- Production builds are triggered by creating a new tag, which is best done through the "do a release" on Github. The tag name equals the version that is then shown on the marketplace, so each tag should have a higher version than the previous.

docs/internal/overview.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ We chose the second option because TypeScript provides a language service which
5252

5353
`svelte2tsx` uses some [ambient definitions](/packages/svelte2tsx/svelte-shims.d.ts) which are loaded by the language server to do some of the transformations. It also provides [JSX definitions](/packages/svelte2tsx/svelte-jsx.d.ts) which are recognized by the TypeScript compiler and define intrinsic elements, attributes and events - so if you ever get an error that a DOM attribute is not assignable to a DOM element, it's likely a missing declaration in there.
5454

55-
The code generated by `svelte2tsx` is not runnable in any way and does not actually exist at runtime when you run your app, it purely exists for the IntelliSense.
55+
The code generated by `svelte2tsx` is not runnable in any way and does not actually exist at runtime when you run your app, it purely exists for the IntelliSense.
5656

5757
The code also returns source mappings so we know which position in the original code corresponds to which generated position.
5858

docs/preprocessors/in-general.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
If a svelte file contains some language other than `html`, `css` or `javascript`, `svelte-vscode` needs to know how to [preprocess](https://svelte.dev/docs#svelte_preprocess) it. This can be achieved by creating a `svelte.config.js` file at the root of your project which exports a svelte options object (similar to `svelte-loader` and `rollup-plugin-svelte`). It's recommended to use the official [svelte-preprocess](https://github.com/sveltejs/svelte-preprocess) package which can handle many languages.
66

7-
> NOTE: you __cannot__ use the new `import x from y` and `export const` / `export default` syntax in `svelte.config.js`.
7+
> NOTE: you **cannot** use the new `import x from y` and `export const` / `export default` syntax in `svelte.config.js`.
88
99
```js
1010
// svelte.config.js
1111
const sveltePreprocess = require('svelte-preprocess');
1212

1313
module.exports = {
14-
preprocess: sveltePreprocess(),
14+
preprocess: sveltePreprocess()
1515
};
1616
```
1717

@@ -46,9 +46,9 @@ const sveltePreprocess = require('svelte-preprocess');
4646
module.exports = {
4747
preprocess: sveltePreprocess({
4848
defaults: {
49-
script: 'typescript', // <-- now you can just write <script>let typingsAllowed: string;</script>
50-
},
51-
}),
49+
script: 'typescript' // <-- now you can just write <script>let typingsAllowed: string;</script>
50+
}
51+
})
5252
};
5353
```
5454

@@ -63,14 +63,14 @@ const sveltePreprocess = require('svelte-preprocess');
6363
// using sourceMap as an example, but could be anything you need dynamically
6464
function createPreprocessors(sourceMap) {
6565
return sveltePreprocess({
66-
sourceMap,
66+
sourceMap
6767
// ... your settings
6868
});
6969
}
7070

7171
module.exports = {
7272
preprocess: createPreprocessors(true),
73-
createPreprocessors,
73+
createPreprocessors
7474
};
7575
```
7676

@@ -88,10 +88,10 @@ export default {
8888
// ...
8989
svelte({
9090
// ...
91-
preprocess: createPreprocessors(!production),
92-
}),
91+
preprocess: createPreprocessors(!production)
92+
})
9393
// ...
94-
],
94+
]
9595
};
9696
```
9797

docs/preprocessors/scss-less.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ You need a `svelte.config.js`. [Read here on how to set it up and also how it re
2727
const sveltePreprocess = require('svelte-preprocess');
2828

2929
module.exports = {
30-
preprocess: sveltePreprocess(),
30+
preprocess: sveltePreprocess()
3131
};
3232
```
3333

@@ -76,6 +76,6 @@ const sveltePreprocess = require('svelte-preprocess');
7676
const path = require('path');
7777

7878
module.exports = {
79-
preprocess: sveltePreprocess({ includePaths: [path.join(__dirname, 'relative/path')] })
79+
preprocess: sveltePreprocess({ includePaths: [path.join(__dirname, 'relative/path')] })
8080
};
8181
```

docs/preprocessors/typescript.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ You may optionally want to add a `svelte.config.js` file - but it is not require
3232
const sveltePreprocess = require('svelte-preprocess');
3333

3434
module.exports = {
35-
preprocess: sveltePreprocess(),
35+
preprocess: sveltePreprocess()
3636
};
3737
```
3838

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
"build": "tsc -b",
1313
"test": "CI=true yarn workspaces run test",
1414
"watch": "tsc -b -watch",
15-
"lint": "eslint \"packages/**/*.{ts,js}\""
15+
"format": "prettier --write .",
16+
"lint": "prettier --check . && eslint \"packages/**/*.{ts,js}\""
1617
},
1718
"dependencies": {
18-
"axios": "0.21.1",
1919
"typescript": "^4.1.3"
2020
},
2121
"devDependencies": {
@@ -24,6 +24,7 @@
2424
"@typescript-eslint/parser": "^4.3.0",
2525
"eslint": "^7.7.0",
2626
"eslint-plugin-import": "^2.22.1",
27-
"eslint-plugin-svelte3": "^2.7.3"
27+
"eslint-plugin-svelte3": "^2.7.3",
28+
"prettier": "2.2.1"
2829
}
2930
}

packages/language-server/src/ls-config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export interface LSTypescriptConfig {
107107
};
108108
semanticTokens: {
109109
enable: boolean;
110-
}
110+
};
111111
}
112112

113113
export interface LSCSSConfig {

packages/language-server/src/plugins/css/features/svelte-selectors.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { IPseudoClassData } from 'vscode-css-languageservice';
33
export const pesudoClass: IPseudoClassData[] = [
44
{
55
name: ':global()',
6-
description:
7-
`[svelte] :global modifier
6+
description: `[svelte] :global modifier
87
98
Applying styles to a selector globally`,
109
references: [

packages/language-server/src/plugins/css/service.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ const customDataProvider: ICSSDataProvider = {
2222
}
2323
};
2424

25-
const [css, scss, less] = [getCSSLanguageService, getSCSSLanguageService, getLESSLanguageService]
26-
.map(getService => getService({
25+
const [css, scss, less] = [
26+
getCSSLanguageService,
27+
getSCSSLanguageService,
28+
getLESSLanguageService
29+
].map((getService) =>
30+
getService({
2731
customDataProviders: [customDataProvider]
28-
}));
32+
})
33+
);
2934

3035
const langs = {
3136
css,

packages/language-server/src/plugins/html/dataProvider.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ const mediaAttributes: IAttributeData[] = [
221221
},
222222
{
223223
name: 'bind:playbackRate',
224-
description: 'how fast or slow to play the video, where 1 is \'normal\''
224+
description: "how fast or slow to play the video, where 1 is 'normal'"
225225
},
226226
{
227227
name: 'bind:paused'
@@ -256,14 +256,14 @@ const addAttributes: Record<string, IAttributeData[]> = {
256256
{ name: 'bind:value' },
257257
{ name: 'bind:group', description: 'Available for type="radio" and type="checkbox"' },
258258
indeterminateAttribute,
259-
{...indeterminateAttribute, name: 'bind:indeterminate'}
259+
{ ...indeterminateAttribute, name: 'bind:indeterminate' }
260260
],
261261
textarea: [{ name: 'bind:value' }],
262262
video: [...mediaAttributes, ...videoAttributes],
263263
audio: [...mediaAttributes]
264264
};
265265

266-
const html5Tags = htmlData.tags!.map(tag => {
266+
const html5Tags = htmlData.tags!.map((tag) => {
267267
let attributes = tag.attributes.map(mapToSvelteEvent);
268268
if (addAttributes[tag.name]) {
269269
attributes = [...attributes, ...addAttributes[tag.name]];

packages/language-server/src/plugins/typescript/LSAndTSDocResolver.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ export class LSAndTSDocResolver {
103103
}
104104

105105
private getUserPreferences(scriptKind: ts.ScriptKind): ts.UserPreferences {
106-
const configLang = scriptKind === ts.ScriptKind.TS || scriptKind === ts.ScriptKind.TSX
107-
? 'typescript' : 'javascript';
106+
const configLang =
107+
scriptKind === ts.ScriptKind.TS || scriptKind === ts.ScriptKind.TSX
108+
? 'typescript'
109+
: 'javascript';
108110

109111
return this.configManager.getTsUserPreferences(configLang);
110112
}

packages/language-server/src/plugins/typescript/features/SelectionRangeProvider.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ export class SelectionRangeProviderImpl implements SelectionRangeProvider {
3636
};
3737
}
3838

39-
private filterOutUnmappedRange(
40-
selectionRange: SelectionRange
41-
): SelectionRange | null {
39+
private filterOutUnmappedRange(selectionRange: SelectionRange): SelectionRange | null {
4240
const flattened = this.flattenAndReverseSelectionRange(selectionRange);
4341
const filtered = flattened.filter((range) => range.start.line > 0 && range.end.line > 0);
4442
if (!filtered.length) {
@@ -54,7 +52,6 @@ export class SelectionRangeProviderImpl implements SelectionRangeProvider {
5452
return result ?? null;
5553
}
5654

57-
5855
/**
5956
* flatten the selection range and its parent to an array in reverse order
6057
* so it's easier to filter out unmapped selection and create a new tree of

packages/language-server/src/plugins/typescript/features/SemanticTokensProvider.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import ts from 'typescript';
2-
import {
3-
Range,
4-
SemanticTokens,
5-
SemanticTokensBuilder
6-
} from 'vscode-languageserver';
2+
import { Range, SemanticTokens, SemanticTokensBuilder } from 'vscode-languageserver';
73
import { Document } from '../../../lib/documents';
84
import { SemanticTokensProvider } from '../../interfaces';
95
import { SnapshotFragment } from '../DocumentSnapshot';
@@ -65,7 +61,7 @@ export class SemanticTokensProviderImpl implements SemanticTokensProvider {
6561

6662
const modifier = this.getTokenModifierFromClassification(encodedClassification);
6763

68-
builder.push(line, character, length, classificationType , modifier);
64+
builder.push(line, character, length, classificationType, modifier);
6965
}
7066

7167
return builder.build();

packages/language-server/src/plugins/typescript/features/SignatureHelpProvider.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { LSAndTSDocResolver } from '../LSAndTSDocResolver';
1414
import { getMarkdownDocumentation } from '../previewer';
1515

1616
export class SignatureHelpProviderImpl implements SignatureHelpProvider {
17-
constructor(private readonly lsAndTsDocResolver: LSAndTSDocResolver) { }
17+
constructor(private readonly lsAndTsDocResolver: LSAndTSDocResolver) {}
1818

1919
private static readonly triggerCharacters = ['(', ',', '<'];
2020
private static readonly retriggerCharacters = [')'];
@@ -41,8 +41,7 @@ export class SignatureHelpProviderImpl implements SignatureHelpProvider {
4141
return null;
4242
}
4343

44-
const signatures = info.items
45-
.map(this.toSignatureHelpInformation);
44+
const signatures = info.items.map(this.toSignatureHelpInformation);
4645

4746
return {
4847
signatures,
@@ -134,18 +133,19 @@ export class SignatureHelpProviderImpl implements SignatureHelpProvider {
134133

135134
return {
136135
label: prefixLabel + signatureLabel + suffixLabel,
137-
documentation: signatureDocumentation ? {
138-
value: signatureDocumentation,
139-
kind: MarkupKind.Markdown
140-
} : undefined,
136+
documentation: signatureDocumentation
137+
? {
138+
value: signatureDocumentation,
139+
kind: MarkupKind.Markdown
140+
}
141+
: undefined,
141142
parameters
142143
};
143144
}
144145

145-
private isInSvelte2tsxGeneratedFunction(
146-
signatureHelpItem: ts.SignatureHelpItem
147-
) {
148-
return signatureHelpItem.prefixDisplayParts
149-
.some((part) => part.text.includes('__sveltets'));
146+
private isInSvelte2tsxGeneratedFunction(signatureHelpItem: ts.SignatureHelpItem) {
147+
return signatureHelpItem.prefixDisplayParts.some((part) =>
148+
part.text.includes('__sveltets')
149+
);
150150
}
151151
}

packages/language-server/src/plugins/typescript/features/getDirectiveCommentCompletions.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import {
1515
export const tsDirectives = [
1616
{
1717
value: '@ts-check',
18-
description:
19-
'Enables semantic checking in a JavaScript file. Must be at the top of a file.'
18+
description: 'Enables semantic checking in a JavaScript file. Must be at the top of a file.'
2019
},
2120
{
2221
value: '@ts-nocheck',

packages/language-server/src/plugins/typescript/svelte-sys.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@ export function createSvelteSys(getSnapshot: (fileName: string) => DocumentSnaps
1818
readDirectory(path, extensions, exclude, include, depth) {
1919
const extensionsWithSvelte = (extensions ?? []).concat('.svelte');
2020

21-
return ts.sys.readDirectory(
22-
path,
23-
extensionsWithSvelte,
24-
exclude,
25-
include,
26-
depth
27-
);
21+
return ts.sys.readDirectory(path, extensionsWithSvelte, exclude, include, depth);
2822
}
2923
};
3024

packages/language-server/src/plugins/typescript/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export function findTsConfigPath(fileName: string, rootUris: string[]) {
111111
ts.findConfigFile(searchDir, ts.sys.fileExists, 'jsconfig.json') ||
112112
'';
113113
// Don't return config files that exceed the current workspace context.
114-
return !!path && rootUris.some(rootUri => isSubPath(rootUri, path)) ? path : '';
114+
return !!path && rootUris.some((rootUri) => isSubPath(rootUri, path)) ? path : '';
115115
}
116116

117117
export function isSubPath(uri: string, possibleSubPath: string): boolean {

0 commit comments

Comments
 (0)