Skip to content

fix(csf-strict): apply csf-strict rules on stories files #201

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
build
dist
node_modules
pnpm-lock.yaml
17 changes: 11 additions & 6 deletions lib/configs/csf-strict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
*/
export = {
extends: require.resolve('./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,
},
],
}
1 change: 1 addition & 0 deletions lib/configs/flat/csf-strict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export = [
...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',
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"test:integration": "jest --config jest.integration.config.js --testTimeout 60000",
"test:ci": "tsc --noEmit && pnpm run test:unit --ci && pnpm run test:integration --ci",
"update-all": "pnpm run update-configs && pnpm run update-docs",
"update-configs": "ts-node ./tools/update-configs",
"update-docs": "ts-node ./tools/update-rules-list"
"update-configs": "ts-node ./tools/update-configs.ts",
"update-docs": "ts-node ./tools/update-rules-list.ts"
},
"lint-staged": {
"*.js": "eslint --cache --fix",
Expand Down
5 changes: 4 additions & 1 deletion tools/update-lib-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ function formatCategory(category: TCategory) {
*/
export = {
extends: require.resolve('./${extendsCategoryId}'),
rules: ${formatRules(category.rules)}
overrides: [{
files: [${STORIES_GLOBS.join(', ')}],
rules: ${formatRules(category.rules)}
},]
}
`
}
Expand Down
1 change: 1 addition & 0 deletions tools/update-lib-flat-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function formatCategory(category: TCategory) {
...config,
{
name: 'storybook:${category.categoryId}:rules',
files: [${STORIES_GLOBS.join(', ')}],
rules: ${formatRules(category.rules)}
}
]
Expand Down