Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 521553 - .tern-project file "plugin" entries can be either object…
…s or boolean (#157)
  • Loading branch information
mrennie committed Aug 29, 2017
1 parent 3a8eb25 commit ee564a2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Expand Up @@ -200,7 +200,7 @@ define({
'notEmpty': "'${0}' should not be empty",
'onlyStrings': "'${0}' entries can only be strings",
'notObject': "'${0}' must be an object",
'pluginNotObject': "plugin '${0}' must be an object",
'pluginNotObject': "plugin '${0}' must be an object or boolean",
'noDupes': "Duplicate entries are not allowed",
'problemInFile': "There is a problem with your .tern-project-file.",
'openFile': "Open the .tern-project file",
Expand Down
Expand Up @@ -93,8 +93,8 @@ define([
report(problems, i18nUtil.formatMessage(Messages['notObject'], key), obj.range);
} else if(obj.properties) {
obj.properties.forEach(function(prop) {
if(prop.value === null || prop.value.type !== 'ObjectExpression') {
report(problems, i18nUtil.formatMessage(Messages['notObject'], prop.key.value), prop.value.range);
if(prop.value === null || !(prop.value.type === 'ObjectExpression' || (prop.value.type === 'Literal' && typeof prop.value.value === 'boolean'))) {
report(problems, i18nUtil.formatMessage(Messages['pluginNotObject'], prop.key.value), prop.value.range);
}
});
}
Expand Down Expand Up @@ -162,7 +162,7 @@ define([
var keys = Object.keys(json.plugins);
for(var i = 0, len = keys.length; i < len; i++) {
var p = json.plugins[keys[i]];
if(p === null || typeof p !== 'object') {
if(p === null || !(typeof p === 'object' || typeof p === 'boolean')) {
problems.push(i18nUtil.formatMessage(Messages['pluginNotObject'], keys[i]));
}
}
Expand Down
@@ -1,6 +1,6 @@
/*******************************************************************************
* @license
* Copyright (c) 2015 IBM Corporation, Inc. and others.
* Copyright (c) 2015, 2017 IBM Corporation, Inc. and others.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0
* (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
Expand Down Expand Up @@ -342,31 +342,31 @@ define([
it("test plugins value - null", function() {
var problems = Validator.validateAST('{"plugins": {"a": null}}');
assertProblems(problems, [
problem(18, 22, "'a' must be an object")
problem(18, 22, "'a' must be an object or boolean")
]);
});
it("test plugins value - undefined", function() {
var problems = Validator.validateAST('{"plugins": {"a": undefined}}');
assertProblems(problems, [
problem(18, 27, "'a' must be an object")
problem(18, 27, "'a' must be an object or boolean")
]);
});
it("test plugins value - boolean", function() {
var problems = Validator.validateAST('{"plugins": {"a": true}}');
assertProblems(problems, [
problem(18, 22, "'a' must be an object")
problem(18, 22, "'a' must be an object or boolean")
]);
});
it("test plugins value - string", function() {
var problems = Validator.validateAST('{"plugins": {"a": "hi"}}');
assertProblems(problems, [
problem(18, 22, "'a' must be an object")
problem(18, 22, "'a' must be an object or boolean")
]);
});
it("test plugins value - array", function() {
var problems = Validator.validateAST('{"plugins": {"a": []}}');
assertProblems(problems, [
problem(18, 20, "'a' must be an object")
problem(18, 20, "'a' must be an object or boolean")
]);
});
it("test dupe entries - root", function() {
Expand Down

0 comments on commit ee564a2

Please sign in to comment.