Skip to content

Commit 3250318

Browse files
author
Edvinas Jurele
committed
Add prettier config and ignore files, lint all js files
1 parent ce9fe3f commit 3250318

File tree

11 files changed

+113
-83
lines changed

11 files changed

+113
-83
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
# Unix-style newlines with a newline ending every file
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
indent_size = 2
9+
indent_style = space
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
# do not remove trailing whitespace in mardown (2 spaces equal <br> in markdown)
14+
[*.md]
15+
trim_trailing_whitespace = false

.prettierignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.*
2+
!*.js
3+
!*.css
4+
!*.scss
5+
!*.json
6+
!*.md
7+
8+
# npm files
9+
node_modules
10+
package.json

.prettierrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "es5"
5+
}

src/App.js

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React, { Component } from "react";
1+
import React, { Component } from 'react';
22

3-
import { Ticket, Sphere, Input, Status } from "./components";
3+
import { Ticket, Sphere, Input, Status } from './components';
44

5-
const STORAGE_KEY = "appState";
5+
const STORAGE_KEY = 'appState';
66

77
const tickets = [
88
{
@@ -11,20 +11,20 @@ const tickets = [
1111
[7, 23, 44, 46, 72],
1212
[11, 26, 43, 50, 64],
1313
[14, 29, 35, 48, 66],
14-
[6, 24, 41, 60, 69]
14+
[6, 24, 41, 60, 69],
1515
],
16-
number: "0642953"
16+
number: '0642953',
1717
},
1818
{
1919
values: [
2020
[7, 27, 39, 51, 66],
2121
[11, 20, 33, 49, 68],
2222
[8, 18, 45, 57, 75],
2323
[13, 21, 36, 53, 65],
24-
[10, 30, 37, 52, 72]
24+
[10, 30, 37, 52, 72],
2525
],
26-
number: "0657387"
27-
}
26+
number: '0657387',
27+
},
2828
];
2929

