codeforlife 2.7.2 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/.github/workflows/main.yml +0 -3
  2. package/CHANGELOG.md +14 -0
  3. package/eslint.config.js +17 -0
  4. package/package.json +45 -24
  5. package/src/api/createApi.ts +4 -4
  6. package/src/api/endpoints/authFactor.ts +2 -2
  7. package/src/api/endpoints/klass.ts +8 -8
  8. package/src/api/endpoints/school.ts +2 -2
  9. package/src/api/endpoints/session.ts +2 -1
  10. package/src/api/endpoints/user.ts +3 -3
  11. package/src/api/models.ts +1 -1
  12. package/src/api/schemas.ts +16 -16
  13. package/src/components/App.css +2 -2
  14. package/src/components/App.tsx +7 -5
  15. package/src/components/CopyIconButton.test.tsx +1 -1
  16. package/src/components/CopyIconButton.tsx +2 -2
  17. package/src/components/Countdown.tsx +3 -3
  18. package/src/components/DownloadFileButton.tsx +2 -1
  19. package/src/components/ElevatedAppBar.tsx +5 -5
  20. package/src/components/Image.tsx +7 -7
  21. package/src/components/InputFileButton.tsx +2 -2
  22. package/src/components/ItemizedList.tsx +4 -4
  23. package/src/components/OrderedGrid.tsx +3 -3
  24. package/src/components/ScrollIntoViewLink.tsx +1 -2
  25. package/src/components/SyncError.tsx +1 -1
  26. package/src/components/TablePagination.tsx +19 -9
  27. package/src/components/YouTubeVideo.tsx +2 -2
  28. package/src/components/form/ApiAutocompleteField.tsx +48 -41
  29. package/src/components/form/AutocompleteField.tsx +22 -11
  30. package/src/components/form/CheckboxField.tsx +14 -9
  31. package/src/components/form/CountryField.tsx +5 -4
  32. package/src/components/form/DatePickerField.tsx +18 -11
  33. package/src/components/form/EmailField.tsx +1 -1
  34. package/src/components/form/FirstNameField.tsx +2 -2
  35. package/src/components/form/Form.tsx +13 -12
  36. package/src/components/form/PasswordField.tsx +2 -2
  37. package/src/components/form/RepeatField.tsx +18 -10
  38. package/src/components/form/SubmitButton.tsx +14 -10
  39. package/src/components/form/TextField.tsx +17 -11
  40. package/src/components/form/UkCountyField.tsx +3 -2
  41. package/src/components/form/index.tsx +35 -28
  42. package/src/components/page/Banner.tsx +3 -3
  43. package/src/components/page/Notification.tsx +3 -3
  44. package/src/components/page/Page.tsx +5 -5
  45. package/src/components/page/Section.tsx +1 -1
  46. package/src/components/page/TabBar.tsx +5 -5
  47. package/src/components/router/Link.tsx +2 -1
  48. package/src/components/router/LinkButton.tsx +1 -0
  49. package/src/components/router/LinkIconButton.tsx +1 -0
  50. package/src/components/router/LinkListItem.tsx +1 -0
  51. package/src/components/router/LinkTab.tsx +1 -0
  52. package/src/components/router/Navigate.tsx +2 -2
  53. package/src/components/router/index.tsx +9 -12
  54. package/src/components/table/CellStack.tsx +2 -2
  55. package/src/components/table/index.tsx +2 -4
  56. package/src/features/InactiveDialog.tsx +2 -2
  57. package/src/features/ScreenTimeDialog.tsx +3 -6
  58. package/src/hooks/api.tsx +4 -2
  59. package/src/hooks/auth.tsx +14 -12
  60. package/src/hooks/{general.ts → general.tsx} +3 -3
  61. package/src/hooks/router.tsx +9 -9
  62. package/src/middlewares/session.ts +15 -10
  63. package/src/settings/index.ts +3 -6
  64. package/src/setupTests.ts +1 -0
  65. package/src/theme/ThemedBox.tsx +9 -9
  66. package/src/theme/components/MuiButton.ts +1 -1
  67. package/src/theme/components/MuiCardActions.tsx +1 -1
  68. package/src/theme/components/MuiContainer.ts +1 -1
  69. package/src/theme/components/MuiFormControlLabel.ts +1 -1
  70. package/src/theme/components/MuiFormHelperText.ts +1 -1
  71. package/src/theme/components/MuiInputBase.ts +1 -1
  72. package/src/theme/components/MuiLink.ts +1 -1
  73. package/src/theme/components/MuiListItemText.ts +1 -1
  74. package/src/theme/components/MuiMenuItem.ts +1 -1
  75. package/src/theme/components/MuiSelect.ts +2 -2
  76. package/src/theme/components/MuiTable.ts +1 -1
  77. package/src/theme/components/MuiTableBody.ts +1 -1
  78. package/src/theme/components/MuiTableHead.ts +2 -2
  79. package/src/theme/components/MuiTextField.ts +3 -3
  80. package/src/theme/components/_components.ts +4 -2
  81. package/src/theme/palette.ts +2 -2
  82. package/src/theme/typography.ts +1 -1
  83. package/src/utils/api.tsx +6 -4
  84. package/src/utils/auth.ts +1 -1
  85. package/src/utils/form.test.ts +1 -1
  86. package/src/utils/form.ts +14 -9
  87. package/src/utils/general.test.ts +7 -7
  88. package/src/utils/general.ts +10 -12
  89. package/src/utils/router.test.ts +1 -1
  90. package/src/utils/router.ts +2 -2
  91. package/src/utils/schema.ts +11 -11
  92. package/src/utils/test.tsx +2 -2
  93. package/src/utils/theme.tsx +7 -6
  94. package/src/utils/window.ts +2 -0
  95. package/tsconfig.app.json +4 -0
  96. package/tsconfig.json +4 -28
  97. package/tsconfig.node.json +3 -10
  98. package/vite.config.ts +1 -1
  99. package/.eslintrc.json +0 -47
  100. package/src/vite.config.ts +0 -49
  101. /package/src/fonts/{Inter-VariableFont_slnt,wght.ttf → ttf/Inter-VariableFont_slnt,wght.ttf} +0 -0
  102. /package/src/fonts/{SpaceGrotesk-VariableFont_wght.ttf → ttf/SpaceGrotesk-VariableFont_wght.ttf} +0 -0
  103. /package/src/{public/images → images/svg}/brain.svg +0 -0
