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?
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?
Share Improve this question asked Sep 24, 2019 at 16:50 Leon GabanLeon Gaban 39k122 gold badges349 silver badges550 bronze badges 1- if you don't use multi-line template strings, a simple RegExp can clean that up for you. – dandavis Commented Sep 24, 2019 at 16:59
3 Answers
Reset to default 4To prevent Prettier from formatting your code, use this ment 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
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.
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 remends not doing), you could increase the width by adding
"printWidth": <whatever you want your max column length to be>
to your prettierrc.json
Print Width in the docs
Alternatively, if you don't want the ments in the code, you can create a .prettierignore file and add your file to that.