Skip to content

Commit 88e1c7b

Browse files
committed
Add eslint
1 parent 7233525 commit 88e1c7b

File tree

6 files changed

+63
-6
lines changed

6 files changed

+63
-6
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[*]
2+
indent_style = space
3+
indent_size = 2
4+
end_of_line = lf
5+
charset = utf-8
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true
8+
9+
# Indentation
10+
[src/**.{js,jsx,css,sass,scss}]
11+
indent_style = space
12+
indent_size = 2

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/*.md
2+
**/*.json
3+
**fixtures**

.eslintrc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"extends": "airbnb",
3+
"env": {
4+
"browser": true,
5+
"node": true,
6+
"jasmine": true,
7+
"jest": true
8+
},
9+
"parser": "babel-eslint",
10+
"rules": {
11+
"quotes": 0,
12+
"no-var": 0,
13+
"vars-on-top": 0,
14+
"func-names": 0,
15+
"eqeqeq": 0,
16+
"consistent-return": 0,
17+
"no-multi-spaces": 0,
18+
"key-spacing": 0,
19+
"new-cap": 0,
20+
"jsx-quotes": 0,
21+
"semi": 0,
22+
"comma-dangle": 0
23+
}
24+
}

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"scripts": {
77
"test": "jest",
88
"build": "webpack --config webpack.config.js",
9-
"prepublish": "npm run build"
9+
"prepublish": "npm run build",
10+
"lint": "eslint ./src"
1011
},
1112
"repository": {
1213
"type": "git",
@@ -34,12 +35,18 @@
3435
"devDependencies": {
3536
"babel-cli": "^6.6.5",
3637
"babel-core": "^6.7.4",
38+
"babel-eslint": "^6.0.4",
3739
"babel-jest": "^12.0.0",
3840
"babel-loader": "^6.2.4",
3941
"babel-preset-es2015": "^6.6.0",
4042
"babel-preset-react": "^6.5.0",
4143
"babel-preset-stage-0": "^6.5.0",
4244
"enzyme": "^2.2.0",
45+
"eslint": "^2.9.0",
46+
"eslint-config-airbnb": "^9.0.1",
47+
"eslint-plugin-import": "^1.7.0",
48+
"eslint-plugin-jsx-a11y": "^1.2.0",
49+
"eslint-plugin-react": "^5.0.1",
4350
"jest-cli": "^12.0.0",
4451
"react": "^15.0.0",
4552
"react-addons-test-utils": "^15.0.0",

src/__tests__/with-theme-test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { render } from 'enzyme'
66

77
describe('WithTheme()', () => {
88
const Header = ({ style }) => (<h1 style={style}>Header</h1>)
9+
Header.propTypes = { style: React.PropTypes.object }
10+
911
const themes = {
1012
default: {
1113
primaryColor: 'transparent',
@@ -25,7 +27,10 @@ describe('WithTheme()', () => {
2527
let lutalica
2628
let klexos
2729

28-
const Decorated = WithTheme(themes)(Header, (theme) => ({ style: { color: theme.primaryColor} }) )
30+
const Decorated = WithTheme(themes)(
31+
Header,
32+
(theme) => ({ style: { color: theme.primaryColor } })
33+
)
2934

3035
beforeEach(() => {
3136
lutalica = render(<Decorated theme={'lutalica'} />)
@@ -42,7 +47,10 @@ describe('WithTheme()', () => {
4247
let noTheme
4348
let wrongTheme
4449

45-
const Decorated = WithTheme(themes)(Header, (theme) => ({ style: { color: theme.primaryColor} }) )
50+
const Decorated = WithTheme(themes)(
51+
Header,
52+
(theme) => ({ style: { color: theme.primaryColor } })
53+
)
4654

4755
beforeEach(() => {
4856
noTheme = render(<Decorated />)

src/with-theme.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import React from 'react'
2-
import { mapProps, wrapDisplayName } from 'recompose'
1+
import { mapProps } from 'recompose'
32

43
const withTheme = (themes) => (BaseComponent, transform) =>
54
mapProps(
6-
(props) => Object.assign({}, props, transform(themes[props.theme] || themes['default']))
5+
(props) => Object.assign(
6+
{},
7+
props,
8+
transform(themes[props.theme] || themes.default)
9+
)
710
)(BaseComponent)
811

912
export default withTheme

0 commit comments

Comments
 (0)