Skip to content

Commit

Permalink
Fixes microsoft#107: "No ESLint configuration found." message keeps r…
Browse files Browse the repository at this point in the history
…eappearing
  • Loading branch information
dbaeumer committed Aug 30, 2016
1 parent e61c46a commit 59c03c9
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions eslint-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,29 @@ function validate(document: TextDocument): void {
return connection.sendDiagnostics({ uri, diagnostics });
}

let ignoreNoConfigFound: boolean = false;

interface ESLintError extends Error {
messageTemplate?: string;
}

function isNoConfigFoundError(err: any): boolean {
let candidate = err as ESLintError;
return candidate.messageTemplate === 'no-config-found' || candidate.message === 'No ESLint configuration found.';
}

function validateSingle(document: TextDocument): void {
try {
validate(document);
} catch (err) {
connection.window.showErrorMessage(getMessage(err, document));
if (isNoConfigFoundError(err)) {
if (!ignoreNoConfigFound) {
ignoreNoConfigFound = true;
connection.window.showErrorMessage(getMessage(err, document));
}
} else {
connection.window.showErrorMessage(getMessage(err, document));
}
}
}

Expand All @@ -250,7 +268,14 @@ function validateMany(documents: TextDocument[]): void {
try {
validate(document);
} catch (err) {
tracker.add(getMessage(err, document));
if (isNoConfigFoundError(err)) {
if (!ignoreNoConfigFound) {
ignoreNoConfigFound = true;
tracker.add(getMessage(err, document));
}
} else {
tracker.add(getMessage(err, document));
}
}
});
tracker.sendErrors(connection);
Expand Down

0 comments on commit 59c03c9

Please sign in to comment.