Skip to content
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

(chore) bump ts to 4.0, fix build/tests #470

Merged
merged 2 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
Expand All @@ -17,10 +15,7 @@ module.exports = {
'keyword-spacing': ['error', { before: true, after: true }],
'space-before-blocks': ['error', 'always'],
'arrow-spacing': 'error',
'max-len': [
'error',
{ code: 100, ignoreComments: true, ignoreStrings: true }
],
'max-len': ['error', { code: 100, ignoreComments: true, ignoreStrings: true }],
'no-trailing-spaces': 'error',

'no-const-assign': 'error',
Expand All @@ -38,11 +33,12 @@ module.exports = {
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_'
}
argsIgnorePattern: '^_',
},
],
'@typescript-eslint/consistent-type-assertions': 'off',
// might wanted to migrate to module only
'@typescript-eslint/no-namespace': 'off'
}
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
};
46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"name": "@svelte/language-tools",
"version": "1.0.0",
"author": "Svelte Contributors",
"license": "MIT",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"bootstrap": "yarn workspace svelte2tsx build",
"build": "tsc -b",
"test": "CI=true yarn workspaces run test",
"watch": "tsc -b -watch",
"lint": "eslint \"packages/**/*.{ts,js}\""
},
"dependencies": {
"axios": "0.19.2"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.30.0",
"@typescript-eslint/parser": "^2.30.0",
"eslint": "^6.8.0"
}
"name": "@svelte/language-tools",
"version": "1.0.0",
"author": "Svelte Contributors",
"license": "MIT",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"bootstrap": "yarn workspace svelte2tsx build",
"build": "tsc -b",
"test": "CI=true yarn workspaces run test",
"watch": "tsc -b -watch",
"lint": "eslint \"packages/**/*.{ts,js}\""
},
"dependencies": {
"axios": "0.19.2"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^3.9.1",
"@typescript-eslint/parser": "^3.9.1",
"eslint": "^7.7.0"
}
}
6 changes: 3 additions & 3 deletions packages/language-server/scripts/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
root: false,
rules: {
"@typescript-eslint/no-var-requires": 'off'
}
}
'@typescript-eslint/no-var-requires': 'off',
},
};
10 changes: 1 addition & 9 deletions packages/language-server/src/plugins/css/CSSDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Document, DocumentMapper, ReadableDocument, TagInformation } from '../.

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

public stylesheet: Stylesheet;
public languageId: string;
Expand Down Expand Up @@ -83,14 +83,6 @@ export class CSSDocument extends ReadableDocument implements DocumentMapper {
return this.styleInfo.attributes;
}

get version(): number {
return this._version;
}

set version(version: number) {
// ignore
}

