Skip to content

Commit

Permalink
Merge branch 'main' into feature/1599/back-to-top-link
Browse files Browse the repository at this point in the history
  • Loading branch information
adi-unni committed Feb 28, 2024
2 parents b76af87 + 502787b commit e7d21ab
Show file tree
Hide file tree
Showing 122 changed files with 775 additions and 1,121 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": "^_"
}
]
}
}
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
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 e7d21ab

Please sign in to comment.