Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add exclude rule flag #13

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -34,6 +35,25 @@ tests/lib/rules/<rule-name>.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:
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
6 changes: 0 additions & 6 deletions lib/configs/csf-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
5 changes: 3 additions & 2 deletions lib/rules/meta-inline-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
2 changes: 2 additions & 0 deletions tools/utils/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)