'How to break eslint or webpack build if any component has imported data from ./Stories/* folder

We have a React/TS project which bacame too big. In this project we use eslint (airbnb) and StoryBook.

Our components structure is:

  • /Stories <-- folder for StoryBook
  • /Helpers <-- getters and setters
  • /Languages <-- i18n and translation
  • Component.tsx

We'd like to have a way to create a custom rule for eslint to thrown an error if import contains Stories in file name or break the webpack build and throw an error if for an accident we import a fake method from /Strories/* folder into the Component.tsx (rather than importing from /Helpers/*).

The eslint would work fine for us as we run the lint command before the build in DevOps pipeline.

Thanks a lot.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source