Skip to content

Commit

Permalink
Merge branch 'main' into extract_entry_points
Browse files Browse the repository at this point in the history
  • Loading branch information
shakyShane authored Nov 4, 2024
2 parents 627d1c1 + 1a553e0 commit b4ab524
Show file tree
Hide file tree
Showing 77 changed files with 1,954 additions and 886 deletions.
14 changes: 0 additions & 14 deletions .eslintignore

This file was deleted.

38 changes: 0 additions & 38 deletions .eslintrc

This file was deleted.

8 changes: 4 additions & 4 deletions .github/scripts/diff-directories.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function displayDiffs (dir1Files, dir2Files, isOpen) {
}
for (const [filePath, fileContent] of Object.entries(dir1Files)) {
let diffOut = ''
let compareOut = undefined
let compareOut
if (filePath in dir2Files) {
const fileOut = fileContent
const file2Out = dir2Files[filePath]
Expand All @@ -71,7 +71,7 @@ function displayDiffs (dir1Files, dir2Files, isOpen) {
const rollup = rollupGrouping[key]
let outString = `
`
let title = key
const title = key
if (rollup.files.length) {
for (const file of rollup.files) {
outString += `- ${file}\n`
Expand All @@ -84,7 +84,7 @@ function displayDiffs (dir1Files, dir2Files, isOpen) {
}

function renderDetails (section, text, isOpen) {
if (section == 'dist') {
if (section === 'dist') {
section = 'apple'
}
const open = section !== 'integration' ? 'open' : ''
Expand Down Expand Up @@ -119,6 +119,6 @@ sortFiles(readFilesRecursively(dir1 + sourcesOutput), 'dir1')
sortFiles(readFilesRecursively(dir2 + sourcesOutput), 'dir2')


//console.log(Object.keys(files))
// console.log(Object.keys(files))
const fileOut = displayDiffs(sections.dir1, sections.dir2, true)
console.log(fileOut)
14 changes: 14 additions & 0 deletions build-output.eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// this belongs to the injected/ package, but eslint has issues with linting files outside of the base directory:
// https://github.com/eslint/eslint/discussions/18806#discussioncomment-10848750

export default [
{
languageOptions: {
ecmaVersion: "latest",
sourceType: "script",
},
rules: {
"no-implicit-globals": "error",
}
}
];
104 changes: 104 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import tseslint from 'typescript-eslint';
import ddgConfig from "@duckduckgo/eslint-config";
import globals from "globals";

// @ts-check
export default tseslint.config(
...ddgConfig,
...tseslint.configs.recommended,
{
ignores: [
"**/build/",
"**/docs/",
"injected/lib",
"Sources/ContentScopeScripts/dist/",
"injected/integration-test/extension/contentScope.js",
"injected/integration-test/test-pages/duckplayer/scripts/dist",
"special-pages/pages/**/public",
"special-pages/playwright-report/",
"special-pages/test-results/",
"special-pages/types/",
"special-pages/messages/",
"playwright-report",
"test-results",
"injected/src/types",
],
},
{
languageOptions: {
globals: {
$USER_PREFERENCES$: "readonly",
$USER_UNPROTECTED_DOMAINS$: "readonly",
$CONTENT_SCOPE$: "readonly",
$BUNDLED_CONFIG$: "readonly",
},

ecmaVersion: "latest",
sourceType: "script",
},

rules: {
"no-restricted-syntax": ["error", {
selector: "MethodDefinition[key.type='PrivateIdentifier']",
message: "Private methods are currently unsupported in older WebKit and ESR Firefox",
}],

"require-await": ["error"],
"promise/prefer-await-to-then": ["error"],
"@typescript-eslint/no-unused-vars": ["error", {
args: "none",
caughtErrors: "none",
ignoreRestSiblings: true,
vars: "all"
}],
},
},
{
ignores: ["injected/integration-test/test-pages/**", "injected/integration-test/extension/**"],
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ['eslint.config.js', 'build-output.eslint.config.js'],
},
}
},
rules: {
"@typescript-eslint/await-thenable": "error",
},
},
{
files: ["**/scripts/*.js", "**/*.mjs", "**/unit-test/**/*.js", "**/integration-test/**/*.spec.js"],
languageOptions: {
globals: {
...globals.node,
}
}
},
{
files: ["injected/**/*.js"],
languageOptions: {
globals: {
windowsInteropPostMessage: "readonly",
windowsInteropAddEventListener: "readonly",
windowsInteropRemoveEventListener: "readonly",
}
}
},
{
files: ["**/unit-test/*.js"],
languageOptions: {
globals: {
...globals.jasmine,
}
}
},
{
ignores: ["**/scripts/*.js"],
languageOptions: {
globals: {
...globals.browser,
...globals.webextensions,
}
}
}
);
12 changes: 0 additions & 12 deletions injected/build-output.eslintrc

This file was deleted.

8 changes: 0 additions & 8 deletions injected/integration-test/.eslintrc

This file was deleted.

4 changes: 2 additions & 2 deletions injected/integration-test/autofill-password-import.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class AutofillPasswordImportSpec {
* @param {string} selector
*/
async waitForAnimation (selector) {
const locator = await this.page.locator(selector)
const locator = this.page.locator(selector)
return await locator.evaluate((el) => {
if (el != null) {
return el.getAnimations().some((animation) => animation.playState === 'running')
Expand All @@ -112,7 +112,7 @@ export class AutofillPasswordImportSpec {
* @param {string} text
*/
async clickOnElement (text) {
const element = await this.page.getByText(text)
const element = this.page.getByText(text)
await element.click()
}
}
2 changes: 1 addition & 1 deletion injected/integration-test/duckplayer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test.describe('Thumbnail Overlays', () => {
const navigation = overlays.requestWillFail()
await overlays.clicksFirstShortsThumbnail()
const url = await navigation
await overlays.opensShort(url)
overlays.opensShort(url)
})
test('Overlays don\'t show on thumbnails when disabled', async ({ page }, workerInfo) => {
const overlays = DuckplayerOverlays.create(page, workerInfo)
Expand Down
1 change: 1 addition & 0 deletions injected/integration-test/fingerprint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { test as base, expect } from '@playwright/test'
import { testContextForExtension } from './helpers/harness.js'
import { createRequire } from 'node:module'

// eslint-disable-next-line no-redeclare
const require = createRequire(import.meta.url)

const test = testContextForExtension(base)
Expand Down
1 change: 1 addition & 0 deletions injected/integration-test/helpers/harness.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global process */
import { mkdtempSync, rmSync } from 'node:fs'
import { tmpdir } from 'os'
import { join } from 'path'
Expand Down
2 changes: 2 additions & 0 deletions injected/integration-test/page-objects/broker-protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,12 @@ export class BrokerProtectionPage {
* @param {object} response
*/
isErrorMessage (response) {
// eslint-disable-next-line no-unsafe-optional-chaining
expect('error' in response[0].payload?.params?.result).toBe(true)
}

isSuccessMessage (response) {
// eslint-disable-next-line no-unsafe-optional-chaining
expect('success' in response[0].payload?.params?.result).toBe(true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class DuckplayerOverlays {
* @return {Promise<string>}
*/
async clicksFirstThumbnail () {
const elem = await this.page.locator('a[href^="/watch?v"]:has(img)').first()
const elem = this.page.locator('a[href^="/watch?v"]:has(img)').first()
const link = await elem.getAttribute('href')
if (!link) throw new Error('link must exist')
await elem.click({ force: true })
Expand Down
1 change: 0 additions & 1 deletion injected/integration-test/test-pages/shared/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ function buildTableCell (value, tagName = 'td') {
* @param {Record<string, ResultRow>} results The results to build the table for.
* @return {Element} The table element.
*/
// eslint-disable-next-line no-unused-vars
function buildResultTable (results) {
const table = document.createElement('table')
table.className = 'results'
Expand Down
2 changes: 1 addition & 1 deletion injected/integration-test/type-helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class Build {
const path = this.switch({
windows: () => '../build/windows/contentScope.js',
android: () => '../build/android/contentScope.js',
'apple': () => '../Sources/ContentScopeScripts/dist/contentScope.js',
apple: () => '../Sources/ContentScopeScripts/dist/contentScope.js',
'apple-isolated': () => '../Sources/ContentScopeScripts/dist/contentScopeIsolated.js',
'android-autofill-password-import': () => '../build/android/autofillPasswordImport.js'
})
Expand Down
4 changes: 1 addition & 3 deletions injected/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
"build-integration": "node scripts/entry-points.js --platform integration",
"build-types": "node scripts/types.mjs",
"bundle-trackers": "node scripts/bundleTrackers.mjs --output ../build/tracker-lookup.json",
"lint": "npm run lint-no-output-globals",
"lint-no-output-globals": "eslint --no-eslintrc --config=build-output.eslintrc --no-ignore ../Sources/ContentScopeScripts/dist/contentScope.js",
"test-unit": "jasmine --config=unit-test/config.json",
"test-int": "npm run build-integration && npm run playwright",
"test-int-x": "xvfb-run --server-args='-screen 0 1024x768x24' npm run test-int",
Expand Down Expand Up @@ -49,7 +47,7 @@
"@types/node": "^22.8.6",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"config-builder": "github:duckduckgo/privacy-configuration#1729260354597",
"fast-check": "^3.22.0",
"fast-check": "^3.23.1",
"jasmine": "^5.4.0",
"minimist": "^1.2.8",
"rollup": "^4.24.3",
Expand Down
1 change: 1 addition & 0 deletions injected/playwright-e2e.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global process */
import { defineConfig } from '@playwright/test'
import { dirname, join } from 'node:path'
const __dirname = dirname(new URL(import.meta.url).pathname)
Expand Down
1 change: 1 addition & 0 deletions injected/playwright.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global process */
import { defineConfig, devices } from '@playwright/test'

export default defineConfig({
Expand Down
1 change: 1 addition & 0 deletions injected/scripts/bundleTrackers.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line no-redeclare
import fetch from 'node-fetch'
import { parseArgs, write } from '../../scripts/script-utils.js'

Expand Down
2 changes: 2 additions & 0 deletions injected/scripts/types.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { buildTypes } from "../../types-generator/build-types.mjs";

const injectRoot = join(cwd(import.meta.url), '..')

// eslint-disable-next-line no-redeclare
const require = createRequire(import.meta.url);
const configBuilderRoot = dirname(require.resolve("config-builder"));

Expand Down Expand Up @@ -42,6 +43,7 @@ const injectSchemaMapping = {

if (isLaunchFile(import.meta.url)) {
buildTypes(injectSchemaMapping)
// eslint-disable-next-line promise/prefer-await-to-then
.catch((error) => {
console.error(error)
process.exit(1)
Expand Down
1 change: 1 addition & 0 deletions injected/src/captured-globals.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-redeclare */
export const Set = globalThis.Set
export const Reflect = globalThis.Reflect
export const customElementsGet = globalThis.customElements?.get.bind(globalThis.customElements)
Expand Down
Loading

0 comments on commit b4ab524

Please sign in to comment.