Skip to content

Commit 015c860

Browse files
committed
Use eslint in the build process.
1 parent d45feb6 commit 015c860

File tree

10 files changed

+35
-24
lines changed

10 files changed

+35
-24
lines changed

.eslintrc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@
254254
"no-array-constructor": 2,
255255
"no-continue": 2,
256256
"no-inline-comments": 2,
257-
"no-lonely-if": 2,
257+
"no-lonely-if": 0,
258258
"no-mixed-spaces-and-tabs": 2,
259259
"no-multiple-empty-lines": [
260260
2,
@@ -382,9 +382,12 @@
382382
"react"
383383
],
384384
"parser": "babel-eslint",
385+
"globals": {
386+
"global": true
387+
},
385388
"env": {
386-
"browser": true
387-
// "mocha": true,
389+
"browser": true,
390+
"mocha": true
388391
// "node": true
389392
}
390393
}

dist/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ var _makeConfig = require('./makeConfig');
2222

2323
var _makeConfig2 = _interopRequireDefault(_makeConfig);
2424

25-
var functionConstructor = undefined,
26-
decoratorConstructor = undefined;
25+
var decoratorConstructor = undefined,
26+
functionConstructor = undefined;
2727

2828
/**
2929
* When used as a function.

dist/linkClass.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ linkClass = function (element) {
2222
var styles = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
2323
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
2424

25-
var newProps = undefined,
26-
newClassName = undefined,
25+
var childrenCount = undefined,
26+
clonedElement = undefined,
27+
moduleName = undefined,
2728
newChildren = undefined,
28-
childrenCount = undefined,
29-
moduleName = undefined;
29+
newClassName = undefined,
30+
newProps = undefined;
3031

3132
if (options.useModuleName) {
3233
moduleName = element.props.moduleName;
@@ -95,12 +96,12 @@ linkClass = function (element) {
9596
}
9697

9798
if (newChildren) {
98-
element = _react2['default'].cloneElement(element, newProps, newChildren);
99+
clonedElement = _react2['default'].cloneElement(element, newProps, newChildren);
99100
} else {
100-
element = _react2['default'].cloneElement(element, newProps);
101+
clonedElement = _react2['default'].cloneElement(element, newProps);
101102
}
102103

103-
return element;
104+
return clonedElement;
104105
};
105106

106107
exports['default'] = linkClass;

dist/makeConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var _utils2 = _interopRequireDefault(_utils);
1616
* @property {Boolean} keepOriginal
1717
* @property {Boolean} errorNotFound
1818
* @property {Boolean} useModuleNam
19+
* @return {Object}
1920
*/
2021

2122
exports['default'] = function () {

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@
2727
},
2828
"devDependencies": {
2929
"babel": "^5.8.21",
30+
"babel-eslint": "^4.1.0",
3031
"chai": "^3.2.0",
32+
"eslint": "^1.2.1",
33+
"eslint-plugin-react": "^3.3.0",
3134
"jsdom": "^6.2.0",
3235
"mocha": "^2.2.5",
3336
"react": "^0.14.0-beta3",
3437
"react-addons-test-utils": "^0.14.0-beta3"
3538
},
3639
"scripts": {
37-
"test": "mocha",
40+
"test": "./node_modules/.bin/eslint ./src/ ./test/ && mocha",
3841
"build": "babel ./src/ --out-dir ./dist/",
3942
"watch": "babel --watch ./src/ --out-dir ./dist/"
4043
}

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import linkClass from './linkClass';
22
import makeConfig from './makeConfig';
33

4-
let functionConstructor,
5-
decoratorConstructor;
4+
let decoratorConstructor,
5+
functionConstructor;
66

77
/**
88
* When used as a function.

src/linkClass.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ let linkClass;
99
* @return {ReactElement}
1010
*/
1111
linkClass = (element, styles = {}, options = {}) => {
12-
let newProps,
13-
newClassName,
12+
let childrenCount,
13+
clonedElement,
14+
moduleName,
1415
newChildren,
15-
childrenCount,
16-
moduleName;
16+
newClassName,
17+
newProps;
1718

1819
if (options.useModuleName) {
1920
moduleName = element.props.moduleName;
@@ -50,7 +51,7 @@ linkClass = (element, styles = {}, options = {}) => {
5051
}
5152
});
5253

53-
newClassName = newClassName.filter(function (className) {
54+
newClassName = newClassName.filter((className) => {
5455
return className.length;
5556
});
5657

@@ -83,12 +84,12 @@ linkClass = (element, styles = {}, options = {}) => {
8384
}
8485

8586
if (newChildren) {
86-
element = React.cloneElement(element, newProps, newChildren);
87+
clonedElement = React.cloneElement(element, newProps, newChildren);
8788
} else {
88-
element = React.cloneElement(element, newProps);
89+
clonedElement = React.cloneElement(element, newProps);
8990
}
9091

91-
return element;
92+
return clonedElement;
9293
};
9394

9495
export default linkClass;

src/makeConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import _ from './utils';
66
* @property {Boolean} keepOriginal
77
* @property {Boolean} errorNotFound
88
* @property {Boolean} useModuleNam
9+
* @return {Object}
910
*/
1011
export default (userConfig = {}) => {
1112
let knownProperties,

test/linkClass.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ describe('linkClass', () => {
169169
describe('when options.errorNotFound is true', () => {
170170
it('throws an error when className defines a CSS class that does not exist in CSS modules styles', () => {
171171
expect(() => {
172-
linkClass(<div className='foo'></div>, {}, {errorNotFound: true})
172+
linkClass(<div className='foo'></div>, {}, {errorNotFound: true});
173173
}).to.throw(Error, '"foo" CSS class name is not found in CSS modules styles.');
174174
});
175175
});

test/makeConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import makeConfig from './../dist/makeConfig';
77
describe('makeConfig', () => {
88
describe('when using default config', () => {
99
let options;
10+
1011
beforeEach(() => {
1112
options = makeConfig();
1213
});

0 commit comments

Comments
 (0)