Skip to content

Commit 146510c

Browse files
committed
fix eslint issues, remove moot code
- fix es-lint issues - remove deprecated unused code, add test for `nameToPath` utility function
1 parent 92553fa commit 146510c

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

src/utils/utils.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
1-
import isNumber from 'lodash/isNumber';
2-
import isObject from 'lodash/isObject';
31
import isArray from 'lodash/isArray';
42
import isPlainObject from 'lodash/isPlainObject';
53

6-
export function fullPath(path) {
7-
return path.map((part, i) => isNumber(part) ? `[${part}]` : (i > 0 ? '.' : '') + part).join('');
8-
}
9-
10-
export function pathToName(path) {
11-
return path.replace(/\[(\d+)\]/g, (_match, i) => `.${i}`);
12-
}
13-
144
export function nameToPath(name) {
155
return name.replace(/\.(\d+)(\.)?/g, (_match, i, dot) => `[${i}]` + (dot ? '.' : ''));
166
}

test/components/Form.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ describe('<Form />', function() {
520520
it('returns whole attrs object when name is not passed', function() {
521521
expect(this.test.wrapper.instance().get()).toMatch({ foo: 'bar' });
522522
});
523-
})
523+
});
524524
});
525525

526526
describe('$render', function() {

test/utils/utils.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { fullPath, fullName } from '../../src/utils';
1+
import { nameToPath } from '../../src/utils';
22
import expect from 'expect';
33

4-
describe('fullPath', function() {
5-
it('generates a lodash path based on passed array', function() {
6-
expect(fullPath(['foo', 1, 'bar', 'baz'])).toEqual('foo[1].bar.baz');
4+
describe('nameToPath', function() {
5+
it('generates a lodash path based on passed name', function() {
6+
expect(nameToPath('foo.1.bar.baz')).toEqual('foo[1].bar.baz');
77
});
88
});

0 commit comments

Comments
 (0)