@@ -7,6 +7,7 @@ import {
7
7
  } from "@mui/material"
8
8
  import { type CommonProps } from "@mui/material/OverridableComponent"
9
9
  import { type OverridesStyleRules } from "@mui/material/styles/overrides"
10
+ import { type TypographyOptions } from "@mui/material/styles/createTypography"
10
11
 
11
12
  import {
12
13
  getClassNames,
@@ -72,8 +73,9 @@ export function getFontStyleOverrides(props: CommonProps): CSSObject {
72
73
  ;["h1", "h2", "h3", "h4", "h5", "h6", "body1", "body2"]
73
74
  .filter(className => className in typography)
74
75
  .forEach(className => {
75
- // @ts-expect-error
76
- const typographyClass = typography[className]
76
+ const typographyClass = typography[
77
+ className as keyof TypographyOptions
78
+ ] as CSSObject
77
79
 
78
80
  if (includesClassNames(classNames, [className])) {
79
81
  styleOverrides = { ...styleOverrides, ...typographyClass }
@@ -1,8 +1,8 @@
1
1
  import {
2
- createTheme,
3
2
  type PaletteColor,
4
- type PaletteOptions,
5
3
  type PaletteColorOptions,
4
+ type PaletteOptions,
5
+ createTheme,
6
6
  } from "@mui/material"
7
7
 
8
8
  import { primary, secondary, tertiary } from "./colors"
@@ -1,6 +1,6 @@
1
1
  import {
2
- type TypographyOptions,
3
2
  type CSSProperties,
3
+ type TypographyOptions,
4
4
  } from "@mui/material/styles/createTypography"
5
5
 
6
6
  // Pseudo typography variant for all form text.
package/src/utils/api.tsx CHANGED
@@ -1,10 +1,10 @@
1
- import { CircularProgress } from "@mui/material"
2
1
  import type {
3
2
  FetchBaseQueryError,
3
+ TypedUseMutationResult,
4
4
  TypedUseQueryHookResult,
5
5
  TypedUseQueryStateResult,
6
- TypedUseMutationResult,
7
6
  } from "@reduxjs/toolkit/query/react"
7
+ import { CircularProgress } from "@mui/material"
8
8
  import { type ReactNode } from "react"
9
9
 
10
10
  import { type Optional, type Required, getNestedProperty } from "./general"
@@ -181,6 +181,7 @@ export function buildUrl(
181
181
  if (Array.isArray(values)) {
182
182
  for (const value of values) searchParams.push([key, String(value)])
183
183
  } else {
184
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
184
185
  searchParams.push([key, String(values)])
185
186
  }
186
187
  }
@@ -244,7 +245,7 @@ export function tagData<Type extends string, M extends Model<any>>(
244
245
  }
245
246
 
246
247
  function getModelId(result: Result<M, any>) {
247
- return getNestedProperty(result, id)
248
+ return getNestedProperty(result, id) as ModelId
248
249
  }
249
250
 
250
251
  return (result, error, arg) => {
@@ -305,7 +306,8 @@ export function handleResultState<QueryArg, ResultType>(
305
306
  children: (data: NonNullable<ResultType>) => ReactNode,
306
307
  options?: HandleQueryStateOptions,
307
308
  ): ReactNode {
308
- const { data, isLoading, isSuccess, error } = result
309
+ const { data, isLoading, isSuccess } = result
310
+ const error = result.error as string | undefined
309
311
 
310
312
  const {
311
313
  loading: loadingNode = <CircularProgress />,
package/src/utils/auth.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import Cookies from "js-cookie"
2
2
 
3
3
  import {
4
+ CSRF_COOKIE_NAME,
4
5
  SESSION_COOKIE_NAME,
5
6
  SESSION_METADATA_COOKIE_NAME,
6
- CSRF_COOKIE_NAME,
7
7
  } from "../settings"
8
8
  import { generateSecureRandomString } from "./general"
9
9
 
@@ -1,4 +1,4 @@
1
- import { isDirty, getDirty, getCleanNames } from "./form"
1
+ import { getCleanNames, getDirty, isDirty } from "./form"
2
2
 
3
3
  const VALUES = {
4
4
  name: { first: "Peter", last: "Parker" },
package/src/utils/form.ts CHANGED
@@ -1,8 +1,8 @@
1
- import type { TypedMutationTrigger } from "@reduxjs/toolkit/query/react"
2
1
  import type { FieldValidator, FormikHelpers } from "formik"
3
- import { ValidationError, type Schema, type ValidateOptions } from "yup"
2
+ import { type Schema, type ValidateOptions, ValidationError } from "yup"
3
+ import type { TypedMutationTrigger } from "@reduxjs/toolkit/query/react"
4
4
 
5
- import { excludeKeyPaths, getNestedProperty, getKeyPaths } from "./general"
5
+ import { excludeKeyPaths, getKeyPaths, getNestedProperty } from "./general"
6
6
 
7
7
  export type FormValues = Record<string, any>
8
8
 
@@ -92,14 +92,14 @@ export function submitForm<
92
92
  initialValues: Values,
93
93
  options?: SubmitFormOptions<Values, QueryArg, ResultType>,
94
94
  ): SubmitFormHandler<Values> {
95
- let {
96
- exclude = [],
95
+ const {
97
96
  include,
98
97
  onlyDirtyValues = false,
99
98
  then,
100
99
  catch: _catch,
101
100
  finally: _finally,
102
101
  } = options || {}
102
+ let { exclude = [] } = options || {}
103
103
 
104
104
  return (values, helpers) => {
105
105
  let arg =
@@ -118,7 +118,7 @@ export function submitForm<
118
118
 
119
119
  if (include) exclude = exclude.filter(name => !include.includes(name))
120
120
 
121
- if (exclude.length) arg = excludeKeyPaths(arg, exclude)
121
+ if (exclude.length) arg = excludeKeyPaths(arg, exclude) as QueryArg
122
122
 
123
123
  trigger(arg)
124
124
  .unwrap()
@@ -171,8 +171,8 @@ export function isDirty<Values extends FormValues>(
171
171
  initialValues: Values,
172
172
  name: string,
173
173
  ): boolean {
174
- const value = getNestedProperty(values, name)
175
- const initialValue = getNestedProperty(initialValues, name)
174
+ const value: unknown = getNestedProperty(values, name)
175
+ const initialValue: unknown = getNestedProperty(initialValues, name)
176
176
 
177
177
  return value !== initialValue
178
178
  }
@@ -183,6 +183,11 @@ export function getCleanNames<Values extends FormValues>(
183
183
  names?: string[],
184
184
  ): string[] {
185
185
  return Object.entries(getDirty(values, initialValues, names))
186
- .filter(([_, isDirty]) => !isDirty)
186
+ .filter(
187
+ ([
188
+ _, // eslint-disable-line @typescript-eslint/no-unused-vars
189
+ isDirty,
190
+ ]) => !isDirty,
191
+ )
187
192
  .map(([name]) => name)
188
193
  }
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  excludeKeyPaths,
3
+ getKeyPaths,
3
4
  getNestedProperty,
4
5
  withKeyPaths,
5
- getKeyPaths,
6
6
  } from "./general"
7
7
 
8
8
  // getNestedProperty
@@ -10,19 +10,19 @@ import {
10
10
  const PERSON = { father: { father: { name: "John" } } }
11
11
 
12
12
  test("get a nested property with dot notation", () => {
13
- const name = getNestedProperty(PERSON, "father.father.name")
13
+ const name = getNestedProperty(PERSON, "father.father.name") as string
14
14
 
15
- expect(name).equal("John")
15
+ expect(name).toEqual("John")
16
16
  })
17
17
 
18
18
  test("get a nested property with string array", () => {
19
- const name = getNestedProperty(PERSON, ["father", "father", "name"])
19
+ const name = getNestedProperty(PERSON, ["father", "father", "name"]) as string
20
20
 
21
- expect(name).equal("John")
21
+ expect(name).toEqual("John")
22
22
  })
23
23
 
24
24
  test("get a nested property that doesn't exist", () => {
25
- const name = getNestedProperty(PERSON, "mother.mother.name")
25
+ const name = getNestedProperty(PERSON, "mother.mother.name") as undefined
26
26
 
27
27
  expect(name).toBeUndefined()
28
28
  })
@@ -49,7 +49,7 @@ test("exclude nested keys by their path", () => {
49
49
  const obj = excludeKeyPaths({ a: 1, b: { c: 2, d: { e: 3 } } }, [
50
50
  "b.c",
51
51
  "b.d.e",
52
- ])
52
+ ]) as object
53
53
 
54
54
  expect(obj).toMatchObject({ a: 1, b: { d: {} } })
55
55
  })
@@ -19,14 +19,14 @@ export function wrap(
19
19
  ): (...args: any[]) => any {
20
20
  return (...args) => {
21
21
  if (newFn.before !== undefined) {
22
- newFn.before(...args)
22
+ newFn.before(...(args as unknown[]))
23
23
  }
24
24
  let value
25
25
  if (fn !== undefined) {
26
- value = fn(...args)
26
+ value = fn(...(args as unknown[])) as unknown
27
27
  }
28
28
  if (newFn.after !== undefined) {
29
- newFn.after(...args)
29
+ newFn.after(...(args as unknown[]))
30
30
  }
31
31
  return value
32
32
  }
@@ -34,30 +34,28 @@ export function wrap(
34
34
 
35
35
  export function snakeCaseToCamelCase(obj: Record<string, any>): void {
36
36
  Object.entries(obj).forEach(([snakeKey, value]) => {
37
- if (typeof value === "object") snakeCaseToCamelCase(value)
37
+ if (typeof value === "object") snakeCaseToCamelCase(value as object)
38
38
 
39
39
  const camelKey = snakeKey.replace(/_+[a-z]/g, _char =>
40
40
  _char[_char.length - 1].toUpperCase(),
41
41
  )
42
42
 
43
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
44
43
  delete obj[snakeKey]
45
- obj[camelKey] = value
44
+ obj[camelKey] = value as unknown
46
45
  })
47
46
  }
48
47
 
49
48
  export function camelCaseToSnakeCase(obj: Record<string, any>): void {
50
49
  Object.entries(obj).forEach(([camelKey, value]) => {
51
- if (typeof value === "object") camelCaseToSnakeCase(value)
50
+ if (typeof value === "object") camelCaseToSnakeCase(value as object)
52
51
 
53
52
  const snakeKey = camelKey.replace(
54
53
  /[A-Z]/g,
55
54
  char => `_${char.toLowerCase()}`,
56
55
  )
57
56
 
58
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
59
57
  delete obj[camelKey]
60
- obj[snakeKey] = value
58
+ obj[snakeKey] = value as unknown
61
59
  })
62
60
  }
63
61
 
@@ -972,7 +970,7 @@ export function withKeyPaths(obj: object, delimiter: string = "."): object {
972
970
  const _path = [...path, key]
973
971
 
974
972
  if (typeof value === "object" && value !== null)
975
- value = _withKeyPaths(value, _path)
973
+ value = _withKeyPaths(value as object, _path)
976
974
 
977
975
  return [_path.join(delimiter), value]
978
976
  }),
@@ -990,7 +988,7 @@ export function getKeyPaths(obj: object, delimiter: string = "."): string[] {
990
988
  const keyPath = _path.join(delimiter)
991
989
 
992
990
  return typeof value === "object" && value !== null
993
- ? [keyPath, ..._getKeyPaths(value, _path)]
991
+ ? [keyPath, ..._getKeyPaths(value as object, _path)]
994
992
  : [keyPath]
995
993
  })
996
994
  .flat()
@@ -1020,7 +1018,7 @@ export function excludeKeyPaths(
1020
1018
  return exclude.includes(_path.join(delimiter)) ? [] : [key, value]
1021
1019
  })
1022
1020
  .filter(entry => entry.length),
1023
- )
1021
+ ) as object
1024
1022
  }
1025
1023
 
1026
1024
  return exclude.length ? _excludeKeyPaths(obj, []) : obj
@@ -1,4 +1,4 @@
1
- import { path as p, type Parameters, type Path } from "./router"
1
+ import { type Parameters, type Path, path as p } from "./router"
2
2
 
3
3
  const m = <SubMatches extends Record<string, Path>>(
4
4
  _: string,
@@ -1,7 +1,7 @@
1
1
  import {
2
- generatePath,
3
- type LinkProps as _LinkProps,
4
2
  type To,
3
+ type LinkProps as _LinkProps,
4
+ generatePath,
5
5
  } from "react-router-dom"
6
6
 
7
7
  import { type PageState } from "../components/page/Page"
@@ -1,21 +1,21 @@
1
1
  import {
2
- ValidationError,
3
2
  type AnyObject,
3
+ type BooleanSchema,
4
+ type DateSchema,
4
5
  type DefaultFromShape,
6
+ type Flags,
5
7
  type InferType,
6
8
  type MakePartial,
9
+ type NumberSchema,
7
10
  type ObjectSchema,
8
11
  type ObjectShape,
9
12
  type Schema,
13
+ type StringSchema,
10
14
  type TypeFromShape,
11
15
  type ValidateOptions,
12
- type StringSchema,
13
- type NumberSchema,
14
- type Flags,
15
- type BooleanSchema,
16
- type DateSchema,
17
- string as YupString,
16
+ ValidationError,
18
17
  number as YupNumber,
18
+ string as YupString,
19
19
  } from "yup"
20
20
 
21
21
  export type _<T> = T extends {}
@@ -137,11 +137,11 @@ export function buildUnicodeCharSet(
137
137
  description: string,
138
138
  options: BuildCharSetOptions = {},
139
139
  ) {
140
- let { flags = "u", ...otherOptions } = options
140
+ let { flags = "u" } = options
141
141
 
142
142
  if (!flags.includes("u")) flags += "u"
143
143
 
144
- return buildCharSet(charSet, description, { flags, ...otherOptions })
144
+ return buildCharSet(charSet, description, { ...options, flags })
145
145
  }
146
146
 
147
147
  export function asciiAlphaString(options?: BuildCharSetOptions) {
@@ -282,9 +282,9 @@ export function tryValidateSync<
282
282
  const { onError, ...validateOptions } = options || {}
283
283
 
284
284
  try {
285
- return schema.validateSync(value, validateOptions)
285
+ return schema.validateSync(value, validateOptions) as unknown
286
286
  } catch (error) {
287
287
  if (!(error instanceof ValidationError)) throw error
288
- else if (onError) return onError(error)
288
+ else if (onError) return onError(error) as unknown
289
289
  }
290
290
  }
@@ -1,9 +1,9 @@
1
1
  import type { Middleware, Reducer, Store } from "@reduxjs/toolkit"
2
+ import type { PropsWithChildren, ReactElement } from "react"
3
+ import { Provider } from "react-redux"
2
4
  import type { RenderOptions } from "@testing-library/react"
3
5
  import { render } from "@testing-library/react"
4
6
  import userEvent from "@testing-library/user-event"
5
- import type { PropsWithChildren, ReactElement } from "react"
6
- import { Provider } from "react-redux"
7
7
 
8
8
  import { makeStore } from "./store"
9
9
 
@@ -1,6 +1,6 @@
1
- import type React from "react"
2
1
  import { Divider, type DividerProps, type ThemeOptions } from "@mui/material"
3
2
  import { type CommonProps } from "@mui/material/OverridableComponent"
3
+ import { type ReactElement } from "react"
4
4
 
5
5
  import _components from "../theme/components"
6
6
 
@@ -8,9 +8,9 @@ export function insertDividerBetweenElements({
8
8
  elements,
9
9
  dividerProps,
10
10
  }: {
11
- elements: React.ReactElement[]
11
+ elements: ReactElement[]
12
12
  dividerProps?: DividerProps
13
- }): React.ReactElement[] {
13
+ }): ReactElement[] {
14
14
  return elements.map((element, index) => (
15
15
  <>
16
16
  {element}
@@ -38,11 +38,12 @@ export function getStyleOverrides(
38
38
  ) {
39
39
  const muiClass = (component.styleOverrides as Record<string, any>)[
40
40
  muiClassName
41
- ]
41
+ ] as object
42
42
 
43
43
  switch (typeof muiClass) {
44
44
  case "function":
45
- return muiClass({ ownerState })
45
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
46
+ return muiClass({ ownerState }) as object
46
47
  case "object":
47
48
  return muiClass
48
49
  }
@@ -78,5 +79,5 @@ export function matchClassNames(
78
79
  return classNames
79
80
  .map(className => className.match(pattern))
80
81
  .filter(match => match !== null)
81
- .map(match => match as RegExpMatchArray)
82
+ .map(match => match)
82
83
  }
@@ -1,9 +1,11 @@
1
1
  export function configureFreshworksWidget(display: "open" | "hide"): void {
2
2
  // @ts-expect-error defined in external script
3
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
3
4
  window.FreshworksWidget(display)
4
5
  }
5
6
 
6
7
  export function toggleOneTrustInfoDisplay(): void {
7
8
  // @ts-expect-error defined in external script
9
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
8
10
  window.Optanon.ToggleInfoDisplay()
9
11
  }
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../configs/frontend/tsconfig.app.json",
3
+ "include": ["src"]
4
+ }
package/tsconfig.json CHANGED
@@ -1,31 +1,7 @@
1
1
  {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "useDefineForClassFields": true,
5
- "lib": [
6
- "DOM",
7
- "DOM.Iterable",
8
- "ESNext"
9
- ],
10
- "allowJs": false,
11
- "skipLibCheck": true,
12
- "esModuleInterop": false,
13
- "allowSyntheticDefaultImports": true,
14
- "strict": true,
15
- "module": "ESNext",
16
- "moduleResolution": "bundler",
17
- "resolveJsonModule": true,
18
- "isolatedModules": true,
19
- "noEmit": true,
20
- "jsx": "react-jsx",
21
- "types": [
22
- "vitest/globals",
23
- "node"
24
- ]
25
- },
2
+ "files": [],
26
3
  "references": [
27
- {
28
- "path": "./tsconfig.node.json"
29
- }
4
+ { "path": "./tsconfig.app.json" },
5
+ { "path": "./tsconfig.node.json" }
30
6
  ]
31
- }
7
+ }
@@ -1,11 +1,4 @@
1
1
  {
2
- "compilerOptions": {
3
- "composite": true,
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "allowSyntheticDefaultImports": true
7
- },
8
- "include": [
9
- "vite.config.ts"
10
- ]
11
- }
2
+ "extends": "../configs/frontend/tsconfig.node.json",
3
+ "include": ["vite.config.ts"]
4
+ }
package/vite.config.ts CHANGED
@@ -1,5 +1,5 @@
1
- import react from "@vitejs/plugin-react"
2
1
  import { defineConfig } from "vitest/config"
2
+ import react from "@vitejs/plugin-react"
3
3
 
4
4
  // https://vitejs.dev/config/
5
5
  // TODO: https://vite.dev/guide/build.html#library-mode
package/.eslintrc.json DELETED
@@ -1,47 +0,0 @@
1
- {
2
- "extends": [
3
- "eslint:recommended",
4
- "react-app",
5
- "plugin:react/jsx-runtime",
6
- "prettier"
7
- ],
8
- "parser": "@typescript-eslint/parser",
9
- "parserOptions": {
10
- "project": true,
11
- "tsconfigRootDir": "./"
12
- },
13
- "plugins": [
14
- "@typescript-eslint"
15
- ],
16
- "root": true,
17
- "ignorePatterns": [
18
- "dist",
19
- "src/scripts",
20
- "**/*.d.ts",
21
- "vite.config.*"
22
- ],
23
- "rules": {
24
- "@typescript-eslint/consistent-type-imports": [
25
- 2,
26
- {
27
- "fixStyle": "inline-type-imports"
28
- }
29
- ]
30
- },
31
- "overrides": [
32
- {
33
- "files": [
34
- "*.{c,m,}{t,j}s",
35
- "*.{t,j}sx"
36
- ]
37
- },
38
- {
39
- "files": [
40
- "*{test,spec}.{t,j}s?(x)"
41
- ],
42
- "env": {
43
- "jest": true
44
- }
45
- }
46
- ]
47
- }
@@ -1,49 +0,0 @@
1
- /**
2
- * Shared Vite configuration for all frontend services.
3
- *
4
- * Vite: https://vitest.dev/config/
5
- * Vitest: https://vitest.dev/config/
6
- *
7
- * NOTE: This doesn't belong in codeforlife-workspace/configs/frontend as it's
8
- * still and a script which needs to be included in a Node.js runtime.
9
- */
10
-
11
- import { defineConfig } from "vitest/config"
12
- import react from "@vitejs/plugin-react"
13
-
14
- export default defineConfig({
15
- plugins: [react()],
16
- resolve: {
17
- alias: {
18
- codeforlife: "codeforlife/src",
19
- },
20
- },
21
- envDir: "env",
22
- server: {
23
- open: true,
24
- host: true,
25
- },
26
- test: {
27
- globals: true,
28
- environment: "jsdom",
29
- setupFiles: "src/setupTests",
30
- mockReset: true,
31
- coverage: {
32
- enabled: true,
33
- provider: "istanbul",
34
- reporter: ["html", "cobertura"],
35
- },
36
- },
37
- optimizeDeps: {
38
- // TODO: investigate which of these are needed
39
- include: [
40
- "@mui/x-date-pickers",
41
- "@mui/x-date-pickers/AdapterDayjs",
42
- "dayjs",
43
- "dayjs/locale/en-gb",
44
- "@mui/icons-material",
45
- "yup",
46
- "formik",
47
- ],
48
- },
49
- })
File without changes