JSX 代码无法被自动修复
Closed this issue · 2 comments
luhc228 commented
原始代码
function Home() {
return (<Select
style={style}
showSearch
placeholder={placeholder}
filterLocal={false}
value={value}
itemRender={itemRender}
valueRender={itemRender}
dataSource={dataSource}
onChange={onChange}
onVisibleChange={onVisibleChange}
onSearch={handleSearch}
{...others}
/>);
}
luhc228 commented
luhc228 commented
原来的规则是 'react/jsx-closing-bracket-location': ['error']
,自动修复后结束标签和开始标签对齐,这时候会跟 indent 缩进的规则产生冲突:
function Home() {
return (<Select
style={style}
showSearch
placeholder={placeholder}
filterLocal={false}
value={value}
itemRender={itemRender}
valueRender={itemRender}
dataSource={dataSource}
onChange={onChange}
onVisibleChange={onVisibleChange}
onSearch={handleSearch}
{...others}
/>);
}
把规则改成 'react/jsx-closing-bracket-location': ['error', 'line-aligned']
,结束标签会跟与包含开始标签的行对齐:
function Home() {
return (<Select
style={style}
showSearch
placeholder={placeholder}
filterLocal={false}
value={value}
itemRender={itemRender}
valueRender={itemRender}
dataSource={dataSource}
onChange={onChange}
onVisibleChange={onVisibleChange}
onSearch={handleSearch}
{...others}
/>);
}