diff --git a/.eslintrc.js b/.eslintrc.js index 043dde1f7..acedb8abf 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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', @@ -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', @@ -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', + }, }; diff --git a/package.json b/package.json index c1380971f..fafa5d510 100644 --- a/package.json +++ b/package.json @@ -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" + } } diff --git a/packages/language-server/scripts/.eslintrc.js b/packages/language-server/scripts/.eslintrc.js index e97f89324..c0ece176c 100644 --- a/packages/language-server/scripts/.eslintrc.js +++ b/packages/language-server/scripts/.eslintrc.js @@ -1,6 +1,6 @@ module.exports = { root: false, rules: { - "@typescript-eslint/no-var-requires": 'off' - } -} + '@typescript-eslint/no-var-requires': 'off', + }, +}; diff --git a/packages/language-server/src/plugins/css/CSSDocument.ts b/packages/language-server/src/plugins/css/CSSDocument.ts index ca553c27f..f6f045b2d 100644 --- a/packages/language-server/src/plugins/css/CSSDocument.ts +++ b/packages/language-server/src/plugins/css/CSSDocument.ts @@ -5,7 +5,7 @@ import { Document, DocumentMapper, ReadableDocument, TagInformation } from '../. export class CSSDocument extends ReadableDocument implements DocumentMapper { private styleInfo: Pick; - private _version = this.parent.version; + readonly version = this.parent.version; public stylesheet: Stylesheet; public languageId: string; @@ -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'; diff --git a/packages/language-server/test/.eslintrc.js b/packages/language-server/test/.eslintrc.js index 0fafa89fd..3b79dff30 100644 --- a/packages/language-server/test/.eslintrc.js +++ b/packages/language-server/test/.eslintrc.js @@ -1,6 +1,6 @@ module.exports = { root: false, rules: { - '@typescript-eslint/no-non-null-assertion': 'off' - } -} + '@typescript-eslint/no-non-null-assertion': 'off', + }, +}; diff --git a/packages/language-server/test/plugins/typescript/TypescriptPlugin.test.ts b/packages/language-server/test/plugins/typescript/TypescriptPlugin.test.ts index fa17cd220..5472c9ac8 100644 --- a/packages/language-server/test/plugins/typescript/TypescriptPlugin.test.ts +++ b/packages/language-server/test/plugins/typescript/TypescriptPlugin.test.ts @@ -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