;
`)
).resolves.toMatchInlineSnapshot(`
- import preview from '#.storybook/preview';
-
- const meta = preview.meta({ title: 'Component' });
+ import preview from "#.storybook/preview";
+ const meta = preview.meta({ title: "Component" });
export const CSF1Story = meta.story(() =>
Hello
);
`);
});
@@ -504,11 +496,10 @@ describe('stories codemod', () => {
`;
it('meta satisfies syntax', async () => {
await expect(transform(inlineMetaSatisfies)).resolves.toMatchInlineSnapshot(`
- import preview from '#.storybook/preview';
+ import preview from "#.storybook/preview";
+ import { ComponentProps } from "./Component";
- import { ComponentProps } from './Component';
-
- const meta = preview.meta({ title: 'Component', component: Component });
+ const meta = preview.meta({ title: "Component", component: Component });
export const A = meta.story({
args: { primary: true },
@@ -528,11 +519,10 @@ describe('stories codemod', () => {
`;
it('meta as syntax', async () => {
await expect(transform(inlineMetaAs)).resolves.toMatchInlineSnapshot(`
- import preview from '#.storybook/preview';
+ import preview from "#.storybook/preview";
+ import { ComponentProps } from "./Component";
- import { ComponentProps } from './Component';
-
- const meta = preview.meta({ title: 'Component', component: Component });
+ const meta = preview.meta({ title: "Component", component: Component });
export const A = meta.story({
args: { primary: true },
@@ -552,11 +542,10 @@ describe('stories codemod', () => {
`;
it('meta satisfies syntax', async () => {
await expect(transform(metaSatisfies)).resolves.toMatchInlineSnapshot(`
- import preview from '#.storybook/preview';
-
- import { ComponentProps } from './Component';
+ import preview from "#.storybook/preview";
+ import { ComponentProps } from "./Component";
- const meta = preview.meta({ title: 'Component', component: Component });
+ const meta = preview.meta({ title: "Component", component: Component });
export const A = meta.story({
args: { primary: true },
@@ -577,11 +566,10 @@ describe('stories codemod', () => {
`;
it('meta type syntax', async () => {
await expect(transform(metaTypeDef)).resolves.toMatchInlineSnapshot(`
- import preview from '#.storybook/preview';
-
- import { ComponentProps } from './Component';
+ import preview from "#.storybook/preview";
+ import { ComponentProps } from "./Component";
- const meta = preview.meta({ title: 'Component', component: Component });
+ const meta = preview.meta({ title: "Component", component: Component });
export const A = meta.story({
args: { primary: true },
@@ -602,11 +590,10 @@ describe('stories codemod', () => {
`;
it('meta as syntax', async () => {
await expect(transform(metaAs)).resolves.toMatchInlineSnapshot(`
- import preview from '#.storybook/preview';
-
- import { ComponentProps } from './Component';
+ import preview from "#.storybook/preview";
+ import { ComponentProps } from "./Component";
- const meta = preview.meta({ title: 'Component', component: Component });
+ const meta = preview.meta({ title: "Component", component: Component });
export const A = meta.story({
args: { primary: true },
@@ -627,11 +614,10 @@ describe('stories codemod', () => {
`;
it('story satisfies syntax', async () => {
await expect(transform(storySatisfies)).resolves.toMatchInlineSnapshot(`
- import preview from '#.storybook/preview';
-
- import { ComponentProps } from './Component';
+ import preview from "#.storybook/preview";
+ import { ComponentProps } from "./Component";
- const meta = preview.meta({ title: 'Component', component: Component });
+ const meta = preview.meta({ title: "Component", component: Component });
export const A = meta.story({
args: { primary: true },
@@ -652,11 +638,10 @@ describe('stories codemod', () => {
`;
it('story as syntax', async () => {
await expect(transform(storyAs)).resolves.toMatchInlineSnapshot(`
- import preview from '#.storybook/preview';
+ import preview from "#.storybook/preview";
+ import { ComponentProps } from "./Component";
- import { ComponentProps } from './Component';
-
- const meta = preview.meta({ title: 'Component', component: Component });
+ const meta = preview.meta({ title: "Component", component: Component });
export const A = meta.story({
args: { primary: true },
@@ -691,9 +676,8 @@ describe('stories codemod', () => {
export const A: Story = {};`
)
).resolves.toMatchInlineSnapshot(`
- import preview from '#.storybook/preview';
-
- import { ComponentProps } from './Component';
+ import preview from "#.storybook/preview";
+ import { ComponentProps } from "./Component";
const meta = preview.meta({});
@@ -724,7 +708,7 @@ describe('stories codemod', () => {
expect(result).not.toContain('UnusedAndShouldBeRemoved');
expect(result).toMatchInlineSnapshot(`
- import preview from '#.storybook/preview';
+ import preview from "#.storybook/preview";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Data = Record;
@@ -733,7 +717,7 @@ describe('stories codemod', () => {
}
const meta = preview.meta({
- title: 'Table',
+ title: "Table",
});
export const A = meta.story({
@@ -762,17 +746,15 @@ describe('stories codemod', () => {
export const A = {};
`)
).resolves.toMatchInlineSnapshot(`
- import { Meta } from '@storybook/react';
-
- import preview from '#.storybook/preview';
-
- import { Button } from './Button';
+ import preview from "#.storybook/preview";
+ import { Meta } from "@storybook/react";
+ import { Button } from "./Button";
type ThisShouldNotBeRemoved = Meta;
const something: ThisShouldNotBeRemoved = {};
const meta = preview.meta({
- title: 'Button',
+ title: "Button",
});
export const A = meta.story();
diff --git a/code/lib/codemod/src/transforms/__tests__/__snapshots__/upgrade-deprecated-types.test.ts.snap b/code/lib/codemod/src/transforms/__tests__/__snapshots__/upgrade-deprecated-types.test.ts.snap
index b6690df75b31..a7744d638370 100644
--- a/code/lib/codemod/src/transforms/__tests__/__snapshots__/upgrade-deprecated-types.test.ts.snap
+++ b/code/lib/codemod/src/transforms/__tests__/__snapshots__/upgrade-deprecated-types.test.ts.snap
@@ -12,15 +12,16 @@ Rename this local import and try again.
exports[`upgrade-deprecated-types > typescript > upgrade imports with local names 1`] = `
import {
+ StoryFn as Story_,
Meta as ComponentMeta_,
StoryObj as ComponentStoryObj_,
- StoryFn as Story_,
-} from '@storybook/react';
-
-import { Cat } from './Cat';
+} from "@storybook/react";
+import { Cat } from "./Cat";
-const meta = { title: 'Cat', component: Cat } satisfies ComponentMeta_;
-const meta2: ComponentMeta_ = { title: 'Cat', component: Cat };
+const meta = { title: "Cat", component: Cat } satisfies ComponentMeta_<
+ typeof Cat
+>;
+const meta2: ComponentMeta_ = { title: "Cat", component: Cat };
export default meta;
export const A: Story__ = (args) => ;
@@ -28,19 +29,18 @@ export const B: any = (args) => ;
export const C: StoryFn_ = (args) => ;
export const D: ComponentStoryObj_ = {
args: {
- name: 'Fluffy',
+ name: "Fluffy",
},
};
export const E: Story_ = (args) => ;
`;
exports[`upgrade-deprecated-types > typescript > upgrade namespaces 1`] = `
-import * as SB from '@storybook/react';
+import * as SB from "@storybook/react";
+import { Cat, CatProps } from "./Cat";
-import { Cat, CatProps } from './Cat';
-
-const meta = { title: 'Cat', component: Cat } satisfies SB.Meta;
-const meta2: SB.Meta = { title: 'Cat', component: Cat };
+const meta = { title: "Cat", component: Cat } satisfies SB.Meta;
+const meta2: SB.Meta = { title: "Cat", component: Cat };
export default meta;
export const A: SB.StoryFn = (args) => ;
@@ -48,19 +48,18 @@ export const B: any = (args) => ;
export const C: SB.StoryFn = (args) => ;
export const D: SB.StoryObj = {
args: {
- name: 'Fluffy',
+ name: "Fluffy",
},
};
export const E: SB.StoryFn = (args) => ;
`;
exports[`upgrade-deprecated-types > typescript > upgrade regular imports 1`] = `
-import { Meta, StoryFn, StoryObj } from '@storybook/react';
-
-import { Cat, CatProps } from './Cat';
+import { StoryFn, Meta, StoryObj } from "@storybook/react";
+import { Cat, CatProps } from "./Cat";
-const meta = { title: 'Cat', component: Cat } satisfies Meta;
-const meta2: Meta = { title: 'Cat', component: Cat };
+const meta = { title: "Cat", component: Cat } satisfies Meta;
+const meta2: Meta = { title: "Cat", component: Cat };
export default meta;
export const A: StoryFn = (args) => ;
@@ -68,7 +67,7 @@ export const B: any = (args) => ;
export const C: StoryFn = (args) => ;
export const D: StoryObj = {
args: {
- name: 'Fluffy',
+ name: "Fluffy",
},
};
export const E: StoryFn = (args) => ;
diff --git a/code/lib/codemod/src/transforms/__tests__/csf-2-to-3.test.ts b/code/lib/codemod/src/transforms/__tests__/csf-2-to-3.test.ts
index 665928c30380..82a85baf23c5 100644
--- a/code/lib/codemod/src/transforms/__tests__/csf-2-to-3.test.ts
+++ b/code/lib/codemod/src/transforms/__tests__/csf-2-to-3.test.ts
@@ -30,7 +30,7 @@ describe('csf-2-to-3', () => {
export const B = (args) => ;
`)
).resolves.toMatchInlineSnapshot(`
- export default { title: 'Cat' };
+ export default { title: "Cat" };
export const A = () => ;
export const B = {
render: (args) => ,
@@ -49,11 +49,11 @@ describe('csf-2-to-3', () => {
A.play = () => {};
`)
).resolves.toMatchInlineSnapshot(`
- export default { title: 'Cat' };
+ export default { title: "Cat" };
export const A = {
render: () => ,
- name: 'foo',
+ name: "foo",
parameters: { bar: 2 },
play: () => {},
};
@@ -72,7 +72,7 @@ describe('csf-2-to-3', () => {
const C = (args) => ;
`)
).resolves.toMatchInlineSnapshot(`
- export default { title: 'components/Fruit', includeStories: ['A'] };
+ export default { title: "components/Fruit", includeStories: ["A"] };
export const A = {
render: (args) => ,
@@ -106,7 +106,7 @@ describe('csf-2-to-3', () => {
export const B = (args) => ;
`)
).resolves.toMatchInlineSnapshot(`
- export default { title: 'Cat', component: Cat };
+ export default { title: "Cat", component: Cat };
export const A = {};
export const B = {
render: (args) => ,
@@ -124,7 +124,7 @@ describe('csf-2-to-3', () => {
};
`)
).resolves.toMatchInlineSnapshot(`
- export default { title: 'Cat', component: Cat };
+ export default { title: "Cat", component: Cat };
export const A = {
render: (args) => ,
@@ -141,7 +141,7 @@ describe('csf-2-to-3', () => {
A.args = { isPrimary: false };
`)
).resolves.toMatchInlineSnapshot(`
- export default { title: 'Cat' };
+ export default { title: "Cat" };
const Template = (args) => ;
export const A = {
@@ -171,7 +171,7 @@ describe('csf-2-to-3', () => {
D.args = { bla: false };
`)
).resolves.toMatchInlineSnapshot(`
- export default { title: 'Cat' };
+ export default { title: "Cat" };
const Template = (args) => ;
export const A = {
@@ -212,7 +212,7 @@ describe('csf-2-to-3', () => {
B.args = { isPrimary: true };
`)
).resolves.toMatchInlineSnapshot(`
- export default { title: 'Cat', component: Cat };
+ export default { title: "Cat", component: Cat };
export const A = {
args: { isPrimary: false },
@@ -238,7 +238,7 @@ describe('csf-2-to-3', () => {
C.parameters = { foo: 2 };
`)
).resolves.toMatchInlineSnapshot(`
- export default { title: 'Cat', component: Cat };
+ export default { title: "Cat", component: Cat };
export const A = {};
export const B = () => ;
@@ -260,7 +260,7 @@ describe('csf-2-to-3', () => {
};
`)
).resolves.toMatchInlineSnapshot(`
- export default { title: 'Cat' };
+ export default { title: "Cat" };
export const A = {
render: (args) => ,
@@ -315,22 +315,21 @@ describe('csf-2-to-3', () => {
};
`)
).resolves.toMatchInlineSnapshot(`
- import { StoryFn as CSF2, StoryObj as CSF3, Meta } from '@storybook/react';
+ import { Meta, StoryObj as CSF3, StoryFn as CSF2 } from "@storybook/react";
+ import { CatProps } from "./Cat";
- import { CatProps } from './Cat';
-
- const meta = { title: 'Cat', component: Cat } satisfies Meta;
+ const meta = { title: "Cat", component: Cat } satisfies Meta;
export default meta;
export const A: CSF2 = () => ;
export const B: CSF3 = {
- args: { name: 'already csf3' },
+ args: { name: "already csf3" },
};
export const C: CSF3 = {
args: {
- name: 'Fluffy',
+ name: "Fluffy",
},
};
`);
@@ -375,17 +374,17 @@ describe('csf-2-to-3', () => {
};
`)
).resolves.toMatchInlineSnapshot(`
- import { StoryFn, StoryObj } from '@storybook/react';
+ import { StoryObj, StoryFn } from "@storybook/react";
// some extra whitespace to test
export default {
- title: 'Cat',
+ title: "Cat",
component: Cat,
} as Meta;
export const A: StoryObj = {
- args: { name: 'Fluffy' },
+ args: { name: "Fluffy" },
};
export const B: any = {
@@ -396,23 +395,23 @@ describe('csf-2-to-3', () => {
export const D: StoryObj = {
args: {
- name: 'Fluffy',
+ name: "Fluffy",
},
};
export const E: StoryObj = {
- args: { name: 'Fluffy' },
+ args: { name: "Fluffy" },
};
export const F: StoryObj = {
args: {
- name: 'Fluffy',
+ name: "Fluffy",
},
};
export const G: StoryObj = {
args: {
- name: 'Fluffy',
+ name: "Fluffy",
},
};
`);
@@ -432,7 +431,7 @@ describe('csf-2-to-3', () => {
export const Default = Template.bind({})
`)
).resolves.toMatchInlineSnapshot(`
- import { Meta, StoryFn } from '@storybook/react';
+ import { StoryFn, Meta } from "@storybook/react";
export default {
component: Cat,
diff --git a/code/lib/eslint-plugin/docs/rules/await-interactions.md b/code/lib/eslint-plugin/docs/rules/await-interactions.md
index 16cde9402495..1945dc55f802 100644
--- a/code/lib/eslint-plugin/docs/rules/await-interactions.md
+++ b/code/lib/eslint-plugin/docs/rules/await-interactions.md
@@ -13,28 +13,28 @@ Storybook provides an instrumented version of the testing library in the [storyb
Examples of **incorrect** code for this rule:
```js
-import { userEvent, within } from 'storybook/test';
+import { userEvent, within } from "storybook/test";
// or from the legacy package "@storybook/testing-library";
MyStory.play = (context) => {
const canvas = within(context.canvasElement);
// not awaited!
- userEvent.click(canvas.getByRole('button'));
+ userEvent.click(canvas.getByRole("button"));
};
```
Examples of **correct** code for this rule:
```js
-import { userEvent, within } from 'storybook/test';
+import { userEvent, within } from "storybook/test";
// or from the legacy package "@storybook/testing-library";
MyStory.play = async (context) => {
const canvas = within(context.canvasElement);
// awaited 👍
- await userEvent.click(canvas.getByRole('button'));
+ await userEvent.click(canvas.getByRole("button"));
};
```
diff --git a/code/lib/eslint-plugin/docs/rules/csf-component.md b/code/lib/eslint-plugin/docs/rules/csf-component.md
index c37678324a05..ed50122f004b 100644
--- a/code/lib/eslint-plugin/docs/rules/csf-component.md
+++ b/code/lib/eslint-plugin/docs/rules/csf-component.md
@@ -14,7 +14,7 @@ Examples of **incorrect** code for this rule:
```js
export default {
- title: 'Button',
+ title: "Button",
};
```
@@ -22,7 +22,7 @@ Examples of **correct** code for this rule:
```js
export default {
- title: 'Button',
+ title: "Button",
component: Button,
};
```
diff --git a/code/lib/eslint-plugin/docs/rules/default-exports.md b/code/lib/eslint-plugin/docs/rules/default-exports.md
index 57393270964b..ff3bd7456d8e 100644
--- a/code/lib/eslint-plugin/docs/rules/default-exports.md
+++ b/code/lib/eslint-plugin/docs/rules/default-exports.md
@@ -21,7 +21,7 @@ Examples of **correct** code for this rule:
```js
export default {
- title: 'Button',
+ title: "Button",
args: { primary: true },
component: Button,
};
diff --git a/code/lib/eslint-plugin/docs/rules/hierarchy-separator.md b/code/lib/eslint-plugin/docs/rules/hierarchy-separator.md
index ce5dfb0ed340..a67d4392f34b 100644
--- a/code/lib/eslint-plugin/docs/rules/hierarchy-separator.md
+++ b/code/lib/eslint-plugin/docs/rules/hierarchy-separator.md
@@ -14,7 +14,7 @@ Examples of **incorrect** code for this rule:
```js
export default {
- title: 'Components|Forms/Input',
+ title: "Components|Forms/Input",
component: Input,
};
```
@@ -23,7 +23,7 @@ Examples of **correct** code for this rule:
```js
export default {
- title: 'Components/Forms/Input',
+ title: "Components/Forms/Input",
component: Input,
};
```
diff --git a/code/lib/eslint-plugin/docs/rules/meta-inline-properties.md b/code/lib/eslint-plugin/docs/rules/meta-inline-properties.md
index 05347855dc23..ba0bc088ffd7 100644
--- a/code/lib/eslint-plugin/docs/rules/meta-inline-properties.md
+++ b/code/lib/eslint-plugin/docs/rules/meta-inline-properties.md
@@ -13,7 +13,7 @@ This rule encourages you to use inline property definitions for the default expo
Examples of **incorrect** code for this rule:
```js
-const title = 'Button';
+const title = "Button";
const args = { primary: true };
export default {
@@ -27,7 +27,7 @@ Examples of **correct** code for this rule:
```js
export default {
- title: 'Button',
+ title: "Button",
args: { primary: true },
component: Button,
};
diff --git a/code/lib/eslint-plugin/docs/rules/meta-satisfies-type.md b/code/lib/eslint-plugin/docs/rules/meta-satisfies-type.md
index 52afe887e3a8..52378e3791e0 100644
--- a/code/lib/eslint-plugin/docs/rules/meta-satisfies-type.md
+++ b/code/lib/eslint-plugin/docs/rules/meta-satisfies-type.md
@@ -16,7 +16,7 @@ Examples of **incorrect** code for this rule:
```ts
export default {
- title: 'Button',
+ title: "Button",
args: { primary: true },
component: Button,
};
@@ -24,7 +24,7 @@ export default {
```ts
const meta: Meta = {
- title: 'Button',
+ title: "Button",
args: { primary: true },
component: Button,
};
@@ -35,7 +35,7 @@ Examples of **correct** code for this rule:
```ts
export default {
- title: 'Button',
+ title: "Button",
args: { primary: true },
component: Button,
} satisfies Meta;
@@ -43,7 +43,7 @@ export default {
```ts
const meta = {
- title: 'Button',
+ title: "Button",
args: { primary: true },
component: Button,
} satisfies Meta;
diff --git a/code/lib/eslint-plugin/docs/rules/no-redundant-story-name.md b/code/lib/eslint-plugin/docs/rules/no-redundant-story-name.md
index 44079b842c52..4528de5c3aa1 100644
--- a/code/lib/eslint-plugin/docs/rules/no-redundant-story-name.md
+++ b/code/lib/eslint-plugin/docs/rules/no-redundant-story-name.md
@@ -15,7 +15,7 @@ Examples of **incorrect** code for this rule:
```js
export const PrimaryButton = {
// no need for this, as Storybook will resolve to this name already
- name: 'Primary Button',
+ name: "Primary Button",
};
```
@@ -23,7 +23,7 @@ Examples of **correct** code for this rule:
```js
export const PrimaryButton = {
- name: 'I am the primary',
+ name: "I am the primary",
};
```
diff --git a/code/lib/eslint-plugin/docs/rules/no-renderer-packages.md b/code/lib/eslint-plugin/docs/rules/no-renderer-packages.md
index 8fa50646898a..72b9ec657039 100644
--- a/code/lib/eslint-plugin/docs/rules/no-renderer-packages.md
+++ b/code/lib/eslint-plugin/docs/rules/no-renderer-packages.md
@@ -24,19 +24,19 @@ Examples of **incorrect** code for this rule:
```js
// Don't import renderer packages directly
-import { something } from '@storybook/react';
-import { something } from '@storybook/vue3';
-import { something } from '@storybook/web-components';
+import { something } from "@storybook/react";
+import { something } from "@storybook/vue3";
+import { something } from "@storybook/web-components";
```
Examples of **correct** code for this rule:
```js
// Do use the appropriate framework package for your build tool
-import { something } from '@storybook/react-vite'; // For Vite
-import { something } from '@storybook/vue3-vite'; // For Vite
-import { something } from '@storybook/web-components-vite'; // For Vite
-import { something } from '@storybook/nextjs'; // For Next.js
+import { something } from "@storybook/react-vite"; // For Vite
+import { something } from "@storybook/vue3-vite"; // For Vite
+import { something } from "@storybook/web-components-vite"; // For Vite
+import { something } from "@storybook/nextjs"; // For Next.js
```
## When Not To Use It
diff --git a/code/lib/eslint-plugin/docs/rules/no-stories-of.md b/code/lib/eslint-plugin/docs/rules/no-stories-of.md
index fba61b3bfc6c..d4e42f9b1183 100644
--- a/code/lib/eslint-plugin/docs/rules/no-stories-of.md
+++ b/code/lib/eslint-plugin/docs/rules/no-stories-of.md
@@ -13,11 +13,11 @@ Starting with Storybook 5.2, the Component Story Format ([CSF](https://storybook
Examples of **incorrect** code for this rule:
```js
-import { storiesOf } from '@storybook/react';
+import { storiesOf } from "@storybook/react";
-import Button from '../components/Button';
+import Button from "../components/Button";
-storiesOf('Button', module).add('primary', () => );
+storiesOf("Button", module).add("primary", () => );
```
Examples of **correct** code for this rule:
diff --git a/code/lib/eslint-plugin/docs/rules/no-title-property-in-meta.md b/code/lib/eslint-plugin/docs/rules/no-title-property-in-meta.md
index f5c32df25567..8c4d548c4ad5 100644
--- a/code/lib/eslint-plugin/docs/rules/no-title-property-in-meta.md
+++ b/code/lib/eslint-plugin/docs/rules/no-title-property-in-meta.md
@@ -15,7 +15,7 @@ Examples of **incorrect** code for this rule:
```js
export default {
- title: 'Components/Forms/Input',
+ title: "Components/Forms/Input",
component: Input,
};
```
diff --git a/code/lib/eslint-plugin/docs/rules/no-uninstalled-addons.md b/code/lib/eslint-plugin/docs/rules/no-uninstalled-addons.md
index f407987a7cfb..742ea6180c63 100644
--- a/code/lib/eslint-plugin/docs/rules/no-uninstalled-addons.md
+++ b/code/lib/eslint-plugin/docs/rules/no-uninstalled-addons.md
@@ -72,7 +72,10 @@ This rule assumes that the `package.json` is located in the root of your project
```js
module.exports = {
rules: {
- 'storybook/no-uninstalled-addons': ['error', { packageJsonLocation: './folder/package.json' }],
+ "storybook/no-uninstalled-addons": [
+ "error",
+ { packageJsonLocation: "./folder/package.json" },
+ ],
},
};
```
@@ -86,11 +89,11 @@ You can also ignore specific addons by providing an ignore array in the options:
```js
module.exports = {
rules: {
- 'storybook/no-uninstalled-addons': [
- 'error',
+ "storybook/no-uninstalled-addons": [
+ "error",
{
- packageJsonLocation: './folder/package.json',
- ignore: ['custom-addon'],
+ packageJsonLocation: "./folder/package.json",
+ ignore: ["custom-addon"],
},
],
},
diff --git a/code/lib/eslint-plugin/docs/rules/story-exports.md b/code/lib/eslint-plugin/docs/rules/story-exports.md
index dbc9c44904cb..7a1be8e6f900 100644
--- a/code/lib/eslint-plugin/docs/rules/story-exports.md
+++ b/code/lib/eslint-plugin/docs/rules/story-exports.md
@@ -14,7 +14,7 @@ Examples of **incorrect** code for this rule:
```js
export default {
- title: 'Button',
+ title: "Button",
args: { primary: true },
component: Button,
};
@@ -25,7 +25,7 @@ Examples of **correct** code for this rule:
```js
export default {
- title: 'Button',
+ title: "Button",
args: { primary: true },
component: Button,
};
diff --git a/code/lib/eslint-plugin/docs/rules/use-storybook-expect.md b/code/lib/eslint-plugin/docs/rules/use-storybook-expect.md
index ae197c50ad37..d7c54c24a2ba 100644
--- a/code/lib/eslint-plugin/docs/rules/use-storybook-expect.md
+++ b/code/lib/eslint-plugin/docs/rules/use-storybook-expect.md
@@ -24,9 +24,9 @@ Examples of **correct** code for this rule:
```js
// Correct import.
-import { expect } from 'storybook/test';
+import { expect } from "storybook/test";
// or this, which is now considered legacy
-import { expect } from '@storybook/jest';
+import { expect } from "@storybook/jest";
Default.play = async () => {
// Using imported expect from storybook package
diff --git a/code/lib/eslint-plugin/docs/rules/use-storybook-testing-library.md b/code/lib/eslint-plugin/docs/rules/use-storybook-testing-library.md
index aefddb556d49..a08b40b8c687 100644
--- a/code/lib/eslint-plugin/docs/rules/use-storybook-testing-library.md
+++ b/code/lib/eslint-plugin/docs/rules/use-storybook-testing-library.md
@@ -15,7 +15,7 @@ Examples of **incorrect** code for this rule:
```js
// wrong import!
-import { within } from '@testing-library/react';
+import { within } from "@testing-library/react";
Default.play = async (context) => {
const canvas = within(context.canvasElement);
@@ -26,9 +26,9 @@ Examples of **correct** code for this rule:
```js
// correct import.
-import { within } from 'storybook/test';
+import { within } from "storybook/test";
// or this, which is now considered legacy
-import { within } from '@storybook/testing-library';
+import { within } from "@storybook/testing-library";
Default.play = async (context) => {
const canvas = within(context.canvasElement);
diff --git a/code/lib/eslint-plugin/scripts/update-lib-configs.ts b/code/lib/eslint-plugin/scripts/update-lib-configs.ts
index 067aac41ce5e..f4045a5c60b8 100644
--- a/code/lib/eslint-plugin/scripts/update-lib-configs.ts
+++ b/code/lib/eslint-plugin/scripts/update-lib-configs.ts
@@ -4,11 +4,7 @@ This script updates `lib/configs/*.js` files from rule's meta data.
import fs from 'node:fs/promises';
import path from 'node:path';
-import type { Options } from 'prettier';
-import { format } from 'prettier';
-
-// @ts-expect-error this file has no types
-import prettierConfig from '../../../../prettier.config.mjs';
+import { format } from 'oxfmt';
import type { TCategory } from './utils/categories';
import { categories } from './utils/categories';
import {
@@ -68,10 +64,11 @@ export async function update() {
await Promise.all(
categories.map(async (category) => {
const filePath = path.join(CONFIG_DIR, `${category.categoryId}.ts`);
- const content = await format(formatCategory(category), {
- parser: 'typescript',
- ...(prettierConfig as Options),
- });
+ const { code: content } = await format(
+ `${category.categoryId}.ts`,
+ formatCategory(category),
+ { singleQuote: true }
+ );
await fs.writeFile(filePath, content);
})
diff --git a/code/lib/eslint-plugin/scripts/update-lib-flat-configs.ts b/code/lib/eslint-plugin/scripts/update-lib-flat-configs.ts
index f011c12cc18e..f779e8e98511 100644
--- a/code/lib/eslint-plugin/scripts/update-lib-flat-configs.ts
+++ b/code/lib/eslint-plugin/scripts/update-lib-flat-configs.ts
@@ -4,11 +4,7 @@ This script updates `lib/configs/flat/*.js` files from rule's meta data.
import fs from 'node:fs/promises';
import path from 'node:path';
-import type { Options } from 'prettier';
-import { format } from 'prettier';
-
-// @ts-expect-error this file has no types
-import prettierConfig from '../../../../prettier.config.mjs';
+import { format } from 'oxfmt';
import type { TCategory } from './utils/categories';
import { categories } from './utils/categories';
import {
@@ -81,10 +77,11 @@ export async function update() {
await Promise.all(
categories.map(async (category) => {
const filePath = path.join(FLAT_CONFIG_DIR, `${category.categoryId}.ts`);
- const content = await format(formatCategory(category), {
- parser: 'typescript',
- ...(prettierConfig as Options),
- });
+ const { code: content } = await format(
+ `${category.categoryId}.ts`,
+ formatCategory(category),
+ { singleQuote: true }
+ );
await fs.writeFile(filePath, content);
})
diff --git a/code/lib/eslint-plugin/scripts/update-lib-index.ts b/code/lib/eslint-plugin/scripts/update-lib-index.ts
index 4f0b04e17212..f3ba39a27890 100644
--- a/code/lib/eslint-plugin/scripts/update-lib-index.ts
+++ b/code/lib/eslint-plugin/scripts/update-lib-index.ts
@@ -5,11 +5,8 @@ This script updates `src/index.js` file from rule's meta data.
*/
import fs from 'fs/promises';
import path from 'path';
-import type { Options } from 'prettier';
-import { format } from 'prettier';
+import { format } from 'oxfmt';
-// @ts-expect-error this file has no types
-import prettierConfig from '../../../../prettier.config.mjs';
import { categoryIds } from './utils/categories';
import rules from './utils/rules';
@@ -56,9 +53,6 @@ export default {
rules,
}
`;
- const content = await format(rawContent, {
- parser: 'typescript',
- ...(prettierConfig as Options),
- });
+ const { code: content } = await format('index.ts', rawContent, { singleQuote: true });
await fs.writeFile(path.resolve(__dirname, '../src/index.ts'), content);
}
diff --git a/code/lib/eslint-plugin/src/index.ts b/code/lib/eslint-plugin/src/index.ts
index 40556e58fca3..1fe2e18edc8d 100644
--- a/code/lib/eslint-plugin/src/index.ts
+++ b/code/lib/eslint-plugin/src/index.ts
@@ -4,14 +4,15 @@
* in order to update its content execute "yarn update"
*/
// configs
-import addonInteractions from './configs/addon-interactions';
import csf from './configs/csf';
import csfStrict from './configs/csf-strict';
-import flatAddonInteractions from './configs/flat/addon-interactions';
+import addonInteractions from './configs/addon-interactions';
+import recommended from './configs/recommended';
import flatCsf from './configs/flat/csf';
import flatCsfStrict from './configs/flat/csf-strict';
+import flatAddonInteractions from './configs/flat/addon-interactions';
import flatRecommended from './configs/flat/recommended';
-import recommended from './configs/recommended';
+
// rules
import awaitInteractions from './rules/await-interactions';
import contextInPlayFunction from './rules/context-in-play-function';
diff --git a/code/package.json b/code/package.json
index 55f8d90fbbbc..784627589f95 100644
--- a/code/package.json
+++ b/code/package.json
@@ -24,13 +24,11 @@
"github-release": "github-release-from-changelog",
"i": "yarn --cwd .. i",
"knip": "knip --config ../scripts/knip.config.ts",
- "lint": "yarn lint:js && yarn lint:other",
+ "lint": "yarn lint:js",
"lint:ejs": "ejslint **/*.ejs",
"lint:js": "yarn lint:js:cmd . --quiet",
"lint:js:cmd": "cross-env NODE_ENV=production eslint --cache --cache-location=../.cache/eslint --ext .js,.jsx,.json,.html,.ts,.tsx,.mjs --report-unused-disable-directives",
- "lint:other": "yarn lint:prettier '**/*.{css,html,json,md,yml}'",
"lint:package": "yarn --cwd ../scripts lint:package",
- "lint:prettier": "prettier --write",
"local-registry": "yarn --cwd ../scripts local-registry",
"publish-sandboxes": "yarn --cwd ../scripts publish",
"storybook:ui": "NODE_OPTIONS=\"--max_old_space_size=4096 --trace-deprecation\" core/dist/bin/dispatcher.js dev --port 6006 --config-dir ./.storybook",
@@ -38,20 +36,6 @@
"storybook:ui:chromatic": "chromatic --storybook-build-dir storybook-static --exit-zero-on-changes --exit-once-uploaded",
"task": "yarn --cwd ../scripts task"
},
- "lint-staged": {
- "*.{html,js,json,jsx,mjs,ts,tsx}": [
- "yarn lint:js:cmd --fix"
- ],
- "*.ejs": [
- "yarn --cwd ../scripts ejslint"
- ],
- "*.{css,html,json,md,yml}": [
- "yarn lint:prettier"
- ],
- "package.json": [
- "yarn lint:package"
- ]
- },
"browserslist": [
"chrome >= 131",
"android >= 131",
@@ -125,7 +109,6 @@
"happy-dom": "^17.6.3",
"http-server": "^14.1.1",
"knip": "^5.70.2",
- "lint-staged": "^16.2.7",
"mock-require": "^3.0.3",
"prettier": "^3.7.1",
"process": "^0.11.10",
@@ -144,6 +127,9 @@
"vitest": "^4.1.0",
"wait-on": "^8.0.3"
},
+ "devDependencies": {
+ "oxfmt": "^0.41.0"
+ },
"dependenciesMeta": {
"ejs": {
"built": false
@@ -209,5 +195,6 @@
"Dependency Upgrades"
]
]
- }
+ },
+ "deferredNextVersion": "10.3.4"
}
diff --git a/code/presets/react-webpack/src/loaders/docgen-resolver.ts b/code/presets/react-webpack/src/loaders/docgen-resolver.ts
index cc325855426a..7a4fa6135b2a 100644
--- a/code/presets/react-webpack/src/loaders/docgen-resolver.ts
+++ b/code/presets/react-webpack/src/loaders/docgen-resolver.ts
@@ -55,9 +55,16 @@ export function defaultLookupModule(filename: string, basedir: string): string {
switch (ext) {
case '.js':
case '.mjs':
- case '.cjs':
- newFilename = `${filename.slice(0, -2)}ts`;
+ case '.cjs': {
+ // Try .ts first, then fall back to .tsx (for React components using ESM-style .js imports)
+ const base = filename.slice(0, -2);
+ try {
+ return resolve.sync(`${base}ts`, { ...resolveOptions, extensions: [] });
+ } catch {
+ newFilename = `${base}tsx`;
+ }
break;
+ }
case '.jsx':
newFilename = `${filename.slice(0, -3)}tsx`;
diff --git a/code/prettier.config.mjs b/code/prettier.config.mjs
deleted file mode 100644
index 61c69633bcd5..000000000000
--- a/code/prettier.config.mjs
+++ /dev/null
@@ -1,3 +0,0 @@
-import base from '../scripts/prettier.config.js';
-
-export default base;
diff --git a/code/project.json b/code/project.json
index ff6804de0ee1..0dd7e1d1c4c5 100644
--- a/code/project.json
+++ b/code/project.json
@@ -2,6 +2,13 @@
"name": "code",
"tags": ["library"],
"targets": {
+ "fmt": {
+ "executor": "nx:run-commands",
+ "options": { "command": "yarn fmt:check" },
+ "cache": true,
+ "inputs": ["sharedGlobals", "{workspaceRoot}/**/*"],
+ "configurations": { "production": {} }
+ },
"lint": {
"dependsOn": [{ "projects": ["*"], "target": "compile" }],
"executor": "nx:run-commands",
diff --git a/code/renderers/react/src/componentManifest/reactDocgen/docgenResolver.ts b/code/renderers/react/src/componentManifest/reactDocgen/docgenResolver.ts
index 6b69ca55d7dd..69dd67e81948 100644
--- a/code/renderers/react/src/componentManifest/reactDocgen/docgenResolver.ts
+++ b/code/renderers/react/src/componentManifest/reactDocgen/docgenResolver.ts
@@ -38,9 +38,16 @@ export function defaultLookupModule(filename: string, basedir: string): string {
switch (ext) {
case '.js':
case '.mjs':
- case '.cjs':
- newFilename = `${filename.slice(0, -2)}ts`;
+ case '.cjs': {
+ // Try .ts first, then fall back to .tsx (for React components using ESM-style .js imports)
+ const base = filename.slice(0, -2); // removes "js" keeping the dot, e.g. "Chip." or "Chip.m"
+ try {
+ return resolve.sync(`${base}ts`, { ...resolveOptions, extensions: [] });
+ } catch {
+ newFilename = `${base}tsx`;
+ }
break;
+ }
case '.jsx':
newFilename = `${filename.slice(0, -3)}tsx`;
diff --git a/code/renderers/web-components/src/csf-factories.test.ts b/code/renderers/web-components/src/csf-factories.test.ts
index 854496233169..61795040ebff 100644
--- a/code/renderers/web-components/src/csf-factories.test.ts
+++ b/code/renderers/web-components/src/csf-factories.test.ts
@@ -22,7 +22,9 @@ class MyButton extends LitElement {
class MyComponent extends LitElement {
render() {
- return html``;
+ return html`
+
+ `;
}
}
declare global {
@@ -102,10 +104,18 @@ describe('Args can be provided in multiple ways', () => {
args: { label: 'good' },
});
const Basic = meta.story({
- render: () => html`
Hello world
`,
+ render: () =>
+ html`
+
Hello world
+ `,
});
- const CSF1 = meta.story(() => html`
Hello world
`);
+ const CSF1 = meta.story(
+ () =>
+ html`
+
Hello world
+ `
+ );
});
it('❌ Required args need to be provided when the user uses a non-empty render', () => {
@@ -118,7 +128,10 @@ describe('Args can be provided in multiple ways', () => {
args: {
label: 'good',
},
- render: (args) => html`