diff --git a/code/lib/eslint-plugin/scripts/update-lib-configs.ts b/code/lib/eslint-plugin/scripts/update-lib-configs.ts index c122dfeab948..067aac41ce5e 100644 --- a/code/lib/eslint-plugin/scripts/update-lib-configs.ts +++ b/code/lib/eslint-plugin/scripts/update-lib-configs.ts @@ -50,7 +50,10 @@ function formatCategory(category: TCategory) { // This file is bundled in an index.js file at the root // so the reference is relative to the src directory extends: './configs/${extendsCategoryId}', - rules: ${formatRules(category.rules)} + overrides: [{ + files: [${STORIES_GLOBS.join(', ')}], + rules: ${formatRules(category.rules)} + },] } `; } diff --git a/code/lib/eslint-plugin/scripts/update-lib-flat-configs.ts b/code/lib/eslint-plugin/scripts/update-lib-flat-configs.ts index b5d9cc662933..e36b5193e2b3 100644 --- a/code/lib/eslint-plugin/scripts/update-lib-flat-configs.ts +++ b/code/lib/eslint-plugin/scripts/update-lib-flat-configs.ts @@ -64,6 +64,7 @@ function formatCategory(category: TCategory) { ...config, { name: 'storybook:${category.categoryId}:rules', + files: [${STORIES_GLOBS.join(', ')}], rules: ${formatRules(category.rules)} } ] diff --git a/code/lib/eslint-plugin/src/configs/csf-strict.ts b/code/lib/eslint-plugin/src/configs/csf-strict.ts index 5a99039d9287..ca88aaaf6ad7 100644 --- a/code/lib/eslint-plugin/src/configs/csf-strict.ts +++ b/code/lib/eslint-plugin/src/configs/csf-strict.ts @@ -7,10 +7,15 @@ export default { // This file is bundled in an index.js file at the root // so the reference is relative to the src directory extends: './configs/csf', - rules: { - 'react-hooks/rules-of-hooks': 'off', - 'import/no-anonymous-default-export': 'off', - 'storybook/no-stories-of': 'error', - 'storybook/no-title-property-in-meta': 'error', - } as const, + overrides: [ + { + files: ['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '**/*.story.@(ts|tsx|js|jsx|mjs|cjs)'], + rules: { + 'react-hooks/rules-of-hooks': 'off', + 'import/no-anonymous-default-export': 'off', + 'storybook/no-stories-of': 'error', + 'storybook/no-title-property-in-meta': 'error', + } as const, + }, + ], }; diff --git a/code/lib/eslint-plugin/src/configs/flat/csf-strict.ts b/code/lib/eslint-plugin/src/configs/flat/csf-strict.ts index bfffc92a693a..32f41846e314 100644 --- a/code/lib/eslint-plugin/src/configs/flat/csf-strict.ts +++ b/code/lib/eslint-plugin/src/configs/flat/csf-strict.ts @@ -9,6 +9,7 @@ export default [ ...config, { name: 'storybook:csf-strict:rules', + files: ['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '**/*.story.@(ts|tsx|js|jsx|mjs|cjs)'], rules: { 'react-hooks/rules-of-hooks': 'off', 'import/no-anonymous-default-export': 'off',