Skip to content

Commit 8b79a6d

Browse files
committed
Merge remote-tracking branch 'origin/main' into add-notification-banner-component
2 parents 2700c85 + dcc0180 commit 8b79a6d

File tree

10 files changed

+181
-90
lines changed

10 files changed

+181
-90
lines changed

.github/dependabot.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
version: 2
2+
3+
updates:
4+
# Update npm packages
5+
- package-ecosystem: npm
6+
directory: /
7+
8+
# Group packages into shared PR
9+
groups:
10+
build:
11+
patterns:
12+
- '@babel/*'
13+
- '@rollup/*'
14+
- '@types/react'
15+
- '@types/react-*'
16+
- 'classnames'
17+
- 'nhsuk-frontend'
18+
- 'react'
19+
- 'react-dom'
20+
- 'rollup'
21+
- 'tslib'
22+
23+
lint:
24+
patterns:
25+
- '@eslint/*'
26+
- '@types/*'
27+
- 'eslint'
28+
- 'eslint-*'
29+
- 'globals'
30+
- 'prettier'
31+
- 'typescript'
32+
- 'typescript-*'
33+
34+
# Exclude packages in other groups
35+
exclude-patterns:
36+
- '@types/jest'
37+
- '@types/jest-*'
38+
- '@types/react'
39+
- '@types/react-*'
40+
41+
test:
42+
patterns:
43+
- '@testing-library/*'
44+
- '@types/jest'
45+
- '@types/jest-*'
46+
- 'babel-*'
47+
- 'jest'
48+
- 'jest-*'
49+
50+
tools:
51+
patterns:
52+
- '@storybook/*'
53+
- 'lodash'
54+
- 'outdent'
55+
- 'sass-embedded'
56+
- 'storybook'
57+
- 'vite'
58+
- 'vite-*'
59+
60+
schedule:
61+
interval: monthly
62+
63+
versioning-strategy: increase
64+
65+
allow:
66+
# Include direct package.json updates
67+
- dependency-type: direct
68+
69+
# Include indirect browser data updates
70+
# https://caniuse.com
71+
- dependency-name: caniuse-lite
72+
73+
# Update GitHub Actions
74+
- package-ecosystem: github-actions
75+
directory: /
76+
77+
schedule:
78+
interval: 'monthly'

.github/workflows/ci.yml

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,65 @@ name: CI Build
22

33
on:
44
push:
5-
branches: main
5+
branches: [main]
6+
67
pull_request:
78

89
jobs:
910
build:
1011
runs-on: ubuntu-latest
1112

