如何在一些情况下禁止部分的 prettier
不同情况下,如何 disable prettier
在JS文件里,禁止单行
// prettier-ignore
var times = [
'01:00:00', '01:25:00', '01:50:00', '02:15:00',
'02:40:00', '03:05:00', '03:30:00', '03:55:00',
'04:20:00', '04:45:00', '05:10:00', '05:35:00',
'06:00:00', '06:25:00', '06:50:00', '07:15:00',
'07:40:00', '08:05:00', '08:30:00', '08:55:00',
'09:20:00', '09:45:00', '10:10:00', '10:35:00',
'11:00:00', '11:25:00', '11:50:00', '12:15:00',
'12:40:00', '13:05:00', '13:30:00', '13:55:00',
'14:20:00', '14:45:00', '15:10:00', '15:35:00',
'16:00:00', '16:25:00', '16:50:00', '17:15:00',
'17:40:00', '18:05:00', '18:30:00', '18:55:00',
'19:20:00', '19:45:00', '20:10:00', '20:35:00',
'21:00:00', '21:25:00', '21:50:00', '22:15:00',
'22:40:00', '23:05:00', '23:30:00', '23:55:00'
];
matrix(1, 0, 0, 0, 1, 0, 0, 0, 1);
// prettier-ignore
matrix(
1, 0, 0,
0, 1, 0,
0, 0, 1
);
在JSX里单行
<div>
{/* prettier-ignore */}
<span ugly format='' />
</div>
在项目中部分文件不需要格式化
在项目根目录建立 .prettierignore 文件
/app/src/scripts/example.js
/app/src/folder/
*.html.erb