Skip to content

Commit 17ba3cd

Browse files
authored
Consistent Prettier config (#222)
* Bump eslint-config * Prettier config consistent with the other repos * Add semicolons (prettier) * Commit build files
1 parent bf32dbf commit 17ba3cd

File tree

115 files changed

+4066
-4046
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+4066
-4046
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Inside `shared/js/ui/base/localize.js` the following line is used to load the tr
6464

6565
```js
6666
// this is picked up by an esbuild plugin to load all locale files, see `scripts/bundle.mjs`
67-
import localeResources from '../../../locales/*/*.json'
67+
import localeResources from '../../../locales/*/*.json';
6868
```
6969

7070
## Building Docs

build/app/public/js/polyfill-loader.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
*/
44
function hasIntlGetCanonicalLocalesBug() {
55
try {
6-
return new Intl.Locale('und-x-private').toString() === 'x-private'
6+
return new Intl.Locale('und-x-private').toString() === 'x-private';
77
} catch (e) {
8-
return true
8+
return true;
99
}
1010
}
1111
function shouldPolyfill() {
12-
return !('Locale' in Intl) || hasIntlGetCanonicalLocalesBug()
12+
return !('Locale' in Intl) || hasIntlGetCanonicalLocalesBug();
1313
}
1414
/**
1515
* Load the Intl.Locale polyfill if needed
1616
*/
1717
if (shouldPolyfill()) {
18-
const script = document.createElement('script')
19-
script.src = '../public/js/polyfills.js'
20-
document.head.appendChild(script)
18+
const script = document.createElement('script');
19+
script.src = '../public/js/polyfills.js';
20+
document.head.appendChild(script);
2121
}

debugger/debugger.jsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2-
import { h } from 'preact'
3-
import styles from './debugger.module.css'
4-
import { requests } from '../shared/js/ui/views/tests/generate-data.mjs'
2+
import { h } from 'preact';
3+
import styles from './debugger.module.css';
4+
import { requests } from '../shared/js/ui/views/tests/generate-data.mjs';
55

66
export function Debugger({ states, initialState, selectedRequests, updateRequests, platforms, items, reflectParams, toggles }) {
77
return (
@@ -18,7 +18,7 @@ export function Debugger({ states, initialState, selectedRequests, updateRequest
1818
<Frames platforms={platforms} initialState={initialState} reflectParams={reflectParams} items={items} states={states} />
1919
</div>
2020
</div>
21-
)
21+
);
2222
}
2323

2424
/**
@@ -42,17 +42,17 @@ export function Selector({ options, selected, label, onChange }) {
4242
<option value={key} selected={selected === key}>
4343
{key}
4444
</option>
45-
)
45+
);
4646
})}
4747
</select>
4848
</label>
49-
)
49+
);
5050
}
5151

5252
export function PlatformToggles({ selected, onChange, items }) {
5353
function onChanged(e) {
54-
const d = new FormData(e.target.form)
55-
onChange(d.getAll('platform'))
54+
const d = new FormData(e.target.form);
55+
onChange(d.getAll('platform'));
5656
}
5757
return (
5858
<form onChange={onChanged}>
@@ -62,16 +62,16 @@ export function PlatformToggles({ selected, onChange, items }) {
6262
<input type="checkbox" name="platform" value={item.platform} checked={selected.includes(item.platform)}></input>{' '}
6363
{item.platform}
6464
</label>
65-
)
65+
);
6666
})}
6767
</form>
68-
)
68+
);
6969
}
7070

7171
function Requests({ selected, onChange }) {
7272
function onChanged(e) {
73-
const d = new FormData(e.target.form)
74-
onChange(d.getAll('request'))
73+
const d = new FormData(e.target.form);
74+
onChange(d.getAll('request'));
7575
}
7676
return (
7777
<div>
@@ -83,17 +83,17 @@ function Requests({ selected, onChange }) {
8383
<input type="checkbox" name="request" value={key} checked={selected.includes(key)}></input>
8484
{key}
8585
</label>
86-
)
86+
);
8787
})}
8888
</form>
8989
</div>
90-
)
90+
);
9191
}
9292

9393
function Frames({ platforms, initialState, states, items, reflectParams }) {
94-
const previewJSON = states[initialState]
95-
const { certificate, ...rest } = previewJSON
96-
rest.certificate = certificate
94+
const previewJSON = states[initialState];
95+
const { certificate, ...rest } = previewJSON;
96+
rest.certificate = certificate;
9797
return (
9898
<div class={styles.frames}>
9999
<div class={styles.code} data-state="ready">
@@ -102,9 +102,9 @@ function Frames({ platforms, initialState, states, items, reflectParams }) {
102102
</pre>
103103
</div>
104104
{items.map((item) => {
105-
const { platform } = item
106-
const src = new URL(item.platform + '.html?' + reflectParams.toString(), location.href)
107-
const height = item.height ?? 600
105+
const { platform } = item;
106+
const src = new URL(item.platform + '.html?' + reflectParams.toString(), location.href);
107+
const height = item.height ?? 600;
108108
return (
109109
<div class={styles.frame} data-state={platforms.includes(platform) ? 'ready' : 'hidden'}>
110110
<p>
@@ -124,8 +124,8 @@ function Frames({ platforms, initialState, states, items, reflectParams }) {
124124
}}
125125
></iframe>
126126
</div>
127-
)
127+
);
128128
})}
129129
</div>
130-
)
130+
);
131131
}

debugger/index.jsx

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,65 @@
11
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2-
import { h, render } from 'preact'
3-
import { Debugger, PlatformToggles, Selector } from './debugger'
2+
import { h, render } from 'preact';
3+
import { Debugger, PlatformToggles, Selector } from './debugger';
44

5-
import google from '../schema/__fixtures__/request-data-google.json'
6-
import cnn from '../schema/__fixtures__/request-data-cnn.json'
7-
import { createDataStates } from '../shared/js/ui/views/tests/generate-data.mjs'
8-
import { Settings } from './settings'
5+
import google from '../schema/__fixtures__/request-data-google.json';
6+
import cnn from '../schema/__fixtures__/request-data-cnn.json';
7+
import { createDataStates } from '../shared/js/ui/views/tests/generate-data.mjs';
8+
import { Settings } from './settings';
99

10-
const states = createDataStates(/** @type {any} */ (google), /** @type {any} */ (cnn))
10+
const states = createDataStates(/** @type {any} */ (google), /** @type {any} */ (cnn));
1111

12-
let searchParams = new URL(window.location.href).searchParams
12+
let searchParams = new URL(window.location.href).searchParams;
1313
const settings = new Settings()
1414
.withState(searchParams.get('state'))
1515
.withScreen(searchParams.get('screen'))
1616
.withPlatforms(searchParams.get('platforms'))
17-
.withRequests(searchParams.getAll('requests'))
17+
.withRequests(searchParams.getAll('requests'));
1818

1919
function updateStateParam(value) {
20-
let reflectList = ['screen', 'requests']
21-
const url = new URL(window.location.href)
20+
let reflectList = ['screen', 'requests'];
21+
const url = new URL(window.location.href);
2222

2323
// remove existing reflected params
2424
for (let key of reflectList) {
25-
url.searchParams.delete(key)
25+
url.searchParams.delete(key);
2626
}
2727

2828
// set the new state (as chosen in the dropdown)
29-
url.searchParams.set('state', value)
30-
const selected = states[value]
29+
url.searchParams.set('state', value);
30+
const selected = states[value];
3131

3232
// reflect explicit url params
3333
for (let [key, value] of Object.entries(selected.urlParams)) {
34-
url.searchParams.set(key, String(value))
34+
url.searchParams.set(key, String(value));
3535
}
3636

3737
// reload the page with all new URL
38-
window.location.href = url.href
38+
window.location.href = url.href;
3939
}
4040

4141
function updatePlatformsParam(value) {
42-
const url = new URL(window.location.href)
43-
url.searchParams.set('platforms', value.join(','))
44-
window.location.href = url.href
42+
const url = new URL(window.location.href);
43+
url.searchParams.set('platforms', value.join(','));
44+
window.location.href = url.href;
4545
}
4646

4747
function updateScreenParam(value) {
48-
const url = new URL(window.location.href)
49-
url.searchParams.set('screen', value)
50-
window.location.href = url.href
48+
const url = new URL(window.location.href);
49+
url.searchParams.set('screen', value);
50+
window.location.href = url.href;
5151
}
5252

5353
/**
5454
* @param {string[]} values
5555
*/
5656
function updateRequestsParam(values) {
57-
const url = new URL(window.location.href)
58-
url.searchParams.delete('requests')
57+
const url = new URL(window.location.href);
58+
url.searchParams.delete('requests');
5959
for (let value of values) {
60-
url.searchParams.append('requests', value)
60+
url.searchParams.append('requests', value);
6161
}
62-
window.location.href = url.href
62+
window.location.href = url.href;
6363
}
6464

6565
render(
@@ -84,4 +84,4 @@ render(
8484
}
8585
/>,
8686
/** @type {HTMLDivElement} */ (document.querySelector('#app'))
87-
)
87+
);

debugger/settings.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { createDataStates, requests } from '../shared/js/ui/views/tests/generate-data.mjs'
2-
import google from '../schema/__fixtures__/request-data-google.json'
3-
import cnn from '../schema/__fixtures__/request-data-cnn.json'
1+
import { createDataStates, requests } from '../shared/js/ui/views/tests/generate-data.mjs';
2+
import google from '../schema/__fixtures__/request-data-google.json';
3+
import cnn from '../schema/__fixtures__/request-data-cnn.json';
44

5-
const states = createDataStates(/** @type {any} */ (google), /** @type {any} */ (cnn))
6-
const keys = Object.keys(states)
5+
const states = createDataStates(/** @type {any} */ (google), /** @type {any} */ (cnn));
6+
const keys = Object.keys(states);
77

88
/**
99
* @typedef {import('../schema/__generated__/schema.types').EventOrigin['screen']} Screen
@@ -20,8 +20,8 @@ const validInitialScreens = [
2020
'categoryTypeSelection',
2121
'categorySelection',
2222
'primaryScreen',
23-
]
24-
const screens = Object.fromEntries(validInitialScreens.map((x) => [x, x]))
23+
];
24+
const screens = Object.fromEntries(validInitialScreens.map((x) => [x, x]));
2525

2626
const items = [
2727
{
@@ -43,9 +43,9 @@ const items = [
4343
{
4444
platform: 'browser',
4545
},
46-
]
46+
];
4747

48-
const knownPlatforms = items.map((x) => x.platform)
48+
const knownPlatforms = items.map((x) => x.platform);
4949

5050
export class Settings {
5151
/**
@@ -56,78 +56,78 @@ export class Settings {
5656
* @param {string[]} [params.requests]
5757
*/
5858
constructor({ state = keys[0], screen = 'primaryScreen', platforms = ['android', 'ios', 'macos'], requests = [] } = {}) {
59-
this.state = state
60-
this.screen = screen
61-
this.screens = screens
62-
this.platforms = platforms
63-
this.requests = requests
64-
this.items = items
59+
this.state = state;
60+
this.screen = screen;
61+
this.screens = screens;
62+
this.platforms = platforms;
63+
this.requests = requests;
64+
this.items = items;
6565
}
6666

6767
get reflectParams() {
68-
const nextParams = new URLSearchParams()
69-
nextParams.set('screen', this.screen)
70-
nextParams.set('state', this.state)
68+
const nextParams = new URLSearchParams();
69+
nextParams.set('screen', this.screen);
70+
nextParams.set('state', this.state);
7171
for (const request of this.requests) {
72-
nextParams.append('requests', request)
72+
nextParams.append('requests', request);
7373
}
74-
return nextParams
74+
return nextParams;
7575
}
7676

7777
/**
7878
* @param {string|null|undefined} state
7979
*/
8080
withState(state) {
81-
if (!state) return this
82-
if (!keys.includes(state)) return this
81+
if (!state) return this;
82+
if (!keys.includes(state)) return this;
8383
return new Settings({
8484
...this,
8585
state,
86-
})
86+
});
8787
}
8888

8989
/**
9090
* @param {string|null|undefined} screen
9191
*/
9292
withScreen(screen) {
93-
if (!screen) return this
94-
if (!validInitialScreens.includes(/** @type {Screen} */ (screen))) return this
93+
if (!screen) return this;
94+
if (!validInitialScreens.includes(/** @type {Screen} */ (screen))) return this;
9595
return new Settings({
9696
...this,
9797
screen,
98-
})
98+
});
9999
}
100100

101101
/**
102102
* @param {string|null|undefined} platforms
103103
*/
104104
withPlatforms(platforms) {
105-
if (!platforms) return this
106-
if (typeof platforms !== 'string') return this
105+
if (!platforms) return this;
106+
if (typeof platforms !== 'string') return this;
107107
const selected = platforms
108108
.split(',')
109109
.map((x) => x.trim())
110-
.filter((x) => knownPlatforms.includes(/** @type {any} */ (x)))
110+
.filter((x) => knownPlatforms.includes(/** @type {any} */ (x)));
111111
if (selected.length > 0) {
112112
return new Settings({
113113
...this,
114114
platforms: selected,
115-
})
115+
});
116116
}
117-
return this
117+
return this;
118118
}
119119

120120
/**
121121
* @param {string[]|null|undefined} requestNames
122122
*/
123123
withRequests(requestNames) {
124-
if (!requestNames) return this
125-
if (!Array.isArray(requestNames)) return this
126-
const known = Object.keys(requests)
127-
const next = requestNames.filter((x) => known.includes(x))
124+
if (!requestNames) return this;
125+
if (!Array.isArray(requestNames)) return this;
126+
const known = Object.keys(requests);
127+
const next = requestNames.filter((x) => known.includes(x));
128128
return new Settings({
129129
...this,
130130
requests: next,
131-
})
131+
});
132132
}
133133
}

0 commit comments

Comments
 (0)