Skip to content

Commit

Permalink
Merge 5d676bc into 04733f1
Browse files Browse the repository at this point in the history
  • Loading branch information
wmertens committed Sep 25, 2016
2 parents 04733f1 + 5d676bc commit 0e3b140
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion options-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function normalizeOpts(opts) {
'ignore',
'plugin',
'rule',
'setting',
'extend'
].forEach(function (singular) {
var plural = singular + 's';
Expand All @@ -57,7 +58,7 @@ function normalizeOpts(opts) {
return;
}

if (singular !== 'rule') {
if (singular !== 'rule' && singular !== 'setting') {
value = arrify(value);
}

Expand All @@ -77,6 +78,7 @@ function mergeWithPkgConf(opts) {
function emptyOptions() {
return {
rules: {},
settings: {},
globals: [],
envs: [],
plugins: [],
Expand Down Expand Up @@ -119,6 +121,10 @@ function buildConfig(opts) {
objectAssign(config.rules, opts.rules);
}

if (opts.settings) {
objectAssign(config.settings, opts.settings);
}

if (opts.extends && opts.extends.length > 0) {
// TODO: this logic needs to be improved, preferably use the same code as ESLint
// user's configs must be resolved to their absolute paths
Expand Down
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ Override any of the [default rules](https://github.com/sindresorhus/eslint-confi

Please take a moment to consider if you really need to use this option.

### settings

Type: `object`

Anything you put here gets passed to `settings` in the ESLint configuration; some of the ESLint plugins use this. For example, to configure the `import` ruleset to use the webpack configuration for determining search paths, you can put `{'import/resolver': 'webpack'}` here.

### semicolon

Type: `boolean`<br>
Expand Down
8 changes: 8 additions & 0 deletions test/options-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ test('normalizeOpts: makes all the opts plural and arrays', t => {
ignore: 'test.js',
plugin: 'my-plugin',
rule: {'my-rule': 'foo'},
setting: {'my-rule': 'bar'},
extend: 'foo'
};

Expand All @@ -23,6 +24,7 @@ test('normalizeOpts: makes all the opts plural and arrays', t => {
ignores: ['test.js'],
plugins: ['my-plugin'],
rules: {'my-rule': 'foo'},
settings: {'my-rule': 'bar'},
extends: ['foo']
});
});
Expand Down Expand Up @@ -73,6 +75,12 @@ test('buildConfig: rules', t => {
t.deepEqual(config.rules, rules);
});

test('buildConfig: settings', t => {
const settings = {'import/resolver': 'webpack'};
const config = manager.buildConfig({settings});
t.deepEqual(config.settings, settings);
});

test('findApplicableOverrides', t => {
const result = manager.findApplicableOverrides('/user/dir/foo.js', [
{files: '**/f*.js'},
Expand Down

0 comments on commit 0e3b140

Please sign in to comment.