Skip to content

Commit

Permalink
Merge branch 'main' into dbajpeyi/fix/supported-paths
Browse files Browse the repository at this point in the history
  • Loading branch information
dbajpeyi authored Nov 4, 2024
2 parents 38f843d + 76bab4d commit 6dde0cd
Show file tree
Hide file tree
Showing 118 changed files with 3,972 additions and 1,741 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)
2 changes: 1 addition & 1 deletion .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/checkout@v4

- name: Use Node.js 20
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 20.x
- uses: actions/cache@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
run: |
ls -la ${{ github.workspace }}/CHANGELOG.txt
cat ${{ github.workspace }}/CHANGELOG.txt
- name: Create Release
uses: softprops/action-gh-release@v2
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 20.x
- uses: actions/cache@v4
Expand All @@ -43,7 +43,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 20.x
- uses: actions/cache@v4
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Cache build outputs
Expand Down
3 changes: 2 additions & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
"keyframes-name-pattern": null,
"block-no-empty": null,
"selector-id-pattern": null,
"selector-pseudo-class-no-unknown": null,
"declaration-block-no-shorthand-property-overrides": null,
"font-family-no-missing-generic-family-keyword": null,
"font-family-name-quotes": null,
"value-no-vendor-prefix": null
}
}
}
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
10 changes: 9 additions & 1 deletion 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 Expand Up @@ -92,9 +93,10 @@ export function testContextForExtension (test) {
* @param {string} urlString
* @param {Record<string, any>} [args]
* @param {string|null} [evalBeforeInit]
* @param {"extension" | "script"} [kind] - if 'extension', the script will be loaded separately. if 'script' we'll append a script tag
* @returns {Promise<void>}
*/
export async function gotoAndWait (page, urlString, args = {}, evalBeforeInit = null) {
export async function gotoAndWait (page, urlString, args = {}, evalBeforeInit = null, kind = 'extension') {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [_, search] = urlString.split('?')
const searchParams = new URLSearchParams(search)
Expand All @@ -104,6 +106,12 @@ export async function gotoAndWait (page, urlString, args = {}, evalBeforeInit =

await page.goto(urlString + '?' + searchParams.toString())

if (kind === 'script') {
await page.addScriptTag({
url: './build/contentScope.js'
})
}

// wait until contentScopeFeatures.load() has completed
await page.waitForFunction(() => {
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
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
Loading

0 comments on commit 6dde0cd

Please sign in to comment.