private get language() {
const attrs = this.getAttributes();
return attrs.lang || attrs.type || 'css';
Expand Down
6 changes: 3 additions & 3 deletions packages/language-server/test/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
root: false,
rules: {
'@typescript-eslint/no-non-null-assertion': 'off'
}
}
'@typescript-eslint/no-non-null-assertion': 'off',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,85 +25,6 @@ describe('TypescriptPlugin', () => {
return { plugin, document };
}

it('provides diagnostics', async () => {
const { plugin, document } = setup('diagnostics.svelte');
const diagnostics = await plugin.getDiagnostics(document);

assert.deepStrictEqual(diagnostics, [
{
code: 2322,
message: "Type 'true' is not assignable to type 'string'.",
range: {
start: {
character: 32,
line: 0,
},
end: {
character: 35,
line: 0,
},
},
severity: 1,
source: 'ts',
},
]);
});

it('provides typecheck diagnostics for js file when //@ts-check at top of script', async () => {
const { plugin, document } = setup('diagnostics-js-typecheck.svelte');
const diagnostics = await plugin.getDiagnostics(document);

assert.deepStrictEqual(diagnostics, [
{
code: 2339,
message: "Property 'bla' does not exist on type '1'.",
range: {
start: {
character: 4,
line: 3,
},
end: {
character: 7,
line: 3,
},
},
severity: 1,
source: 'js',
},
]);
});

it('provides no typecheck diagnostics for js file', async () => {
const { plugin, document } = setup('diagnostics-js-notypecheck.svelte');
const diagnostics = await plugin.getDiagnostics(document);

assert.deepStrictEqual(diagnostics, []);
});

it('provides diagnostics when there is a parser error', async () => {
const { plugin, document } = setup('diagnostics-parsererror.svelte');
const diagnostics = await plugin.getDiagnostics(document);

assert.deepStrictEqual(diagnostics, [
{
code: -1,
message: 'You can only have one top-level <style> tag per component',
range: {
start: {
character: 0,
line: 1,
},
end: {
character: 0,
line: 1,
},
},
severity: 1,
source: 'js',
},
]);
});

it('provides basic hover info when no docstring exists', async () => {
const { plugin, document } = setup('hoverinfo.svelte');

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

// make it the same style of path delimiter as vscode's request
const projectJsFile = urlToPath(
pathToUrl(path.join(path.dirname(filePath), 'documentation.ts'))
) ?? '';
const projectJsFile =
urlToPath(pathToUrl(path.join(path.dirname(filePath), 'documentation.ts'))) ?? '';

plugin.onWatchFileChanges(projectJsFile, FileChangeType.Changed);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ describe('CodeActionsProvider', () => {
Range.create(Position.create(7, 8), Position.create(7, 42)),
{ diagnostics: [], only: [CodeActionKind.Refactor] },
);
const action = actions[0];
const action = actions[1];

assert.deepStrictEqual(action, {
command: {
Expand Down Expand Up @@ -338,7 +338,7 @@ describe('CodeActionsProvider', () => {
Range.create(Position.create(7, 8), Position.create(7, 42)),
{ diagnostics: [], only: [CodeActionKind.Refactor] },
);
const action = actions[1];
const action = actions[0];

assert.deepStrictEqual(action, {
command: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ describe('CompletionProviderImpl', () => {
assert.deepStrictEqual(data, {
hasAction: undefined,
insertText: undefined,
isPackageJsonImport: undefined,
isRecommended: undefined,
kind: 'method',
kindModifiers: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { LSConfigManager } from '../../../../src/ls-config';
import { TypeScriptPlugin } from '../../../../src/plugins';
import { pathToUrl } from '../../../../src/utils';

describe('TypescriptPlugin', () => {
describe('DiagnosticsProvider', () => {
function setup(filename: string) {
const docManager = new DocumentManager(() => document);
const testDir = path.join(__dirname, '..');
Expand All @@ -25,7 +25,7 @@ describe('TypescriptPlugin', () => {
assert.deepStrictEqual(diagnostics, [
{
code: 2322,
message: "Type 'true' is not assignable to type 'string'.",
message: "Type 'boolean' is not assignable to type 'string'.",
range: {
start: {
character: 32,
Expand Down
6 changes: 3 additions & 3 deletions packages/svelte-vscode/scripts/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
root: false,
rules: {
"@typescript-eslint/no-var-requires": 'off',
}
}
'@typescript-eslint/no-var-requires': 'off',
},
};
4 changes: 2 additions & 2 deletions packages/svelte2tsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
"svelte": "3.24.0",
"tiny-glob": "^0.2.6",
"tslib": "^1.10.0",
"typescript": "^3.9.3"
"typescript": "^4.0.2"
},
"peerDependencies": {
"svelte": "^3.24",
"typescript": "^3.9.3"
"typescript": "^4.0.2"
},
"scripts": {
"build": "rollup -c",
Expand Down
1 change: 0 additions & 1 deletion packages/svelte2tsx/src/nodes/ExportedNames.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
export interface IExportedNames {
has(name: string): boolean;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte2tsx/svelte-jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
interface HTMLAttributes<T> extends DOMAttributes<T> {
// jsx-dom-specific Attributes
class?: ClassName;
dataset?: object;
dataset?: object; // eslint-disable-line

// Standard HTML Attributes
accept?: string;
Expand Down
Loading