From 5f670db1f2e1d1f07ca64f6dcb08365d8820f395 Mon Sep 17 00:00:00 2001 From: James Ruskin Date: Thu, 14 Sep 2017 13:15:28 +0100 Subject: [PATCH 1/2] Adds setting for write-good languages, and checks that the current document is using one of those languages before linting. Addresses issue #3. --- package.json | 23 +++++++++++++++++++++++ src/extension.ts | 17 +++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7317512..49b5320 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,29 @@ "onLanguage:markdown" ], "main": "./out/src/extension", + "contributes": { + "configuration":{ + "type": "object", + "title": "write-good", + "properties": { + "write-good.languages": { + "default": [ + "markdown", + "plaintext" + ], + "type": [ + "string", + "array" + ], + "items": { + "type": "string" + }, + "description": "Languages to lint with the write-good linter", + "scope": "resource" + } + } + } + }, "scripts": { "vscode:prepublish": "node ./node_modules/vscode/bin/compile", "compile": "node ./node_modules/vscode/bin/compile -watch -p ./", diff --git a/src/extension.ts b/src/extension.ts index bdfd209..23d1bdb 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -8,15 +8,28 @@ export function activate(context: ExtensionContext) { console.log("Write-Good Linter active..."); + function isWriteGoodLanguage(languageId) { + let wgLanguages: string = workspace.getConfiguration('write-good').get('include'); + return (wgLanguages.indexOf(languageId) > -1); + } + context.subscriptions.push(workspace.onDidChangeTextDocument(event => { - doLint(event.document); + if (isWriteGoodLanguage(event.document.languageId)) { + doLint(event.document); + } })); context.subscriptions.push(workspace.onDidOpenTextDocument(event => { - doLint(event); + if (isWriteGoodLanguage(event.languageId) { + doLint(event); + } })); } +export function deactivate() { + console.log("Write-Good Linter deactivating...") +} + interface Suggestion { index: number, offset: number, From 279af2a86deefdaaec70184a7ecc2b9eaf37f7be Mon Sep 17 00:00:00 2001 From: James Ruskin Date: Fri, 15 Sep 2017 18:05:56 +0100 Subject: [PATCH 2/2] Updates setting to "Languages" instead of "Include", as it seems like a better label. --- package.json | 5 ++--- src/extension.ts | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 49b5320..aa1eae2 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,7 @@ "properties": { "write-good.languages": { "default": [ - "markdown", - "plaintext" + "markdown" ], "type": [ "string", @@ -31,7 +30,7 @@ "items": { "type": "string" }, - "description": "Languages to lint with the write-good linter", + "description": "Languages to lint with the write-good linter. '*' to enable on all languages.", "scope": "resource" } } diff --git a/src/extension.ts b/src/extension.ts index 23d1bdb..79fda0e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -9,8 +9,8 @@ export function activate(context: ExtensionContext) { console.log("Write-Good Linter active..."); function isWriteGoodLanguage(languageId) { - let wgLanguages: string = workspace.getConfiguration('write-good').get('include'); - return (wgLanguages.indexOf(languageId) > -1); + let wgLanguages: string = workspace.getConfiguration('write-good').get('languages'); + return (wgLanguages.indexOf(languageId) > -1 || wgLanguages === '*'); } context.subscriptions.push(workspace.onDidChangeTextDocument(event => { @@ -20,7 +20,7 @@ export function activate(context: ExtensionContext) { })); context.subscriptions.push(workspace.onDidOpenTextDocument(event => { - if (isWriteGoodLanguage(event.languageId) { + if (isWriteGoodLanguage(event.languageId)) { doLint(event); } }));