Skip to content

Commit

Permalink
Prefer not to use destructuring with default values
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Sep 18, 2023
1 parent 1deaeb0 commit 090e1b6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/govuk-frontend/src/govuk/errors/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,14 @@ export class ElementError extends GOVUKFrontendError {

/**
* @param {Element} element - The element in error
* @param {object} options - options
* @param {object} options - Element error options
* @param {string} options.componentName - The name of the component throwing the error
* @param {string} options.identifier - An identifier that'll let the user understand which element has an error (variable name, CSS selector)
* @param {typeof HTMLElement} [options.expectedType] - The type that was expected for the element
*/
constructor(
element,
{ componentName, identifier, expectedType = HTMLElement }
) {
constructor(element, { componentName, identifier, expectedType }) {
expectedType = expectedType || HTMLElement

Check failure on line 65 in packages/govuk-frontend/src/govuk/errors/index.mjs

View workflow job for this annotation

GitHub Actions / JavaScript unit tests (ubuntu-latest)

errors › ElementError › is an instance of GOVUKFrontendError

ReferenceError: HTMLElement is not defined at new HTMLElement (packages/govuk-frontend/src/govuk/errors/index.mjs:65:36) at Object.<anonymous> (packages/govuk-frontend/src/govuk/errors/index.unit.test.mjs:31:9)

Check failure on line 65 in packages/govuk-frontend/src/govuk/errors/index.mjs

View workflow job for this annotation

GitHub Actions / JavaScript unit tests (ubuntu-latest)

errors › ElementError › has its own name set

ReferenceError: HTMLElement is not defined at new HTMLElement (packages/govuk-frontend/src/govuk/errors/index.mjs:65:36) at Object.<anonymous> (packages/govuk-frontend/src/govuk/errors/index.unit.test.mjs:39:9)

Check failure on line 65 in packages/govuk-frontend/src/govuk/errors/index.mjs

View workflow job for this annotation

GitHub Actions / JavaScript unit tests (ubuntu-latest)

errors › ElementError › formats the message when the element is not found

ReferenceError: HTMLElement is not defined at new HTMLElement (packages/govuk-frontend/src/govuk/errors/index.mjs:65:36) at Object.<anonymous> (packages/govuk-frontend/src/govuk/errors/index.unit.test.mjs:47:9)

Check failure on line 65 in packages/govuk-frontend/src/govuk/errors/index.mjs

View workflow job for this annotation

GitHub Actions / JavaScript unit tests (windows-latest)

errors › ElementError › is an instance of GOVUKFrontendError

ReferenceError: HTMLElement is not defined at new HTMLElement (packages/govuk-frontend/src/govuk/errors/index.mjs:65:36) at Object.<anonymous> (packages/govuk-frontend/src/govuk/errors/index.unit.test.mjs:31:9)

Check failure on line 65 in packages/govuk-frontend/src/govuk/errors/index.mjs

View workflow job for this annotation

GitHub Actions / JavaScript unit tests (windows-latest)

errors › ElementError › has its own name set

ReferenceError: HTMLElement is not defined at new HTMLElement (packages/govuk-frontend/src/govuk/errors/index.mjs:65:36) at Object.<anonymous> (packages/govuk-frontend/src/govuk/errors/index.unit.test.mjs:39:9)

Check failure on line 65 in packages/govuk-frontend/src/govuk/errors/index.mjs

View workflow job for this annotation

GitHub Actions / JavaScript unit tests (windows-latest)

errors › ElementError › formats the message when the element is not found

ReferenceError: HTMLElement is not defined at new HTMLElement (packages/govuk-frontend/src/govuk/errors/index.mjs:65:36) at Object.<anonymous> (packages/govuk-frontend/src/govuk/errors/index.unit.test.mjs:47:9)

const reason = !element
? `${identifier} not found`
: `${identifier} is not an instance of "${expectedType.name}"`
Expand Down

0 comments on commit 090e1b6

Please sign in to comment.