Skip to content

Commit

Permalink
chore: format files with prettier (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Aug 27, 2021
1 parent 2428d38 commit 2a1bb87
Show file tree
Hide file tree
Showing 25 changed files with 159 additions and 87 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -24,6 +24,7 @@
"build": "babel src --out-dir dist",
"test": "ava",
"lint": "eslint ./src",
"format": "prettier --write \"./{src,test}/**/*.{js,css}\"",
"prepublishOnly": "yarn build && yarn test && yarn lint --quiet"
},
"husky": {
Expand Down
5 changes: 4 additions & 1 deletion src/lib/stylesheet.js
Expand Up @@ -3,7 +3,10 @@ Based on Glamor's sheet
https://github.com/threepointone/glamor/blob/667b480d31b3721a905021b26e1290ce92ca2879/src/sheet.js
*/

const isProd = typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'production'
const isProd =
typeof process !== 'undefined' &&
process.env &&
process.env.NODE_ENV === 'production'
const isString = o => Object.prototype.toString.call(o) === '[object String]'

export default class StyleSheet {
Expand Down
12 changes: 10 additions & 2 deletions test/fixtures/different-jsx-ids.js
Expand Up @@ -4,14 +4,22 @@ const otherColor = 'green'
const A = () => (
<div>
<p>test</p>
<style jsx>{`p { color: ${color} }`}</style>
<style jsx>{`
p {
color: ${color};
}
`}</style>
</div>
)

const B = () => (
<div>
<p>test</p>
<style jsx>{`p { color: ${otherColor} }`}</style>
<style jsx>{`
p {
color: ${otherColor};
}
`}</style>
</div>
)

Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/external-stylesheet-global.js
Expand Up @@ -2,7 +2,7 @@ import styles, { foo as styles3 } from './styles'

const styles2 = require('./styles2')

export default () =>
export default () => (
<div>
<p>test</p>
<div>woot</div>
Expand All @@ -17,3 +17,4 @@ export default () =>
{styles}
</style>
</div>
)
7 changes: 3 additions & 4 deletions test/fixtures/external-stylesheet-multi-line.js
@@ -1,9 +1,8 @@
import styles from './styles'

export default () =>
export default () => (
<div>
<p>test</p>
<style jsx>
{styles}
</style>
<style jsx>{styles}</style>
</div>
)
15 changes: 11 additions & 4 deletions test/fixtures/global.js
Expand Up @@ -2,11 +2,14 @@ const Test = () => (
<div>
<style jsx global>{`
body {
color: red
color: red;
}
:hover { color: red; display: flex;
animation: foo 1s ease-out }
:hover {
color: red;
display: flex;
animation: foo 1s ease-out;
}
div a {
display: none;
Expand All @@ -19,4 +22,8 @@ const Test = () => (
</div>
)

const Test2 = () => <style global jsx>{'p { color: red }'}</style>
const Test2 = () => (
<style global jsx>
{'p { color: red }'}
</style>
)
1 change: 0 additions & 1 deletion test/fixtures/ignore.js
Expand Up @@ -8,4 +8,3 @@ export default () => (
`}</style>
</div>
)

13 changes: 10 additions & 3 deletions test/fixtures/mixed-global-scoped.js
@@ -1,10 +1,17 @@
const Test = () => <style global jsx>{'p { color: red }'}</style>
const Test = () => (
<style global jsx>
{'p { color: red }'}
</style>
)

export default () => (
<div>
<p>test</p>
<style jsx global>{`body { background: red }`}</style>
<style jsx global>{`
body {
background: red;
}
`}</style>
<style jsx>{'p { color: red }'}</style>
</div>
)

6 changes: 4 additions & 2 deletions test/fixtures/multiple-jsx.js
Expand Up @@ -4,7 +4,9 @@ const attrs = {

const Test1 = () => (
<div>
<span {...attrs} data-test="test">test</span>
<span {...attrs} data-test="test">
test
</span>
<Component />
<style jsx>{`
span {
Expand All @@ -28,7 +30,7 @@ const Test3 = () => (
)

export default class {
render () {
render() {
return (
<div>
<p>test</p>
Expand Down
10 changes: 5 additions & 5 deletions test/fixtures/nested-style-tags.js
@@ -1,6 +1,6 @@
import styles from './styles'

export default () =>
export default () => (
<div>
<span>
test
Expand All @@ -18,8 +18,9 @@ export default () =>
}
`}</style>
</div>
)

export const Test = () =>
export const Test = () => (
<div>
<span>
test
Expand All @@ -46,7 +47,6 @@ export const Test = () =>
color: red;
}
`}</style>
<style jsx>
{styles}
</style>
<style jsx>{styles}</style>
</div>
)
2 changes: 1 addition & 1 deletion test/fixtures/non-styled-jsx-style.js
@@ -1,7 +1,7 @@
export default () => (
<div>
<p>woot</p>
<style dangerouslySetInnerHTML={{ __html: `body { margin: 0; }` }}></style>
<style dangerouslySetInnerHTML={{ __html: `body { margin: 0; }` }} />
<style jsx>{'p { color: red }'}</style>
</div>
)
10 changes: 8 additions & 2 deletions test/fixtures/not-styled-jsx-tagged-templates.js
Expand Up @@ -9,7 +9,11 @@ const bar = css`
`
export const uh = bar

export const foo = css`div { color: ${color}}`
export const foo = css`
div {
color: ${color};
}
`

export default css`
div {
Expand All @@ -25,6 +29,8 @@ const Title = styled.h1`
font-size: 50px;
`

const AnotherTitle = Title.extend`color: blue;`
const AnotherTitle = Title.extend`
color: blue;
`

export const Component = () => <AnotherTitle>My page</AnotherTitle>
15 changes: 12 additions & 3 deletions test/fixtures/styles-external-invalid.js
Expand Up @@ -2,11 +2,20 @@ import css from 'styled-jsx/css'

const color = 'red'

export const foo = css`div { color: ${color}}`
export const foo = css`
div {
color: ${color};
}
`

const props = { color: 'red ' }

export default css`
div { font-size: 3em; color: ${props.color} }
p { color: ${this.props.color};}
div {
font-size: 3em;
color: ${props.color};
}
p {
color: ${this.props.color};
}
`
14 changes: 11 additions & 3 deletions test/fixtures/styles-external-invalid2.js
Expand Up @@ -2,9 +2,17 @@ import css from 'styled-jsx/css'

const color = 'red'

export const foo = css`div { color: ${color}}`
export const foo = css`
div {
color: ${color};
}
`

export default css`
div { font-size: 3em }
p { color: ${props.color};}
div {
font-size: 3em;
}
p {
color: ${props.color};
}
`
6 changes: 5 additions & 1 deletion test/fixtures/styles.js
Expand Up @@ -22,7 +22,11 @@ const a = global`

export const uh = bar

export const foo = css`div { color: ${color}}`
export const foo = css`
div {
color: ${color};
}
`

css.resolve`
div {
Expand Down
4 changes: 3 additions & 1 deletion test/fixtures/styles2.js
@@ -1,5 +1,7 @@
import css from 'styled-jsx/css'

module.exports = css`
div { font-size: 3em }
div {
font-size: 3em;
}
`

0 comments on commit 2a1bb87

Please sign in to comment.