简体   繁体   English

期望一个字符串,得到对象 gatsby-plugin-prettier-eslint Gatsby

[英]Expected a string, got object gatsby-plugin-prettier-eslint Gatsby

I am trying to learn Gatsby and I included prettier-eslint plugin with a common configuration.我正在尝试学习 Gatsby,并且包含了具有通用配置的 prettier-eslint 插件。 You can see my configuration, the files, etc你可以看到我的配置、文件等

When I try to add a css file I get this error:当我尝试添加 css 文件时,出现此错误:

错误

Have you tried using the following?您是否尝试过使用以下方法?

eslint: {
  patterns: "**/*.{js,jsx,ts,tsx}",
  customOptions: {
    fix: true,
    cache: true,
  },
},

The eslint pattern seems to be a string, not an array according to the plugin's example .根据 插件的示例eslint模式似乎是一个字符串,而不是一个数组。


This seems to be an unresolved issue of the plugin, according to this opened issue (from a week ago), so keep an eye on that stack trace to see how it evolves.根据这个打开的问题(一周前),这似乎是插件的一个未解决的问题,所以请密切关注该堆栈跟踪以了解它是如何演变的。 If the dependency has a bug when using the defaults (and suggested) configuration, there's nothing you can do except making a PR if you are able to spot the bug in the source code or wait for the resolution.如果在使用默认(和建议的)配置时依赖项有错误,如果您能够在源代码中发现错误或等待解决方案,那么除了制作 PR 之外,您无能为力。

I had the same issue.我遇到过同样的问题。 Turns out you must have a prettier config (.prettierrc or similar) set up.原来你必须有一个更漂亮的配置(.prettierrc 或类似的)设置。 Check to make sure you have a config as mentioned in the Prettier docs .检查以确保您拥有Prettier 文档中提到的配置。

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

相关问题 Gatsby JS 元素类型无效:应为字符串(用于内置组件)或类/函数(用于复合组件)但得到:未定义 - Gatsby JS Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 简单的 react-spring 组件在 gatsby 中不起作用 - 元素类型无效:预期为字符串或类/函数但得到:未定义 - Simple react-spring component not working in gatsby - Element type is invalid: expected a string or a class/function but got: undefined 带有 gatsby-plugin-image 的引导卡 ImgOverlay 未按预期调整大小 - Bootstrap Card ImgOverlay with gatsby-plugin-image not rezizing as expected Gatsby 插件错误 Gatsby-Source-Wordpress - Error with Gatsby plugin Gatsby-Source-Wordpress 将 create-react-app 转换为 Gatsby 后出错。 WEBPACK:浏览器查询必须是数组或字符串。 有对象 - Error after converting create-react-app to Gatsby. WEBPACK: Browser queries must be an array or string. Got object Gatsby中的对象内的道具 - Props inside object in Gatsby 如何使用 Eslint 在 Gatsby 中使用绝对导入? - How to use absolute imports in Gatsby with Eslint? gatsby-image-plugin 和内容丰富 - gatsby-image-plugin and contentful Gatsby插件MDX和组件无法正常工作 - Gatsby plugin MDX and components not working Gatsby 本地插件构建崩溃 - Gatsby Local Plugin Build Crash
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM