-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { categories, TCategory } from './categories' | ||
|
||
export const extendsCategories = { | ||
csf: null, | ||
recommended: null, | ||
'csf-strict': 'csf', | ||
} | ||
|
||
const externalRuleOverrides = { | ||
'react-hooks/rules-of-hooks': 'off', | ||
'import/no-anonymous-default-export': 'off', | ||
} | ||
|
||
export function formatRules(rules: TCategory['rules'], exclude?: string[]) { | ||
const obj = rules.reduce( | ||
(setting, rule) => { | ||
if (!exclude?.includes(rule.ruleId)) { | ||
setting[rule.ruleId] = rule.meta.docs.recommended || 'error' | ||
} | ||
return setting | ||
}, | ||
{ ...externalRuleOverrides } | ||
) | ||
|
||
return JSON.stringify(obj, null, 2) | ||
} | ||
|
||
export function formatSingleRule(rules: TCategory['rules'], ruleId: string) { | ||
const ruleOpt = rules.find((rule) => rule.ruleId === ruleId)?.meta.docs.recommended || 'error' | ||
|
||
return JSON.stringify({ [ruleId]: ruleOpt }, null, 2) | ||
} | ||
|
||
export const SUPPORTED_EXTENSIONS = ['ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs'] | ||
export const STORIES_GLOBS = [ | ||
`'*.stories.@(${SUPPORTED_EXTENSIONS.join('|')})'`, | ||
`'*.story.@(${SUPPORTED_EXTENSIONS.join('|')})'`, | ||
] | ||
|
||
// Other files that will be linted | ||
export const MAIN_JS_FILE = [`'.storybook/main.@(js|cjs|mjs|ts)'`] |