eslint-plugin-storybook
Advanced tools
Comparing version 0.5.4 to 0.5.5
@@ -0,1 +1,14 @@ | ||
# v0.5.5 (Mon Dec 20 2021) | ||
#### 🐛 Bug Fix | ||
- no-redundant-story-name: use same naming algorithm as storybook [#69](https://github.com/storybookjs/eslint-plugin-storybook/pull/69) ([@yannbf](https://github.com/yannbf)) | ||
- fix: gracefully handle dynamic values in non-story exports configuration [#68](https://github.com/storybookjs/eslint-plugin-storybook/pull/68) ([@yannbf](https://github.com/yannbf)) | ||
#### Authors: 1 | ||
- Yann Braga ([@yannbf](https://github.com/yannbf)) | ||
--- | ||
# v0.5.4 (Mon Dec 20 2021) | ||
@@ -2,0 +15,0 @@ |
@@ -6,2 +6,3 @@ "use strict"; | ||
*/ | ||
const csf_1 = require("@storybook/csf"); | ||
const ast_1 = require("../utils/ast"); | ||
@@ -29,14 +30,3 @@ const constants_1 = require("../utils/constants"); | ||
create(context) { | ||
// variables should be defined here | ||
//---------------------------------------------------------------------- | ||
// Helpers | ||
//---------------------------------------------------------------------- | ||
//@TODO use the correct name resolver (equivalent to lodash.startcase used in @storybook/csf) | ||
const resolveStoryName = (str) => str | ||
.replace(/([A-Z]{1,})/g, ' $1') | ||
.replace(/(^\w|\s\w)/g, (m) => m.toUpperCase()) | ||
.split(' ') | ||
.filter(Boolean) | ||
.join(' '); | ||
//---------------------------------------------------------------------- | ||
// Public | ||
@@ -64,3 +54,3 @@ //---------------------------------------------------------------------- | ||
const { name } = id; | ||
const resolvedStoryName = resolveStoryName(name); | ||
const resolvedStoryName = (0, csf_1.storyNameFromExport)(name); | ||
//@ts-ignore | ||
@@ -92,3 +82,3 @@ if ((0, ast_1.isLiteral)(storyNameNode.value) && storyNameNode.value.value === resolvedStoryName) { | ||
const propertyValue = right.value; | ||
const resolvedStoryName = resolveStoryName(propertyName); | ||
const resolvedStoryName = (0, csf_1.storyNameFromExport)(propertyName); | ||
if (propertyValue === resolvedStoryName) { | ||
@@ -95,0 +85,0 @@ context.report({ |
@@ -103,6 +103,9 @@ "use strict"; | ||
if (meta) { | ||
nonStoryExportsConfig = { | ||
excludeStories: (0, utils_1.getDescriptor)(meta, 'excludeStories'), | ||
includeStories: (0, utils_1.getDescriptor)(meta, 'includeStories'), | ||
}; | ||
try { | ||
nonStoryExportsConfig = { | ||
excludeStories: (0, utils_1.getDescriptor)(meta, 'excludeStories'), | ||
includeStories: (0, utils_1.getDescriptor)(meta, 'includeStories'), | ||
}; | ||
} | ||
catch (err) { } | ||
} | ||
@@ -109,0 +112,0 @@ }, |
@@ -47,6 +47,9 @@ "use strict"; | ||
if (meta) { | ||
nonStoryExportsConfig = { | ||
excludeStories: (0, utils_1.getDescriptor)(meta, 'excludeStories'), | ||
includeStories: (0, utils_1.getDescriptor)(meta, 'includeStories'), | ||
}; | ||
try { | ||
nonStoryExportsConfig = { | ||
excludeStories: (0, utils_1.getDescriptor)(meta, 'excludeStories'), | ||
includeStories: (0, utils_1.getDescriptor)(meta, 'includeStories'), | ||
}; | ||
} | ||
catch (err) { } | ||
} | ||
@@ -53,0 +56,0 @@ }, |
{ | ||
"name": "eslint-plugin-storybook", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"description": "Best practice rules for Storybook", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
79532
1354