From 9b3f6b3e5bcd87d9a0e7dbd0eeb36afc1e6c5fad Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Mon, 4 Nov 2024 09:54:19 +0100 Subject: [PATCH] Update docs to be more clear about extended categories --- README.md | 32 +++++++++++++-------------- docs/rules/csf-component.md | 2 +- docs/rules/default-exports.md | 2 +- docs/rules/hierarchy-separator.md | 2 +- docs/rules/no-redundant-story-name.md | 2 +- docs/rules/story-exports.md | 2 +- tools/update-rules-list.ts | 18 +++++++++++++-- 7 files changed, 37 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 4843f46..291b828 100644 --- a/README.md +++ b/README.md @@ -162,22 +162,22 @@ This plugin does not support MDX files. **Configurations**: csf, csf-strict, addon-interactions, recommended -| Name | Description | 🔧 | Included in configurations | -| ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | --- | ----------------------------------------------------------------------------------------------------------------- | -| [`storybook/await-interactions`](./docs/rules/await-interactions.md) | Interactions should be awaited | 🔧 | | -| [`storybook/context-in-play-function`](./docs/rules/context-in-play-function.md) | Pass a context when invoking play function of another story | | | -| [`storybook/csf-component`](./docs/rules/csf-component.md) | The component property should be set | | | -| [`storybook/default-exports`](./docs/rules/default-exports.md) | Story files should have a default export | 🔧 | | -| [`storybook/hierarchy-separator`](./docs/rules/hierarchy-separator.md) | Deprecated hierarchy separator in title property | 🔧 | | -| [`storybook/meta-inline-properties`](./docs/rules/meta-inline-properties.md) | Meta should only have inline properties | | N/A | -| [`storybook/no-redundant-story-name`](./docs/rules/no-redundant-story-name.md) | A story should not have a redundant name property | 🔧 | | -| [`storybook/no-stories-of`](./docs/rules/no-stories-of.md) | storiesOf is deprecated and should not be used | | | -| [`storybook/no-title-property-in-meta`](./docs/rules/no-title-property-in-meta.md) | Do not define a title in meta | 🔧 | | -| [`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. | | | -| [`storybook/prefer-pascal-case`](./docs/rules/prefer-pascal-case.md) | Stories should use PascalCase | 🔧 | | -| [`storybook/story-exports`](./docs/rules/story-exports.md) | A story file must contain at least one story export | | | -| [`storybook/use-storybook-expect`](./docs/rules/use-storybook-expect.md) | Use expect from `@storybook/test` or `@storybook/jest` | 🔧 | | -| [`storybook/use-storybook-testing-library`](./docs/rules/use-storybook-testing-library.md) | Do not use testing-library directly on stories | 🔧 | | +| Name | Description | 🔧 | Included in configurations | +| ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | --- | ------------------------------------------------------------------------------------------------------------------------------ | +| [`storybook/await-interactions`](./docs/rules/await-interactions.md) | Interactions should be awaited | 🔧 | | +| [`storybook/context-in-play-function`](./docs/rules/context-in-play-function.md) | Pass a context when invoking play function of another story | | | +| [`storybook/csf-component`](./docs/rules/csf-component.md) | The component property should be set | | | +| [`storybook/default-exports`](./docs/rules/default-exports.md) | Story files should have a default export | 🔧 | | +| [`storybook/hierarchy-separator`](./docs/rules/hierarchy-separator.md) | Deprecated hierarchy separator in title property | 🔧 | | +| [`storybook/meta-inline-properties`](./docs/rules/meta-inline-properties.md) | Meta should only have inline properties | | N/A | +| [`storybook/no-redundant-story-name`](./docs/rules/no-redundant-story-name.md) | A story should not have a redundant name property | 🔧 | | +| [`storybook/no-stories-of`](./docs/rules/no-stories-of.md) | storiesOf is deprecated and should not be used | | | +| [`storybook/no-title-property-in-meta`](./docs/rules/no-title-property-in-meta.md) | Do not define a title in meta | 🔧 | | +| [`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. | | | +| [`storybook/prefer-pascal-case`](./docs/rules/prefer-pascal-case.md) | Stories should use PascalCase | 🔧 | | +| [`storybook/story-exports`](./docs/rules/story-exports.md) | A story file must contain at least one story export | | | +| [`storybook/use-storybook-expect`](./docs/rules/use-storybook-expect.md) | Use expect from `@storybook/test` or `@storybook/jest` | 🔧 | | +| [`storybook/use-storybook-testing-library`](./docs/rules/use-storybook-testing-library.md) | Do not use testing-library directly on stories | 🔧 | | diff --git a/docs/rules/csf-component.md b/docs/rules/csf-component.md index 2a71b7f..5878fac 100644 --- a/docs/rules/csf-component.md +++ b/docs/rules/csf-component.md @@ -2,7 +2,7 @@ -**Included in these configurations**: +**Included in these configurations**: diff --git a/docs/rules/default-exports.md b/docs/rules/default-exports.md index 7de9d6c..072618c 100644 --- a/docs/rules/default-exports.md +++ b/docs/rules/default-exports.md @@ -2,7 +2,7 @@ -**Included in these configurations**: +**Included in these configurations**: diff --git a/docs/rules/hierarchy-separator.md b/docs/rules/hierarchy-separator.md index 4d42160..94f3996 100644 --- a/docs/rules/hierarchy-separator.md +++ b/docs/rules/hierarchy-separator.md @@ -2,7 +2,7 @@ -**Included in these configurations**: +**Included in these configurations**: diff --git a/docs/rules/no-redundant-story-name.md b/docs/rules/no-redundant-story-name.md index 85e01ca..7a0f09f 100644 --- a/docs/rules/no-redundant-story-name.md +++ b/docs/rules/no-redundant-story-name.md @@ -2,7 +2,7 @@ -**Included in these configurations**: +**Included in these configurations**: diff --git a/docs/rules/story-exports.md b/docs/rules/story-exports.md index ae4f95e..3e8666a 100644 --- a/docs/rules/story-exports.md +++ b/docs/rules/story-exports.md @@ -2,7 +2,7 @@ -**Included in these configurations**: +**Included in these configurations**: diff --git a/tools/update-rules-list.ts b/tools/update-rules-list.ts index 2d3f9d6..76f0811 100644 --- a/tools/update-rules-list.ts +++ b/tools/update-rules-list.ts @@ -1,6 +1,7 @@ import rules from './utils/rules' import { emojiKey, writeRulesListInReadme, updateRulesDocs } from './utils/docs' +import { extendsCategories } from './utils/updates' /* This script updates the rules table in `README.md`from rule's meta data. @@ -25,6 +26,19 @@ const rulesList: TRulesList[] = Object.entries(rules) return ruleNameA.localeCompare(ruleNameB) }) .map(([_, rule]) => { + const ruleCategories: string[] = rule.meta.docs?.categories ?? [] + const extendedCategories: string[] = [] + + Object.entries(extendsCategories).map(([category, extendedCategory]) => { + if ( + extendedCategory && + !ruleCategories.includes(category) && + ruleCategories.includes(extendedCategory) + ) { + ruleCategories.push(category) + } + }) + return [ rule.name, createRuleLink(rule.name), @@ -32,8 +46,8 @@ const rulesList: TRulesList[] = Object.entries(rules) rule.meta.fixable ? emojiKey.fixable : '', rule.meta.docs?.excludeFromConfig ? 'N/A' - : rule.meta.docs?.categories - ? `` + : ruleCategories + ? `` : '', ] })