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: Do not throw exception if baseConfig is provided (fixes #6605) #6625

Merged
merged 1 commit into from
Jul 8, 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
1 change: 1 addition & 0 deletions docs/user-guide/migrating-to-3.0.0.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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