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
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ updates:
lint:
patterns:
- '@eslint/*'
- '@trivago/prettier-plugin-*'
- '@types/*'
- 'eslint'
- 'eslint-*'
Expand Down
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"importOrder": ["<BUILTIN_MODULES>", "<THIRD_PARTY_MODULES>", "^#(.*)$", "^[./]"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"printWidth": 100,
"quoteProps": "consistent",
"semi": true,
Expand Down
2 changes: 1 addition & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type StorybookConfig } from '@storybook/react-vite';
import preserveDirectives from 'rollup-preserve-directives';
import { mergeConfig, type InlineConfig } from 'vite';
import { type InlineConfig, mergeConfig } from 'vite';
import tsConfigPaths from 'vite-tsconfig-paths';

const config: StorybookConfig = {
Expand Down
3 changes: 2 additions & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import './storybook.scss';
import { type Preview } from '@storybook/react-vite';

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

import './storybook.scss';

const preview: Preview = {
decorators: (Story, { parameters }) =>
parameters.width === false ? (
Expand Down
37 changes: 3 additions & 34 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ 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 pluginNodeImport from 'eslint-plugin-node-import';
import pluginReact from 'eslint-plugin-react';
import pluginReactHooks from 'eslint-plugin-react-hooks';
import { defineConfig, globalIgnores } from 'eslint/config';
import globals from 'globals';
import pluginTypeScript from 'typescript-eslint';

Expand All @@ -19,9 +19,8 @@ export default defineConfig([
files: ['**/*.{js,mjs,ts,tsx}'],
extends: [
eslint.configs.recommended,
pluginImport.flatConfigs.recommended,
pluginImport.flatConfigs.typescript,
pluginTypeScript.configs.recommended,
pluginNodeImport.configs['flat/recommended'],
configPrettier,
],
languageOptions: {
Expand All @@ -33,30 +32,6 @@ export default defineConfig([
},
},
rules: {
// Turn off rules that are handled by TypeScript
// https://typescript-eslint.io/troubleshooting/typed-linting/performance/#eslint-plugin-import
'import/default': 'off',
'import/named': 'off',
'import/namespace': 'off',
'import/no-cycle': 'off',
'import/no-deprecated': 'off',
'import/no-named-as-default': 'off',
'import/no-named-as-default-member': 'off',
'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',
Expand All @@ -71,12 +46,6 @@ export default defineConfig([
},
],
},
settings: {
'import/resolver': {
node: true,
typescript: true,
},
},
},
{
files: ['**/*.{ts,tsx}'],
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@babel/preset-env": "^7.29.2",
"@babel/preset-react": "^7.28.5",
"@babel/preset-typescript": "^7.28.5",
"@eslint/compat": "^2.0.3",
"@eslint/compat": "^2.0.5",
"@eslint/js": "^9.39.4",
"@rollup/plugin-babel": "^7.0.0",
"@rollup/plugin-commonjs": "^29.0.2",
Expand All @@ -80,11 +80,12 @@
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
"@types/eslint": "^9.6.1",
"@types/eslint-plugin-jsx-a11y": "^6.10.1",
"@types/jest": "^30.0.0",
"@types/jest-axe": "^3.5.9",
"@types/node": "^24.12.0",
"@types/node": "^24.12.2",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"babel-jest": "^30.3.0",
Expand All @@ -94,17 +95,17 @@
"eslint": "^9.39.4",
"eslint-config-prettier": "^10.1.8",
"eslint-import-resolver-typescript": "^4.4.4",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-node-import": "^1.2.0",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.0.1",
"globals": "^17.3.0",
"globals": "^17.5.0",
"jest": "^30.3.0",
"jest-axe": "^10.0.0",
"jest-environment-jsdom": "^30.3.0",
"nhsuk-frontend": "^10.3.1",
"outdent": "^0.8.0",
"prettier": "^3.8.0",
"prettier": "^3.8.3",
"react": "^19.2.5",
"react-dom": "^19.2.5",
"rollup": "^4.60.0",
Expand All @@ -113,7 +114,7 @@
"storybook": "^10.2.14",
"tslib": "^2.8.1",
"typescript": "^6.0.2",
"typescript-eslint": "^8.58.0",
"typescript-eslint": "^8.58.2",
"vite": "^7.3.2",
"vite-tsconfig-paths": "^6.1.1"
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/content-presentation/details/Details.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from 'classnames';
import { forwardRef, type ComponentPropsWithoutRef, type FC } from 'react';
import { type ComponentPropsWithoutRef, type FC, forwardRef } from 'react';

export interface DetailsProps extends ComponentPropsWithoutRef<'details'> {
expander?: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';

import { Details } from '..';

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

import { Details } from '..';

describe('Details', () => {
it('matches snapshot', async () => {
const { container } = await renderClient(<Details />, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use client';

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

import { Heading, type HeadingProps } from '#components/typography/Heading.js';

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

import { Heading, type HeadingProps } from '#components/typography/Heading.js';

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

import { DoAndDontList } from '..';

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

import { DoAndDontList } from '..';

describe('DoAndDontList', () => {
describe('list type "do"', () => {
it('matches snapshot', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

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

import { CrossIcon, TickIcon } from '../../icons/index.js';
import { DoAndDontListContext, type DoAndDontListType } from '../DoAndDontListContext.js';
Expand Down
2 changes: 1 addition & 1 deletion src/components/content-presentation/hero/Hero.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from 'classnames';
import { forwardRef, type ComponentPropsWithoutRef, type FC } from 'react';
import { type ComponentPropsWithoutRef, type FC, forwardRef } from 'react';

import { Col, Container, Row } from '#components/layout/index.js';
import { Heading, type HeadingProps } from '#components/typography/Heading.js';
Expand Down
2 changes: 1 addition & 1 deletion src/components/content-presentation/images/Images.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from 'classnames';
import { forwardRef, type ComponentPropsWithoutRef } from 'react';
import { type ComponentPropsWithoutRef, forwardRef } from 'react';

export interface ImagesProps extends ComponentPropsWithoutRef<'img'> {
caption?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from 'classnames';
import { forwardRef, type ComponentPropsWithoutRef } from 'react';
import { type ComponentPropsWithoutRef, forwardRef } from 'react';

export type InsetTextProps = ComponentPropsWithoutRef<'div'>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import classNames from 'classnames';
import { type NotificationBanner as NotificationBannerModule } from 'nhsuk-frontend';
import {
Children,
type ComponentPropsWithoutRef,
forwardRef,
useEffect,
useImperativeHandle,
useRef,
useState,
type ComponentPropsWithoutRef,
} from 'react';

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

import {
NotificationBannerHeading,
NotificationBannerLink,
NotificationBannerTitle,
} from './components/index.js';

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

export interface NotificationBannerProps extends ComponentPropsWithoutRef<'div'> {
success?: boolean;
disableAutoFocus?: boolean;
Expand Down
6 changes: 3 additions & 3 deletions src/components/content-presentation/panel/Panel.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import classNames from 'classnames';
import { Children, forwardRef, type ComponentPropsWithoutRef } from 'react';

import { PanelTitle } from './components/index.js';
import { Children, type ComponentPropsWithoutRef, forwardRef } from 'react';

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

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

export interface PanelProps extends ComponentPropsWithoutRef<'div'> {
interruption?: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';

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

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

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

describe('Panel', () => {
const Example = (props: Parameters<typeof Panel>[0]) => (
<Panel {...props}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from 'classnames';
import { forwardRef, type ComponentPropsWithoutRef } from 'react';
import { type ComponentPropsWithoutRef, forwardRef } from 'react';

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

import { SummaryList } from '..';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { forwardRef, type ReactElement } from 'react';
import { type ReactElement, forwardRef } from 'react';

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import classNames from 'classnames';
import { Children, type ComponentPropsWithoutRef, type FC } from 'react';

import { SummaryListAction } from './SummaryListAction.js';

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

import { SummaryListAction } from './SummaryListAction.js';

export interface SummaryListRowProps extends ComponentPropsWithoutRef<'div'> {
noBorder?: boolean;
}
Expand Down
12 changes: 6 additions & 6 deletions src/components/content-presentation/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

import classNames from 'classnames';
import {
type ComponentPropsWithoutRef,
type ReactNode,
forwardRef,
useMemo,
useState,
type ComponentPropsWithoutRef,
type ReactNode,
} from 'react';

import { TableContext, type ITableContext } from './TableContext.js';
import { type Card as _Card } from '#components/navigation/card/index.js';

import { type ITableContext, TableContext } from './TableContext.js';
import {
TableBody,
TableCaption,
type TableCaptionProps,
TableCell,
TableContainer,
TableHead,
TableRow,
type TableCaptionProps,
} from './components/index.js';

import { type Card as _Card } from '#components/navigation/card/index.js';

export interface TableProps extends ComponentPropsWithoutRef<'table'> {
firstCellIsHeader?: boolean;
responsive?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/components/content-presentation/table/TableContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { createContext, type ReactNode } from 'react';
import { type ReactNode, createContext } from 'react';

export interface ITableContext {
firstCellIsHeader: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/components/content-presentation/table/TableHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Children, type ReactElement, type ReactNode } from 'react';

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

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

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

export const isTableCell = (
child: ReactNode,
): child is ReactElement<TableCellProps, typeof TableCell> => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use client';

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

import { TableContext, type ITableContext } from '../TableContext.js';
import { TableSection, TableSectionContext } from '../TableSectionContext.js';
import { type ComponentPropsWithoutRef, type FC, useContext } from 'react';

import { useDevWarning } from '#util/hooks/index.js';

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

const CellOutsideOfSectionWarning =
'Table.Cell used outside of a Table.Head or Table.Body component. Unable to determine section type from context.';

Expand Down
Loading