Skip to content

Commit

Permalink
Fix: Do not throw exception if baseConfig is provided (fixes #6605) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
platinumazure authored and gyandeeps committed Jul 8, 2016
1 parent e42cacb commit 2bdf22c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/user-guide/migrating-to-3.0.0.md
Expand Up @@ -15,6 +15,7 @@ ESLint v3.0.0 now requires that you use a configuration to run. A configuration
1. A `.eslintrc.js`, `.eslintrc.json`, `.eslintrc.yml`, `.eslintrc.yaml`, or `.eslintrc` file either in your project or home directory.
2. Configuration options passed on the command line using `--rule` (or to CLIEngine using `rules`).
3. A configuration file passed on the command line using `-c` (or to CLIEngine using `configFile`).
4. A base configuration is provided to CLIEngine using the `baseConfig` option.

If ESLint can't find a configuration, then it will throw an error and ask you to provide one.

Expand Down
2 changes: 1 addition & 1 deletion lib/config.js
Expand Up @@ -162,7 +162,7 @@ function getLocalConfig(thisConfig, directory) {

if (personalConfig) {
config = ConfigOps.merge(config, personalConfig);
} else if (!hasRules(thisConfig.options)) {
} else if (!hasRules(thisConfig.options) && !thisConfig.options.baseConfig) {

// No config file, no manual configuration, and no rules, so error.
var noConfigError = new Error("No ESLint configuration found.");
Expand Down
20 changes: 20 additions & 0 deletions tests/lib/config.js
Expand Up @@ -1043,6 +1043,26 @@ describe("Config", function() {
config.getConfig(filePath);
}, "No ESLint configuration found");
});

it("should not throw an error if no local config and no personal config was found but baseConfig is specified", function() {
var projectPath = getFakeFixturePath("personal-config", "project-without-config"),
homePath = getFakeFixturePath("personal-config", "folder-does-not-exist"),
filePath = getFakeFixturePath("personal-config", "project-without-config", "foo.js");

var StubbedConfig = proxyquire("../../lib/config", { "user-home": homePath });

mockPersonalConfigFileSystem();
mockCWDResponse(projectPath);

var config = new StubbedConfig({
cwd: process.cwd(),
baseConfig: {}
});

assert.doesNotThrow(function() {
config.getConfig(filePath);
}, "No ESLint configuration found");
});
});
});

Expand Down

0 comments on commit 2bdf22c

Please sign in to comment.