3030
class App extends Component {
@@ -36,15 +36,15 @@ class App extends Component {
3636
getInitialState = () => {
3737
const initialState = {
3838
rolledValues: [],
39-
value: "",
40-
removeValue: "",
39+
value: '',
40+
removeValue: '',
4141
status: {
42-
color: "default",
43-
message: ""
42+
color: 'default',
43+
message: '',
4444
},
4545
options: {
46-
isTicketsClickable: false
47-
}
46+
isTicketsClickable: false,
47+
},
4848
};
4949

5050
return initialState;
@@ -69,7 +69,7 @@ class App extends Component {
6969
countOccurencies = number => {
7070
let occurenciesCount = 0;
7171
tickets.map(ticket => {
72-
const arr = ticket.values.toString().split(",");
72+
const arr = ticket.values.toString().split(',');
7373
occurenciesCount += arr.reduce((a, v) => (v === number ? ++a : a), 0);
7474
});
7575
return occurenciesCount;
@@ -80,10 +80,10 @@ class App extends Component {
8080
const count = this.countOccurencies(number);
8181
if (count > 0) {
8282
count === 1
83-
? this.setStatusMessage("green", `Išbrauktas ${count} langelis`)
84-
: this.setStatusMessage("green", `Išbraukti ${count} langeliai`);
83+
? this.setStatusMessage('green', `Išbrauktas ${count} langelis`)
84+
: this.setStatusMessage('green', `Išbraukti ${count} langeliai`);
8585
} else {
86-
this.setStatusMessage("default", "Nerasta");
86+
this.setStatusMessage('default', 'Nerasta');
8787
}
8888

8989
this.pushStateToStorage();
@@ -93,8 +93,8 @@ class App extends Component {
9393
const regexDigits = /\D/;
9494
const regexTwoDigits = /(^[\d]{2})[\d]/;
9595
const value = inputValue
96-
.replace(regexDigits, "")
97-
.replace(regexTwoDigits, "$1");
96+
.replace(regexDigits, '')
97+
.replace(regexTwoDigits, '$1');
9898
return value;
9999
};
100100

@@ -113,12 +113,12 @@ class App extends Component {
113113
) {
114114
this.crossOutNumber(value);
115115
}
116-
this.setState({ value: "" });
116+
this.setState({ value: '' });
117117
};
118118

119119
invalidateCache = () => {
120120
if (
121-
window.confirm("Ar tikrai? Bus ištrinti bilietai ir kamuoliukų istorija.")
121+
window.confirm('Ar tikrai? Bus ištrinti bilietai ir kamuoliukų istorija.')
122122
) {
123123
localStorage.removeItem(STORAGE_KEY);
124124
this.resetState();
@@ -127,7 +127,7 @@ class App extends Component {
127127

128128
removeLastRolledValue = () => {
129129
if (
130-
window.confirm("Ar tikrai norite pašalinti paskutinį ridentą kamuoliuką?")
130+
window.confirm('Ar tikrai norite pašalinti paskutinį ridentą kamuoliuką?')
131131
) {
132132
this.setState({ rolledValues: this.state.rolledValues.slice(0, -1) });
133133
this.resetStatusMessage();
@@ -138,24 +138,24 @@ class App extends Component {
138138
componentWillMount() {
139139
var cache = JSON.parse(localStorage.getItem(STORAGE_KEY));
140140
if (cache != null) {
141-
this.setState({ ...cache, value: "" });
141+
this.setState({ ...cache, value: '' });
142142
}
143143
}
144144

145145
handleIsClickableChange = () =>
146146
this.setState({
147147
options: {
148148
...this.state.options,
149-
isTicketsClickable: !this.state.options.isTicketsClickable
150-
}
149+
isTicketsClickable: !this.state.options.isTicketsClickable,
150+
},
151151
});
152152

153153
render() {
154154
const {
155155
rolledValues,
156156
value,
157157
status,
158-
options: { isTicketsClickable }
158+
options: { isTicketsClickable },
159159
} = this.state;
160160
return (
161161
<div className="App">

src/components/Input/index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
import React from "react";
2-
import PropTypes from "prop-types";
3-
import cx from "classnames";
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import cx from 'classnames';
44

5-
import "./index.css";
5+
import './index.css';
66

77
const Input = ({ className, size, ...props }) => {
88
const inputSize = {
9-
lg: "form-control-lg",
10-
sm: "form-control-sm"
9+
lg: 'form-control-lg',
10+
sm: 'form-control-sm',
1111
}[size];
1212

1313
return (
1414
<input
1515
type="text"
1616
{...props}
17-
className={cx("Input form-control", inputSize, className)}
17+
className={cx('Input form-control', inputSize, className)}
1818
/>
1919
);
2020
};
2121

2222
Input.propTypes = {
2323
className: PropTypes.string,
24-
size: PropTypes.oneOf(["lg", "sm", undefined])
24+
size: PropTypes.oneOf(['lg', 'sm', undefined]),
2525
};
2626

2727
Input.defaultProps = {
2828
className: undefined,
29-
size: undefined
29+
size: undefined,
3030
};
3131

3232
export default Input;

src/components/Sphere/index.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
import React from "react";
2-
import PropTypes from "prop-types";
3-
import cx from "classnames";
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import cx from 'classnames';
44

5-
import "./index.css";
5+
import './index.css';
66

77
const Sphere = ({ value, className }) => {
88
const getSphereColor = color => {
9-
if (value > 0 && value < 16) return "Sphere--blue";
10-
if (value >= 16 && value < 31) return "Sphere--black";
11-
if (value >= 31 && value < 46) return "Sphere--red";
12-
if (value >= 46 && value < 61) return "Sphere--yellow";
13-
if (value >= 61 && value < 76) return "Sphere--green";
9+
if (value > 0 && value < 16) return 'Sphere--blue';
10+
if (value >= 16 && value < 31) return 'Sphere--black';
11+
if (value >= 31 && value < 46) return 'Sphere--red';
12+
if (value >= 46 && value < 61) return 'Sphere--yellow';
13+
if (value >= 61 && value < 76) return 'Sphere--green';
1414
};
1515

1616
return (
17-
<div className={cx("Sphere", className, getSphereColor())}>
17+
<div className={cx('Sphere', className, getSphereColor())}>
1818
{value.toString().length === 1 ? `0${value}` : value}
1919
</div>
2020
);
2121
};
2222

2323
Sphere.propTypes = {
2424
value: PropTypes.string.isRequired,
25-
className: PropTypes.string
25+
className: PropTypes.string,
2626
};
2727

2828
Sphere.defaultProps = {
29-
className: undefined
29+
className: undefined,
3030
};
3131

3232
export default Sphere;

src/components/Status/index.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import React from "react";
2-
import PropTypes from "prop-types";
3-
import cx from "classnames";
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import cx from 'classnames';
44

5-
import "./index.css";
5+
import './index.css';
66

77
const Status = ({ color, message }) => {
88
const colorClass = {
9-
green: "Status--green"
9+
green: 'Status--green',
1010
}[color];
1111

12-
return <p className={cx("Status d-inline-block", colorClass)}>{message}</p>;
12+
return <p className={cx('Status d-inline-block', colorClass)}>{message}</p>;
1313
};
1414

1515
Status.propTypes = {
16-
color: PropTypes.oneOf(["green", "default"]).isRequired
16+
color: PropTypes.oneOf(['green', 'default']).isRequired,
1717
};
1818

1919
export default Status;

src/components/Ticket/index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React from "react";
2-
import PropTypes from "prop-types";
3-
import cx from "classnames";
4-
import TicketField from "../TicketField";
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import cx from 'classnames';
4+
import TicketField from '../TicketField';
55

6-
import "./index.css";
6+
import './index.css';
77

8-
const headerLetters = ["M", "J", "R", "G", "Ž"];
8+
const headerLetters = ['M', 'J', 'R', 'G', 'Ž'];
99

1010
const Ticket = ({
1111
values,
@@ -16,7 +16,7 @@ const Ticket = ({
1616
className,
1717
...props
1818
}) => (
19-
<div className={cx("Ticket", className)} {...props}>
19+
<div className={cx('Ticket', className)} {...props}>
2020
<table>
2121
<thead>
2222
<tr>
@@ -52,12 +52,12 @@ const Ticket = ({
5252
Ticket.propTypes = {
5353
values: PropTypes.arrayOf(PropTypes.array.isRequired).isRequired,
5454
rolledValues: PropTypes.arrayOf(PropTypes.string),
55-
className: PropTypes.string
55+
className: PropTypes.string,
5656
};
5757

5858
Ticket.defaultProps = {
5959
rolledValues: [],
60-
className: undefined
60+
className: undefined,
6161
};
6262

6363
export default Ticket;

src/components/TicketField/index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React from "react";
2-
import PropTypes from "prop-types";
3-
import cx from "classnames";
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import cx from 'classnames';
44

5-
import "./index.css";
5+
import './index.css';
66

77
const TicketField = ({
88
value,
@@ -15,9 +15,9 @@ const TicketField = ({
1515
return (
1616
<td
1717
className={cx(
18-
"TicketField",
19-
{ "TicketField--crossed-out": isCrossedOut },
20-
{ "TicketField--clickable": shouldInteract }
18+
'TicketField',
19+
{ 'TicketField--crossed-out': isCrossedOut },
20+
{ 'TicketField--clickable': shouldInteract }
2121
)}
2222
onClick={shouldInteract ? () => clickHandler(+value) : undefined}
2323
{...props}
@@ -29,11 +29,11 @@ const TicketField = ({
2929

3030
TicketField.propTypes = {
3131
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
32-
isCrossedOut: PropTypes.bool
32+
isCrossedOut: PropTypes.bool,
3333
};
3434

3535
TicketField.defaultProps = {
36-
isCrossedOut: false
36+
isCrossedOut: false,
3737
};
3838

3939
export default TicketField;

src/components/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import Ticket from "./Ticket";
2-
import Sphere from "./Sphere";
3-
import Input from "./Input";
4-
import Status from "./Status";
1+
import Ticket from './Ticket';
2+
import Sphere from './Sphere';
3+
import Input from './Input';
4+
import Status from './Status';
55

66
export { Ticket, Sphere, Input, Status };

0 commit comments

Comments
 (0)