Skip to content

Commit f31d970

Browse files
committed
add proseWrap rule to prettier
1 parent 9405790 commit f31d970

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

.prettierrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ module.exports = {
44
singleQuote: true,
55
printWidth: 120,
66
tabWidth: 2,
7+
proseWrap: 'always',
78
};

CONTRIBUTING.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ To get started with mdx-embed we suggest you clone the repo then do the followin
1010

1111
## Change an existing component
1212

13-
Feel free to make changes wherever you see bit but please be mindful that removing or changing prop names will count as a breaking change and we'll only do this if it's absolutely necessary.
13+
Feel free to make changes wherever you see bit but please be mindful that removing or changing prop names will count as
14+
a breaking change and we'll only do this if it's absolutely necessary.
1415

15-
Check the existing props still work by checking against the story in the components `.stories.mdx` file. Each prop usually means the component will behave in a different way so please check the component still does what it's supposed to do when you're altering prop _values_ or code.
16+
Check the existing props still work by checking against the story in the components `.stories.mdx` file. Each prop
17+
usually means the component will behave in a different way so please check the component still does what it's supposed
18+
to do when you're altering prop _values_ or code.
1619

1720
## To add a new component
1821

@@ -22,31 +25,43 @@ To add a new component there are several locations the new component needs to go
2225
- All components are `FunctionComponents` and named using the [PascalCase](https://wiki.c2.com/?PascalCase) convention
2326
- Add an `index.ts` file to the same dir and export the component: `export { ComponentName } from './component-name';`
2427
- Add export to `mdx-embed/src/index.ts`: `export { ComponentName } from './components/component-name`
25-
- Include component in the `components` object that gets passed onto the MDXProvider in `src/components/mdx-embed-provider/mdx-embed-provider.tsx`
28+
- Include component in the `components` object that gets passed onto the MDXProvider in
29+
`src/components/mdx-embed-provider/mdx-embed-provider.tsx`
2630
- Add component to stories `docs/src/components/component-name.stories.mdx`
2731

2832
## Final checks
2933

30-
It's important for our users to understand how the component works so we always try to give any props the component has a brief description of what it does _and_ create a `<Story />` for each prop visually showing the usage.
34+
It's important for our users to understand how the component works so we always try to give any props the component has
35+
a brief description of what it does _and_ create a `<Story />` for each prop visually showing the usage.
3136

3237
## Create PR
3338

34-
Once you're happy with your new component create a PR that merges in to the `main` branch and one of the team will happily review your code.
39+
Once you're happy with your new component create a PR that merges in to the `main` branch and one of the team will
40+
happily review your code.
3541

36-
The team are on hand should you require any assistance of have any questions at all so please feel free to reach out on Twitter
42+
The team are on hand should you require any assistance of have any questions at all so please feel free to reach out on
43+
Twitter
3744

3845
- Paul Scanlon | [@pauliescanlon](https://twitter.com/PaulieScanlon)
3946
- Scott Spence | [@spences10](https://twitter.com/spences10)
4047
- Rich Haines | [@studio_hungry](https://twitter.com/studio_hungry)
4148

4249
## Testing WIP
4350

44-
Each component will at some point require at least one test to check it renders correctly.
45-
Each component in `mdx-embed/src/components/` is wrapped in what we call the **GeneralObserver** This component is responsible for ensuring the 3rd part embed script isn't invoked until the component has entered the viewport. This is particularly important for Lighthouse scores and page load speeds. If a blog post page for example has 10 or 15 embed codes, Twitter, CodePend, YouTube etc on the page we don't want to load all that 3rd party JavaScript until the reader has scrolled down to where the component is used. When it scrolls in to view **GeneralObserver** which is an [Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) triggers a React state change which causes the children to be rendered in the DOM
51+
Each component will at some point require at least one test to check it renders correctly. Each component in
52+
`mdx-embed/src/components/` is wrapped in what we call the **GeneralObserver** This component is responsible for
53+
ensuring the 3rd part embed script isn't invoked until the component has entered the viewport. This is particularly
54+
important for Lighthouse scores and page load speeds. If a blog post page for example has 10 or 15 embed codes, Twitter,
55+
CodePend, YouTube etc on the page we don't want to load all that 3rd party JavaScript until the reader has scrolled down
56+
to where the component is used. When it scrolls in to view **GeneralObserver** which is an
57+
[Intersection Observer](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) triggers a React
58+
state change which causes the children to be rendered in the DOM
4659

47-
This presents an issue when we come to test the components because we need to fake the "scrolled in to view" action which allows the children of **GeneralObserver** to render.
60+
This presents an issue when we come to test the components because we need to fake the "scrolled in to view" action
61+
which allows the children of **GeneralObserver** to render.
4862

49-
To _mock_ this is a test we've globally exposed a method called `triggerGeneralObserver()` and since we're using Testing Library this state change must be wrapped in an `act`.
63+
To _mock_ this is a test we've globally exposed a method called `triggerGeneralObserver()` and since we're using Testing
64+
Library this state change must be wrapped in an `act`.
5065

5166
With that said we require each `test(() => {})` to contain an `act()` and a call to `triggerGeneralObserver()`
5267

@@ -67,7 +82,8 @@ describe('<CodePen />', () => {
6782
});
6883
```
6984

70-
The other important part of the test is the use of `getByTestId` this is a special data attribute we use from Testing Library called `data-testid` and will need to be added to components with _new_ tests.
85+
The other important part of the test is the use of `getByTestId` this is a special data attribute we use from Testing
86+
Library called `data-testid` and will need to be added to components with _new_ tests.
7187

7288
In the `CodePen` example that looks a bit like this:
7389

0 commit comments

Comments
 (0)