13+
env:
14+
CHROMATIC_BRANCH: ${{ github.event.pull_request.head.ref || github.ref_name }}
15+
CHROMATIC_SHA: ${{ github.event.pull_request.head.sha || github.ref }}
16+
CHROMATIC_SLUG: ${{ github.repository }}
17+
CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
1220
steps:
13-
- uses: actions/checkout@v4
14-
- name: Set up Node.js
15-
uses: actions/setup-node@v2
21+
- name: Checkout
22+
uses: actions/checkout@v5
1623
with:
17-
node-version-file: .nvmrc
24+
fetch-depth: 0
25+
1826
- name: Enable corepack
1927
run: corepack enable
20-
- name: Set Yarn version
21-
run: yarn set version stable
28+
29+
- name: Set up Node.js
30+
uses: actions/setup-node@v5
31+
with:
32+
cache: yarn
33+
node-version-file: .nvmrc
34+
2235
- name: Yarn Install
2336
run: yarn
37+
2438
- name: Lint
2539
run: yarn lint
40+
2641
- name: Jest Tests
2742
run: yarn test --coverage
43+
2844
- name: Typescript build
2945
run: yarn build
46+
3047
- name: Storybook build
3148
run: yarn build-storybook
49+
50+
- name: Switch to PR branch
51+
if: ${{ github.event_name == 'pull_request' && env.CHROMATIC_PROJECT_TOKEN }}
52+
uses: actions/checkout@v5
53+
with:
54+
clean: false
55+
fetch-depth: 0
56+
ref: ${{ env.CHROMATIC_BRANCH }}
57+
58+
- name: Storybook deploy
59+
if: ${{ env.CHROMATIC_PROJECT_TOKEN }}
60+
uses: chromaui/action@v13
61+
with:
62+
autoAcceptChanges: main
63+
branchName: ${{ env.CHROMATIC_BRANCH}}
64+
onlyChanged: ${{ github.event_name == 'pull_request' }}
65+
projectToken: ${{ env.CHROMATIC_PROJECT_TOKEN }}
66+
token: ${{ env.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,19 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v4
12+
- name: Checkout
13+
uses: actions/checkout@v5
1314
with:
1415
fetch-depth: 0
1516

16-
- name: Set up Node.js
17-
uses: actions/setup-node@v2
18-
with:
19-
node-version-file: .nvmrc
20-
2117
- name: Enable corepack
2218
run: corepack enable
2319

24-
- name: Set Yarn version
25-
run: yarn set version stable
20+
- name: Set up Node.js
21+
uses: actions/setup-node@v5
22+
with:
23+
cache: yarn
24+
node-version-file: .nvmrc
2625

2726
- name: Yarn Install
2827
run: yarn

.github/workflows/storybook.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.storybook/main.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import type { StorybookConfig } from '@storybook/react-vite';
2-
import { mergeConfig } from 'vite';
1+
import { type StorybookConfig } from '@storybook/react-vite';
2+
import { mergeConfig, type InlineConfig } from 'vite';
33
import tsConfigPaths from 'vite-tsconfig-paths';
4+
import { isLogIgnored } from '../rollup.config.js';
45

56
const config: StorybookConfig = {
67
stories: ['../stories/**/*.stories.@(ts|tsx)', '../stories/**/*.mdx'],
@@ -16,7 +17,17 @@ const config: StorybookConfig = {
1617

1718
viteFinal(config) {
1819
return mergeConfig(config, {
19-
plugins: [tsConfigPaths()],
20+
build: {
21+
rollupOptions: {
22+
onwarn(warning, handler) {
23+
if (isLogIgnored(warning)) {
24+
return;
25+
}
26+
27+
handler(warning);
28+
},
29+
},
30+
},
2031
css: {
2132
preprocessorOptions: {
2233
scss: {
@@ -25,7 +36,15 @@ const config: StorybookConfig = {
2536
},
2637
},
2738
},
28-
});
39+
esbuild: {
40+
jsx: 'automatic',
41+
},
42+
plugins: [
43+
tsConfigPaths({
44+
projects: ['./tsconfig.dev.json', './tsconfig.build.json'],
45+
}),
46+
],
47+
} satisfies InlineConfig);
2948
},
3049
};
3150

.yarnrc.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ packageExtensions:
77
peerDependencies:
88
"@types/react": "*"
99
"@types/react-dom": "*"
10-
1110
"@storybook/react-vite@*":
1211
peerDependencies:
1312
typescript: "*"
14-
15-
"storybook@*":
13+
storybook@*:
1614
peerDependencies:
1715
"@testing-library/dom": "*"

babel.config.cjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
const { NODE_ENV } = process.env;
1+
// Node.js environment with default
2+
// https://nodejs.org/en/learn/getting-started/nodejs-the-difference-between-development-and-production
3+
const { NODE_ENV = 'development' } = process.env;
24

35
/**
46
* Babel config
@@ -25,7 +27,7 @@ module.exports = {
2527
[
2628
'@babel/preset-react',
2729
{
28-
development: NODE_ENV === 'development',
30+
development: NODE_ENV === 'test' || NODE_ENV === 'development',
2931
runtime: 'automatic',
3032
useBuiltIns: true,
3133
},

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@
5252
],
5353
"scripts": {
5454
"cleanup": "rm -rf dist/ > /dev/null",
55-
"build": "yarn cleanup && rollup -c",
56-
"storybook": "NODE_ENV=development storybook dev -p 6006",
55+
"build": "NODE_ENV=production yarn cleanup && rollup -c",
56+
"storybook": "storybook dev -p 6006",
5757
"build-storybook": "storybook build",
58-
"test": "jest",
59-
"test:watch": "jest --watch",
58+
"test": "jest --color",
59+
"test:watch": "yarn test --watch",
6060
"lint": "yarn lint:types && yarn lint:js && yarn lint:prettier",
6161
"lint:fix": "yarn lint:js:fix && yarn lint:prettier:fix",
6262
"lint:prettier": "prettier --check .",
6363
"lint:prettier:fix": "prettier --write .",
64-
"lint:js": "eslint . --max-warnings 0",
64+
"lint:js": "eslint . --color --max-warnings 0",
6565
"lint:js:fix": "yarn lint:js --fix",
6666
"lint:types": "tsc --build tsconfig.json --pretty",
67-
"prepublishOnly": "yarn lint && yarn test && yarn storybook --smoke-test"
67+
"prepublishOnly": "yarn storybook --smoke-test"
6868
},
6969
"devDependencies": {
7070
"@babel/core": "^7.28.4",

rollup.config.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default defineConfig(
4040
},
4141
],
4242
external: ['react/jsx-runtime', ...external],
43-
jsx: /** @type {const} */ ('react-jsx'),
43+
jsx: 'react-jsx',
4444
treeshake: false,
4545
plugins: [
4646
nodeResolve({
@@ -63,10 +63,7 @@ export default defineConfig(
6363

6464
// Handle warnings as errors
6565
onwarn(warning) {
66-
const { code, message } = warning;
67-
68-
// Skip warnings about "use client" directives
69-
if (code === 'MODULE_LEVEL_DIRECTIVE' && message.includes(`"use client"`)) {
66+
if (isLogIgnored(warning)) {
7067
return;
7168
}
7269

@@ -77,5 +74,21 @@ export default defineConfig(
7774
);
7875

7976
/**
80-
* @import { OutputOptions, RollupOptions } from 'rollup'
77+
* Whether to ignore Rollup log messages
78+
*
79+
* @param {RollupLog} warning
80+
*/
81+
export function isLogIgnored(warning) {
82+
const { code, message } = warning;
83+
84+
// Skip warnings related to "use client" directives including
85+
// source map issues when directives are bundled by Storybook
86+
return (
87+
code === 'SOURCEMAP_ERROR' ||
88+
(code === 'MODULE_LEVEL_DIRECTIVE' && message.includes('"use client"'))
89+
);
90+
}
91+
92+
/**
93+
* @import { OutputOptions, RollupLog, RollupOptions } from 'rollup'
8194
*/

yarn.lock

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4465,16 +4465,7 @@ __metadata:
44654465
languageName: node
44664466
linkType: hard
44674467

4468-
"braces@npm:^3.0.2, braces@npm:~3.0.2":
4469-
version: 3.0.2
4470-
resolution: "braces@npm:3.0.2"
4471-
dependencies:
4472-
fill-range: "npm:^7.0.1"
4473-
checksum: 10c0/321b4d675791479293264019156ca322163f02dc06e3c4cab33bb15cd43d80b51efef69b0930cfde3acd63d126ebca24cd0544fa6f261e093a0fb41ab9dda381
4474-
languageName: node
4475-
linkType: hard
4476-
4477-
"braces@npm:^3.0.3":
4468+
"braces@npm:^3.0.2, braces@npm:^3.0.3, braces@npm:~3.0.2":
44784469
version: 3.0.3
44794470
resolution: "braces@npm:3.0.3"
44804471
dependencies:
@@ -6061,15 +6052,6 @@ __metadata:
60616052
languageName: node
60626053
linkType: hard
60636054

6064-
"fill-range@npm:^7.0.1":
6065-
version: 7.0.1
6066-
resolution: "fill-range@npm:7.0.1"
6067-
dependencies:
6068-
to-regex-range: "npm:^5.0.1"
6069-
checksum: 10c0/7cdad7d426ffbaadf45aeb5d15ec675bbd77f7597ad5399e3d2766987ed20bda24d5fac64b3ee79d93276f5865608bb22344a26b9b1ae6c4d00bd94bf611623f
6070-
languageName: node
6071-
linkType: hard
6072-
60736055
"fill-range@npm:^7.1.1":
60746056
version: 7.1.1
60756057
resolution: "fill-range@npm:7.1.1"

0 commit comments

Comments
 (0)