简体   繁体   English

在双花括号、ESLint/Prettier 警告上反应原生错误

[英]React Native error on double curly braces, ESLint/Prettier Warnings

I'm new to React Native and try to walk through a basic tutorial on official website.我是 React Native 的新手,并尝试在官方网站上浏览基本教程。 but when I finish the configuration this error come out.但是当我完成配置时,这个错误就出来了。 it seems like something to do with Prettier issue but I couldn't figure out why.这似乎与 Prettier 问题有关,但我不知道为什么。 This is the code.这是代码。

在此处输入图片说明

在此处输入图片说明

.prettierrc .prettierrc

module.exports = {
  bracketSpacing: true,
  jsxBracketSameLine: true,
  singleQuote: true,
  trailingComma: 'all',
  semi: true,
};

those are prettier and eslint error.那些更漂亮和 eslint 错误。 For prettier issue maybe you can use format onsave on vscode, so whenever you save the file, it will format the file according to your prettierrc.对于更漂亮的问题,也许您可​​以在vscode上使用format onsave ,因此无论何时保存文件,它都会根据您的 prettierrc 格式化文件。

For eslint error usually because of your code is breaking the rules of your eslint config.对于 eslint 错误,通常是因为您的代码违反了 eslint 配置的规则。 For example on your screenshot above, there is error from react-native/no-inline-styles , refer to rules description is telling us to not put style inline.例如,在上面的屏幕截图中, react-native/no-inline-styles有错误,请参阅规则描述告诉我们不要将样式内联。 If you want this rule to be ignored, you can set on your eslint config file like如果你想忽略这条规则,你可以在你的 eslint 配置文件上设置,比如

"rules": {
  "react-native/no-inline-styles": "off",
}

You will have to put the styling in quotes.您必须将样式放在引号中。 You will have to see the error and fix them accordingly.您必须查看错误并相应地修复它们。 All of them are related to styling for now.目前所有这些都与造型有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM