diff --git a/src/compiler/transform/remove-export-default.test.ts b/src/compiler/transform/remove-export-default.test.ts index e3e7edf..78fd6b8 100644 --- a/src/compiler/transform/remove-export-default.test.ts +++ b/src/compiler/transform/remove-export-default.test.ts @@ -9,6 +9,7 @@ import { describe, it } from 'vitest'; import { removeExportDefault } from './remove-export-default'; import { extractCompiledASTNodes } from '#parser/extract/compiled/nodes'; +import { StorybookSvelteCSFError } from '#utils/error'; const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); @@ -36,7 +37,7 @@ describe(removeExportDefault.name, () => { ` [SB_SVELTE_CSF_PARSER_EXTRACT_COMPILED_0003 (NoExportDefaultError): Could not find 'export default' in the compiled output of the stories file: - More info: https://github.com/storybookjs/addon-svelte-csf/blob/v4.1.2/ERRORS.md#SB_SVELTE_CSF_PARSER_EXTRACT_COMPILED_0003 + More info: https://github.com/storybookjs/addon-svelte-csf/blob/v${StorybookSvelteCSFError.packageVersion}/ERRORS.md#SB_SVELTE_CSF_PARSER_EXTRACT_COMPILED_0003 ] ` ); diff --git a/src/parser/analyse/story/attributes.test.ts b/src/parser/analyse/story/attributes.test.ts index 20a9184..b1fd661 100644 --- a/src/parser/analyse/story/attributes.test.ts +++ b/src/parser/analyse/story/attributes.test.ts @@ -5,6 +5,7 @@ import { getArrayOfStringsValueFromAttribute, getStringValueFromAttribute } from import { getSvelteAST } from '#parser/ast'; import { extractSvelteASTNodes } from '#parser/extract/svelte/nodes'; import { extractStoryAttributesNodes } from '#parser/extract/svelte/story/attributes'; +import { StorybookSvelteCSFError } from '#utils/error'; describe(getStringValueFromAttribute.name, () => { it("throws error when a `` 'name' attribute value is not a string", async ({ @@ -34,10 +35,12 @@ describe(getStringValueFromAttribute.name, () => { expect(() => getStringValueFromAttribute({ component, node: name })) .toThrowErrorMatchingInlineSnapshot(` - [SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0001 (AttributeNotStringError): Invalid schema. - In the stories file: + [SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0001 (AttributeNotStringError): In the stories file: - A '' has an attribute 'name' whose value was expected to be a static literal string.] + A '' has a prop 'name' whose value must be a static literal string. + + More info: https://github.com/storybookjs/addon-svelte-csf/blob/v${StorybookSvelteCSFError.packageVersion}/ERRORS.md#SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0001 + ] `); }); }); @@ -72,12 +75,14 @@ describe(getArrayOfStringsValueFromAttribute.name, () => { getArrayOfStringsValueFromAttribute({ component, node: tags }) ).toThrowErrorMatchingInlineSnapshot( ` - [SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0002 (AttributeNotArrayError): Invalid schema. - In the stories file: + [SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0002 (AttributeNotArrayError): In the stories file: + + A '' has a prop'tags' whose value was expected to be a static array. + Instead the value type is '0'. - A '' has attribute 'tags' whose value was expected to be an array expression. - Instead the value type is '0'.] - ` + More info: https://github.com/storybookjs/addon-svelte-csf/blob/v${StorybookSvelteCSFError.packageVersion}/ERRORS.md#SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0002 + ] + ` ); }); @@ -110,13 +115,14 @@ describe(getArrayOfStringsValueFromAttribute.name, () => { getArrayOfStringsValueFromAttribute({ component, node: tags }) ).toThrowErrorMatchingInlineSnapshot( ` - [SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0003 (AttributeNotArrayOfStringsError): Invalid schema. - In the stories file: + [SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0003 (AttributeNotArrayOfStringsError): In the stories file: + + A '' has attribute 'tags' whose value was expected to be an array expression. + All elements in the array must be static literal strings only, but one of the elements is of type 'undefined'. - A '' has attribute 'tags' whose value was expected to be an array expression. - And this array elements are supposed to be static literal strings only. - One of the elements has a type 'undefined'] - ` + More info: https://github.com/storybookjs/addon-svelte-csf/blob/v${StorybookSvelteCSFError.packageVersion}/ERRORS.md#SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0003 + ] + ` ); }); diff --git a/src/parser/analyse/story/attributes/identifiers.test.ts b/src/parser/analyse/story/attributes/identifiers.test.ts index e52e364..a501e0a 100644 --- a/src/parser/analyse/story/attributes/identifiers.test.ts +++ b/src/parser/analyse/story/attributes/identifiers.test.ts @@ -5,6 +5,7 @@ import { getStoryIdentifiers, getStoriesIdentifiers } from './identifiers'; import { getSvelteAST } from '#parser/ast'; import { extractSvelteASTNodes } from '#parser/extract/svelte/nodes'; import { extractStoryAttributesNodes } from '#parser/extract/svelte/story/attributes'; +import { StorybookSvelteCSFError } from '#utils/error'; describe(getStoryIdentifiers.name, () => { it("extracts 'exportName' attribute when is a Text string", async () => { @@ -92,7 +93,10 @@ describe(getStoryIdentifiers.name, () => { ).toThrowErrorMatchingInlineSnapshot( ` [SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0004 (NoStoryIdentifierError): Missing 'name' or 'exportName' attribute (prop) in a '' definition in the stories file: 'file://${process.cwd()}/invalid.stories.svelte'. - All stories must either have a 'name' or an 'exportName' prop.] + All stories must either have a 'name' or an 'exportName' prop, or both. + + More info: https://github.com/storybookjs/addon-svelte-csf/blob/v${StorybookSvelteCSFError.packageVersion}/ERRORS.md#SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0004 + ] ` ); }); @@ -216,7 +220,10 @@ describe(getStoryIdentifiers.name, () => { 'exportName' value must be a valid JavaScript variable name. It must start with a letter, $ or _, followed by letters, numbers, $ or _. - Reserved words like 'default' are also not allowed (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#reserved_words)] + Reserved words like 'default' are also not allowed (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#reserved_words) + + More info: https://github.com/storybookjs/addon-svelte-csf/blob/v${StorybookSvelteCSFError.packageVersion}/ERRORS.md#SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0005 + ] ` ); }); @@ -289,7 +296,10 @@ describe(getStoriesIdentifiers.name, () => { This can happen when 'exportName' is implicitly derived by 'name'. Complex names will be simplified to a PascalCased, valid JavaScript variable name, eg. 'Some story name!!' will be converted to 'SomeStoryName'. - You can fix this collision by providing a unique 'exportName' prop with .] + You can fix this collision by providing a unique 'exportName' prop with . + + More info: https://github.com/storybookjs/addon-svelte-csf/blob/v${StorybookSvelteCSFError.packageVersion}/ERRORS.md#SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0006 + ] ` ); }); @@ -322,7 +332,10 @@ describe(getStoriesIdentifiers.name, () => { This can happen when 'exportName' is implicitly derived by 'name'. Complex names will be simplified to a PascalCased, valid JavaScript variable name, eg. 'Some story name!!' will be converted to 'SomeStoryName'. - You can fix this collision by providing a unique 'exportName' prop with .] + You can fix this collision by providing a unique 'exportName' prop with . + + More info: https://github.com/storybookjs/addon-svelte-csf/blob/v${StorybookSvelteCSFError.packageVersion}/ERRORS.md#SB_SVELTE_CSF_PARSER_ANALYSE_STORY_0006 + ] ` ); }); diff --git a/src/parser/extract/svelte/module-nodes.test.ts b/src/parser/extract/svelte/module-nodes.test.ts index e63d7e3..748b8b3 100644 --- a/src/parser/extract/svelte/module-nodes.test.ts +++ b/src/parser/extract/svelte/module-nodes.test.ts @@ -3,6 +3,7 @@ import { describe, it } from 'vitest'; import { extractModuleNodes } from './module-nodes'; import { getSvelteAST } from '#parser/ast'; +import { StorybookSvelteCSFError } from '#utils/error'; describe(extractModuleNodes.name, () => { it('fails when module tag not found', ({ expect }) => { @@ -22,7 +23,7 @@ describe(extractModuleNodes.name, () => { const { Story } = defineMeta({}); - More info: https://github.com/storybookjs/addon-svelte-csf/blob/v4.1.2/ERRORS.md#SB_SVELTE_CSF_PARSER_EXTRACT_SVELTE_0001 + More info: https://github.com/storybookjs/addon-svelte-csf/blob/v${StorybookSvelteCSFError.packageVersion}/ERRORS.md#SB_SVELTE_CSF_PARSER_EXTRACT_SVELTE_0001 ] `); }); @@ -44,7 +45,7 @@ describe(extractModuleNodes.name, () => { const { Story } = defineMeta({}); - More info: https://github.com/storybookjs/addon-svelte-csf/blob/v4.1.2/ERRORS.md#SB_SVELTE_CSF_PARSER_EXTRACT_SVELTE_0003 + More info: https://github.com/storybookjs/addon-svelte-csf/blob/v${StorybookSvelteCSFError.packageVersion}/ERRORS.md#SB_SVELTE_CSF_PARSER_EXTRACT_SVELTE_0003 ] `); }); @@ -69,7 +70,7 @@ describe(extractModuleNodes.name, () => { const { Story } = defineMeta({}); - More info: https://github.com/storybookjs/addon-svelte-csf/blob/v4.1.2/ERRORS.md#SB_SVELTE_CSF_PARSER_EXTRACT_SVELTE_0004 + More info: https://github.com/storybookjs/addon-svelte-csf/blob/v${StorybookSvelteCSFError.packageVersion}/ERRORS.md#SB_SVELTE_CSF_PARSER_EXTRACT_SVELTE_0004 ] `); }); @@ -94,7 +95,7 @@ describe(extractModuleNodes.name, () => { const { Story } = defineMeta({}); - More info: https://github.com/storybookjs/addon-svelte-csf/blob/v4.1.2/ERRORS.md#SB_SVELTE_CSF_PARSER_EXTRACT_SVELTE_0004 + More info: https://github.com/storybookjs/addon-svelte-csf/blob/v${StorybookSvelteCSFError.packageVersion}/ERRORS.md#SB_SVELTE_CSF_PARSER_EXTRACT_SVELTE_0004 ] `); });