Skip to content

Commit be60200

Browse files
committed
Prettier the world
1 parent 06b3683 commit be60200

33 files changed

+548
-485
lines changed

.eslintrc.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ module.exports = {
55
node: true,
66
jest: true,
77
},
8-
extends: ["eslint:recommended", "plugin:react/recommended", "prettier"],
8+
extends: ['eslint:recommended', 'plugin:react/recommended', 'prettier'],
99
parserOptions: {
1010
ecmaFeatures: {
1111
jsx: true,
1212
},
1313
ecmaVersion: 12,
14-
sourceType: "module",
14+
sourceType: 'module',
1515
},
16-
plugins: ["react", "prettier"],
16+
plugins: ['react', 'prettier'],
1717
rules: {
18-
"prettier/prettier": "error",
18+
'prettier/prettier': 'error',
1919
},
2020
settings: {
2121
react: {
22-
version: "detect",
22+
version: 'detect',
2323
},
2424
},
2525
};

__tests__/add-rhythm.test.js

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from 'react';
2-
import RhythmischApp from "../pages/app";
3-
import { RhythmsProvider } from "../hooks/rhythms";
4-
import { render, screen } from "@testing-library/react";
5-
import userEvent from "@testing-library/user-event";
6-
import "@testing-library/jest-dom/extend-expect";
7-
import { ThemeProvider } from "../hooks/theme";
8-
import { setLocalStorageRhythms } from "../hooks/rhythms/local-storage";
2+
import RhythmischApp from '../pages/app';
3+
import { RhythmsProvider } from '../hooks/rhythms';
4+
import { render, screen } from '@testing-library/react';
5+
import userEvent from '@testing-library/user-event';
6+
import '@testing-library/jest-dom/extend-expect';
7+
import { ThemeProvider } from '../hooks/theme';
8+
import { setLocalStorageRhythms } from '../hooks/rhythms/local-storage';
99

