Skip to content

Commit 7c02ffd

Browse files
yannbfstorybook-bot
authored andcommitted
Merge pull request #31963 from cylewaitforit/csf-strict-on-stories-files
ESLint: Only apply csf-strict rules on stories files (cherry picked from commit d1b4c2f)
1 parent c77e1be commit 7c02ffd

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

code/lib/eslint-plugin/scripts/update-lib-configs.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ function formatCategory(category: TCategory) {
5050
// This file is bundled in an index.js file at the root
5151
// so the reference is relative to the src directory
5252
extends: './configs/${extendsCategoryId}',
53-
rules: ${formatRules(category.rules)}
53+
overrides: [{
54+
files: [${STORIES_GLOBS.join(', ')}],
55+
rules: ${formatRules(category.rules)}
56+
},]
5457
}
5558
`;
5659
}

code/lib/eslint-plugin/scripts/update-lib-flat-configs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ function formatCategory(category: TCategory) {
6464
...config,
6565
{
6666
name: 'storybook:${category.categoryId}:rules',
67+
files: [${STORIES_GLOBS.join(', ')}],
6768
rules: ${formatRules(category.rules)}
6869
}
6970
]

code/lib/eslint-plugin/src/configs/csf-strict.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ export default {
77
// This file is bundled in an index.js file at the root
88
// so the reference is relative to the src directory
99
extends: './configs/csf',
10-
rules: {
11-
'react-hooks/rules-of-hooks': 'off',
12-
'import/no-anonymous-default-export': 'off',
13-
'storybook/no-stories-of': 'error',
14-
'storybook/no-title-property-in-meta': 'error',
15-
} as const,
10+
overrides: [
11+
{
12+
files: ['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '**/*.story.@(ts|tsx|js|jsx|mjs|cjs)'],
13+
rules: {
14+
'react-hooks/rules-of-hooks': 'off',
15+
'import/no-anonymous-default-export': 'off',
16+
'storybook/no-stories-of': 'error',
17+
'storybook/no-title-property-in-meta': 'error',
18+
} as const,
19+
},
20+
],
1621
};

code/lib/eslint-plugin/src/configs/flat/csf-strict.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default [
99
...config,
1010
{
1111
name: 'storybook:csf-strict:rules',
12+
files: ['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '**/*.story.@(ts|tsx|js|jsx|mjs|cjs)'],
1213
rules: {
1314
'react-hooks/rules-of-hooks': 'off',
1415
'import/no-anonymous-default-export': 'off',

0 commit comments

Comments
 (0)