Skip to content

Commit 5742428

Browse files
committed
remove trailing commas for functions
They're not supported in ES5, which is tested against in the node versions included by the styled-components CI. Also disabled an eslint rule that was conflicting with what prettier was doing.
1 parent 4ed8b69 commit 5742428

26 files changed

+64
-65
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"rules": {
66
"semi": 0,
77
"quotes": 0,
8+
"comma-dangle": 0,
89
"curly": [2, "multi-line"],
910
"arrow-parens": 0,
1011
"class-methods-use-this": 0,

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"semi": false,
33
"singleQuote": true,
4-
"trailingComma": "all"
4+
"trailingComma": "es5"
55
}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ All notable changes to this project will be documented in this file. If a contri
1010

1111
- Add warning if you've accidently imported 'styled-components' on React Native instead of 'styled-components/native', thanks to [@tazsingh](https://github.com/tazsingh) (see [#1391](https://github.com/styled-components/styled-components/pull/1391))
1212

13+
- Remove trailing commas on function arguments (not compatible with ES5 JS engines)
14+
1315
## [v2.4.0] - 2017-12-22
1416

1517
- remove some extra information from the generated hash that can differ between build environments ([see #1381](https://github.com/styled-components/styled-components/pull/1381))

src/constructors/constructWithOptions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default (css: Function) => {
55
const constructWithOptions = (
66
componentConstructor: Function,
77
tag: Target,
8-
options: Object = {},
8+
options: Object = {}
99
) => {
1010
if (
1111
process.env.NODE_ENV !== 'production' &&

src/constructors/keyframes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const replaceWhitespace = (str: string): string => str.replace(/\s|\\n/g, '')
88
export default (
99
nameGenerator: NameGenerator,
1010
stringifyRules: Stringifier,
11-
css: Function,
11+
css: Function
1212
) => (
1313
strings: Array<string>,
1414
...interpolations: Array<Interpolation>
@@ -28,7 +28,7 @@ export default (
2828
true,
2929
generatedCSS,
3030
hash,
31-
name,
31+
name
3232
)
3333
return name
3434
}

src/hoc/withTheme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const wrapWithTheme = (Component: ReactClass<any>) => {
4646
) {
4747
// eslint-disable-next-line no-console
4848
console.warn(
49-
'[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps',
49+
'[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps'
5050
)
5151
} else if (styledContext === undefined && themeProp !== undefined) {
5252
this.setState({ theme: themeProp })

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ if (
3131
console.warn(
3232
"It looks like you've imported 'styled-components' on React Native.\n" +
3333
"Perhaps you're looking to import 'styled-components/native'?\n" +
34-
'Read more about this at https://www.styled-components.com/docs/basics#react-native',
34+
'Read more about this at https://www.styled-components.com/docs/basics#react-native'
3535
)
3636
}
3737

3838
/* Instantiate singletons */
3939
const ComponentStyle = _ComponentStyle(
4040
generateAlphabeticName,
4141
flatten,
42-
stringifyRules,
42+
stringifyRules
4343
)
4444
const constructWithOptions = _constructWithOptions(css)
4545
const StyledComponent = _StyledComponent(ComponentStyle, constructWithOptions)

src/models/BrowserStyleSheet.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class BrowserTag implements Tag {
6767

6868
if (process.env.NODE_ENV !== 'production' && !comp) {
6969
throw new Error(
70-
'Must add a new component before you can inject css into it',
70+
'Must add a new component before you can inject css into it'
7171
)
7272
}
7373
if (comp.textNode.data === '') {
@@ -79,7 +79,7 @@ class BrowserTag implements Tag {
7979
const existingNames = this.el.getAttribute(SC_ATTR)
8080
this.el.setAttribute(
8181
SC_ATTR,
82-
existingNames ? `${existingNames} ${name}` : name,
82+
existingNames ? `${existingNames} ${name}` : name
8383
)
8484
}
8585

@@ -145,11 +145,7 @@ export default {
145145
const el = nodes[i]
146146

147147
tags.push(
148-
new BrowserTag(
149-
el,
150-
el.getAttribute(LOCAL_ATTR) === 'true',
151-
el.innerHTML,
152-
),
148+
new BrowserTag(el, el.getAttribute(LOCAL_ATTR) === 'true', el.innerHTML)
153149
)
154150

155151
const attr = el.getAttribute(SC_ATTR)

src/models/ComponentStyle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const isHRMEnabled =
4444
export default (
4545
nameGenerator: NameGenerator,
4646
flatten: Flattener,
47-
stringifyRules: Stringifier,
47+
stringifyRules: Stringifier
4848
) => {
4949
class ComponentStyle {
5050
rules: RuleSet

src/models/InlineStyle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default (styleSheet: StyleSheet) => {
3939
) {
4040
/* eslint-disable no-console */
4141
console.warn(
42-
`Node of type ${node.type} not supported as an inline style`,
42+
`Node of type ${node.type} not supported as an inline style`
4343
)
4444
}
4545
})

0 commit comments

Comments
 (0)