Skip to content
This repository was archived by the owner on Jul 9, 2021. It is now read-only.

Commit f29f23d

Browse files
committed
[fixed] favor lodash over native methods
1 parent 41c8c95 commit f29f23d

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/SASSLint.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import type {LintCallback} from './typedef';
44
import {join} from 'path';
55
import forEach from 'lodash/forEach';
6+
import replace from 'lodash/replace';
67
import {lint} from 'stylelint';
78
import {logError} from './logger';
89

@@ -69,7 +70,7 @@ export class SASSLint {
6970

7071
forEach(results, ({source: file, warnings}) => {
7172
forEach(warnings, ({line, column, text, rule}) => {
72-
errors.push({file, line, column, message: text.replace(new RegExp(`\\s*\\(${rule}\\)$`), ''), rule});
73+
errors.push({file, line, column, message: replace(text, new RegExp(`\\s*\\(${rule}\\)$`), ''), rule});
7374
});
7475
});
7576
callback(errors.length ? errors : null);

src/jsx.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import has from 'lodash/has';
99
import flattenDeep from 'lodash/flattenDeep';
1010
import isString from 'lodash/isString';
1111
import trim from 'lodash/trim';
12+
import replace from 'lodash/replace';
13+
import toUpper from 'lodash/toUpper';
14+
import toLower from 'lodash/toLower';
15+
import split from 'lodash/split';
1216

1317
/**
1418
* Useful utilities for working with JSX.
@@ -43,7 +47,7 @@ export function parseHTML(html: string): Object {
4347
* @return {string} JSX style key
4448
*/
4549
export function toJSXKey(key: string): string {
46-
return (/^-ms-/.test(key) ? key.substr(1) : key).replace(/-(.)/g, (match, chr) => chr.toUpperCase());
50+
return replace(/^-ms-/.test(key) ? key.substr(1) : key, /-(.)/g, (match, chr) => toUpper(chr));
4751
}
4852

4953
/**
@@ -56,12 +60,12 @@ export function toJSXKey(key: string): string {
5660
*/
5761
export function transformStyle(object: Object) {
5862
if (has(object, 'style')) {
59-
object.style = transform(object.style.split(';'), (result, style) => {
63+
object.style = transform(split(object.style, ';'), (result, style) => {
6064
const firstColon = style.indexOf(':'),
61-
key = style.substr(0, firstColon).trim();
65+
key = trim(style.substr(0, firstColon));
6266

6367
if (key) {
64-
result[toJSXKey(key.toLowerCase())] = style.substr(firstColon + 1).trim();
68+
result[toJSXKey(toLower(key))] = trim(style.substr(firstColon + 1));
6569
}
6670
}, {});
6771
}

0 commit comments

Comments
 (0)