diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 15a7991..ba6e693 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,6 +3,7 @@ - [1. About the Project](#about-the-project) - [2. Getting Started](#getting-started) - [2.1. Creating a new rule](#creating-a-new-rule) + - [2.1.1. Important metadata for a rule](#important-metadata-for-a-rule) - [2.2. Testing rules](#testing-rules) - [2.3. Updating configs or documentation](#updating-configs-or-documentation) - [3. Useful resources](#useful-resources) @@ -34,6 +35,25 @@ tests/lib/rules/.js This command will auto-generate the test file with an example for you. Please refer to existing tests if more reference is needed. +#### Important metadata for a rule + +```js +const { docsUrl } = require('../utils') +const { CATEGORY_ID } = require('../utils/constants') + +module.exports = { + meta: { + docs: { + category: CATEGORY_ID.CSF, // You should always use an existing category from the CATEGORY_ID enum, or create a new one there + recommended: true, // When setting to true, the rule will be part of plugin:storybook/recommended + excludeFromConfig: true, // If the rule is not ready to be shipped in any category, set this flag to true, otherwise remove it + url: docsUrl('meta-inline-properties'), // Every rule must have a URL to the documentation page. Use docsUrl to build it + }, + }, + ...otherProperties, +} +``` + ### Testing rules Run the following command for testing the rules: diff --git a/README.md b/README.md index d05e6a5..d11973f 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,6 @@ Another approach for customizing ESLint config by paths is through [ESLint Casca | [`storybook/csf-component`](./docs/rules/csf-component.md) | The component property should be set | | csf | | [`storybook/default-exports`](./docs/rules/default-exports.md) | Story files should have a default export | | csf, recommended | | [`storybook/hierarchy-separator`](./docs/rules/hierarchy-separator.md) | Deprecated hierachy separator in title property | 🔧 | csf, recommended | -| [`storybook/meta-inline-properties`](./docs/rules/meta-inline-properties.md) | Meta should only have inline properties | | csf-strict | | [`storybook/no-redundant-story-name`](./docs/rules/no-redundant-story-name.md) | A story should not have a redundant name property | 🔧 | csf, recommended | | [`storybook/no-stories-of`](./docs/rules/no-stories-of.md) | storiesOf is deprecated and should not be used | | csf-strict | | [`storybook/no-title-property-in-meta`](./docs/rules/no-title-property-in-meta.md) | Do not define a title in meta | 🔧 | csf-strict | diff --git a/lib/configs/csf-strict.js b/lib/configs/csf-strict.js index 78fc1ab..fe4c967 100644 --- a/lib/configs/csf-strict.js +++ b/lib/configs/csf-strict.js @@ -7,12 +7,6 @@ module.exports = { extends: require.resolve('./csf'), rules: { 'import/no-anonymous-default-export': 'off', - 'storybook/meta-inline-properties': [ - 'error', - { - csfVersion: 3, - }, - ], 'storybook/no-stories-of': 'error', 'storybook/no-title-property-in-meta': 'error', }, diff --git a/lib/rules/meta-inline-properties.js b/lib/rules/meta-inline-properties.js index e61d45e..359d1d9 100644 --- a/lib/rules/meta-inline-properties.js +++ b/lib/rules/meta-inline-properties.js @@ -16,8 +16,9 @@ module.exports = { type: 'problem', docs: { description: 'Meta should only have inline properties', - category: CATEGORY_ID.CSF_STRICT, - recommended: false, + category: CATEGORY_ID.CSF, + recommended: true, + excludeFromConfig: true, recommendedConfig: ['error', { csfVersion: 3 }], url: docsUrl('meta-inline-properties'), // URL to the documentation page for this rule }, diff --git a/tools/utils/rules.js b/tools/utils/rules.js index 2bcc8b7..dc7e878 100644 --- a/tools/utils/rules.js +++ b/tools/utils/rules.js @@ -29,3 +29,5 @@ module.exports = fs meta, } }) + // We might have rules which are almost ready but should not be shipped + .filter((rule) => !rule.meta.docs.excludeFromConfig)