Skip to content

Commit

Permalink
Fix: Merge in various command line configs at the same time (fixes #6104
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Mardak committed May 7, 2016
1 parent 716345f commit f293330
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
30 changes: 14 additions & 16 deletions lib/config.js
Expand Up @@ -231,7 +231,7 @@ Config.prototype.getConfig = function(filePath) {
}

// Step 2: Create a copy of the baseConfig
config = ConfigOps.merge({parser: this.parser, parserOptions: this.parserOptions}, this.baseConfig);
config = ConfigOps.merge({}, this.baseConfig);

// Step 3: Merge in the user-specified configuration from .eslintrc and package.json
config = ConfigOps.merge(config, userConfig);
Expand All @@ -243,27 +243,25 @@ Config.prototype.getConfig = function(filePath) {
config = ConfigOps.merge(config, this.useSpecificConfig);
}

// Step 5: Merge in command line environments
debug("Merging command line environment settings");
config = ConfigOps.merge(config, { env: this.env });

// Step 6: Merge in command line rules
if (this.options.rules) {
debug("Merging command line rules");
config = ConfigOps.merge(config, { rules: this.options.rules });
}

// Step 7: Merge in command line globals
config = ConfigOps.merge(config, { globals: this.globals });

// Step 8: Merge in command line plugins
// Step 5: Merge in command line settings: environments, globals, parser,
// parserOptions, rules
debug("Merging command line settings");
config = ConfigOps.merge(config, {
env: this.env,
globals: this.globals,
parser: this.parser,
parserOptions: this.parserOptions,
rules: this.options.rules || {}
});

// Step 6: Merge in command line plugins
if (this.options.plugins) {
debug("Merging command line plugins");
Plugins.loadAll(this.options.plugins);
config = ConfigOps.merge(config, { plugins: this.options.plugins });
}

// Step 9: Apply environments to the config if present
// Step 7: Apply environments to the config if present
if (config.env) {
config = ConfigOps.applyEnvironments(config);
}
Expand Down
5 changes: 5 additions & 0 deletions tests/fixtures/configurations/es6.json
@@ -0,0 +1,5 @@
{
"parserOptions": {
"ecmaVersion": 6
}
}
9 changes: 9 additions & 0 deletions tests/lib/cli.js
Expand Up @@ -635,6 +635,15 @@ describe("cli", function() {

assert.equal(exit, 0);
});

it("should exit with no error on ecmaVersion 7 feature with config ecmaVersion 6 and command line ecmaVersion 7", function() {

var configPath = getFixturePath("configurations", "es6.json");
var filePath = getFixturePath("passing-es7.js");
var exit = cli.execute("--no-ignore --config " + configPath + " --parser-options=ecmaVersion:7 " + filePath);

assert.equal(exit, 0);
});
});

describe("when given the max-warnings flag", function() {
Expand Down

0 comments on commit f293330

Please sign in to comment.