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 “ignore untitled” setting #1563

Merged
merged 4 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 10 additions & 2 deletions client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ export class Validator {

public check(textDocument: TextDocument): Validate {
const config = Workspace.getConfiguration('eslint', textDocument.uri);

if (!config.get<boolean>('enable', true)) {
return Validate.off;
}

if (textDocument.uri.scheme === 'untitled' && config.get<boolean>('ignoreUntitled', false)) {
return Validate.off;
}

const languageId = textDocument.languageId;
const validate = config.get<(ValidateItem | string)[]>('validate');
if (Array.isArray(validate)) {
Expand All @@ -51,10 +57,11 @@ export class Validator {
}
}
}
const uri: string = textDocument.uri.toString();
if (this.probeFailed.has(uri)) {

if (this.probeFailed.has(textDocument.uri.toString())) {
return Validate.off;
}

const probe: string[] | undefined = config.get<string[]>('probe');
if (Array.isArray(probe)) {
for (const item of probe) {
Expand All @@ -63,6 +70,7 @@ export class Validator {
}
}
}

return Validate.off;
}
}
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,12 @@
},
"description": "An array of language ids which should be validated by ESLint. If not installed ESLint will show an error."
},
"eslint.ignoreUntitled": {
"scope": "resource",
"type": "boolean",
"default": false,
"description": "If true, untitled files won't be validated by ESLint."
},
"eslint.probe": {
"scope": "resource",
"type": "array",
Expand Down