chore: clean up ESLint config, enable a few rules (#6514)

* chore: clean up ESLint config, enable a few rules

* enable max-len for comments

* fix build
This commit is contained in:
Joshua Chen 2022-01-31 10:31:24 +08:00 committed by GitHub
parent b8ccb869f1
commit aa446b7a9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
167 changed files with 1157 additions and 960 deletions

View file

@ -46,7 +46,7 @@ function getSWBabelLoader() {
};
}
export default function (
export default function pluginPWA(
context: LoadContext,
options: PluginOptions,
): Plugin<void> {

View file

@ -219,8 +219,8 @@ async function registerSW() {
}
}
// TODO these events still works in chrome but have been removed from the spec in 2019!
// See https://github.com/w3c/manifest/pull/836
// TODO these events still works in chrome but have been removed from the spec
// in 2019! See https://github.com/w3c/manifest/pull/836
function addLegacyAppInstalledEventsListeners() {
if (typeof window !== 'undefined') {
if (debug) {
@ -248,7 +248,8 @@ function addLegacyAppInstalledEventsListeners() {
await clearRegistrations();
});
// TODO this event still works in chrome but has been removed from the spec in 2019!!!
// TODO this event still works in chrome but has been removed from the spec
// in 2019!!!
window.addEventListener('beforeinstallprompt', async (event) => {
if (debug) {
console.log(
@ -256,7 +257,8 @@ function addLegacyAppInstalledEventsListeners() {
event,
);
}
// TODO instead of default browser install UI, show custom docusaurus prompt?
// TODO instead of default browser install UI, show custom docusaurus
// prompt?
// event.preventDefault();
if (debug) {
console.log(
@ -273,7 +275,7 @@ function addLegacyAppInstalledEventsListeners() {
}
// After uninstalling the app, if the user doesn't clear all data, then
// the previous service worker will continue serving cached files. We
// need to clear registrations and reload, otherwise the popup will show.
// need to clear registrations and reload, otherwise the popup shows.
await clearRegistrations();
}
});

View file

@ -18,10 +18,10 @@ function parseSwParams() {
return params;
}
// doc advise against dynamic imports in SW
// doc advises against dynamic imports in SW
// https://developers.google.com/web/tools/workbox/guides/using-bundlers#code_splitting_and_dynamic_imports
// https://twitter.com/sebastienlorber/status/1280155204575518720
// but I think it's working fine as it's inlined by webpack, need to double check?
// but looks it's working fine as it's inlined by webpack, need to double check
async function runSWCustomCode(params) {
if (process.env.PWA_SW_CUSTOM) {
const customSW = await import(process.env.PWA_SW_CUSTOM);
@ -70,6 +70,7 @@ function getPossibleURLs(url) {
(async () => {
const params = parseSwParams();
// eslint-disable-next-line no-underscore-dangle
const precacheManifest = self.__WB_MANIFEST;
const controller = new PrecacheController({
fallbackToNetwork: true, // safer to turn this true?