Skip to content

Commit 6703e8b

Browse files
authored
(chore) bump ts to 4.0, fix build/tests (#470)
- Change in CSSDocument necessary to avoid new "is defined as a property in class '..', but is overridden here in '..' as an accessor" error - Changes in tests necessary because diagnostics + refactoring order changed slightly - Also removed some duplicated tests - bump eslint, adjust config (a new rule "@typescript-eslint/explicit-module-boundary-types" caused many warnings, therefore disabled)
1 parent ee5f940 commit 6703e8b

File tree

14 files changed

+203
-440
lines changed

14 files changed

+203
-440
lines changed

.eslintrc.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
module.exports = {
22
root: true,
33
parser: '@typescript-eslint/parser',
4-
plugins: [
5-
'@typescript-eslint',
6-
],
4+
plugins: ['@typescript-eslint'],
75
extends: [
86
'eslint:recommended',
97
'plugin:@typescript-eslint/eslint-recommended',
@@ -17,10 +15,7 @@ module.exports = {
1715
'keyword-spacing': ['error', { before: true, after: true }],
1816
'space-before-blocks': ['error', 'always'],
1917
'arrow-spacing': 'error',
20-
'max-len': [
21-
'error',
22-
{ code: 100, ignoreComments: true, ignoreStrings: true }
23-
],
18+
'max-len': ['error', { code: 100, ignoreComments: true, ignoreStrings: true }],
2419
'no-trailing-spaces': 'error',
2520

2621
'no-const-assign': 'error',
@@ -38,11 +33,12 @@ module.exports = {
3833
'@typescript-eslint/no-unused-vars': [
3934
'error',
4035
{
41-
argsIgnorePattern: '^_'
42-
}
36+
argsIgnorePattern: '^_',
37+
},
4338
],
4439
'@typescript-eslint/consistent-type-assertions': 'off',
4540
// might wanted to migrate to module only
46-
'@typescript-eslint/no-namespace': 'off'
47-
}
41+
'@typescript-eslint/no-namespace': 'off',
42+
'@typescript-eslint/explicit-module-boundary-types': 'off',
43+
},
4844
};

package.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
2-
"name": "@svelte/language-tools",
3-
"version": "1.0.0",
4-
"author": "Svelte Contributors",
5-
"license": "MIT",
6-
"private": true,
7-
"workspaces": [
8-
"packages/*"
9-
],
10-
"scripts": {
11-
"bootstrap": "yarn workspace svelte2tsx build",
12-
"build": "tsc -b",
13-
"test": "CI=true yarn workspaces run test",
14-
"watch": "tsc -b -watch",
15-
"lint": "eslint \"packages/**/*.{ts,js}\""
16-
},
17-
"dependencies": {
18-
"axios": "0.19.2"
19-
},
20-
"devDependencies": {
21-
"@typescript-eslint/eslint-plugin": "^2.30.0",
22-
"@typescript-eslint/parser": "^2.30.0",
23-
"eslint": "^6.8.0"
24-
}
2+
"name": "@svelte/language-tools",
3+
"version": "1.0.0",
4+
"author": "Svelte Contributors",
5+
"license": "MIT",
6+
"private": true,
7+
"workspaces": [
8+
"packages/*"
9+
],
10+
"scripts": {
11+
"bootstrap": "yarn workspace svelte2tsx build",
12+
"build": "tsc -b",
13+
"test": "CI=true yarn workspaces run test",
14+
"watch": "tsc -b -watch",
15+
"lint": "eslint \"packages/**/*.{ts,js}\""
16+
},
17+
"dependencies": {
18+
"axios": "0.19.2"
19+
},
20+
"devDependencies": {
21+
"@typescript-eslint/eslint-plugin": "^3.9.1",
22+
"@typescript-eslint/parser": "^3.9.1",
23+
"eslint": "^7.7.0"
24+
}
2525
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
root: false,
33
rules: {
4-
"@typescript-eslint/no-var-requires": 'off'
5-
}
6-
}
4+
'@typescript-eslint/no-var-requires': 'off',
5+
},
6+
};

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Document, DocumentMapper, ReadableDocument, TagInformation } from '../.
55

66
export class CSSDocument extends ReadableDocument implements DocumentMapper {
77
private styleInfo: Pick<TagInformation, 'attributes' | 'start' | 'end'>;
8-
private _version = this.parent.version;
8+
readonly version = this.parent.version;
99

1010
public stylesheet: Stylesheet;
1111
public languageId: string;
@@ -83,14 +83,6 @@ export class CSSDocument extends ReadableDocument implements DocumentMapper {
8383
return this.styleInfo.attributes;
8484
}
8585

86-
get version(): number {
87-
return this._version;
88-
}
89-
90-
set version(version: number) {
91-
// ignore
92-
}
93-
9486
private get language() {
9587
const attrs = this.getAttributes();
9688
return attrs.lang || attrs.type || 'css';
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
root: false,
33
rules: {
4-
'@typescript-eslint/no-non-null-assertion': 'off'
5-
}
6-
}
4+
'@typescript-eslint/no-non-null-assertion': 'off',
5+
},
6+
};

packages/language-server/test/plugins/typescript/TypescriptPlugin.test.ts

