问题描述
这没道理...
ESLint在那之后抱怨新行(第11行.
ESLint is complainig about the new line after that ( on line 11.
如果我将其拿走并将Provider组件放在同一行,并从第12行和第13行拿一个标签(App组件并关闭Provider标签,那么它会抱怨:
If I take it away and put the Provider component on the same line, and take one tab away from line 12 and 13 (App component and closing Provider tag, then it complains about:
预期的结束标记以匹配开始的缩进.(react/jsx-closing-tag-location)
Expected closing tag to match indentation of opening. (react/jsx-closing-tag-location)
如果我确实将其缩进开始标记的级别,该标记现在开始16个字符,原因是我必须删除新行,则出现另一个错误:预期缩进0个空格字符,但发现16个.(react/jsx-indent)
If I do indent it to the level of opening tag which now starts 16 characters in cause I had to remove the new line, I get another error:Expected indentation of 0 space characters but found 16. (react/jsx-indent)
使用ESLint和AirBNB规范的React/Redux是否对此具有正确的语法?
Is there correct syntax for this with React/Redux that works with ESLint and AirBNB spec?
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import './index.css';
import App from './components/App';
import registerServiceWorker from './registerServiceWorker';
import configureStore from './state/store/configureStore';
window.store = configureStore();
ReactDOM.render(
<Provider store={window.store}>
<App />
</Provider>, document.getElementById('root'));
registerServiceWorker();
推荐答案
airbnb似乎对该规则使用了 function-paren-newline:'multiline'
,这意味着应该通过:
It seems airbnb uses function-paren-newline: 'multiline'
for that rule, which means this should pass:
ReactDOM.render(
<Provider store={window.store}>
<App />
</Provider>,
document.getElementById('root')
);
我认为您只需要将每个参数放在单独的行上即可.
I think you just need each argument on a separate line.
更新:参见 eslint.org
update:See demo of the rule passing/failing on eslint.org
这篇关于ESLint简单反应App.js括号后的意外换行function-paren-newline的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!