Skip to content

Commit

Permalink
Merge branch 'main' into enhancement/3013/explore-unnecessary-conditi…
Browse files Browse the repository at this point in the history
…onals-autosugget
  • Loading branch information
SriHV committed Mar 4, 2024
2 parents d463536 + d960c8e commit 053e3f7
Show file tree
Hide file tree
Showing 159 changed files with 1,435 additions and 1,186 deletions.
15 changes: 13 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parser": "@babel/eslint-parser",
"plugins": ["prettier"],
"plugins": ["prettier", "unused-imports"],
"extends": ["prettier"],
"env": {
"es6": true,
Expand All @@ -24,6 +24,17 @@
"one-var": [0],
"max-len": [0, { "code": 140, "ignoreUrls": true }],
"comma-dangle": ["error", "always-multiline"],
"arrow-parens": 1
"arrow-parens": 1,
"indent": ["error", 2, { "SwitchCase": 1 }],
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"error",
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "after-used",
"argsIgnorePattern": "^_"
}
]
}
}
2 changes: 1 addition & 1 deletion .github/workflows/check-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
steps:
- uses: docker://onsdigital/github-pr-label-checker:v1.2.7
with:
one_of: Breaking changes,Accessibility,Bug,Documentation,Dependencies,Enhancement,Example
one_of: Breaking changes,Accessibility,Bug,Documentation,Dependencies,Enhancement,Example,Component,Pattern
none_of: Awaiting resource,Do not merge,Duplicate,Needs validating,Not doing
repo_token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/lighthouse-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macro-and-script-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
with:
ref: ${{ github.event.release.target_commitish }}
- name: Install Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
registry-url: https://registry.npmjs.org/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Install dependencies
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,8 @@ yarn build
- [Sass](https://marketplace.visualstudio.com/items?itemName=robinbentley.sass-indented)
- [Stylelint](https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint)
- [vscode-remark-lint](https://marketplace.visualstudio.com/items?itemName=drewbourne.vscode-remark-lint)

## Recommended Visual Studio Code settings for this project

- "render whitespace" set to "all"
- "insert spaces when pressing tab" checked
8 changes: 5 additions & 3 deletions __snapshots__/layout/_template.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1595,8 +1595,9 @@ exports[`base page template matches the full configuration snapshot 1`] = `
</div>


<div class="ons-footer__poweredby ons-u-mb-m">

<a class="ons-footer__poweredBy-link" href="https://www.ons.gov.uk/">
<div class="ons-footer__poweredby-logo ons-u-mb-m">

<svg class="ons-icon--logo" xmlns="http://www.w3.org/2000/svg" width="197" height="19" viewBox="33 2 552 60" aria-labelledby="ons-logo-en-footer-alt">
<title id="ons-logo-en-footer-alt">Office for National Statistics</title>
<g class="ons-icon--logo__group ons-icon--logo__group--secondary" fill="#a8bd3a">
Expand Down Expand Up @@ -1636,7 +1637,8 @@ exports[`base page template matches the full configuration snapshot 1`] = `
</g>
</svg>

</div>
</div>
</a>

</div>

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"eslint-cli": "^1.1.1",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-unused-imports": "^3.1.0",
"express": "^4.17.1",
"front-matter": "^4.0.2",
"fs-extra": "^11.1.1",
Expand Down
12 changes: 2 additions & 10 deletions src/components/access-code/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ describe('macro: access-code', () => {
}),
);

expect(
$('.ons-panel__body')
.text()
.trim(),
).toBe('Example security message.');
expect($('.ons-panel__body').text().trim()).toBe('Example security message.');
});

it('has provided `postTextBoxLinkText` and `postTextBoxLinkUrl`', () => {
Expand All @@ -139,11 +135,7 @@ describe('macro: access-code', () => {
}),
);

expect(
$('a[href="#3"]')
.text()
.trim(),
).toBe('Example link text');
expect($('a[href="#3"]').text().trim()).toBe('Example link text');
});

