admin管理员组

文章数量:1431426

I am getting this error when I make changes to the generated code from running Storybook.js. These are the instructions I am following

But because I am adding StorybookJS to an existing project, the only mands I've ran are:

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

Running yarn storybook produces this error.

ERROR in ./src/stories/0-Wele.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.

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. My guess is that a eslint typescript rule is missing so upon Storybook reloading any type of change, the missing rule error occurs

I am getting this error when I make changes to the generated code from running Storybook.js. These are the instructions I am following

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

But because I am adding StorybookJS to an existing project, the only mands I've ran are:

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

Running yarn storybook produces this error.

ERROR in ./src/stories/0-Wele.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.

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. My guess is that a eslint typescript rule is missing so upon Storybook reloading any type of change, the missing rule error occurs

Share Improve this question edited Jan 1, 2020 at 3:26 Liondancer asked Dec 31, 2019 at 23:29 LiondancerLiondancer 16.5k54 gold badges163 silver badges263 bronze badges 9
  • Have you seen this? github./typescript-eslint/typescript-eslint/issues/379 Also, if you can find the json file for you eslint, you can just add the rule to see if that resolves. – mwilson Commented Dec 31, 2019 at 23:34
  • @mwilson With create-react-app I think the .eslintrc file is hidden from me. So I just have to find that JSON file and add the rule? – Liondancer Commented Dec 31, 2019 at 23:37
  • Yea, I'm not sure if that app uses something different, but usually there is a file called tslint.json which is just a json file with TypeScript lint rules. If you have this in a repo somewhere, I can take a look – mwilson Commented Dec 31, 2019 at 23:38
  • The error message is kind of confusing though. ES screams JavaScript, but no-implicit-any is a TypeScript thing. Since it's hanging off the @typescript-eslint path, I'm assuming you're working with TypeScript – mwilson Commented Dec 31, 2019 at 23:40
  • 1 @mwilson I added .eslintrc.json and it worked! You answer the question and I will mark it! Thank you! – Liondancer Commented Jan 1, 2020 at 5:25
 |  Show 4 more ments

1 Answer 1

Reset to default 3

It sounds like you're missing the .eslintrc.json file which describes the rules. You can read more about the file format and options here: https://eslint/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.

本文标签: