You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+73-18
Original file line number
Diff line number
Diff line change
@@ -59,9 +59,23 @@ This allows for this plugin to also lint your configuration files inside the .st
59
59
60
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).
61
61
62
+
If you are using [flat config style](https://eslint.org/docs/latest/use/configure/configuration-files-new), add this to your configuration file:
63
+
64
+
```js
65
+
exportdefault [
66
+
// ...
67
+
{
68
+
// Inside your .eslintignore file
69
+
ignores: ['!.storybook'],
70
+
},
71
+
]
72
+
```
73
+
62
74
## Usage
63
75
64
-
Use `.eslintrc.*` file to configure rules. See also: https://eslint.org/docs/user-guide/configuring
76
+
### Configuration (`.eslintrc`)
77
+
78
+
Use `.eslintrc.*` file to configure rules in ESLint < v9. See also: https://eslint.org/docs/latest/use/configure/.
65
79
66
80
Add `plugin:storybook/recommended` to the extends section of your `.eslintrc` configuration file. Note that we can omit the `eslint-plugin-` prefix:
67
81
@@ -74,7 +88,7 @@ Add `plugin:storybook/recommended` to the extends section of your `.eslintrc` co
74
88
75
89
This plugin will only be applied to files following the `*.stories.*` (we recommend this) or `*.story.*` pattern. This is an automatic configuration, so you don't have to do anything.
76
90
77
-
### Overriding/disabling rules
91
+
####Overriding/disabling rules
78
92
79
93
Optionally, you can override, add or disable rules settings. You likely don't want these settings to be applied in every file, so make sure that you add a `overrides` section in your `.eslintrc.*` file that applies the overrides only to your stories files.
80
94
@@ -83,7 +97,7 @@ Optionally, you can override, add or disable rules settings. You likely don't wa
83
97
"overrides": [
84
98
{
85
99
// or whatever matches stories specified in .storybook/main.js
@@ -95,6 +109,47 @@ Optionally, you can override, add or disable rules settings. You likely don't wa
95
109
}
96
110
```
97
111
112
+
### Configuration (`eslint.config.[c|m]?js`)
113
+
114
+
Use `eslint.config.[c|m]?js` file to configure rules. This is the default in ESLint v9, but can be used starting from ESLint v8.57.0. See also: https://eslint.org/docs/latest/use/configure/configuration-files-new.
115
+
116
+
```js
117
+
importstorybookfrom'eslint-plugin-storybook'
118
+
119
+
exportdefault [
120
+
// add more generic rulesets here, such as:
121
+
// js.configs.recommended,
122
+
...storybook.configs['flat/recommended'],
123
+
124
+
// something ...
125
+
]
126
+
```
127
+
128
+
#### Overriding/disabling rules
129
+
130
+
Optionally, you can override, add or disable rules settings. You likely don't want these settings to be applied in every file, so make sure that you add a flat config section in your `eslint.config.[m|c]?js` file that applies the overrides only to your stories files.
131
+
132
+
```js
133
+
importstorybookfrom'eslint-plugin-storybook'
134
+
135
+
exportdefault [
136
+
// ...
137
+
138
+
...storybook.configs['flat/recommended'],
139
+
{
140
+
files: ['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)'],
141
+
rules: {
142
+
// example of overriding a rule
143
+
'storybook/hierarchy-separator':'error',
144
+
// example of disabling a rule
145
+
'storybook/default-exports':'off',
146
+
},
147
+
},
148
+
149
+
// something ...
150
+
]
151
+
```
152
+
98
153
### MDX Support
99
154
100
155
This plugin does not support MDX files.
@@ -107,21 +162,21 @@ This plugin does not support MDX files.
|[`storybook/await-interactions`](./docs/rules/await-interactions.md)| Interactions should be awaited | 🔧 | <ul><li>addon-interactions</li><li>recommended</li></ul> |
113
-
|[`storybook/context-in-play-function`](./docs/rules/context-in-play-function.md)| Pass a context when invoking play function of another story || <ul><li>recommended</li><li>addon-interactions</li></ul> |
114
-
|[`storybook/csf-component`](./docs/rules/csf-component.md)| The component property should be set || <ul><li>csf</li></ul> |
115
-
|[`storybook/default-exports`](./docs/rules/default-exports.md)| Story files should have a default export | 🔧 | <ul><li>csf</li><li>recommended</li></ul> |
116
-
|[`storybook/hierarchy-separator`](./docs/rules/hierarchy-separator.md)| Deprecated hierarchy separator in title property | 🔧 | <ul><li>csf</li><li>recommended</li></ul> |
117
-
|[`storybook/no-redundant-story-name`](./docs/rules/no-redundant-story-name.md)| A story should not have a redundant name property | 🔧 | <ul><li>csf</li><li>recommended</li></ul> |
118
-
|[`storybook/no-stories-of`](./docs/rules/no-stories-of.md)| storiesOf is deprecated and should not be used || <ul><li>csf-strict</li></ul> |
119
-
|[`storybook/no-title-property-in-meta`](./docs/rules/no-title-property-in-meta.md)| Do not define a title in meta | 🔧 | <ul><li>csf-strict</li></ul> |
120
-
|[`storybook/no-uninstalled-addons`](./docs/rules/no-uninstalled-addons.md)| This rule identifies storybook addons that are invalid because they are either not installed or contain a typo in their name. || <ul><li>recommended</li></ul> |
121
-
|[`storybook/prefer-pascal-case`](./docs/rules/prefer-pascal-case.md)| Stories should use PascalCase | 🔧 | <ul><li>recommended</li></ul> |
122
-
|[`storybook/story-exports`](./docs/rules/story-exports.md)| A story file must contain at least one story export || <ul><li>recommended</li><li>csf</li></ul> |
123
-
|[`storybook/use-storybook-expect`](./docs/rules/use-storybook-expect.md)| Use expect from `@storybook/jest`| 🔧 | <ul><li>addon-interactions</li><li>recommended</li></ul> |
124
-
|[`storybook/use-storybook-testing-library`](./docs/rules/use-storybook-testing-library.md)| Do not use testing-library directly on stories | 🔧 | <ul><li>addon-interactions</li><li>recommended</li></ul> |
165
+
| Name | Description | 🔧 | Included in configurations |
|[`storybook/await-interactions`](./docs/rules/await-interactions.md)| Interactions should be awaited | 🔧 | <ul><li>addon-interactions</li><li>flat/addon-interactions</li><li>recommended</li><li>flat/recommended</li></ul> |
168
+
|[`storybook/context-in-play-function`](./docs/rules/context-in-play-function.md)| Pass a context when invoking play function of another story || <ul><li>recommended</li><li>flat/recommended</li><li>addon-interactions</li><li>flat/addon-interactions</li></ul> |
169
+
|[`storybook/csf-component`](./docs/rules/csf-component.md)| The component property should be set || <ul><li>csf</li><li>flat/csf</li></ul>|
170
+
|[`storybook/default-exports`](./docs/rules/default-exports.md)| Story files should have a default export | 🔧 | <ul><li>csf</li><li>flat/csf</li><li>recommended</li><li>flat/recommended</li></ul>|
171
+
|[`storybook/hierarchy-separator`](./docs/rules/hierarchy-separator.md)| Deprecated hierarchy separator in title property | 🔧 | <ul><li>csf</li><li>flat/csf</li><li>recommended</li><li>flat/recommended</li></ul>|
172
+
|[`storybook/no-redundant-story-name`](./docs/rules/no-redundant-story-name.md)| A story should not have a redundant name property | 🔧 | <ul><li>csf</li><li>flat/csf</li><li>recommended</li><li>flat/recommended</li></ul>|
173
+
|[`storybook/no-stories-of`](./docs/rules/no-stories-of.md)| storiesOf is deprecated and should not be used || <ul><li>csf-strict</li><li>flat/csf-strict</li></ul>|
174
+
|[`storybook/no-title-property-in-meta`](./docs/rules/no-title-property-in-meta.md)| Do not define a title in meta | 🔧 | <ul><li>csf-strict</li><li>flat/csf-strict</li></ul>|
175
+
|[`storybook/no-uninstalled-addons`](./docs/rules/no-uninstalled-addons.md)| This rule identifies storybook addons that are invalid because they are either not installed or contain a typo in their name. || <ul><li>recommended</li><li>flat/recommended</li></ul>|
176
+
|[`storybook/prefer-pascal-case`](./docs/rules/prefer-pascal-case.md)| Stories should use PascalCase | 🔧 | <ul><li>recommended</li><li>flat/recommended</li></ul>|
177
+
|[`storybook/story-exports`](./docs/rules/story-exports.md)| A story file must contain at least one story export || <ul><li>recommended</li><li>flat/recommended</li><li>csf</li><li>flat/csf</li></ul>|
178
+
|[`storybook/use-storybook-expect`](./docs/rules/use-storybook-expect.md)| Use expect from `@storybook/jest`| 🔧 | <ul><li>addon-interactions</li><li>flat/addon-interactions</li><li>recommended</li><li>flat/recommended</li></ul> |
179
+
|[`storybook/use-storybook-testing-library`](./docs/rules/use-storybook-testing-library.md)| Do not use testing-library directly on stories | 🔧 | <ul><li>addon-interactions</li><li>flat/addon-interactions</li><li>recommended</li><li>flat/recommended</li></ul> |
Copy file name to clipboardExpand all lines: docs/rules/await-interactions.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
<!-- RULE-CATEGORIES:START -->
4
4
5
-
**Included in these configurations**: <ul><li>addon-interactions</li><li>recommended</li></ul>
5
+
**Included in these configurations**: <ul><li>addon-interactions</li><li>flat/addon-interactions</li><li>recommended</li><li>flat/recommended</li></ul>
Copy file name to clipboardExpand all lines: docs/rules/context-in-play-function.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
<!-- RULE-CATEGORIES:START -->
4
4
5
-
**Included in these configurations**: <ul><li>recommended</li><li>addon-interactions</li></ul>
5
+
**Included in these configurations**: <ul><li>recommended</li><li>flat/recommended</li><li>addon-interactions</li><li>flat/addon-interactions</li></ul>
0 commit comments