Lines changed: 2 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -25,85 +25,6 @@ describe('TypescriptPlugin', () => {
2525
return { plugin, document };
2626
}
2727

28-
it('provides diagnostics', async () => {
29-
const { plugin, document } = setup('diagnostics.svelte');
30-
const diagnostics = await plugin.getDiagnostics(document);
31-
32-
assert.deepStrictEqual(diagnostics, [
33-
{
34-
code: 2322,
35-
message: "Type 'true' is not assignable to type 'string'.",
36-
range: {
37-
start: {
38-
character: 32,
39-
line: 0,
40-
},
41-
end: {
42-
character: 35,
43-
line: 0,
44-
},
45-
},
46-
severity: 1,
47-
source: 'ts',
48-
},
49-
]);
50-
});
51-
52-
it('provides typecheck diagnostics for js file when //@ts-check at top of script', async () => {
53-
const { plugin, document } = setup('diagnostics-js-typecheck.svelte');
54-
const diagnostics = await plugin.getDiagnostics(document);
55-
56-
assert.deepStrictEqual(diagnostics, [
57-
{
58-
code: 2339,
59-
message: "Property 'bla' does not exist on type '1'.",
60-
range: {
61-
start: {
62-
character: 4,
63-
line: 3,
64-
},
65-
end: {
66-
character: 7,
67-
line: 3,
68-
},
69-
},
70-
severity: 1,
71-
source: 'js',
72-
},
73-
]);
74-
});
75-
76-
it('provides no typecheck diagnostics for js file', async () => {
77-
const { plugin, document } = setup('diagnostics-js-notypecheck.svelte');
78-
const diagnostics = await plugin.getDiagnostics(document);
79-
80-
assert.deepStrictEqual(diagnostics, []);
81-
});
82-
83-
it('provides diagnostics when there is a parser error', async () => {
84-
const { plugin, document } = setup('diagnostics-parsererror.svelte');
85-
const diagnostics = await plugin.getDiagnostics(document);
86-
87-
assert.deepStrictEqual(diagnostics, [
88-
{
89-
code: -1,
90-
message: 'You can only have one top-level <style> tag per component',
91-
range: {
92-
start: {
93-
character: 0,
94-
line: 1,
95-
},
96-
end: {
97-
character: 0,
98-
line: 1,
99-
},
100-
},
101-
severity: 1,
102-
source: 'js',
103-
},
104-
]);
105-
});
106-
10728
it('provides basic hover info when no docstring exists', async () => {
10829
const { plugin, document } = setup('hoverinfo.svelte');
10930

@@ -299,9 +220,8 @@ describe('TypescriptPlugin', () => {
299220
const snapshotManager = plugin.getSnapshotManager(filePath);
300221

301222
// make it the same style of path delimiter as vscode's request
302-
const projectJsFile = urlToPath(
303-
pathToUrl(path.join(path.dirname(filePath), 'documentation.ts'))
304-
) ?? '';
223+
const projectJsFile =
224+
urlToPath(pathToUrl(path.join(path.dirname(filePath), 'documentation.ts'))) ?? '';
305225

306226
plugin.onWatchFileChanges(projectJsFile, FileChangeType.Changed);
307227

packages/language-server/test/plugins/typescript/features/CodeActionsProvider.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ describe('CodeActionsProvider', () => {
248248
Range.create(Position.create(7, 8), Position.create(7, 42)),
249249
{ diagnostics: [], only: [CodeActionKind.Refactor] },
250250
);
251-
const action = actions[0];
251+
const action = actions[1];
252252

253253
assert.deepStrictEqual(action, {
254254
command: {
@@ -338,7 +338,7 @@ describe('CodeActionsProvider', () => {
338338
Range.create(Position.create(7, 8), Position.create(7, 42)),
339339
{ diagnostics: [], only: [CodeActionKind.Refactor] },
340340
);
341-
const action = actions[1];
341+
const action = actions[0];
342342

343343
assert.deepStrictEqual(action, {
344344
command: {

packages/language-server/test/plugins/typescript/features/CompletionProvider.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ describe('CompletionProviderImpl', () => {
152152
assert.deepStrictEqual(data, {
153153
hasAction: undefined,
154154
insertText: undefined,
155+
isPackageJsonImport: undefined,
155156
isRecommended: undefined,
156157
kind: 'method',
157158
kindModifiers: '',

packages/language-server/test/plugins/typescript/features/DiagnosticsProvider.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { LSConfigManager } from '../../../../src/ls-config';
66
import { TypeScriptPlugin } from '../../../../src/plugins';
77
import { pathToUrl } from '../../../../src/utils';
88

9-
describe('TypescriptPlugin', () => {
9+
describe('DiagnosticsProvider', () => {
1010
function setup(filename: string) {
1111
const docManager = new DocumentManager(() => document);
1212
const testDir = path.join(__dirname, '..');
@@ -25,7 +25,7 @@ describe('TypescriptPlugin', () => {
2525
assert.deepStrictEqual(diagnostics, [
2626
{
2727
code: 2322,
28-
message: "Type 'true' is not assignable to type 'string'.",
28+
message: "Type 'boolean' is not assignable to type 'string'.",
2929
range: {
3030
start: {
3131
character: 32,
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
root: false,
33
rules: {
4-
"@typescript-eslint/no-var-requires": 'off',
5-
}
6-
}
4+
'@typescript-eslint/no-var-requires': 'off',
5+
},
6+
};

0 commit comments

Comments
 (0)