简体   繁体   English

在 Storybook js 中找不到规则“@typescript-eslint/no-implicit-any”的定义

[英]Definition for rule '@typescript-eslint/no-implicit-any' was not found with Storybook js

I am getting this error when I make changes to the generated code from running Storybook.js .当我通过运行Storybook.js更改生成的代码时出现此错误。 These are the instructions I am following这些是我遵循的说明

https://gist.github.com/shilman/bc9cbedb2a7efb5ec6710337cbd20c0c https://gist.github.com/shilman/bc9cbedb2a7efb5ec6710337cbd20c0c

But because I am adding StorybookJS to an existing project, the only commands I've ran are:但是因为我将StorybookJS添加到现有项目中,所以我运行的唯一命令是:

$ npx -p @storybook/cli@next sb init --story-format=csf-ts
$ yarn add @storybook/addon-docs@next --dev

Running yarn storybook produces this error.运行yarn storybook会产生此错误。

ERROR in ./src/stories/0-Welcome.stories.tsx
Module Error (from ./node_modules/eslint-loader/dist/cjs.js):

  Line 5:1:   Definition for rule '@typescript-eslint/no-implicit-any' was not found  @typescript-eslint/no-implicit-any
  Line 24:1:  Definition for rule '@typescript-eslint/no-implicit-any' was not found  @typescript-eslint/no-implicit-any

The storybook server runs fine but as soon as I make changes to some text and Storybook tries to reload the changes, I get the error seen above. Storybook服务器运行良好,但是一旦我对某些文本进行更改并且Storybook尝试重新加载更改,我就会收到上面看到的错误。

There is a lot of magic that happens behind the scenes of create-react-app so I am unaware of how to pinpoint and fix this error. create-react-app的幕后发生了很多魔法,所以我不知道如何查明和修复这个错误。 My guess is that a eslint typescript rule is missing so upon Storybook reloading any type of change, the missing rule error occurs我的猜测是缺少eslint typescript rule ,因此在Storybook重新加载任何类型的更改时,会发生缺少规则的错误

在此处输入图片说明

It sounds like you're missing the .eslintrc.json file which describes the rules.听起来您缺少描述规则的.eslintrc.json文件。 You can read more about the file format and options here: https://eslint.org/docs/user-guide/configuring您可以在此处阅读有关文件格式和选项的更多信息: https : //eslint.org/docs/user-guide/configuring

Example:例子:

{
    "parserOptions": {
        "ecmaVersion": 6,
        "sourceType": "module",
        "ecmaFeatures": {
            "jsx": true
        }
    },
    "rules": {
        "semi": "error"
    }
}

If the error still occurs, try configuring the no-implicit-any rule.如果错误仍然出现,请尝试配置no-implicit-any规则。

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

相关问题 如何解决“未找到规则‘@typescript-eslint/rule-name’的定义” - How to resolve "Definition for rule '@typescript-eslint/rule-name' was not found" 加载规则“@typescript-eslint/dot-notation”时出错 - Error while loading rule '@typescript-eslint/dot-notation' @typescript-eslint/no-unsafe-assignment:任何值的不安全赋值 - @typescript-eslint/no-unsafe-assignment: Unsafe assignment of an any value Typescript:ESLint:任何类型值的不安全返回 @typescript-eslint/no-unsafe-return - Typescript : ESLint : Unsafe return of an any typed value @typescript-eslint/no-unsafe-return eslint 缩进和@typescript-eslint/indent 冲突 - eslint indent and @typescript-eslint/indent conflict 如何处理 catch(err) 块上的 @typescript-eslint/no-unsafe-member-access 规则? - How to handle the @typescript-eslint/no-unsafe-member-access rule on catch(err) blocks? 如何在 VSCode 中的同一项目中的 .ts 文件和 .js 文件上运行 typescript-eslint - How to run typescript-eslint on .ts files and eslint on .js files in the same project in VSCode ESLint 无法识别“@typescript-eslint/eslint-plugin” - ESLint is not recognizing "@typescript-eslint/eslint-plugin" (ESLint) 未找到规则“re​​act/jsx-sort-prop-types”的定义 - (ESLint) Definition for rule 'react/jsx-sort-prop-types' was not found angular-eslint 和 typescript-eslint 之间的区别 - Difference between angular-eslint and typescript-eslint
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM