From b2c69fe5bd09969818eb47d5f5c8f0fd941daf9a Mon Sep 17 00:00:00 2001 From: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com> Date: Mon, 5 Feb 2024 10:26:37 +0100 Subject: [PATCH] build: fix EsLint rule and add fixer (#11826) --- .eslintrc.js | 11 +++- docker/test/smoke-test.js | 5 ++ examples/cross-browser.js | 5 ++ package-lock.json | 8 +-- packages/browsers/test/src/mocha-utils.ts | 5 ++ .../src/builders/puppeteer/index.ts | 5 ++ .../ng-schematics/test/src/config.test.ts | 5 ++ packages/ng-schematics/test/src/e2e.test.ts | 5 ++ .../ng-schematics/test/src/ng-add.test.ts | 5 ++ packages/ng-schematics/test/src/utils.ts | 5 ++ packages/ng-schematics/test/tsdoc.json | 15 +++++ packages/puppeteer-core/Herebyfile.mjs | 5 ++ packages/puppeteer-core/src/api/CDPSession.ts | 5 ++ .../src/bidi/BrowsingContext.ts | 5 ++ packages/puppeteer-core/src/bidi/Realm.ts | 5 ++ packages/puppeteer-core/src/cdp/Binding.ts | 5 ++ .../src/common/ScriptInjector.ts | 5 ++ packages/puppeteer-core/src/injected/util.ts | 5 ++ packages/puppeteer-core/src/util/Deferred.ts | 5 ++ packages/puppeteer-core/src/util/Mutex.ts | 5 ++ test-d/CommonEventEmitter.test-d.ts | 5 ++ test-d/ElementHandle.test-d.ts | 5 ++ test-d/JSHandle.test-d.ts | 5 ++ test-d/NodeFor.test-d.ts | 5 ++ test-d/puppeteer.test-d.ts | 5 ++ test/.eslintrc.js | 5 ++ test/fixtures/closeme.js | 5 ++ test/fixtures/dumpio.js | 5 ++ tools/analyze_issue.mjs | 6 ++ tools/eslint/src/check-license.ts | 63 +++++++++++-------- tools/eslint/tsconfig.json | 1 - website/archive.js | 5 ++ website/sidebars.js | 5 ++ website/src/theme/SearchBar/index.js | 5 ++ website/src/theme/SearchMetadata/index.js | 5 ++ website/src/theme/SearchPage/index.js | 5 ++ website/static/fix-location.js | 5 ++ website/static/sw.js | 5 ++ 38 files changed, 230 insertions(+), 34 deletions(-) create mode 100644 packages/ng-schematics/test/tsdoc.json diff --git a/.eslintrc.js b/.eslintrc.js index 250aa0c169d..40978c1f327 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -172,8 +172,6 @@ module.exports = { curly: ['error', 'all'], // Brackets keep code readable and `return` intentions clear. 'arrow-body-style': ['error', 'always'], - // Error if comments do not adhere to `tsdoc`. - 'tsdoc/syntax': 'error', // Keeps array types simple only when they are simple for readability. '@typescript-eslint/array-type': ['error', {default: 'array-simple'}], 'no-unused-vars': 'off', @@ -277,5 +275,14 @@ module.exports = { }, ], }, + + { + // Applies to only published packages + files: ['packages/**/*.ts'], + rules: { + // Error if comments do not adhere to `tsdoc`. + 'tsdoc/syntax': 'error', + }, + }, ], }; diff --git a/docker/test/smoke-test.js b/docker/test/smoke-test.js index 0ac836ab895..14b84c20db0 100644 --- a/docker/test/smoke-test.js +++ b/docker/test/smoke-test.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ const puppeteer = require('puppeteer'); (async () => { diff --git a/examples/cross-browser.js b/examples/cross-browser.js index 0f972a0b703..037dba24826 100644 --- a/examples/cross-browser.js +++ b/examples/cross-browser.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ const puppeteer = require('puppeteer'); /** diff --git a/package-lock.json b/package-lock.json index cce3af3d7bb..58dced081e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10893,7 +10893,7 @@ "@types/yargs": "17.0.32" }, "engines": { - "node": ">=18.17.1" + "node": ">=18" } }, "packages/browsers/node_modules/cliui": { @@ -10945,7 +10945,7 @@ "@schematics/angular": "^17.0.7" }, "engines": { - "node": ">=18.17.1" + "node": ">=18" } }, "packages/ng-schematics/node_modules/@angular-devkit/architect": { @@ -11382,7 +11382,7 @@ "@types/node": "18.17.15" }, "engines": { - "node": ">=18.17.1" + "node": ">=18" } }, "packages/puppeteer-core": { @@ -11405,7 +11405,7 @@ "rxjs": "7.8.1" }, "engines": { - "node": ">=18.17.1" + "node": ">=18" } }, "packages/puppeteer-core/node_modules/@types/node": { diff --git a/packages/browsers/test/src/mocha-utils.ts b/packages/browsers/test/src/mocha-utils.ts index 245a0048b23..f3ee678d4ea 100644 --- a/packages/browsers/test/src/mocha-utils.ts +++ b/packages/browsers/test/src/mocha-utils.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import debug from 'debug'; export const mochaHooks = { diff --git a/packages/ng-schematics/src/builders/puppeteer/index.ts b/packages/ng-schematics/src/builders/puppeteer/index.ts index 82a1e8e7da8..e8caab83c94 100644 --- a/packages/ng-schematics/src/builders/puppeteer/index.ts +++ b/packages/ng-schematics/src/builders/puppeteer/index.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import {spawn} from 'child_process'; import {normalize, join} from 'path'; diff --git a/packages/ng-schematics/test/src/config.test.ts b/packages/ng-schematics/test/src/config.test.ts index e4ec03ed547..9390e6fd74c 100644 --- a/packages/ng-schematics/test/src/config.test.ts +++ b/packages/ng-schematics/test/src/config.test.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import {describe, it} from 'node:test'; import expect from 'expect'; diff --git a/packages/ng-schematics/test/src/e2e.test.ts b/packages/ng-schematics/test/src/e2e.test.ts index 8ae211cd59d..2d80c613f96 100644 --- a/packages/ng-schematics/test/src/e2e.test.ts +++ b/packages/ng-schematics/test/src/e2e.test.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import {describe, it} from 'node:test'; import expect from 'expect'; diff --git a/packages/ng-schematics/test/src/ng-add.test.ts b/packages/ng-schematics/test/src/ng-add.test.ts index d912c5dc3d2..56f82ef926b 100644 --- a/packages/ng-schematics/test/src/ng-add.test.ts +++ b/packages/ng-schematics/test/src/ng-add.test.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import {describe, it} from 'node:test'; import expect from 'expect'; diff --git a/packages/ng-schematics/test/src/utils.ts b/packages/ng-schematics/test/src/utils.ts index 503cbd5cecf..ea74d8e21f5 100644 --- a/packages/ng-schematics/test/src/utils.ts +++ b/packages/ng-schematics/test/src/utils.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import https from 'https'; import {before, after} from 'node:test'; import {join} from 'path'; diff --git a/packages/ng-schematics/test/tsdoc.json b/packages/ng-schematics/test/tsdoc.json new file mode 100644 index 00000000000..f5b91f4af69 --- /dev/null +++ b/packages/ng-schematics/test/tsdoc.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + + "extends": ["@microsoft/api-extractor/extends/tsdoc-base.json"], + "tagDefinitions": [ + { + "tagName": "@license", + "syntaxKind": "modifier", + "allowMultiple": false + } + ], + "supportForTags": { + "@license": true + } +} diff --git a/packages/puppeteer-core/Herebyfile.mjs b/packages/puppeteer-core/Herebyfile.mjs index 723fa2868a7..a221a688205 100644 --- a/packages/puppeteer-core/Herebyfile.mjs +++ b/packages/puppeteer-core/Herebyfile.mjs @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import {mkdir, readFile, readdir, writeFile} from 'fs/promises'; import {join} from 'path/posix'; diff --git a/packages/puppeteer-core/src/api/CDPSession.ts b/packages/puppeteer-core/src/api/CDPSession.ts index 8bdf96f9544..3a1fdf1e24f 100644 --- a/packages/puppeteer-core/src/api/CDPSession.ts +++ b/packages/puppeteer-core/src/api/CDPSession.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import type {ProtocolMapping} from 'devtools-protocol/types/protocol-mapping.js'; import type {Connection} from '../cdp/Connection.js'; diff --git a/packages/puppeteer-core/src/bidi/BrowsingContext.ts b/packages/puppeteer-core/src/bidi/BrowsingContext.ts index 0804628c061..97479effa67 100644 --- a/packages/puppeteer-core/src/bidi/BrowsingContext.ts +++ b/packages/puppeteer-core/src/bidi/BrowsingContext.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import type * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js'; import type ProtocolMapping from 'devtools-protocol/types/protocol-mapping.js'; diff --git a/packages/puppeteer-core/src/bidi/Realm.ts b/packages/puppeteer-core/src/bidi/Realm.ts index 84f13bc7032..53812e145df 100644 --- a/packages/puppeteer-core/src/bidi/Realm.ts +++ b/packages/puppeteer-core/src/bidi/Realm.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import * as Bidi from 'chromium-bidi/lib/cjs/protocol/protocol.js'; import {EventEmitter, type EventType} from '../common/EventEmitter.js'; diff --git a/packages/puppeteer-core/src/cdp/Binding.ts b/packages/puppeteer-core/src/cdp/Binding.ts index 7a6a6f8582c..7fe372788ff 100644 --- a/packages/puppeteer-core/src/cdp/Binding.ts +++ b/packages/puppeteer-core/src/cdp/Binding.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import {JSHandle} from '../api/JSHandle.js'; import {debugError} from '../common/util.js'; import {DisposableStack} from '../util/disposable.js'; diff --git a/packages/puppeteer-core/src/common/ScriptInjector.ts b/packages/puppeteer-core/src/common/ScriptInjector.ts index 0264c9175ff..d505d6c5ff8 100644 --- a/packages/puppeteer-core/src/common/ScriptInjector.ts +++ b/packages/puppeteer-core/src/common/ScriptInjector.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import {source as injectedSource} from '../generated/injected.js'; /** diff --git a/packages/puppeteer-core/src/injected/util.ts b/packages/puppeteer-core/src/injected/util.ts index 34fe8f77484..cfc209ba570 100644 --- a/packages/puppeteer-core/src/injected/util.ts +++ b/packages/puppeteer-core/src/injected/util.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ const HIDDEN_VISIBILITY_VALUES = ['hidden', 'collapse']; /** diff --git a/packages/puppeteer-core/src/util/Deferred.ts b/packages/puppeteer-core/src/util/Deferred.ts index 0dfb013bb3f..6699ace36dd 100644 --- a/packages/puppeteer-core/src/util/Deferred.ts +++ b/packages/puppeteer-core/src/util/Deferred.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import {TimeoutError} from '../common/Errors.js'; /** diff --git a/packages/puppeteer-core/src/util/Mutex.ts b/packages/puppeteer-core/src/util/Mutex.ts index 9498bac3060..f789837def2 100644 --- a/packages/puppeteer-core/src/util/Mutex.ts +++ b/packages/puppeteer-core/src/util/Mutex.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import {Deferred} from './Deferred.js'; import {disposeSymbol} from './disposable.js'; diff --git a/test-d/CommonEventEmitter.test-d.ts b/test-d/CommonEventEmitter.test-d.ts index 581b248b8a5..40d0f9106ba 100644 --- a/test-d/CommonEventEmitter.test-d.ts +++ b/test-d/CommonEventEmitter.test-d.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ // eslint-disable-next-line no-restricted-imports import {EventEmitter as NodeEventEmitter} from 'node:events'; diff --git a/test-d/ElementHandle.test-d.ts b/test-d/ElementHandle.test-d.ts index 469150933bf..aa01ca2b28a 100644 --- a/test-d/ElementHandle.test-d.ts +++ b/test-d/ElementHandle.test-d.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import {expectNotType, expectType} from 'tsd'; import type {ElementHandle} from 'puppeteer'; diff --git a/test-d/JSHandle.test-d.ts b/test-d/JSHandle.test-d.ts index fa7348d28e0..67a56760c2d 100644 --- a/test-d/JSHandle.test-d.ts +++ b/test-d/JSHandle.test-d.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import {expectNotAssignable, expectNotType, expectType} from 'tsd'; import type {ElementHandle, JSHandle} from 'puppeteer'; diff --git a/test-d/NodeFor.test-d.ts b/test-d/NodeFor.test-d.ts index 0a40b4e689f..53487619e95 100644 --- a/test-d/NodeFor.test-d.ts +++ b/test-d/NodeFor.test-d.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import {expectType, expectNotType} from 'tsd'; import type {NodeFor} from 'puppeteer'; diff --git a/test-d/puppeteer.test-d.ts b/test-d/puppeteer.test-d.ts index f7a45c0db44..66baff695af 100644 --- a/test-d/puppeteer.test-d.ts +++ b/test-d/puppeteer.test-d.ts @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import {expectType} from 'tsd'; import puppeteer, { diff --git a/test/.eslintrc.js b/test/.eslintrc.js index 489868b6ed3..5f7746a76b9 100644 --- a/test/.eslintrc.js +++ b/test/.eslintrc.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ module.exports = { rules: { 'no-restricted-imports': [ diff --git a/test/fixtures/closeme.js b/test/fixtures/closeme.js index dbe798f70df..a534f9acde1 100644 --- a/test/fixtures/closeme.js +++ b/test/fixtures/closeme.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ (async () => { const [, , puppeteerRoot, options] = process.argv; const browser = await require(puppeteerRoot).launch(JSON.parse(options)); diff --git a/test/fixtures/dumpio.js b/test/fixtures/dumpio.js index a16cf4d633d..3df71b43b5e 100644 --- a/test/fixtures/dumpio.js +++ b/test/fixtures/dumpio.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ (async () => { const [, , puppeteerRoot, options] = process.argv; const browser = await require(puppeteerRoot).launch(JSON.parse(options)); diff --git a/tools/analyze_issue.mjs b/tools/analyze_issue.mjs index 9592112de0a..eff6a4122ed 100755 --- a/tools/analyze_issue.mjs +++ b/tools/analyze_issue.mjs @@ -1,4 +1,10 @@ #!/usr/bin/env node +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ + // @ts-check 'use strict'; diff --git a/tools/eslint/src/check-license.ts b/tools/eslint/src/check-license.ts index 7ae1a543841..c1cc31a0031 100644 --- a/tools/eslint/src/check-license.ts +++ b/tools/eslint/src/check-license.ts @@ -11,15 +11,16 @@ const createRule = ESLintUtils.RuleCreator(name => { return `https://github.com/puppeteer/puppeteer/tree/main/tools/eslint/${name}.ts`; }); -const copyrightPattern = /Copyright ([0-9]{4}) Google Inc\./; +const currentYear = new Date().getFullYear(); -// const currentYear = new Date().getFullYear; - -// const licenseHeader = `/** -// * @license -// * Copyright ${currentYear} Google Inc. -// * SPDX-License-Identifier: Apache-2.0 -// */`; +// Needs to start and end with new line +const licenseHeader = ` +/** + * @license + * Copyright ${currentYear} Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ +`; const enforceLicenseRule = createRule<[], 'licenseRule'>({ name: 'check-license', @@ -29,7 +30,7 @@ const enforceLicenseRule = createRule<[], 'licenseRule'>({ description: 'Validate existence of license header', requiresTypeChecking: false, }, - fixable: undefined, // TODO: change to 'code' once fixer works. + fixable: 'code', schema: [], messages: { licenseRule: 'Add license header.', @@ -39,16 +40,26 @@ const enforceLicenseRule = createRule<[], 'licenseRule'>({ create(context) { const sourceCode = context.sourceCode; const comments = sourceCode.getAllComments(); - const header = - comments[0]?.type === 'Block' && isHeaderComment(comments[0]) - ? comments[0] - : null; - - function isHeaderComment(comment: TSESTree.Comment) { - if (comment && comment.range[0] >= 0 && comment.range[1] <= 88) { - return true; - } else { - return false; + let insertAfter = [0, 0] as TSESTree.Range; + let header: TSESTree.Comment | null = null; + // Check only the first 2 comments + for (let index = 0; index < 2; index++) { + const comment = comments[index]; + if (!comment) { + break; + } + // Shebang comments should be at the top + if ( + // Types don't have it debugger showed it... + (comment.type as string) === 'Shebang' || + (comment.type === 'Line' && comment.value.startsWith('#!')) + ) { + insertAfter = comment.range; + continue; + } + if (comment.type === 'Block') { + header = comment; + break; } } @@ -56,23 +67,21 @@ const enforceLicenseRule = createRule<[], 'licenseRule'>({ Program(node) { if ( header && - header.value.includes('@license') && - header.value.includes('SPDX-License-Identifier: Apache-2.0') && - copyrightPattern.test(header.value) + (header.value.includes('@license') || + header.value.includes('License') || + header.value.includes('Copyright')) ) { return; } // Add header license if (!header || !header.value.includes('@license')) { - // const startLoc: [number, number] = [0, 88]; context.report({ node: node, messageId: 'licenseRule', - // TODO: fix the fixer. - // fix(fixer) { - // return fixer.insertTextBeforeRange(startLoc, licenseHeader); - // }, + fix(fixer) { + return fixer.insertTextAfterRange(insertAfter, licenseHeader); + }, }); } }, diff --git a/tools/eslint/tsconfig.json b/tools/eslint/tsconfig.json index da26cc936ba..9fe95f8215e 100644 --- a/tools/eslint/tsconfig.json +++ b/tools/eslint/tsconfig.json @@ -7,7 +7,6 @@ "outDir": "./lib", "declaration": false, "declarationMap": false, - "sourceMap": false, "composite": false, "removeComments": true, }, diff --git a/website/archive.js b/website/archive.js index 7afd5ab42e9..498d5ce9f06 100644 --- a/website/archive.js +++ b/website/archive.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ /** * "Archives" older versions of the website docs to reduce the build time: * diff --git a/website/sidebars.js b/website/sidebars.js index 5aed3faed0f..e63a2bdc425 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ module.exports = { docs: [ diff --git a/website/src/theme/SearchBar/index.js b/website/src/theme/SearchBar/index.js index 41ec8f8b23f..86baf797b43 100644 --- a/website/src/theme/SearchBar/index.js +++ b/website/src/theme/SearchBar/index.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import {DocSearchButton, useDocSearchKeyboardEvents} from '@docsearch/react'; import Head from '@docusaurus/Head'; import Link from '@docusaurus/Link'; diff --git a/website/src/theme/SearchMetadata/index.js b/website/src/theme/SearchMetadata/index.js index 692c3bd912f..1d220865307 100644 --- a/website/src/theme/SearchMetadata/index.js +++ b/website/src/theme/SearchMetadata/index.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import Head from '@docusaurus/Head'; import React from 'react'; diff --git a/website/src/theme/SearchPage/index.js b/website/src/theme/SearchPage/index.js index 9d762c487ee..1b64060f317 100644 --- a/website/src/theme/SearchPage/index.js +++ b/website/src/theme/SearchPage/index.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment'; import Head from '@docusaurus/Head'; import Link from '@docusaurus/Link'; diff --git a/website/static/fix-location.js b/website/static/fix-location.js index 710716d7d70..6657479077b 100644 --- a/website/static/fix-location.js +++ b/website/static/fix-location.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ const url = new URL(window.location.href); if (url.pathname.endsWith('/') && url.pathname !== '/') { url.pathname = url.pathname.substring(0, url.pathname.length - 1); diff --git a/website/static/sw.js b/website/static/sw.js index 644c18db63a..6cdfa07b829 100644 --- a/website/static/sw.js +++ b/website/static/sw.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2024 Google Inc. + * SPDX-License-Identifier: Apache-2.0 + */ self.addEventListener('install', () => { self.skipWaiting(); });