Skip to content

Commit f2bae3a

Browse files
yannbfandrelas1
andcommitted
fix(no-uninstalled-addons): restrict rule to .storybook folder
And add a section on how to configure if users have a custom config directory Co-authored-by: Andre Santos <[email protected]>
1 parent 567e208 commit f2bae3a

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,11 @@ And finally, add this to your `.eslintignore` file:
5353
```
5454
// Inside your .eslintignore file
5555
!.storybook
56-
!.storybook/*
5756
```
5857

5958
This allows for this plugin to also lint your configuration files inside the .storybook folder, so that you always have a correct configuration and don't face any issues regarding mistyped addon names, for instance.
6059

61-
For more info on why these lines are required in the .eslintignore file, check this [ESLint documentation](https://eslint.org/docs/latest/user-guide/configuring/ignoring-code#:~:text=In%20addition%20to,contents%2C%20are%20ignored).
60+
> For more info on why this line is required in the .eslintignore file, check this [ESLint documentation](https://eslint.org/docs/latest/user-guide/configuring/ignoring-code#:~:text=In%20addition%20to,contents%2C%20are%20ignored).
6261
6362
## Usage
6463

docs/rules/no-uninstalled-addons.md

+17-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ Another very important side note: your ESLint config must allow the linting of t
1919
```
2020
// Inside your .eslintignore file
2121
!.storybook
22-
.storybook/*
23-
!.storybook/main.js
2422
```
2523

2624
For more info, check this [ESLint documentation](https://eslint.org/docs/latest/user-guide/configuring/ignoring-code#:~:text=In%20addition%20to,contents%2C%20are%20ignored).
@@ -33,7 +31,7 @@ module.exports = {
3331
addons: [
3432
'@storybook/addon-links',
3533
'@storybook/addon-essentials',
36-
'@storybook/addon-interactions',
34+
'@storybook/addon-interactions', // <-- this addon is not listed in the package.json
3735
],
3836
}
3937

@@ -69,7 +67,22 @@ module.exports = {
6967
}
7068
```
7169
72-
### Options
70+
### Configure
71+
72+
Some Storybook folders use a different name for their config directory other than `.storybook`. This rule will not be applied there by default. If you want to have it, then you must add an override in your `.eslintrc.js` file, defining your config directory:
73+
74+
```js
75+
{
76+
overrides: [
77+
{
78+
files: ['your-config-dir/main.@(js|cjs|mjs|ts)'],
79+
rules: {
80+
'storybook/no-uninstalled-addons': 'error',
81+
},
82+
},
83+
],
84+
}
85+
```
7386
7487
## When Not To Use It
7588

lib/rules/no-uninstalled-addons.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @fileoverview This rule identifies storybook addons that are invalid because they are either not installed or contain a typo in their name.
3-
* @author Andre Santos
3+
* @author Andre "andrelas1" Santos
44
*/
55

66
import { readFileSync } from 'fs'

tools/update-configs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const STORIES_GLOBS = [
4646
]
4747

4848
// Other files that will be linted
49-
const MAIN_JS_FILE = [`'main.@(js|cjs|mjs|ts)'`]
49+
const MAIN_JS_FILE = [`'.storybook/main.@(js|cjs|mjs|ts)'`]
5050

5151
function formatCategory(category: TCategory) {
5252
const extendsCategoryId = extendsCategories[category.categoryId]

0 commit comments

Comments
 (0)