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

Fix: Merge various command line configs at the same time (fixes #6104) #6108

Merged
merged 1 commit into from May 9, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
}
}
8 changes: 8 additions & 0 deletions tests/lib/cli.js
Expand Up @@ -635,6 +635,14 @@ 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