覆盖更漂亮的配置
Overriding Prettier Configuration
我在 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
评论以将其从格式中排除
我在 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
评论以将其从格式中排除