Skip to content

Commit 2c24b61

Browse files
committed
Meeting the updated linting requirements.
1 parent 21fe573 commit 2c24b61

14 files changed

+79
-67
lines changed

.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
[![Travis build status](http://img.shields.io/travis/gajus/react-css-modules/master.svg?style=flat)](https://travis-ci.org/gajus/react-css-modules)
44
[![NPM version](http://img.shields.io/npm/v/react-css-modules.svg?style=flat)](https://www.npmjs.org/package/react-css-modules)
5-
[![Coverage Status](https://coveralls.io/repos/gajus/react-css-modules/badge.svg?branch=master&service=github)](https://coveralls.io/github/gajus/react-css-modules?branch=master)
65

76
<img src='./README/react-css-modules.png' height='150' />
87

package.json

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-css-modules",
33
"description": "Seamless mapping of class names to CSS modules inside of React components.",
4-
"main": "./dist/index.js",
4+
"main": "./dist/",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/gajus/react-css-modules"
@@ -15,25 +15,28 @@
1515
"version": "3.6.1",
1616
"author": {
1717
"name": "Gajus Kuizinas",
18-
"email": "gk@anuary.com",
18+
"email": "gajus@gajus.com",
1919
"url": "http://gajus.com"
2020
},
2121
"license": "BSD-3-Clause",
2222
"dependencies": {
2323
"lodash": "^3.10.1"
2424
},
2525
"devDependencies": {
26-
"chai": "^3.4.0",
27-
"coveralls": "^2.11.4",
28-
"jsdom": "^7.0.2",
29-
"pragmatist": "^1.1.5",
30-
"react": "^0.14.0",
31-
"react-addons-test-utils": "^0.14.0"
26+
"chai": "^3.4.1",
27+
"jsdom": "^7.1.1",
28+
"pragmatist": "^1.9.4",
29+
"react": "^0.14.3",
30+
"react-addons-test-utils": "^0.14.3"
3231
},
3332
"scripts": {
3433
"pragmatist": "node ./node_modules/.bin/pragmatist",
3534
"lint": "npm run pragmatist lint",
35+
"test": "npm run pragmatist test",
3636
"build": "npm run pragmatist build",
37-
"test": "npm run pragmatist test && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls"
37+
"watch": "npm run pragmatist watch",
38+
"watch-lint": "npm run pragmatist watch-lint",
39+
"watch-test": "npm run pragmatist watch-test",
40+
"watch-build": "npm run pragmatist watch-build"
3841
}
3942
}

src/extendReactClass.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable react/prop-types */
2+
13
import linkClass from './linkClass';
24
import React from 'react';
35
import _ from 'lodash';

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import _ from 'lodash';
12
import extendReactClass from './extendReactClass';
23
import wrapStatelessFunction from './wrapStatelessFunction';
34

@@ -12,7 +13,7 @@ let decoratorConstructor,
1213
* @return {boolean}
1314
*/
1415
isReactComponent = (Component) => {
15-
return 'prototype' in Component && typeof Component.prototype.render === 'function';
16+
return 'prototype' in Component && _.isFunction(Component.prototype.render);
1617
};
1718

1819
/**
@@ -55,7 +56,7 @@ decoratorConstructor = (defaultStyles, options) => {
5556
};
5657

5758
export default (...args) => {
58-
if (typeof args[0] === 'function') {
59+
if (_.isFunction(args[0])) {
5960
return functionConstructor(args[0], args[1], args[2]);
6061
} else {
6162
return decoratorConstructor(args[0], args[1]);

src/isIterable.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
1-
import { isObject } from 'lodash';
1+
import _ from 'lodash';
22

3-
const ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
4-
const OLD_ITERATOR_SYMBOL = '@@iterator';
3+
let ITERATOR_SYMBOL,
4+
OLD_ITERATOR_SYMBOL;
55

6-
export default function isIterable(obj) {
7-
return isObject(obj) &&
8-
typeof ((ITERATOR_SYMBOL && obj[ITERATOR_SYMBOL])
9-
|| obj[OLD_ITERATOR_SYMBOL]) === 'function';
10-
}
6+
ITERATOR_SYMBOL = _.isFunction(Symbol) && Symbol.iterator;
7+
OLD_ITERATOR_SYMBOL = '@@iterator';
8+
9+
/**
10+
* @see https://github.com/lodash/lodash/issues/1668
11+
* @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Iteration_protocols
12+
* @param {Object} target
13+
* @returns {boolean}
14+
*/
15+
export default (target) => {
16+
let iterator;
17+
18+
if (!_.isObject(target)) {
19+
return false;
20+
}
21+
22+
if (ITERATOR_SYMBOL) {
23+
iterator = target[ITERATOR_SYMBOL];
24+
} else {
25+
iterator = target[OLD_ITERATOR_SYMBOL];
26+
}
27+
28+
return _.isFunction(iterator);
29+
};

src/linkClass.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,22 @@ linkClass = (element, styles = {}, userConfiguration) => {
3434
styleNames = _.filter(styleNames);
3535

3636
if (configuration.allowMultiple === false && styleNames.length > 1) {
37-
throw new Error(`ReactElement styleName property defines multiple module names ("${element.props.styleName}").`);
37+
throw new Error('ReactElement styleName property defines multiple module names ("' + element.props.styleName + '").');
3838
}
3939

40-
appendClassName = styleNames.map((styleName) => {
40+
appendClassName = _.map(styleNames, (styleName) => {
4141
if (styles[styleName]) {
4242
return styles[styleName];
4343
} else {
4444
if (configuration.errorWhenNotFound === true) {
45-
throw new Error(`"${styleName}" CSS module is undefined.`);
45+
throw new Error('"' + styleName + '" CSS module is undefined.');
4646
}
4747

4848
return '';
4949
}
5050
});
5151

52-
appendClassName = appendClassName.filter((className) => {
53-
return className.length;
54-
});
52+
appendClassName = _.filter(appendClassName, 'length');
5553

5654
appendClassName = appendClassName.join(' ');
5755
}
@@ -62,14 +60,14 @@ linkClass = (element, styles = {}, userConfiguration) => {
6260
// [ReactElement, 'text']
6361
// ReactElement
6462

65-
// console.log(`element.props.children`, element.props.children, `React.Children.count(element.props.children)`, React.Children.count(element.props.children));
66-
6763
children = element.props.children;
6864

6965
if (React.isValidElement(children)) {
7066
newChildren = linkClass(React.Children.only(children), styles, configuration);
7167
} else if (_.isArray(children) || isIterable(children)) {
68+
/* eslint-disable lodash3/prefer-lodash-method */
7269
newChildren = React.Children.map(children, (node) => {
70+
/* eslint-enable lodash3/prefer-lodash-method */
7371
if (React.isValidElement(node)) {
7472
return linkClass(node, styles, configuration);
7573
} else {
@@ -85,7 +83,7 @@ linkClass = (element, styles = {}, userConfiguration) => {
8583

8684
if (appendClassName) {
8785
if (element.props.className) {
88-
appendClassName = `${element.props.className} ${appendClassName}`;
86+
appendClassName = element.props.className + ' ' + appendClassName;
8987
}
9088

9189
newProps = {

src/makeConfiguration.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ export default (userConfiguration = {}) => {
2020
};
2121

2222
_.forEach(userConfiguration, (value, name) => {
23-
if (typeof configuration[name] === 'undefined') {
24-
throw new Error(`Unknown configuration property "${name}".`);
23+
if (_.isUndefined(configuration[name])) {
24+
throw new Error('Unknown configuration property "' + name + '".');
2525
}
2626

27-
if (typeof value !== 'boolean') {
28-
throw new Error(`"${name}" property value must be a boolean.`);
27+
if (!_.isBoolean(value)) {
28+
throw new Error('"' + name + '" property value must be a boolean.');
2929
}
3030

3131
configuration[name] = value;

src/wrapStatelessFunction.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable react/prop-types */
2+
13
import linkClass from './linkClass';
24
import React from 'react';
35
import _ from 'lodash';

tests/extendReactClass.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@ import extendReactClass from './../src/extendReactClass';
1111

1212
describe('extendReactClass', () => {
1313
beforeEach(() => {
14-
global.document = jsdom.jsdom(`
15-
<!DOCTYPE html>
16-
<html>
17-
<head>
18-
</head>
19-
<body>
20-
</body>
21-
</html>
22-
`);
14+
global.document = jsdom.jsdom('<!DOCTYPE html><html><head></head><body></body></html>');
2315

2416
global.window = document.defaultView;
2517
});

0 commit comments

Comments
 (0)