Skip to content

Commit

Permalink
[html] setting to disable script & style validation
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed Jan 4, 2017
1 parent 420de32 commit 939f087
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
10 changes: 10 additions & 0 deletions extensions/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@
"default": true,
"description": "%html.suggest.html5.desc%"
},
"html.validate.scripts": {
"type": "boolean",
"default": true,
"description": "%html.validate.scripts%"
},
"html.validate.styles": {
"type": "boolean",
"default": true,
"description": "%html.validate.styles%"
},
"html.trace.server": {
"type": "string",
"enum": [
Expand Down
4 changes: 3 additions & 1 deletion extensions/html/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@
"html.format.extraLiners.desc": "List of tags, comma separated, that should have an extra newline before them. 'null' defaults to \"head, body, /html\".",
"html.suggest.angular1.desc": "Configures if the built-in HTML language support suggests Angular V1 tags and properties.",
"html.suggest.ionic.desc": "Configures if the built-in HTML language support suggests Ionic tags, properties and values.",
"html.suggest.html5.desc":"Configures if the built-in HTML language support suggests HTML5 tags, properties and values."
"html.suggest.html5.desc":"Configures if the built-in HTML language support suggests HTML5 tags, properties and values.",
"html.validate.scripts": "Configures if the built-in HTML language support validates embedded scripts.",
"html.validate.styles": "Configures if the built-in HTML language support validates embedded styles."
}
11 changes: 10 additions & 1 deletion extensions/html/server/src/htmlServerMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,18 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
};
});

let validation = {
html: true,
css: true,
javascript: true
};

// The settings have changed. Is send on server activation as well.
connection.onDidChangeConfiguration((change) => {
settings = change.settings;
let validationSettings = settings && settings.html && settings.html.validate || {};
validation.css = validationSettings.styles !== false;
validation.javascript = validationSettings.scripts !== false;

languageModes.getAllModes().forEach(m => {
if (m.configure) {
Expand Down Expand Up @@ -117,7 +126,7 @@ function triggerValidation(textDocument: TextDocument): void {
function validateTextDocument(textDocument: TextDocument): void {
let diagnostics: Diagnostic[] = [];
languageModes.getAllModesInDocument(textDocument).forEach(mode => {
if (mode.doValidation) {
if (mode.doValidation && validation[mode.getId()]) {
pushAll(diagnostics, mode.doValidation(textDocument));
}
});
Expand Down

0 comments on commit 939f087

Please sign in to comment.