Reputation: 39018
Code in question
it('will display No Policy Found after fist submit attempt.', () => {
const policyDetails = {
partyID: null,
agreementID: null,
isValidPolicy: false,
};
wrapper.setProps({policyDetails});
wrapper.setState({submitCount: 1});
const result = wrapper.instance().displayUserNotices();
const render = shallow(result)
.find('UserNotice')
.find('p');
expect(render.text()).toEqual(NO_POLICY_USER_NOTICE);
});
I keep writing
const render = shallow(result)
.find('UserNotice')
.find('p');
as the desired following 1-liner:
const render = shallow(result).find('UserNotice').find('p');
But prettier keeps reverting it.
I tried adding
noUnexpectedMultiline: true
in the .prettierrc.yml but that didn't work.
Ideas?
Upvotes: 6
Views: 7055
Reputation: 2644
To prevent Prettier from formatting your code, use this comment before the variable/function/etc.
// prettier-ignore
Alternatively, if you're in Markdown, you can ignore multiple lines, like this:
<!-- prettier-ignore-start -->
# Headline
```js
const foo = 'hey';
console.log (foo);
```
<!-- prettier-ignore-end -->
For more information: https://prettier.io/docs/en/ignore.html
Upvotes: 4
Reputation: 658
Would love to see them add the ability to ignore specific functions, in Javascript, like 'console.log'. Had to change my snippets to add the //prettier-ignore at the end of every line.
Upvotes: 1
Reputation: 49
If this is something that will happen regularly in your codebase, and you don't want to have ignore
statements all over your code, and you want to enable going past 80 characters (which Prettier recommends not doing), you could increase the width by adding
"printWidth": <whatever you want your max column length to be>
to your prettierrc.json
Alternatively, if you don't want the comments in the code, you can create a .prettierignore file and add your file to that.
Upvotes: 0