Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Commit e324d29

Browse files
committed
formatting src jsx
1 parent 60d4c32 commit e324d29

17 files changed

+86
-72
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"git.ignoreLimitWarning": true,
33
"eslint.enable": false,
44
"editor.defaultFormatter": "esbenp.prettier-vscode",
5-
"editor.formatOnSave": true
5+
"editor.formatOnSave": true,
6+
"editor.formatOnPaste": false
67
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"watch": "tsc -w",
1414
"pretest": "npm run lint && npm run transpile",
1515
"lint": "standard --verbose --fix *.js src cypress/integration",
16-
"semantic-release": "semantic-action pre && npm run transpile && npm publish && semantic-action post"
16+
"semantic-release": "semantic-action pre && npm run transpile && npm publish && semantic-action post",
17+
"format": "prettier --write 'src/*.jsx' 'integration/**/*.js(x)'"
1718
},
1819
"files": [
1920
"dist",

src/Button.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import React from 'react'
22
import './Button.css'
33

44
export class Button extends React.Component {
5-
handleClick () {
5+
handleClick() {
66
this.props.clickHandler(this.props.name)
77
}
88

9-
render () {
9+
render() {
1010
const className = [
1111
'component-button',
1212
this.props.orange ? 'orange' : '',
13-
this.props.wide ? 'wide' : ''
13+
this.props.wide ? 'wide' : '',
1414
]
1515

1616
return (
@@ -20,4 +20,3 @@ export class Button extends React.Component {
2020
)
2121
}
2222
}
23-

src/CssInJsComponent.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// https://emotion.sh/docs/introduction
22
/** @jsx jsx */
3-
import { css, jsx } from "@emotion/core";
3+
import { css, jsx } from '@emotion/core'
44

55
// several Emotion examples
66

77
export const Emotion = () => {
88
return (
99
<div
1010
css={{
11-
color: "hotpink"
11+
color: 'hotpink',
1212
}}
1313
>
1414
Emotion 😈
1515
</div>
16-
);
17-
};
16+
)
17+
}
1818

1919
export const Emotion2 = () => {
2020
return (

src/counter-with-hooks.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import React from "react";
1+
import React from 'react'
22

33
export default function CounterWithHooks({ initialCount = 0 }) {
4-
const [count, setCount] = React.useState(initialCount);
4+
const [count, setCount] = React.useState(initialCount)
55

66
const handleCountIncrement = React.useCallback(() => {
7-
setCount(count + 1);
8-
}, [count]);
7+
setCount(count + 1)
8+
}, [count])
99

1010
return (
1111
<>
1212
<div className="counter">{count}</div>
13-
<button id="increment" onClick={handleCountIncrement}>+</button>
13+
<button id="increment" onClick={handleCountIncrement}>
14+
+
15+
</button>
1416
</>
15-
);
17+
)
1618
}
17-

src/counter.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import React from "react";
1+
import React from 'react'
22

33
export class Counter extends React.Component {
44
constructor(props) {
5-
super(props);
5+
super(props)
66
this.state = {
7-
count: 0
8-
};
7+
count: 0,
8+
}
99
}
1010

1111
click = () => {
1212
this.setState({
13-
count: this.state.count + 1
14-
});
15-
};
13+
count: this.state.count + 1,
14+
})
15+
}
1616

1717
render() {
18-
return <p onClick={this.click}>count: {this.state.count}</p>;
18+
return <p onClick={this.click}>count: {this.state.count}</p>
1919
}
2020
}

src/counter2-with-hooks.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// example from https://reactjs.org/docs/hooks-overview.html
2-
import React, { useState, useEffect } from 'react';
2+
import React, { useState, useEffect } from 'react'
33

44
export default function Counter2WithHooks() {
5-
const [count, setCount] = useState(0);
5+
const [count, setCount] = useState(0)
66

77
useEffect(() => {
8-
document.title = `You clicked ${count} times`;
9-
});
8+
document.title = `You clicked ${count} times`
9+
})
1010

1111
return (
1212
<div>
@@ -15,5 +15,5 @@ export default function Counter2WithHooks() {
1515
Click me
1616
</button>
1717
</div>
18-
);
18+
)
1919
}

src/error-boundary.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React from 'react'
22

33
export class ErrorBoundary extends React.Component {
4-
constructor (props) {
4+
constructor(props) {
55
super(props)
66
this.state = { error: null, info: '' }
77
}
88

9-
static getDerivedStateFromError (error) {
9+
static getDerivedStateFromError(error) {
1010
console.error(error)
1111
return { error }
1212
}
@@ -15,12 +15,12 @@ export class ErrorBoundary extends React.Component {
1515
// Catch errors in any components below and re-render with error message
1616
this.setState({
1717
error: error,
18-
info: errorInfo
18+
info: errorInfo,
1919
})
2020
// You can also log error messages to an error reporting service here
2121
}
2222

23-
render () {
23+
render() {
2424
const { name } = this.props
2525
const { error } = this.state
2626
if (error) {

src/forward-ref.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import React from 'react';
1+
import React from 'react'
22

3-
const Button = React.forwardRef(({ children, ...rest }, ref) => <button {...rest} ref={ref}>{children}</button>);
3+
const Button = React.forwardRef(({ children, ...rest }, ref) => (
4+
<button {...rest} ref={ref}>
5+
{children}
6+
</button>
7+
))
48

5-
export default Button;
9+
export default Button

src/hello-world.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22

33
export class HelloWorld extends React.Component {
4-
render () {
4+
render() {
55
return <p>Hello World!</p>
66
}
77
}

0 commit comments

Comments
 (0)