我在js
文件中定义了一个对象。我希望该对象具有某种外观-但要更漂亮些。
这是我想要的样子:
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'),
})
这是更漂亮的格式:
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'),
})
我能做些什么来表明自己更漂亮以保持格式吗?如果可以,怎么办?
答案 0 :(得分:1)
您可以在分配作业之前添加// prettier-ignore
条注释,以将其从格式中排除