Skip to content

Commit cea1384

Browse files
✨ introduce possibility to specify camelCase as string
1 parent f379830 commit cea1384

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/options_resolvers/camelCase.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import { isBoolean } from '../utils';
77
* @returns {boolean}
88
*/
99
export default function camelCase(value/* , currentConfig */) {
10-
if (!isBoolean(value)) {
11-
throw new Error(`Configuration 'camelCase' is not a boolean`);
10+
if (!isBoolean(value) && ['dashes', 'dashesOnly', 'only'].indexOf(value) < 0) {
11+
throw new Error(
12+
`Configuration 'camelCase' is not a boolean or one of 'dashes'|'dashesOnly'|'only'`
13+
);
1214
}
1315

1416
return value;

test/options_resolvers/camelCase.spec.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@ import { expect } from 'chai';
33
import camelCase from '../../src/options_resolvers/camelCase';
44

55
describe('options_resolvers/camelCase', () => {
6-
it('should throw if camelCase value is not a boolean', () => {
6+
it('should throw if camelCase value is not a boolean or is not in enum', () => {
77
expect(
88
() => camelCase(null)
99
).to.throw();
1010

11+
expect(
12+
() => camelCase('unknown')
13+
).to.throw();
14+
1115
expect(camelCase(true)).to.be.equal(true);
16+
expect(camelCase('dashes')).to.be.equal('dashes');
17+
expect(camelCase('dashesOnly')).to.be.equal('dashesOnly');
18+
expect(camelCase('only')).to.be.equal('only');
1219
});
1320
});

0 commit comments

Comments
 (0)