it('has provided `error` output', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/access-code/access-code.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ domready(async () => {
if (accessCodeInputs.length) {
const accessCode = (await import('./access-code')).default;

accessCodeInputs.forEach(element => new accessCode(element));
accessCodeInputs.forEach((element) => new accessCode(element));
}
});
4 changes: 2 additions & 2 deletions src/components/access-code/access-code.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ describe('script: access-code', () => {
await page.focus('#test-access-code');
await page.keyboard.type('1234');

const valueSample1 = await page.$eval('#test-access-code', element => element.value);
const valueSample1 = await page.$eval('#test-access-code', (element) => element.value);
expect(valueSample1).toBe('1234');

await page.keyboard.type('5678');

const valueSample2 = await page.$eval('#test-access-code', element => element.value);
const valueSample2 = await page.$eval('#test-access-code', (element) => element.value);
expect(valueSample2).toBe('12345 678');
});
});
Expand Down
8 changes: 4 additions & 4 deletions src/components/accordion/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ export default class Accordion {
this.button = button;
this.buttonInner = button.querySelector('.ons-accordion__toggle-all-inner');
this.group = button.getAttribute('data-group');
this.detailsEls = detailsEls.filter(details => details.group === this.group);
this.detailsEls = detailsEls.filter((details) => details.group === this.group);
this.totalDetailsEls = this.detailsEls.length;
this.buttonOpenEl = this.buttonInner.querySelector('.ons-btn__text');
this.buttonOpen = this.buttonOpenEl.innerHTML.trim();
this.closeButton = button.getAttribute('data-close-all');
this.open = this.detailsEls.find(details => details.open === true);
this.open = this.detailsEls.find((details) => details.open === true);

this.detailsEls.forEach(details => {
this.detailsEls.forEach((details) => {
details.onOpen = this.onOpen.bind(this);
details.onClose = this.onClose.bind(this);
});
Expand All @@ -31,7 +31,7 @@ export default class Accordion {

const open = !this.canClose();

this.detailsEls.forEach(details => {
this.detailsEls.forEach((details) => {
details.setOpen(open);
});
}
Expand Down
18 changes: 3 additions & 15 deletions src/components/address-input/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,7 @@ describe('macro: address-input', () => {
}),
);

expect(
$('.ons-js-address-search-btn')
.text()
.trim(),
).toBe('Search for address');
expect($('.ons-js-address-search-btn').text().trim()).toBe('Search for address');
});
});

Expand Down Expand Up @@ -408,11 +404,7 @@ describe('macro: address-input', () => {
);

expect($('.ons-js-address-manual-btn').attr('href')).toBe('#0');
expect(
$('.ons-js-address-manual-btn')
.text()
.trim(),
).toBe('Manually enter address');
expect($('.ons-js-address-manual-btn').text().trim()).toBe('Manually enter address');
});

it('renders `manualLinkText` with `manualLink` when provided', () => {
Expand All @@ -425,11 +417,7 @@ describe('macro: address-input', () => {
);

expect($('.ons-js-address-manual-btn').attr('href')).toBe('https://example.com/edit-address');
expect(
$('.ons-js-address-manual-btn')
.text()
.trim(),
).toBe('Manually enter address');
expect($('.ons-js-address-manual-btn').text().trim()).toBe('Manually enter address');
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/address-input/autosuggest.address.dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ async function initialiseAddressAutosuggests() {
if (addressAutosuggests.length) {
const AutosuggestAddress = (await import('./autosuggest.address')).default;

addressAutosuggests.forEach(addressAutosuggest => new AutosuggestAddress(addressAutosuggest));
addressAutosuggests.forEach((addressAutosuggest) => new AutosuggestAddress(addressAutosuggest));
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/components/address-input/autosuggest.address.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export default class AutosuggestAddress {
for (const item of items) {
if (item.addressCount === 1 && item.firstUprn !== 0) {
let result = await this.createAddressObject(item.firstUprn);
const matchingItem = items.findIndex(x => x.firstUprn == result.uprn);
const matchingItem = items.findIndex((x) => x.firstUprn == result.uprn);
items[matchingItem] = result;
}
}
Expand All @@ -244,7 +244,8 @@ export default class AutosuggestAddress {
}

testFullPostcodeQuery(input) {
const fullPostcodeRegex = /\b((?:(?:gir)|(?:[a-pr-uwyz])(?:(?:[0-9](?:[a-hjkpstuw]|[0-9])?)|(?:[a-hk-y][0-9](?:[0-9]|[abehmnprv-y])?)))) ?([0-9][abd-hjlnp-uw-z]{2})\b/i;
const fullPostcodeRegex =
/\b((?:(?:gir)|(?:[a-pr-uwyz])(?:(?:[0-9](?:[a-hjkpstuw]|[0-9])?)|(?:[a-hk-y][0-9](?:[0-9]|[abehmnprv-y])?)))) ?([0-9][abd-hjlnp-uw-z]{2})\b/i;
const testFullPostcode = fullPostcodeRegex.test(input);
if (testFullPostcode) {
return true;
Expand Down
6 changes: 3 additions & 3 deletions src/components/address-input/autosuggest.address.setter.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default class AddressSetter {
}

clearManualInputs() {
this.manualInputs.forEach(input => {
this.manualInputs.forEach((input) => {
if (input) {
input.value = '';
}
Expand All @@ -112,13 +112,13 @@ export default class AddressSetter {

checkManualInputsValues(onLoad) {
if (onLoad) {
this.originalValues = this.manualInputs.map(input => {
this.originalValues = this.manualInputs.map((input) => {
if (input) {
return input.value;
}
});
} else if (this.uprn.value !== '' && this.originalValues.length) {
this.newValues = this.manualInputs.map(input => {
this.newValues = this.manualInputs.map((input) => {
return input.value;
});
if (this.originalValues.toString() !== this.newValues.toString()) {
Expand Down
Loading

0 comments on commit 053e3f7

Please sign in to comment.