【发布时间】:2020-07-22 19:38:01
【问题描述】:
我创建了一个 React Native 项目,版本是0.62.2
我把eslintrc.js改成如下
module.exports = {
parser:'babel-eslint',
env: {
browser: true,
es6: true,
},
extends: '@react-native-community',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: [
'react',
],
rules: {
... my other rules
"react-native/no-inline-styles": 1,
"prettier/prettier": ["error", {
"no-inline-styles": false
}],
},
};
我希望我的样式代码像这样{{ flex: 1, marginTop: 5 }} 而不是{{flex:1,marginTop:5}}
但我的警告显示信息:
(property) FlexStyle.marginTop?: React.ReactText
Inline style: { flex: 1, marginTop: 5 }eslint(react-native/no-inline-styles)
Replace `·flex:1,·marginTop:5·` with `flex:·1,·marginTop:·5`eslintprettier/prettier
我不知道如何设置内联样式空间以及如何解决更漂亮的问题。
【问题讨论】:
标签: react-native eslint eslintrc