diff --git a/package-lock.json b/package-lock.json index 81d86a5..eeff8c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,8 +15,8 @@ "devDependencies": { "@types/glob": "^8.0.0", "@types/mocha": "^10.0.0", - "@types/node": "^18.7.23", - "@types/vscode": "^1.71.0", + "@types/node": "^18.11.0", + "@types/vscode": "^1.72.0", "@types/which": "^2.0.1", "glob": "^8.0.3", "mocha": "^10.0.0", @@ -28,7 +28,7 @@ "webpack-cli": "^4.10.0" }, "engines": { - "vscode": "^1.71.0" + "vscode": "^1.72.0" } }, "node_modules/@babel/code-frame": { @@ -268,15 +268,15 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.7.23", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.23.tgz", - "integrity": "sha512-DWNcCHolDq0ZKGizjx2DZjR/PqsYwAcYUJmfMWqtVU2MBMG5Mo+xFZrhGId5r/O5HOuMPyQEcM6KUBp5lBZZBg==", + "version": "18.11.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.2.tgz", + "integrity": "sha512-BWN3M23gLO2jVG8g/XHIRFWiiV4/GckeFIqbU/C4V3xpoBBWSMk4OZomouN0wCkfQFPqgZikyLr7DOYDysIkkw==", "dev": true }, "node_modules/@types/vscode": { - "version": "1.71.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.71.0.tgz", - "integrity": "sha512-nB50bBC9H/x2CpwW9FzRRRDrTZ7G0/POttJojvN/LiVfzTGfLyQIje1L1QRMdFXK9G41k5UJN/1B9S4of7CSzA==", + "version": "1.72.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.72.0.tgz", + "integrity": "sha512-WvHluhUo+lQvE3I4wUagRpnkHuysB4qSyOQUyIAS9n9PYMJjepzTUD8Jyks0YeXoPD0UGctjqp2u84/b3v6Ydw==", "dev": true }, "node_modules/@types/which": { @@ -3226,15 +3226,15 @@ "dev": true }, "@types/node": { - "version": "18.7.23", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.23.tgz", - "integrity": "sha512-DWNcCHolDq0ZKGizjx2DZjR/PqsYwAcYUJmfMWqtVU2MBMG5Mo+xFZrhGId5r/O5HOuMPyQEcM6KUBp5lBZZBg==", + "version": "18.11.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.2.tgz", + "integrity": "sha512-BWN3M23gLO2jVG8g/XHIRFWiiV4/GckeFIqbU/C4V3xpoBBWSMk4OZomouN0wCkfQFPqgZikyLr7DOYDysIkkw==", "dev": true }, "@types/vscode": { - "version": "1.71.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.71.0.tgz", - "integrity": "sha512-nB50bBC9H/x2CpwW9FzRRRDrTZ7G0/POttJojvN/LiVfzTGfLyQIje1L1QRMdFXK9G41k5UJN/1B9S4of7CSzA==", + "version": "1.72.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.72.0.tgz", + "integrity": "sha512-WvHluhUo+lQvE3I4wUagRpnkHuysB4qSyOQUyIAS9n9PYMJjepzTUD8Jyks0YeXoPD0UGctjqp2u84/b3v6Ydw==", "dev": true }, "@types/which": { diff --git a/package.json b/package.json index f4cbb8b..c87a3c4 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,21 @@ "type": "boolean", "default": false, "description": "Do not show warning dialog that a file must be saved to be linted." + }, + "vale.readabilityProblemLocation": { + "type": "string", + "enum": [ + "status", + "inline", + "both" + ], + "default": "status", + "markdownEnumDescriptions": [ + "Displays readability problems in the status bar.", + "Displays readability problems inline with other problems.", + "Displays readability problems both in the status bar and inline in the file." + ], + "markdownDescription": "Determines where file-level readability problems are displayed." } } } diff --git a/src/features/vsProvider.ts b/src/features/vsProvider.ts index 29e8697..23778b5 100644 --- a/src/features/vsProvider.ts +++ b/src/features/vsProvider.ts @@ -5,6 +5,7 @@ import * as fs from "fs"; import * as vscode from "vscode"; import * as utils from "./vsUtils"; +import { getReadabilityProblemLocation } from "./vsUtils"; export default class ValeProvider implements vscode.CodeActionProvider { private diagnosticCollection!: vscode.DiagnosticCollection; @@ -103,14 +104,20 @@ export default class ValeProvider implements vscode.CodeActionProvider { return; } + const readabilityProblemLocation = getReadabilityProblemLocation() this.readabilityStatus.hide(); + for (let key in body) { const alerts = body[key]; for (var i = 0; i < alerts.length; ++i) { - if (alerts[i].Match === "") { + const isReadabilityProblem = alerts[i].Match === "" + + if (isReadabilityProblem && readabilityProblemLocation !== "inline") { var readabilityMessage = alerts[0].Message; this.updateStatusBarItem(readabilityMessage); - } else { + } + + if (!isReadabilityProblem || readabilityProblemLocation !== "status") { let diagnostic = utils.toDiagnostic( alerts[i], this.stylesPath, diff --git a/src/features/vsTypes.ts b/src/features/vsTypes.ts index 986e094..f821d52 100644 --- a/src/features/vsTypes.ts +++ b/src/features/vsTypes.ts @@ -30,3 +30,8 @@ interface IValeErrorJSON { readonly Span: [number, number]; readonly Severity: ValeSeverity; } + +/** + * Where to display file-level readability problems. + */ +type ValeReadabilityProblemLocation = "both" | "inline" | "status"; diff --git a/src/features/vsUtils.ts b/src/features/vsUtils.ts index 2cc3ced..f8cb68a 100644 --- a/src/features/vsUtils.ts +++ b/src/features/vsUtils.ts @@ -266,3 +266,12 @@ export const buildCommand = ( command = command.concat(["--output", "JSON", path]); return command; }; + +export const getReadabilityProblemLocation = (): ValeReadabilityProblemLocation => { + const configuration = vscode.workspace.getConfiguration(); + + return configuration.get( + "vale.readabilityProblemLocation", + "status" + ); +}