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

Refactor: Add ESLint and set TypeScript to strict #2

Merged
merged 2 commits into from
Sep 19, 2023
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
27 changes: 27 additions & 0 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
env: {
browser: true,
es2021: true
},
extends: 'standard-with-typescript',
overrides: [
{
env: {
node: true
},
files: [
'.eslintrc.{js,cjs}',
'*.ts'
],
parserOptions: {
sourceType: 'script'
}
}
],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
rules: {},
ignorePatterns: ['out']
}
52 changes: 26 additions & 26 deletions client/language-configuration.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"comments": {
// symbol used for single line comment.
"lineComment": "#"
},
// symbols used as brackets
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
// symbols that are auto closed when typing
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
// symbols that that can be used to surround a selection
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
"comments": {
// symbol used for single line comment.
"lineComment": "#"
},
// symbols used as brackets
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
// symbols that are auto closed when typing
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
// symbols that that can be used to surround a selection
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}
18 changes: 14 additions & 4 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,22 @@
}
]
},
"scripts": {},
"scripts": {
"lint": "eslint ."
},
"dependencies": {
"vscode-languageclient": "^8.1.0"
},
"devDependencies": {
"@types/vscode": "^1.75.1",
"@vscode/test-electron": "^2.2.3"
}
"@types/node": "^20.6.2",
"@types/vscode": "^1.75.1",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@vscode/test-electron": "^2.2.3",
"eslint": "^8.49.0",
"eslint-config-standard-with-typescript": "^39.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-n": "^16.1.0",
"eslint-plugin-promise": "^6.1.1",
"typescript": "^5.2.2"
}
}
101 changes: 51 additions & 50 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,57 @@
* Copyright (c) Eugen Wiens. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';

import * as path from 'path';

import { workspace, ExtensionContext } from 'vscode';
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from 'vscode-languageclient/node';

let client: LanguageClient;
export function activate(context: ExtensionContext) {
console.log('Congratulations, your extension "BitBake" is now active!');
let serverModule = context.asAbsolutePath(path.join('../server', 'out','server.js'));
// The debug options for the server
let debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };

// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
let serverOptions: ServerOptions = {
run : { module: serverModule, transport: TransportKind.ipc },
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
}

// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for bitbake documents
// TODO: check new documentSelector
documentSelector: [{scheme: 'file', language: 'bitbake'}],
synchronize: {
configurationSection: 'bitbake',

// Notify the server about file changes to '.clientrc files contain in the workspace
fileEvents: [
workspace.createFileSystemWatcher('**/*.bbclass', false, true, false),
workspace.createFileSystemWatcher('**/*.inc', false, true, false),
workspace.createFileSystemWatcher('**/*.bb', false, true, false),
workspace.createFileSystemWatcher('**/*.conf', false, true, false)
]
}
}

// Create the language client and start the client.
client = new LanguageClient('bitbake', 'Language Server Bitbake', serverOptions, clientOptions)

// Start the client and launch the server
client.start();

import * as path from 'path'

import { workspace } from 'vscode'
import { LanguageClient, TransportKind } from 'vscode-languageclient/node'

import type { ExtensionContext } from 'vscode'
import type { LanguageClientOptions, ServerOptions } from 'vscode-languageclient/node'

let client: LanguageClient
export async function activate (context: ExtensionContext): Promise<void> {
console.log('Congratulations, your extension "BitBake" is now active!')
const serverModule = context.asAbsolutePath(path.join('../server', 'out', 'server.js'))
// The debug options for the server
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] }

// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
const serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
}

// Options to control the language client
const clientOptions: LanguageClientOptions = {
// Register the server for bitbake documents
// TODO: check new documentSelector
documentSelector: [{ scheme: 'file', language: 'bitbake' }],
synchronize: {
configurationSection: 'bitbake',

// Notify the server about file changes to '.clientrc files contain in the workspace
fileEvents: [
workspace.createFileSystemWatcher('**/*.bbclass', false, true, false),
workspace.createFileSystemWatcher('**/*.inc', false, true, false),
workspace.createFileSystemWatcher('**/*.bb', false, true, false),
workspace.createFileSystemWatcher('**/*.conf', false, true, false)
]
}
}

// Create the language client and start the client.
client = new LanguageClient('bitbake', 'Language Server Bitbake', serverOptions, clientOptions)

// Start the client and launch the server
await client.start()
}

export function deactivate(): Thenable<void> | undefined {
if (!client) {
return undefined;
}
return client.stop();
export function deactivate (): Thenable<void> | undefined {
if (client === undefined) {
return undefined
}
return client.stop()
}

Loading