Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(cli-options): rules should be passed as an object instead of array of strings #39

Merged
merged 1 commit into from
May 27, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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