Skip to content

Commit ae1be36

Browse files
author
Markus Günther
committed
TASK: Adjust code style to prettier
Adjusting the codestyle to standard prettier code, exerpt the tailing semicolon.
1 parent 3cb7576 commit ae1be36

File tree

4 files changed

+178
-136
lines changed

4 files changed

+178
-136
lines changed

src/components/themr.js

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ const DEFAULT_OPTIONS = {
2121
mapThemrProps: defaultMapThemrProps
2222
}
2323

24-
const THEMR_CONFIG = typeof Symbol !== 'undefined' ?
25-
Symbol('THEMR_CONFIG') :
26-
'__REACT_CSS_THEMR_CONFIG__'
24+
const THEMR_CONFIG =
25+
typeof Symbol !== 'undefined'
26+
? Symbol('THEMR_CONFIG')
27+
: '__REACT_CSS_THEMR_CONFIG__'
2728

2829
/**
2930
* Themr decorator
@@ -32,7 +33,7 @@ const THEMR_CONFIG = typeof Symbol !== 'undefined' ?
3233
* @param {{}} [options] - Themr options
3334
* @returns {function(ThemedComponent:Function):Function} - ThemedComponent
3435
*/
35-
export default (componentName, localTheme, options = {}) => (ThemedComponent) => {
36+
export default (componentName, localTheme, options = {}) => ThemedComponent => {
3637
const {
3738
composeTheme: optionComposeTheme,
3839
mapThemrProps: optionMapThemrProps
@@ -54,15 +55,21 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) =>
5455
* @property {{wrappedInstance: *}} refs
5556
*/
5657
class Themed extends Component {
57-
static displayName = `Themed${(ThemedComponent.displayName || ThemedComponent.name || "Component")}`;
58+
static displayName = `Themed${ThemedComponent.displayName ||
59+
ThemedComponent.name ||
60+
'Component'}`
5861

5962
static contextTypes = {
6063
themr: PropTypes.object
6164
}
6265

6366
static propTypes = {
6467
...ThemedComponent.propTypes,
65-
composeTheme: PropTypes.oneOf([ COMPOSE_DEEPLY, COMPOSE_SOFTLY, DONT_COMPOSE ]),
68+
composeTheme: PropTypes.oneOf([
69+
COMPOSE_DEEPLY,
70+
COMPOSE_SOFTLY,
71+
DONT_COMPOSE
72+
]),
6673
innerRef: PropTypes.func,
6774
theme: PropTypes.object,
6875
themeNamespace: PropTypes.string,
@@ -81,9 +88,10 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) =>
8188
}
8289

8390
getWrappedInstance() {
84-
invariant(true,
91+
invariant(
92+
true,
8593
'DEPRECATED: To access the wrapped instance, you have to pass ' +
86-
'{ innerRef: fn } and retrieve with a callback ref style.'
94+
'{ innerRef: fn } and retrieve with a callback ref style.'
8795
)
8896

8997
return this.refs.wrappedInstance
@@ -94,13 +102,21 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) =>
94102
if (!themeNamespace) return theme
95103

96104
if (themeNamespace && !theme) {
97-
throw new Error('Invalid themeNamespace use in friendsofreactjs/react-css-themr. ' +
98-
'themeNamespace prop should be used only with theme prop.')
105+
throw new Error(
106+
'Invalid themeNamespace use in friendsofreactjs/react-css-themr. ' +
107+
'themeNamespace prop should be used only with theme prop.'
108+
)
99109
}
100110

101111
return Object.keys(theme)
102112
.filter(key => key.startsWith(themeNamespace))
103-
.reduce((result, key) => ({ ...result, [removeNamespace(key, themeNamespace)]: theme[key] }), {})
113+
.reduce(
114+
(result, key) => ({
115+
...result,
116+
[removeNamespace(key, themeNamespace)]: theme[key]
117+
}),
118+
{}
119+
)
104120
}
105121

106122
getThemeNotComposed(props) {
@@ -118,14 +134,14 @@ export default (componentName, localTheme, options = {}) => (ThemedComponent) =>
118134
getTheme(props) {
119135
return props.composeTheme === COMPOSE_SOFTLY
120136
? {
121-
...this.getContextTheme(),
122-
...config.localTheme,
123-
...this.getNamespacedTheme(props)
124-
}
137+
...this.getContextTheme(),
138+
...config.localTheme,
139+
...this.getNamespacedTheme(props)
140+
}
125141
: themeable(
126-
themeable(this.getContextTheme(), config.localTheme),
127-
this.getNamespacedTheme(props)
128-
)
142+
themeable(this.getContextTheme(), config.localTheme),
143+
this.getNamespacedTheme(props)
144+
)
129145
}
130146

131147
calcTheme(props) {
@@ -208,7 +224,9 @@ function merge(original = {}, mixin = {}) {
208224

209225
default: {
210226
//can't merge an object with a non-object
211-
throw new Error(`You are merging object ${key} with a non-object ${originalValue}`)
227+
throw new Error(
228+
`You are merging object ${key} with a non-object ${originalValue}`
229+
)
212230
}
213231
}
214232
break
@@ -225,7 +243,9 @@ function merge(original = {}, mixin = {}) {
225243
switch (typeof originalValue) {
226244
case 'object': {
227245
//can't merge a non-object with an object
228-
throw new Error(`You are merging non-object ${mixinValue} with an object ${key}, (can occur when using empty or :global only base theme stylesheet)`)
246+
throw new Error(
247+
`You are merging non-object ${mixinValue} with an object ${key}, (can occur when using empty or :global only base theme stylesheet)`
248+
)
229249
}
230250

231251
case 'undefined': {
@@ -240,9 +260,12 @@ function merge(original = {}, mixin = {}) {
240260

241261
default: {
242262
//finally we can merge
243-
result[key] = originalValue.split(' ')
263+
result[key] = originalValue
264+
.split(' ')
244265
.concat(mixinValue.split(' '))
245-
.filter((item, pos, self) => self.indexOf(item) === pos && item !== '')
266+
.filter(
267+
(item, pos, self) => self.indexOf(item) === pos && item !== ''
268+
)
246269
.join(' ')
247270
break
248271
}
@@ -263,7 +286,9 @@ function merge(original = {}, mixin = {}) {
263286
* @returns {undefined}
264287
*/
265288
function validateComposeOption(composeTheme) {
266-
if ([ COMPOSE_DEEPLY, COMPOSE_SOFTLY, DONT_COMPOSE ].indexOf(composeTheme) === -1) {
289+
if (
290+
[COMPOSE_DEEPLY, COMPOSE_SOFTLY, DONT_COMPOSE].indexOf(composeTheme) === -1
291+
) {
267292
throw new Error(
268293
`Invalid composeTheme option for friendsofreactjs/react-css-themr. Valid composition options\
269294
are ${COMPOSE_DEEPLY}, ${COMPOSE_SOFTLY} and ${DONT_COMPOSE}. The given\
@@ -294,10 +319,10 @@ function removeNamespace(key, themeNamespace) {
294319
*/
295320
function defaultMapThemrProps(ownProps, theme) {
296321
const {
297-
composeTheme, //eslint-disable-line no-unused-vars
322+
composeTheme, //eslint-disable-line no-unused-vars
298323
innerRef,
299324
themeNamespace, //eslint-disable-line no-unused-vars
300-
mapThemrProps, //eslint-disable-line no-unused-vars
325+
mapThemrProps, //eslint-disable-line no-unused-vars
301326
...rest
302327
} = ownProps
303328

test/components/ThemeProvider.spec.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import PropTypes from 'prop-types'
44
import TestUtils from 'react-dom/test-utils'
55
import { ThemeProvider } from '../../src/index'
66

7-
8-
before(function () {
7+
before(function() {
98
/* eslint-disable no-console */
10-
console.error = function () {}
9+
console.error = function() {}
1110
})
1211

13-
after(function () {
12+
after(function() {
1413
delete console.error
1514
})
1615

@@ -33,23 +32,26 @@ describe('ThemeProvider', () => {
3332
ThemeProvider.propTypes = {}
3433

3534
try {
36-
expect(() => TestUtils.renderIntoDocument(
37-
<ThemeProvider theme={theme}>
38-
<div />
39-
</ThemeProvider>
40-
)).toNotThrow()
35+
expect(() =>
36+
TestUtils.renderIntoDocument(
37+
<ThemeProvider theme={theme}>
38+
<div />
39+
</ThemeProvider>
40+
)
41+
).toNotThrow()
4142

42-
expect(() => TestUtils.renderIntoDocument(
43-
<ThemeProvider theme={theme}>
44-
<div />
45-
<div />
46-
</ThemeProvider>
47-
)).toThrow(/expected to receive a single React element child/)
43+
expect(() =>
44+
TestUtils.renderIntoDocument(
45+
<ThemeProvider theme={theme}>
46+
<div />
47+
<div />
48+
</ThemeProvider>
49+
)
50+
).toThrow(/expected to receive a single React element child/)
4851

49-
expect(() => TestUtils.renderIntoDocument(
50-
<ThemeProvider theme={theme}>
51-
</ThemeProvider>
52-
)).toThrow(/expected to receive a single React element child/)
52+
expect(() =>
53+
TestUtils.renderIntoDocument(<ThemeProvider theme={theme} />)
54+
).toThrow(/expected to receive a single React element child/)
5355
} finally {
5456
ThemeProvider.propTypes = propTypes
5557
}

0 commit comments

Comments
 (0)