覆盖更漂亮的配置

时间:2019-09-08 19:57:53

标签: javascript prettier

我在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'),
})

我能做些什么来表明自己更漂亮以保持格式吗?如果可以,怎么办?

1 个答案:

答案 0 :(得分:1)

您可以在分配作业之前添加// prettier-ignore条注释,以将其从格式中排除