eslint-plugin-storybook
Advanced tools
Comparing version 0.11.2 to 0.11.3--canary.187.1af857a.0
@@ -52,2 +52,3 @@ "use strict"; | ||
let hasDefaultExport = false; | ||
let isCsf4Style = false; | ||
let hasStoriesOfImport = false; | ||
@@ -60,2 +61,19 @@ return { | ||
}, | ||
VariableDeclaration(node) { | ||
// we check for variables declared at the root in a CSF4 style | ||
// e.g. const meta = config.meta({}) | ||
if (node.parent.type === 'Program') { | ||
node.declarations.forEach((declaration) => { | ||
const init = declaration.init; | ||
if (init && init.type === 'CallExpression') { | ||
const callee = init.callee; | ||
if (callee.type === 'MemberExpression' && | ||
callee.property.type === 'Identifier' && | ||
callee.property.name === 'meta') { | ||
isCsf4Style = true; | ||
} | ||
} | ||
}); | ||
} | ||
}, | ||
ExportDefaultSpecifier: function () { | ||
@@ -68,3 +86,3 @@ hasDefaultExport = true; | ||
'Program:exit': function (program) { | ||
if (!hasDefaultExport && !hasStoriesOfImport) { | ||
if (!isCsf4Style && !hasDefaultExport && !hasStoriesOfImport) { | ||
const componentName = getComponentName(program, context.getFilename()); | ||
@@ -71,0 +89,0 @@ const firstNonImportStatement = program.body.find((n) => !(0, ast_1.isImportDeclaration)(n)); |
{ | ||
"name": "eslint-plugin-storybook", | ||
"version": "0.11.2", | ||
"version": "0.11.3--canary.187.1af857a.0", | ||
"description": "Best practice rules for Storybook", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
138930
2677