eslint-plugin-storybook
Advanced tools
Comparing version 0.6.6 to 0.6.7
@@ -0,1 +1,14 @@ | ||
# v0.6.7 (Tue Nov 01 2022) | ||
#### 🐛 Bug Fix | ||
- fix: add declaration checks to avoid destructuring undefined [#99](https://github.com/storybookjs/eslint-plugin-storybook/pull/99) ([@stefanprobst](https://github.com/stefanprobst) [@yannbf](https://github.com/yannbf)) | ||
#### Authors: 2 | ||
- [@stefanprobst](https://github.com/stefanprobst) | ||
- Yann Braga ([@yannbf](https://github.com/yannbf)) | ||
--- | ||
# v0.6.6 (Tue Oct 11 2022) | ||
@@ -2,0 +15,0 @@ |
@@ -40,3 +40,6 @@ "use strict"; | ||
if ((0, ast_1.isVariableDeclaration)(decl)) { | ||
const { id, init } = decl.declarations[0]; | ||
const declaration = decl.declarations[0]; | ||
if (declaration == null) | ||
return; | ||
const { id, init } = declaration; | ||
if ((0, ast_1.isIdentifier)(id) && (0, ast_1.isObjectExpression)(init)) { | ||
@@ -43,0 +46,0 @@ const storyNameNode = init.properties.find((prop) => { |
@@ -72,3 +72,3 @@ "use strict"; | ||
const ref = variable.references[i]; | ||
if (!ref.init) { | ||
if (ref && !ref.init) { | ||
yield fixer.replaceTextRange(ref.identifier.range, pascal); | ||
@@ -115,3 +115,6 @@ } | ||
if ((0, ast_1.isVariableDeclaration)(decl)) { | ||
const { id } = decl.declarations[0]; | ||
const declaration = decl.declarations[0]; | ||
if (declaration == null) | ||
return; | ||
const { id } = declaration; | ||
if ((0, ast_1.isIdentifier)(id)) { | ||
@@ -118,0 +121,0 @@ namedExports.push(id); |
@@ -43,4 +43,11 @@ "use strict"; | ||
const { specifiers } = node; | ||
if (!specifiers[0]) { | ||
return null; | ||
} | ||
const start = specifiers[0].range[0]; | ||
let end = specifiers[specifiers.length - 1].range[1]; | ||
const previousSpecifier = specifiers[specifiers.length - 1]; | ||
if (!previousSpecifier) { | ||
return null; | ||
} | ||
let end = previousSpecifier.range[1]; | ||
// this weird hack is necessary because the specifier range | ||
@@ -83,4 +90,7 @@ // does not include the closing brace: | ||
if (hasDefaultImport(node.specifiers)) { | ||
const { range, text } = getSpecifiers(node); | ||
yield fixer.replaceTextRange(range, fixSpecifiers(text)); | ||
const specifiers = getSpecifiers(node); | ||
if (specifiers) { | ||
const { range, text } = specifiers; | ||
yield fixer.replaceTextRange(range, fixSpecifiers(text)); | ||
} | ||
} | ||
@@ -94,4 +104,7 @@ }, | ||
if (hasDefaultImport(node.specifiers)) { | ||
const { range, text } = getSpecifiers(node); | ||
yield fixer.replaceTextRange(range, fixSpecifiers(text)); | ||
const specifiers = getSpecifiers(node); | ||
if (specifiers) { | ||
const { range, text } = specifiers; | ||
yield fixer.replaceTextRange(range, fixSpecifiers(text)); | ||
} | ||
} | ||
@@ -98,0 +111,0 @@ }, |
@@ -65,6 +65,9 @@ "use strict"; | ||
if ((0, ast_1.isVariableDeclaration)(decl)) { | ||
const { id } = decl.declarations[0]; | ||
// e.g. `export const MyStory` | ||
if ((0, ast_1.isIdentifier)(id)) { | ||
return [id]; | ||
const declaration = decl.declarations[0]; | ||
if (declaration) { | ||
const { id } = declaration; | ||
// e.g. `export const MyStory` | ||
if ((0, ast_1.isIdentifier)(id)) { | ||
return [id]; | ||
} | ||
} | ||
@@ -71,0 +74,0 @@ } |
{ | ||
"name": "eslint-plugin-storybook", | ||
"version": "0.6.6", | ||
"version": "0.6.7", | ||
"description": "Best practice rules for Storybook", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
102811
1594