Skip to content
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
5 changes: 3 additions & 2 deletions .storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { addons } from 'storybook/manager-api';
import nhsTheme from './theme';
import { startCase, upperFirst } from 'lodash';
import { addons } from 'storybook/manager-api';

import nhsTheme from './theme.js';

const sentenceCase = (name = '') => {
if (!name || typeof name !== 'string') {
Expand Down
1 change: 1 addition & 0 deletions .storybook/theme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { create } from 'storybook/theming/create';

import packageJson from '../package.json' with { type: 'json' };

export default create({
Expand Down
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ packageExtensions:
storybook@*:
peerDependencies:
"@testing-library/dom": "*"
react: "*"
react-dom: "*"
vite@*:
peerDependencies:
rollup: "*"
26 changes: 21 additions & 5 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { join } from 'node:path';

import { includeIgnoreFile } from '@eslint/compat';
import eslint from '@eslint/js';
import { defineConfig, globalIgnores } from 'eslint/config';
import configPrettier from 'eslint-config-prettier/flat';
import pluginImport from 'eslint-plugin-import';
import pluginJsxA11y from 'eslint-plugin-jsx-a11y';
import pluginReact from 'eslint-plugin-react';
import pluginReactHooks from 'eslint-plugin-react-hooks';
import eslint from '@eslint/js';
import pluginJsxA11y from 'eslint-plugin-jsx-a11y';
import { includeIgnoreFile } from '@eslint/compat';
import { defineConfig, globalIgnores } from 'eslint/config';
import globals from 'globals';
import pluginImport from 'eslint-plugin-import';
import pluginTypeScript from 'typescript-eslint';

const rootPath = import.meta.dirname;
Expand Down Expand Up @@ -44,8 +45,23 @@ export default defineConfig([
'import/no-unresolved': 'off',
'import/no-unused-modules': 'off',

// Always import Node.js packages from `node:*`
'import/enforce-node-protocol-usage': ['error', 'always'],

// Check import or require statements are A-Z ordered
'import/order': [
'error',
{
'alphabetize': { order: 'asc' },
'newlines-between': 'always',
},
],

// Prefer rules that are type aware
'no-redeclare': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
Expand Down
20 changes: 6 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,10 @@
"import": "./dist/esm/components/*",
"require": "./dist/cjs/components/*"
},
"#components": {
"import": "./dist/esm/components/index.js",
"require": "./dist/cjs/components/index.cjs"
},
"#patterns/*": {
"import": "./dist/esm/patterns/*",
"require": "./dist/cjs/patterns/*"
},
"#patterns": {
"import": "./dist/esm/patterns/index.js",
"require": "./dist/cjs/patterns/index.cjs"
},
"#util/*": {
"import": "./dist/esm/util/*",
"require": "./dist/cjs/util/*"
Expand Down Expand Up @@ -78,9 +70,9 @@
"@rollup/plugin-commonjs": "^29.0.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-typescript": "^12.3.0",
"@storybook/addon-docs": "9.1.10",
"@storybook/addon-links": "^9.1.10",
"@storybook/react-vite": "^9.1.10",
"@storybook/addon-docs": "10.0.3",
"@storybook/addon-links": "^10.0.3",
"@storybook/react-vite": "^10.0.3",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.0",
Expand Down Expand Up @@ -114,12 +106,12 @@
"react-dom": "^19.2.0",
"rollup": "^4.52.5",
"rollup-preserve-directives": "^1.1.3",
"sass-embedded": "^1.93.2",
"storybook": "^9.1.10",
"sass-embedded": "^1.93.3",
"storybook": "^10.0.3",
"tslib": "^2.8.1",
"typescript": "^5.9.3",
"typescript-eslint": "^8.46.2",
"vite": "^7.1.11",
"vite": "^7.1.12",
"vite-tsconfig-paths": "^5.1.4"
},
"peerDependencies": {
Expand Down
12 changes: 10 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { join } from 'node:path';
import { dirname, join, relative, resolve } from 'node:path';

import { DEFAULT_EXTENSIONS as extensions } from '@babel/core';
import { babel } from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import preserveDirectives from 'rollup-preserve-directives';
import { defineConfig } from 'rollup';
import preserveDirectives from 'rollup-preserve-directives';

import packageJson from './package.json' with { type: 'json' };
import tsBuildConfig from './tsconfig.build.json' with { type: 'json' };

Expand Down Expand Up @@ -38,6 +40,12 @@ export default defineConfig(
preserveModulesRoot: 'src',
sourcemap: true,
sourcemapExcludeSources: true,

// Fix source map relative paths to sources
sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => {
const sourcePath = resolve(sourcemapPath, relativeSourcePath);
return relative(dirname(sourcemapPath), sourcePath);
},
},
],
external: ['react/jsx-runtime', ...external],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';

import { Details } from '..';

import { renderClient, renderServer } from '#util/components';

describe('Details', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import classNames from 'classnames';
import { forwardRef, type ComponentPropsWithoutRef } from 'react';
import { HeadingLevel, type HeadingLevelProps } from '#components/utils/HeadingLevel.js';

import { DoAndDontListContext, type DoAndDontListType } from './DoAndDontListContext.js';
import { DoAndDontListItem } from './components/index.js';

import { HeadingLevel, type HeadingLevelProps } from '#components/utils/HeadingLevel.js';

export interface DoAndDontListProps
extends ComponentPropsWithoutRef<'div'>,
Pick<HeadingLevelProps, 'headingLevel'> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';

import { DoAndDontList } from '..';

import { renderClient, renderServer } from '#util/components';

describe('DoAndDontList', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import { useContext, type ComponentPropsWithoutRef, type FC, type ReactNode } from 'react';

import { CrossIcon, TickIcon } from '../../icons/index.js';
import { DoAndDontListContext, type DoAndDontListType } from '../DoAndDontListContext.js';

Expand Down
1 change: 1 addition & 0 deletions src/components/content-presentation/hero/Hero.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import classNames from 'classnames';
import { forwardRef, type ComponentPropsWithoutRef, type FC } from 'react';

import { Col, Container, Row } from '#components/layout/index.js';
import { HeadingLevel, type HeadingLevelProps } from '#components/utils/HeadingLevel.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';

import { Hero } from '..';

describe('Hero', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { render } from '@testing-library/react';

import * as Icons from '..';

describe('Icons', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type FC } from 'react';

import { Icon, type IconProps } from '../Icon.js';

export const ArrowLeftIcon: FC<IconProps> = (props) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type FC } from 'react';

import { Icon, type IconProps } from '../Icon.js';

export const ArrowRightCircleIcon: FC<IconProps> = (props) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type FC } from 'react';

import { Icon, type IconProps } from '../Icon.js';

export const ArrowRightIcon: FC<IconProps> = (props) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type FC } from 'react';

import { Icon, type IconProps } from '../Icon.js';

export const ChevronRightCircleIcon: FC<IconProps> = (props) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type FC } from 'react';

import { Icon, type IconProps } from '../Icon.js';

export const CrossIcon: FC<IconProps> = (props) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type FC } from 'react';

import { Icon, type IconProps } from '../Icon.js';

export const SearchIcon: FC<IconProps> = (props) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type FC } from 'react';

import { Icon, type IconProps } from '../Icon.js';

export const TickIcon: FC<IconProps> = (props) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type FC } from 'react';

import { Icon, type IconProps } from '../Icon.js';

export const UserIcon: FC<IconProps> = (props) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';

import { Images } from '..';

describe('Images', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';

import { InsetText } from '..';

describe('InsetText', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use client';

import classNames from 'classnames';
import { type NotificationBanner as NotificationBannerModule } from 'nhsuk-frontend';
import {
Children,
forwardRef,
Expand All @@ -9,13 +11,13 @@ import {
useState,
type ComponentPropsWithoutRef,
} from 'react';
import classNames from 'classnames';

import {
NotificationBannerHeading,
NotificationBannerLink,
NotificationBannerTitle,
} from './components/index.js';
import { type NotificationBanner as NotificationBannerModule } from 'nhsuk-frontend';

import { childIsOfComponentType } from '#util/types/TypeGuards.js';

export interface NotificationBannerProps extends ComponentPropsWithoutRef<'div'> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { renderClient, renderServer } from '#util/components';
import { NotificationBanner } from '#components/content-presentation/notification-banner';
import { createRef } from 'react';

import { NotificationBanner } from '#components/content-presentation/notification-banner';
import { NotificationBannerLink } from '#components/content-presentation/notification-banner/components';
import { renderClient, renderServer } from '#util/components';

describe('NotificationBanner', () => {
it('matches snapshot', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use client';

import { HeadingLevel, type HeadingLevelProps } from '#components/utils/HeadingLevel.js';
import type { FC } from 'react';

import { HeadingLevel, type HeadingLevelProps } from '#components/utils/HeadingLevel.js';

export type NotificationBannerHeadingProps = HeadingLevelProps;

export const NotificationBannerHeading: FC<NotificationBannerHeadingProps> = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { AsElementLink } from '#util/types/index.js';
import { forwardRef } from 'react';
import classNames from 'classnames';
import { forwardRef } from 'react';

import type { AsElementLink } from '#util/types/index.js';

export type NotificationBannerLinkProps = AsElementLink<HTMLAnchorElement>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HeadingLevel, type HeadingLevelProps } from '#components/utils/HeadingLevel.js';
import type { FC } from 'react';

import { HeadingLevel, type HeadingLevelProps } from '#components/utils/HeadingLevel.js';

export interface NotificationBannerTitleProps extends HeadingLevelProps {
success?: boolean;
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/content-presentation/panel/Panel.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import classNames from 'classnames';
import { Children, forwardRef, type ComponentPropsWithoutRef } from 'react';
import { childIsOfComponentType } from '#util/types/TypeGuards.js';

import { PanelTitle } from './components/index.js';

import { childIsOfComponentType } from '#util/types/TypeGuards.js';

export type PanelProps = ComponentPropsWithoutRef<'div'>;

const PanelComponent = forwardRef<HTMLDivElement, PanelProps>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';

import { Panel, type PanelTitleProps } from '..';

import { renderClient, renderServer } from '#util/components';

describe('Panel', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type FC } from 'react';

import { HeadingLevel, type HeadingLevelProps } from '#components/utils/HeadingLevel.js';

export type PanelTitleProps = HeadingLevelProps;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';

import { SummaryList } from '..';

describe('SummaryList', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/content-presentation/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
type ComponentPropsWithoutRef,
type ReactNode,
} from 'react';

import { TableContext, type ITableContext } from './TableContext.js';
import {
TableBody,
TableCaption,
Expand All @@ -18,7 +20,6 @@ import {
TableRow,
type TableCaptionProps,
} from './components/index.js';
import { TableContext, type ITableContext } from './TableContext.js';

export interface TableProps extends ComponentPropsWithoutRef<'table'> {
firstCellIsHeader?: boolean;
Expand Down
2 changes: 2 additions & 0 deletions src/components/content-presentation/table/TableHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Children, type ReactElement, type ReactNode } from 'react';

import { TableCell, type TableCellProps } from './components/TableCell.js';

import { childIsOfComponentType } from '#util/types/TypeGuards.js';

export const isTableCell = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import classNames from 'classnames';
import { type ComponentPropsWithoutRef, type FC } from 'react';

import { TableSection, TableSectionContext } from '../TableSectionContext.js';

export type TableBodyProps = ComponentPropsWithoutRef<'tbody'>;
Expand Down
Loading