gpt4 book ai didi

javascript - 覆盖更漂亮的配置

转载 作者:行者123 更新时间:2023-11-30 19:17:19 25 4
gpt4 key购买 nike

我在 js 文件中定义了一个对象。我希望对象看起来像某种方式——但 prettier 会改变它。

这是我希望的样子:

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

这是 prettier 重新格式化它的方式:

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

我可以做些什么来指示 prettier 以保持我的格式?如果是,怎么办?

最佳答案

您可以在赋值之前添加 //prettier-ignore 注释以将其从格式化中排除

关于javascript - 覆盖更漂亮的配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57845320/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com