Skip to content

refactor: create import alias for .storybook directory #14941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
["^@/data"],
// From the `constants` directory.
["^@/lib/constants"],
// From the `.storybook/utils` file
["^@/storybook-utils"],
// `.storybook` directory and utils files`
["^@/storybook","^@/storybook-utils"],
// Parent imports. Put `..` last.
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
// Other relative imports. Put same-folder imports and `.` last.
Expand Down
7 changes: 7 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import path from "path"

import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin"
import type { StorybookConfig } from "@storybook/nextjs"

Expand Down Expand Up @@ -51,6 +53,11 @@ const config: StorybookConfig = {
extensions: config.resolve.extensions,
}),
]

config.resolve.alias = {
...config.resolve.alias,
"@/storybook/*": path.resolve(__dirname, "./.storybook/"),
}
}

// This modifies the existing image rule to exclude .svg files
Expand Down
2 changes: 1 addition & 1 deletion src/components/Hero/ContentHero/ContentHero.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTranslations } from "next-intl"
import { Meta, StoryObj } from "@storybook/react"

import { langViewportModes } from "../../../../.storybook/modes"
import { langViewportModes } from "@/storybook/modes"

import ContentHeroComponent, { ContentHeroProps } from "."

Expand Down
6 changes: 3 additions & 3 deletions src/components/Hero/HomeHero/HomeHero.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Meta, StoryObj } from "@storybook/react"

import { langViewportModes } from "../../../../.storybook/modes"
import { langViewportModes } from "@/storybook/modes"

import HomeHeroComponent from "."

import homeHeroImg from "@/public/images/home/hero.png"

const meta = {
title: "Organisms / Layouts / Hero",
component: HomeHeroComponent,
Expand All @@ -26,8 +28,6 @@ const meta = {

export default meta

import homeHeroImg from "@/public/images/home/hero.png"

export const HomeHero: StoryObj<typeof meta> = {
args: {
heroImg: homeHeroImg,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Hero/HubHero/HubHero.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Meta, StoryObj } from "@storybook/react"

import { screens } from "@/lib/utils/screen"

import { langViewportModes } from "../../../../.storybook/modes"
import { langViewportModes } from "@/storybook/modes"

import HubHeroComponent, { type HubHeroProps } from "./"

Expand Down
2 changes: 1 addition & 1 deletion src/components/Hero/MdxHero/MdxHero.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HStack } from "@/components/ui/flex"

import { screens } from "@/lib/utils/screen"

import { langViewportModes } from "../../../../.storybook/modes"
import { langViewportModes } from "@/storybook/modes"

import MdxHeroComponent from "./"

Expand Down
2 changes: 1 addition & 1 deletion src/components/MdComponents/MdComponents.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pickBy from "lodash/pickBy"
import type { Meta, StoryObj } from "@storybook/react/*"

import { viewportModes } from "../../../.storybook/modes"
import { viewportModes } from "@/storybook/modes"

import MdComponentSet from "."

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta, StoryObj } from "@storybook/react"

import { langViewportModes } from "../../../.storybook/modes"
import { langViewportModes } from "@/storybook/modes"

import MergeInfographicComponent from "."

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import pickBy from "lodash/pickBy"
import type { Meta, StoryObj } from "@storybook/react"
import { fn } from "@storybook/test"

import { viewportModes } from "../../../../.storybook/modes"
import { viewportModes } from "@/storybook/modes"

import { Explanation as ExplanationComponent } from "../Explanation"
import { SendReceiveIcon } from "../icons"

Expand Down
3 changes: 2 additions & 1 deletion src/layouts/stories/BaseLayout.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type { Meta, StoryObj } from "@storybook/react"

import { Center } from "@/components/ui/flex"

import { langViewportModes } from "../../../.storybook/modes"
import { langViewportModes } from "@/storybook/modes"

import { BaseLayout as BaseLayoutComponent } from "../BaseLayout"

const meta = {
Expand Down
3 changes: 2 additions & 1 deletion src/layouts/stories/ContentLayout.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type { Meta, StoryObj } from "@storybook/react"

import { Center } from "@/components/ui/flex"

import { langViewportModes } from "../../../.storybook/modes"
import { langViewportModes } from "@/storybook/modes"

import { ContentLayout as ContentLayoutComponent } from "../ContentLayout"

const meta = {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"paths": {
"@/*": ["./src/*"],
"@/public/*": ["./public/*"],
"@/storybook-utils": ["./.storybook/utils.ts"]
"@/storybook-utils": ["./.storybook/utils.ts"],
"@/storybook/*": ["./.storybook/*"]
}
},
"include": ["./src/**/*", "next-env.d.ts", "**/*.ts", "**/*.tsx", ".storybook/**/*"],
Expand Down