Skip to content

Commit

Permalink
added severity off to customizations setting (#1243)
Browse files Browse the repository at this point in the history
  • Loading branch information
edupsousa authored May 14, 2021
1 parent 2e0e525 commit 2e04670
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ enum RuleSeverity {
info = 'info',
warn = 'warn',
error = 'error',
off = 'off',

// Added severity override changes
default = 'default',
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@
"info",
"default",
"upgrade",
"warn"
"warn",
"off"
],
"type": "string"
},
Expand Down
1 change: 1 addition & 0 deletions playgrounds/6.0/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"sourceType": "module"
},
"rules": {
"no-use-before-define": "error",
"no-useless-escape": "error",
"no-const-assign": "warn",
"no-this-before-super": "warn",
Expand Down
3 changes: 2 additions & 1 deletion playgrounds/6.0/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
{ "rule": "!no-*", "severity": "upgrade" },
{ "rule": "*console*", "severity": "upgrade" },
{ "rule": "*semi*", "severity": "default" },
{ "rule": "radix", "severity": "default" }
{ "rule": "radix", "severity": "default" },
{ "rule": "no-use-before-define", "severity": "off" }
],
"editor.codeActionsOnSaveTimeout": 2000,
"eslint.format.enable": true,
Expand Down
6 changes: 6 additions & 0 deletions server/src/eslintServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ function recordCodeAction(document: TextDocument, diagnostic: Diagnostic, proble

function adjustSeverityForOverride(severity: number | RuleSeverity, severityOverride?: RuleSeverity) {
switch (severityOverride) {
case RuleSeverity.off:
case RuleSeverity.info:
case RuleSeverity.warn:
case RuleSeverity.error:
Expand Down Expand Up @@ -1404,6 +1405,11 @@ function validate(document: TextDocument, settings: TextDocumentSettings & { lib
if (docReport.messages && Array.isArray(docReport.messages)) {
docReport.messages.forEach((problem) => {
if (problem) {
const isOff = getSeverityOverride(problem.ruleId, settings.rulesCustomizations) === RuleSeverity.off;
if (isOff) {
// Filter out rules with severity override to off
return;
}
const isWarning = convertSeverityToDiagnostic(problem.severity) === DiagnosticSeverity.Warning;
if (settings.quiet && isWarning) {
// Filter out warnings when quiet mode is enabled
Expand Down

0 comments on commit 2e04670

Please sign in to comment.