Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 525699 - Using only eslintConfig in package.json the ECMA version…
… is not correctly set
  • Loading branch information
mrennie committed Jan 31, 2018
1 parent 2cc747b commit 3bd9412
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
@@ -1,6 +1,6 @@
/*******************************************************************************
* @license
* Copyright (c) 2016, 2017 IBM Corporation and others.
* Copyright (c) 2016, 2018 IBM Corporation 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 @@ -500,6 +500,9 @@ define([
project.map.env.defs.push(project.DEFINITIONS+'/'+def.Name);
});
}
if(project.map.env.ternproject && project.map.env.ternproject.vals && project.map.env.ternproject.vals.ecmaVersion > project.map.env.ecmaVersion) {
project.map.env.ecmaVersion = project.map.env.ternproject.vals.ecmaVersion;
}
return project.map.env;
}, function rejected() {
return project.map.env;
Expand Down Expand Up @@ -616,7 +619,7 @@ define([
});
}
if(options.vals.ecmaVersion) {
project.map.env.ecmaVersion = options.vals.ecmaVersion;
project.map.env.ecmaVersion = translateEcma(options.vals.ecmaVersion);
}
}
}
Expand Down Expand Up @@ -657,6 +660,11 @@ define([
if(!project.map.env.eslint) {
project.map.env.eslint = {file: file, vals: vals.eslintConfig};
}
if(typeof vals.eslintConfig.ecmaVersion === "number") {
var val = translateEcma(vals.eslintConfig.ecmaVersion);
//what to do here is ecmaVersion is set via someone else? package.json will torch it
project.map.env.ecmaVersion = val;
}
}
}
} catch(e) {
Expand Down
@@ -1,6 +1,6 @@
/*******************************************************************************
* @license
* Copyright (c) 2015, 2017 IBM Corporation and others.
* Copyright (c) 2015, 2018 IBM Corporation 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 @@ -282,6 +282,15 @@ define([
* @since 14.0
*/
function prepareOptions(json, env) {
if(typeof env.ecmaVersion === 'number') {
if(!json.ecmaVersion) {
//just set it
json.ecmaVersion = env.ecmaVersion;
} else if(env.ecmaVersion > json.ecmaVersion){
//only set it if its greater (more compatible) - don't downgrade ECMA via multiple configs
json.ecmaVersion = env.ecmaVersion;
}
}
if(env && env.envs) {
//TODO make this more dynamic once we have the ability to install definition files and plugins
TernDefaults.defNames.forEach(function(def) {
Expand Down

0 comments on commit 3bd9412

Please sign in to comment.