Update Prettier

Also manually run prettier on `src/` and `lib/` to ensure
consistent formatting.
This commit is contained in:
Tim van der Lippe
2021-10-20 12:21:56 +01:00
parent e3f840c6da
commit e23bc4d2e5
8 changed files with 49 additions and 50 deletions

View File

@ -77,7 +77,9 @@ export default function entryDataPlugin() {
}
return JSON.stringify(
getDependencies(chunks, chunk).map((filename) => fileNameToURL(filename)),
getDependencies(chunks, chunk).map((filename) =>
fileNameToURL(filename),
),
);
},
);

14
package-lock.json generated
View File

@ -40,7 +40,7 @@
"postcss-url": "^8.0.0",
"preact": "^10.5.5",
"preact-render-to-string": "^5.1.11",
"prettier": "^2.1.2",
"prettier": "^2.4.1",
"rollup": "^2.38.0",
"rollup-plugin-terser": "^7.0.2",
"serve": "^11.3.2",
@ -7529,9 +7529,9 @@
}
},
"node_modules/prettier": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.2.tgz",
"integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==",
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz",
"integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
@ -15029,9 +15029,9 @@
}
},
"prettier": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.2.tgz",
"integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==",
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz",
"integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==",
"dev": true
},
"pretty-format": {

View File

@ -40,7 +40,7 @@
"postcss-url": "^8.0.0",
"preact": "^10.5.5",
"preact-render-to-string": "^5.1.11",
"prettier": "^2.1.2",
"prettier": "^2.4.1",
"rollup": "^2.38.0",
"rollup-plugin-terser": "^7.0.2",
"serve": "^11.3.2",

View File

@ -40,24 +40,23 @@ type PartialButNotUndefined<T> = {
[P in keyof T]: T[P];
};
const supportedEncoderMapP: Promise<PartialButNotUndefined<
typeof encoderMap
>> = (async () => {
const supportedEncoderMap: PartialButNotUndefined<typeof encoderMap> = {
...encoderMap,
};
const supportedEncoderMapP: Promise<PartialButNotUndefined<typeof encoderMap>> =
(async () => {
const supportedEncoderMap: PartialButNotUndefined<typeof encoderMap> = {
...encoderMap,
};
// Filter out entries where the feature test fails
await Promise.all(
Object.entries(encoderMap).map(async ([encoderName, details]) => {
if ('featureTest' in details && !(await details.featureTest())) {
delete supportedEncoderMap[encoderName as keyof typeof encoderMap];
}
}),
);
// Filter out entries where the feature test fails
await Promise.all(
Object.entries(encoderMap).map(async ([encoderName, details]) => {
if ('featureTest' in details && !(await details.featureTest())) {
delete supportedEncoderMap[encoderName as keyof typeof encoderMap];
}
}),
);
return supportedEncoderMap;
})();
return supportedEncoderMap;
})();
export default class Options extends Component<Props, State> {
state: State = {

View File

@ -14,9 +14,11 @@ import { EncodeOptions } from '../shared/meta';
import { threads } from 'wasm-feature-detect';
async function initMT() {
const { default: init, initThreadPool, optimise } = await import(
'codecs/oxipng/pkg-parallel/squoosh_oxipng'
);
const {
default: init,
initThreadPool,
optimise,
} = await import('codecs/oxipng/pkg-parallel/squoosh_oxipng');
await init();
await initThreadPool(navigator.hardwareConcurrency);
return optimise;

View File

@ -2,9 +2,9 @@ import * as styles from './styles.css';
import 'add-css:./styles.css';
// So it doesn't cause an error when running in node
const HTMLEl = ((__PRERENDER__
const HTMLEl = (__PRERENDER__
? Object
: HTMLElement) as unknown) as typeof HTMLElement;
: HTMLElement) as unknown as typeof HTMLElement;
/**
* A simple spinner. This custom element has no JS API. Just put it in the document, and it'll

View File

@ -2,9 +2,9 @@ import * as style from './styles.css';
import 'add-css:./styles.css';
// So it doesn't cause an error when running in node
const HTMLEl = ((__PRERENDER__
const HTMLEl = (__PRERENDER__
? Object
: HTMLElement) as unknown) as typeof HTMLElement;
: HTMLElement) as unknown as typeof HTMLElement;
export interface SnackOptions {
timeout?: number;

View File

@ -82,24 +82,20 @@ initialJs = subtractSets(
export const initial = ['/', ...initialJs];
export const theRest = (async () => {
const [
supportsThreads,
supportsSimd,
supportsWebP,
supportsAvif,
] = await Promise.all([
threads(),
simd(),
...[webpDataUrl, avifDataUrl].map(async (dataUrl) => {
if (!self.createImageBitmap) return false;
const response = await fetch(dataUrl);
const blob = await response.blob();
return createImageBitmap(blob).then(
() => true,
() => false,
);
}),
]);
const [supportsThreads, supportsSimd, supportsWebP, supportsAvif] =
await Promise.all([
threads(),
simd(),
...[webpDataUrl, avifDataUrl].map(async (dataUrl) => {
if (!self.createImageBitmap) return false;
const response = await fetch(dataUrl);
const blob = await response.blob();
return createImageBitmap(blob).then(
() => true,
() => false,
);
}),
]);
const items: string[] = [];