Skip to content
\n

In Storybook v8, it properly removes whitespace and newlines attributes when appropriate:

\n\"Screenshot\n

In Storybook v9, looks like neither of those are happening:

\n\"Screenshot\n

Any help is appreciated!

\n

Additional information

\n

storybook 9.0.15
\nangular 19.2.6

\n
import type { StorybookConfig } from '@storybook/angular';\n\nconst config: StorybookConfig = {\n  stories: [\n    '../src/lib/**/*.mdx',\n    '../src/lib/**/*.stories.@(js|jsx|mjs|ts|tsx)',\n  ],\n  addons: [\n    '@chromatic-com/storybook',\n    '@storybook/addon-themes',\n    '@storybook/addon-designs',\n    '@storybook/addon-docs',\n  ],\n  framework: {\n    name: '@storybook/angular',\n    options: {},\n  },\n  staticDirs: ['./static'],\n};\n\nexport default config;
\n

Create a reproduction

\n

No response

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

@dosu thanks for the quick reply! I went with Prettier since I've already got it installed. Looks like the formatting is back to how it was before.

\n

formatCode.ts

\n
import * as prettier from 'prettier/standalone';\nimport * as prettierPluginHtml from 'prettier/plugins/html';\n\nexport async function formatCode(code: string) {\n  return await prettier.format(code, {\n    parser: 'angular',\n    plugins: [prettierPluginHtml],\n  });\n}
\n

preview.ts

\n
docs: {\n  source: {\n    transform: async (code: string) => {\n      return await formatCode(code);\n    },\n  },\n}
\n

Appreciate the help!

","upvoteCount":0,"url":"https://github.com/storybookjs/storybook/discussions/32008#discussioncomment-13723716"}}}

Storybook v9 not formatting Angular source code the same way it did in v8 #32008

Closed Answered by cocco3
cocco3 asked this question in Help
Discussion options

You must be logged in to vote

@dosu thanks for the quick reply! I went with Prettier since I've already got it installed. Looks like the formatting is back to how it was before.

formatCode.ts

import * as prettier from 'prettier/standalone';
import * as prettierPluginHtml from 'prettier/plugins/html';

export async function formatCode(code: string) {
  return await prettier.format(code, {
    parser: 'angular',
    plugins: [prettierPluginHtml],
  });
}

preview.ts

docs: {
  source: {
    transform: async (code: string) => {
      return await formatCode(code);
    },
  },
}

Appreciate the help!

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@cocco3
Comment options

Answer selected by valentinpalkovic
@dosubot
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant