Skip to content

Commit

Permalink
fix(cli-options): rules should be passed as an object instead of arra…
Browse files Browse the repository at this point in the history
…y of strings (#39)
  • Loading branch information
emmenko authored and rogeliog committed May 27, 2018
1 parent 591de9e commit 3bd91fe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,5 @@ jest-runner-eslint maps a lot of ESLint CLI arguments to config options. For exa
|parser|`espree`|`"parser": "flow"`
|parserOptions|`{}`|`"parserOptions": { "myOption": true }`
|plugin|`[]`|`"plugin": "prettier"` or `"plugin": ["pettier", "other"]`
|rule|`null`|`"rule": "'quotes: [2, double]'"` or `"rule": ["quotes: [2, double]", "no-console: 2"]`
|rules|`null`|`"rules": {"quotes": [2, "double"]}` or `"rules": {"quotes": [2, "double"], "no-console": 2}`
|rulesdir|`[]`|`"rulesdir": "/path/to/rules/dir"` or `"env": ["/path/to/rules/dir", "/path/to/other"]`
10 changes: 4 additions & 6 deletions src/utils/__tests__/normalizeConfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,15 @@ it('normalizes rulesdir', () => {
});
});

it('normalizes rule', () => {
it('normalizes rules', () => {
expect(normalizeCLIOptions({})).toMatchObject({
rules: null,
});

expect(normalizeCLIOptions({ rule: ['quotes: [2, double]'] })).toMatchObject({
rules: ['quotes: [2, double]'],
});
const ruleOptions = { quotes: [2, 'double'], 'no-console': 2 };

expect(normalizeCLIOptions({ rule: 'quotes: [2, double]' })).toMatchObject({
rules: ['quotes: [2, double]'],
expect(normalizeCLIOptions({ rules: ruleOptions })).toMatchObject({
rules: ruleOptions,
});
});

Expand Down
6 changes: 2 additions & 4 deletions src/utils/normalizeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const BASE_CONFIG = {
default: false,
},
format: {
default: null
default: null,
},
global: {
name: 'globals',
Expand Down Expand Up @@ -60,10 +60,8 @@ const BASE_CONFIG = {
default: [],
transform: asArray,
},
rule: {
name: 'rules',
rules: {
default: null,
transform: asArray,
},
rulesdir: {
name: 'rulePaths',
Expand Down

0 comments on commit 3bd91fe

Please # to comment.