Reputation: 6991
I have an object that I am defining in a js
file. I would like the object to look a certain way -- but prettier changes it.
Here is how I would like it to look:
const validationSchema = Yup.object().shape({
name: Yup
.string('Enter a name')
.required('Name is required'),
email: Yup
.string('Enter your email')
.email('Enter a valid email')
.required('Email is required'),
password: Yup
.string('')
.min(8, 'Password must contain at least 8 characters')
.required('Enter your password'),
confirmPassword: Yup
.string('Enter your password')
.required('Confirm your password')
.oneOf([Yup.ref('password')], 'Password does not match'),
})
Here is how prettier reformats it:
const validationSchema = Yup.object().shape({
name: Yup.string('Enter a name').required('Name is required'),
email: Yup.string('Enter your email')
.email('Enter a valid email')
.required('Email is required'),
password: Yup.string('')
.min(8, 'Password must contain at least 8 characters')
.required('Enter your password'),
confirmPassword: Yup.string('Enter your password')
.required('Confirm your password')
.oneOf([Yup.ref('password')], 'Password does not match'),
})
Is there anything that I can do to indicate to prettier to keep my formatting? If so, how?
Upvotes: 1
Views: 391
Reputation: 558
You can add // prettier-ignore
comment before your assignment to exclude it from formatting
Upvotes: 1