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

Add setting to show linting errors as warnings #108

Merged
merged 3 commits into from
Nov 29, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 3 additions & 1 deletion client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ interface TextDocumentSettings {
workspaceFolder: VWorkspaceFolder | undefined
workingDirectory: DirectoryItem.DirectoryItem | undefined
library: undefined
treatErrorsAsWarnings: boolean
}

interface NoStandardState {
Expand Down Expand Up @@ -499,7 +500,8 @@ export function realActivate (context: ExtensionContext): void {
nodePath: config.get('nodePath', undefined),
workingDirectory: undefined,
workspaceFolder: undefined,
library: undefined
library: undefined,
treatErrorsAsWarnings: config.get('treatErrorsAsWarnings', false)
}
const document: TextDocument = syncedDocuments.get(item.scopeUri)
if (document == null) {
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@
"type": "boolean",
"default": false,
"description": "Activate JavaScript Standard Style based on project's package.json settings, use globally installed standard module if set to \"false\""
},
"standard.treatErrorsAsWarnings": {
"type": "boolean",
"default": false,
"description": "Any linting error reported by Standard will instead be displayed as a warning within VS Code."
}
}
},
Expand Down
9 changes: 5 additions & 4 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ interface TextDocumentSettings {
workspaceFolder: { name: string, uri: URI } | undefined
workingDirectory: DirectoryItem.DirectoryItem | undefined
library: StandardModule | undefined
treatErrorsAsWarnings: boolean
}

interface StandardAutoFixEdit {
Expand Down Expand Up @@ -135,7 +136,7 @@ interface StandardModule {

function makeDiagnostic (
problem: StandardProblem,
source: LinterValues
settings: TextDocumentSettings
): Diagnostic {
const message =
problem.ruleId != null
Expand All @@ -149,8 +150,8 @@ function makeDiagnostic (
problem.endColumn != null ? Math.max(0, problem.endColumn - 1) : startChar
return {
message: message,
severity: convertSeverity(problem.severity),
source: source,
severity: settings.treatErrorsAsWarnings ? DiagnosticSeverity.Warning : convertSeverity(problem.severity),
source: settings.engine,
range: {
start: { line: startLine, character: startChar },
end: { line: endLine, character: endChar }
Expand Down Expand Up @@ -968,7 +969,7 @@ function validate (
) {
docReport.messages.forEach(problem => {
if (problem != null) {
const diagnostic = makeDiagnostic(problem, settings.engine)
const diagnostic = makeDiagnostic(problem, settings)
diagnostics.push(diagnostic)
if (settings.autoFix) {
recordCodeAction(document, diagnostic, problem)
Expand Down