1010
beforeEach(() => {
1111
setLocalStorageRhythms([]);
@@ -19,15 +19,17 @@ beforeEach(() => {
1919
);
2020
});
2121

22-
it("can add a new rhythm", () => {
22+
it('can add a new rhythm', () => {
2323
const addButton = screen.getByRole('button', { name: 'Add' });
2424
userEvent.click(addButton);
2525
const modal = screen.getByRole('dialog');
2626
expect(modal).toBeInTheDocument();
2727

2828
const action = screen.getByLabelText('Rhythm action description');
2929
const numeratorFrequency = screen.getByLabelText('Rhythm action count');
30-
const denomenatorFrequency = screen.getByLabelText('Rhythm action count time span');
30+
const denomenatorFrequency = screen.getByLabelText(
31+
'Rhythm action count time span'
32+
);
3133
const reason = screen.getByLabelText('Rhythm reason description');
3234
const submit = screen.getByRole('button', { name: 'Create' });
3335

@@ -41,14 +43,18 @@ it("can add a new rhythm", () => {
4143

4244
expect(screen.getByText('Read every day')).toBeInTheDocument();
4345
expect(screen.getByText('thrice every week')).toBeInTheDocument();
44-
expect(screen.getByText('because there is much I would like to learn')).toBeInTheDocument();
46+
expect(
47+
screen.getByText('because there is much I would like to learn')
48+
).toBeInTheDocument();
4549

46-
const localStorageRhythms = JSON.parse(window.localStorage.getItem("app.rhythms"));
50+
const localStorageRhythms = JSON.parse(
51+
window.localStorage.getItem('app.rhythms')
52+
);
4753
expect(localStorageRhythms).toHaveLength(1);
4854
const addedRhythm = localStorageRhythms[0];
4955
expect(addedRhythm.id).toBeTruthy;
50-
expect(addedRhythm.action).toBe("read every day");
51-
expect(addedRhythm.reason).toBe("there is much I would like to learn");
56+
expect(addedRhythm.action).toBe('read every day');
57+
expect(addedRhythm.reason).toBe('there is much I would like to learn');
5258
expect(addedRhythm.frequency).toMatchObject([3, 7]);
5359
expect(addedRhythm.hits).toMatchObject([]);
5460
});

__tests__/edit-rhythm.test.js

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from 'react';
2-
import RhythmischApp from "../pages/app";
3-
import { RhythmsProvider } from "../hooks/rhythms";
4-
import { render, screen } from "@testing-library/react";
5-
import userEvent from "@testing-library/user-event";
6-
import "@testing-library/jest-dom/extend-expect";
7-
import { ThemeProvider } from "../hooks/theme";
8-
import { setLocalStorageRhythms } from "../hooks/rhythms/local-storage";
2+
import RhythmischApp from '../pages/app';
3+
import { RhythmsProvider } from '../hooks/rhythms';
4+
import { render, screen } from '@testing-library/react';
5+
import userEvent from '@testing-library/user-event';
6+
import '@testing-library/jest-dom/extend-expect';
7+
import { ThemeProvider } from '../hooks/theme';
8+
import { setLocalStorageRhythms } from '../hooks/rhythms/local-storage';
99

1010
const getLocalStorageRhythms = () => {
1111
const localStorageRhythms = JSON.parse(
12-
window.localStorage.getItem("app.rhythms")
12+
window.localStorage.getItem('app.rhythms')
1313
);
1414
return localStorageRhythms;
1515
};
@@ -18,9 +18,9 @@ let rhythm;
1818

1919
beforeEach(() => {
2020
rhythm = {
21-
id: "local-storage-rhythm",
22-
action: "pass this test",
23-
reason: "tests should pass",
21+
id: 'local-storage-rhythm',
22+
action: 'pass this test',
23+
reason: 'tests should pass',
2424
frequency: [1, 1],
2525
hits: [],
2626
};
@@ -36,7 +36,7 @@ beforeEach(() => {
3636
);
3737
});
3838

39-
it("can edit an existing rhythm", () => {
39+
it('can edit an existing rhythm', () => {
4040
let localStorageRhythms = getLocalStorageRhythms();
4141
expect(localStorageRhythms).toHaveLength(1);
4242
const localStorageRhythm = localStorageRhythms[0];
@@ -49,31 +49,31 @@ it("can edit an existing rhythm", () => {
4949
const editButton = screen.getByRole('button', { name: 'Edit' });
5050
userEvent.click(editButton);
5151

52-
const modal = screen.getByRole("dialog");
52+
const modal = screen.getByRole('dialog');
5353
expect(modal).toBeInTheDocument();
5454

55-
const action = screen.getByLabelText("Rhythm action description");
56-
const numeratorFrequency = screen.getByLabelText("Rhythm action count");
55+
const action = screen.getByLabelText('Rhythm action description');
56+
const numeratorFrequency = screen.getByLabelText('Rhythm action count');
5757
const denomenatorFrequency = screen.getByLabelText(
58-
"Rhythm action count time span"
58+
'Rhythm action count time span'
5959
);
60-
const reason = screen.getByLabelText("Rhythm reason description");
61-
const submit = screen.getByRole("button", { name: "Update" });
60+
const reason = screen.getByLabelText('Rhythm reason description');
61+
const submit = screen.getByRole('button', { name: 'Update' });
6262

6363
userEvent.clear(action);
64-
userEvent.type(action, "read every day");
65-
userEvent.selectOptions(numeratorFrequency, "thrice");
66-
userEvent.selectOptions(denomenatorFrequency, "week");
64+
userEvent.type(action, 'read every day');
65+
userEvent.selectOptions(numeratorFrequency, 'thrice');
66+
userEvent.selectOptions(denomenatorFrequency, 'week');
6767
userEvent.clear(reason);
68-
userEvent.type(reason, "there is much I would like to learn");
68+
userEvent.type(reason, 'there is much I would like to learn');
6969
userEvent.click(submit);
7070

7171
expect(modal).not.toBeInTheDocument();
7272

73-
expect(screen.getByText("Read every day")).toBeInTheDocument();
74-
expect(screen.getByText("thrice every week")).toBeInTheDocument();
73+
expect(screen.getByText('Read every day')).toBeInTheDocument();
74+
expect(screen.getByText('thrice every week')).toBeInTheDocument();
7575
expect(
76-
screen.getByText("because there is much I would like to learn")
76+
screen.getByText('because there is much I would like to learn')
7777
).toBeInTheDocument();
7878

7979
localStorageRhythms = getLocalStorageRhythms();
@@ -82,7 +82,7 @@ it("can edit an existing rhythm", () => {
8282
expect(updatedLocalStorageRhythm.id).toBe(rhythm.id);
8383
expect(updatedLocalStorageRhythm.action).toBe('read every day');
8484
expect(updatedLocalStorageRhythm.reason).toBe(
85-
"there is much I would like to learn"
85+
'there is much I would like to learn'
8686
);
8787
expect(updatedLocalStorageRhythm.frequency).toMatchObject([3, 7]);
8888
expect(updatedLocalStorageRhythm.hits).toMatchObject([]);

__tests__/remove-rhythm.test.js

+21-19
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
import React from 'react';
2-
import RhythmischApp from "../pages/app";
3-
import { RhythmsProvider } from "../hooks/rhythms";
4-
import { ThemeProvider } from "../hooks/theme";
5-
import { render, screen } from "@testing-library/react";
6-
import userEvent from "@testing-library/user-event";
7-
import "@testing-library/jest-dom/extend-expect";
8-
import { setLocalStorageRhythms } from "../hooks/rhythms/local-storage";
2+
import RhythmischApp from '../pages/app';
3+
import { RhythmsProvider } from '../hooks/rhythms';
4+
import { ThemeProvider } from '../hooks/theme';
5+
import { render, screen } from '@testing-library/react';
6+
import userEvent from '@testing-library/user-event';
7+
import '@testing-library/jest-dom/extend-expect';
8+
import { setLocalStorageRhythms } from '../hooks/rhythms/local-storage';
99

1010
const getLocalStorageRhythms = () => {
1111
const localStorageRhythms = JSON.parse(
12-
window.localStorage.getItem("app.rhythms")
12+
window.localStorage.getItem('app.rhythms')
1313
);
1414
return localStorageRhythms;
1515
};
1616

1717
beforeEach(() => {
18-
setLocalStorageRhythms([{
19-
id: 'local-storage-rhythm',
20-
action: 'pass this test',
21-
reason: 'tests should pass',
22-
frequency: [1, 1],
23-
hits: [],
24-
}]);
18+
setLocalStorageRhythms([
19+
{
20+
id: 'local-storage-rhythm',
21+
action: 'pass this test',
22+
reason: 'tests should pass',
23+
frequency: [1, 1],
24+
hits: [],
25+
},
26+
]);
2527

2628
render(
2729
<ThemeProvider>
@@ -32,12 +34,12 @@ beforeEach(() => {
3234
);
3335
});
3436

35-
it("can delete an existing rhythm", () => {
37+
it('can delete an existing rhythm', () => {
3638
expect(getLocalStorageRhythms()).toHaveLength(1);
3739

38-
const action = screen.getByText("Pass this test");
39-
const frequency = screen.getByText("once every day");
40-
const reason = screen.getByText("because tests should pass");
40+
const action = screen.getByText('Pass this test');
41+
const frequency = screen.getByText('once every day');
42+
const reason = screen.getByText('because tests should pass');
4143

4244
expect(action).toBeInTheDocument();
4345
expect(frequency).toBeInTheDocument();

__tests__/render.test.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
2-
import { render } from "@testing-library/react";
3-
import RhythmischApp from "../pages/app";
2+
import { render } from '@testing-library/react';
3+
import RhythmischApp from '../pages/app';
44
import { RhythmsProvider } from '../hooks/rhythms';
55
import { ThemeProvider } from '../hooks/theme';
66
import { setLocalStorageRhythms } from '../hooks/rhythms/local-storage';
7-
import "@testing-library/jest-dom/extend-expect";
7+
import '@testing-library/jest-dom/extend-expect';
88

99
let rendered;
1010

@@ -18,17 +18,17 @@ function setup() {
1818
);
1919
}
2020

21-
describe('render' , () => {
21+
describe('render', () => {
2222
beforeEach(() => {
2323
setup();
2424
});
2525

26-
it("renders an Add button", () => {
26+
it('renders an Add button', () => {
2727
const addButton = rendered.getByRole('button', { name: 'Add' });
2828
expect(addButton).toBeInTheDocument();
2929
});
3030

31-
it("renders the default Rhythm", () => {
31+
it('renders the default Rhythm', () => {
3232
const action = rendered.getByText('Use Rhythmisch on this device');
3333
expect(action).toBeInTheDocument();
3434

@@ -38,16 +38,15 @@ describe('render' , () => {
3838
const reason = rendered.getByText('because I want to get into the rhythm');
3939
expect(reason).toBeInTheDocument();
4040

41-
const historicalOccurrences = rendered.getAllByLabelText(/Missed target on /);
41+
const historicalOccurrences =
42+
rendered.getAllByLabelText(/Missed target on /);
4243
expect(historicalOccurrences).toHaveLength(13);
4344

4445
const todaysOccurrence = rendered.getByLabelText(/Mark as /);
4546
expect(todaysOccurrence).toBeInTheDocument();
4647

4748
// the default rhythm is not stored in local storage
48-
expect(JSON.parse(
49-
window.localStorage.getItem("app.rhythms")
50-
)).toBeNull;
49+
expect(JSON.parse(window.localStorage.getItem('app.rhythms'))).toBeNull;
5150
});
5251

5352
describe('with an empty list of rhythms', () => {
@@ -56,8 +55,10 @@ describe('render' , () => {
5655
setup();
5756
});
5857

59-
it("renders an empty rhythm list message", () => {
60-
const emptyRhythmsText = rendered.getByText("All out of rhythms, enjoy some fresh air 💜");
58+
it('renders an empty rhythm list message', () => {
59+
const emptyRhythmsText = rendered.getByText(
60+
'All out of rhythms, enjoy some fresh air 💜'
61+
);
6162
expect(emptyRhythmsText).toBeInTheDocument();
6263
});
6364
});

components/button.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
import React from "react";
2-
import { useTheme } from "../hooks/theme/index";
1+
import React from 'react';
2+
import { useTheme } from '../hooks/theme/index';
33

44
export default function Button({
55
children,
66
onClick = () => {},
77
attrs = {},
8-
size = "large",
8+
size = 'large',
99
}) {
1010
const [theme] = useTheme();
1111
const { buttonTextColor, buttonBgColor } = theme;
1212

13-
const { className = "", type: buttonType, ...buttonAttrs } = attrs;
13+
const { className = '', type: buttonType, ...buttonAttrs } = attrs;
1414

1515
const largeButtonClassNames = [
1616
buttonTextColor,
1717
buttonBgColor,
18-
"inline-block",
19-
"font-medium",
20-
"py-1.5",
21-
"text-lg",
22-
"md:text-xl",
18+
'inline-block',
19+
'font-medium',
20+
'py-1.5',
21+
'text-lg',
22+
'md:text-xl',
2323
];
2424

2525
const smallButtonClassNames = [
2626
buttonTextColor,
2727
buttonBgColor,
28-
"inline-block",
29-
"font-medium",
30-
"py-1.5",
28+
'inline-block',
29+
'font-medium',
30+
'py-1.5',
3131
];
3232

3333
const sizeClassName =
34-
size === "large"
35-
? largeButtonClassNames.join(" ")
36-
: smallButtonClassNames.join(" ");
34+
size === 'large'
35+
? largeButtonClassNames.join(' ')
36+
: smallButtonClassNames.join(' ');
3737

3838
return (
3939
<button
4040
{...buttonAttrs}
41-
type={buttonType || "button"}
41+
type={buttonType || 'button'}
4242
onClick={onClick}
4343
className={`${className} ${sizeClassName}`}
4444
>

components/content/section.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React from 'react';
22

33
export function SectionHeading({ children }) {
44
return <h3 className="text-3xl text-gray-800 font-bold mb-4">{children}</h3>;

0 commit comments

Comments
 (0)