Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[email protected], fix peer deps, upgrades and fixes #27086

Merged
merged 8 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
extends: ['prettier'],
plugins: ['guardian-frontend', 'prettier'],
parser: 'babel-eslint',
parser: '@babel/eslint-parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 6,
Expand Down
62 changes: 32 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
"@braze/web-sdk-core": "3.5.1",
"@emotion/cache": "^11.1.5",
"@emotion/core": "^10.0.27",
"@emotion/react": "^11.1.5",
"@emotion/react": "11.11.1",
"@emotion/styled": "^10.0.27",
"@guardian/ab-core": "^5.0.0",
"@guardian/ab-core": "7.0.1",
"@guardian/automat-modules": "^0.3.8",
"@guardian/commercial": "^17.14.0",
"@guardian/core-web-vitals": "^5.0.0",
"@guardian/core-web-vitals": "6.0.0",
"@guardian/identity-auth": "2.1.0",
"@guardian/identity-auth-frontend": "4.0.0",
"@guardian/libs": "16.1.0",
"@guardian/shimport": "^1.0.2",
"@guardian/source-foundations": "^13.2.1",
"@guardian/source-react-components": "^12.0.0",
"@guardian/source-react-components-development-kitchen": "^10.0.1",
"@guardian/source-foundations": "14.2.2",
"@guardian/source-react-components": "22.1.0",
"@guardian/source-react-components-development-kitchen": "19.0.0",
"@guardian/support-dotcom-components": "1.1.3",
"bean": "~1.0.14",
"bonzo": "~2.0.0",
Expand All @@ -43,14 +43,14 @@
"qwery": "3.4.2",
"rangefix": "^0.2.5",
"raven-js": "^3.19.1",
"tslib": "^2.5.3",
"tslib": "2.6.2",
"video.js": "~5.3",
"videojs-contrib-ads": "3.1.3",
"videojs-embed": "guardian/videojs-embed#v0.3.3",
"videojs-ima": "googleads/videojs-ima#0.3.0",
"videojs-persistvolume": "guardian/videojs-persistvolume#0.1.4",
"videojs-playlist": "guardian/videojs-playlist#0.1.4",
"web-vitals": "^3.3.0",
"web-vitals": "3.5.1",
"wolfy87-eventemitter": "~5.2.4"
},
"resolutions": {
Expand All @@ -60,6 +60,7 @@
"@aws-sdk/client-cloudwatch": "3.441.0",
"@babel/cli": "^7.11.6",
"@babel/core": "^7.11.6",
"@babel/eslint-parser": "7.24.1",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
Expand All @@ -69,22 +70,21 @@
"@babel/preset-typescript": "^7.17.12",
"@babel/register": "^7.11.5",
"@babel/runtime": "^7.11.2",
"@guardian/eslint-config-typescript": "^0.7.0",
"@guardian/eslint-config-typescript": "9.0.1",
"@guardian/prettier": "^3.0.0",
"@types/google.analytics": "^0.0.42",
"@types/googletag": "^1.1.3",
"@types/jest": "^26.0.20",
"@types/jest": "29.5.12",
"@types/lodash-es": "^4.17.4",
"@types/webpack-env": "^1.16.2",
"@types/youtube": "^0.0.44",
"@typescript-eslint/eslint-plugin": "^4.12.0",
"@typescript-eslint/parser": "^4.12.0",
"@typescript-eslint/eslint-plugin": "5.61.0",
"@typescript-eslint/parser": "5.61.0",
"amphtml-validator": "^1.0.21",
"any-observable": "^0.2.0",
"autoprefixer": "^10.3.7",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.3.0",
"babel-jest": "29.7.0",
"babel-loader": "^8.1.0",
"babel-plugin-dynamic-import-node": "^2.3.3",
"browser-sync": "^2.18.13",
Expand All @@ -101,7 +101,7 @@
"css-loader": "^5.2.7",
"cssstats": "^3.1.0",
"csstype": "^3.0.6",
"eslint": "^7.17.0",
"eslint": "8.56.0",
"eslint-config-prettier": "^7.1.0",
"eslint-import-resolver-webpack": "^0.13.0",
"eslint-plugin-eslint-comments": "^3.2.0",
Expand All @@ -117,9 +117,9 @@
"glob": "^7.2.0",
"gzip-size": "^3.0.0",
"hasha": "^3.0.0",
"jest": "^26.6.3",
"jest-environment-jsdom": "^26.6.2",
"jest-environment-jsdom-global": "^2.0.4",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jest-environment-jsdom-global": "4.0.0",
"listr": "^0.14.3",
"lodash.merge": "^4.6.2",
"lodash.takewhile": "^4.6.0",
Expand Down Expand Up @@ -150,9 +150,9 @@
"stream-to-observable": "^0.2.0",
"svgo": "^2.3.0",
"tcp-ping": "^0.1.1",
"ts-jest": "^26.4.4",
"ts-jest": "29.1.2",
"ts-loader": "^8.0.12",
"typescript": "~4.9.5",
"typescript": "5.3.3",
"uglify-js": "^3.17.4",
"webpack": "^5.79.0",
"webpack-bundle-analyzer": "^4.8.0",
Expand All @@ -164,23 +164,23 @@
},
"optionalDependencies": {
"fsevents": "^2.3.2",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react": "18.2.0",
"react-dom": "18.2.0"
},
"jest": {
"preset": "ts-jest/presets/js-with-babel",
"globals": {
"ts-jest": {
"tsconfig": "tsconfig.test.json"
}
},
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
"^.+\\.(ts|tsx)$": [
"ts-jest",
{
"tsconfig": "tsconfig.test.json"
}
]
},
"testMatch": [
"**/*.(test|spec).+(ts|tsx|js)"
Expand All @@ -207,9 +207,11 @@
"<rootDir>/dev/jest.setupTestFrameworkScriptFile.js"
],
"testEnvironment": "jest-environment-jsdom-global",
"testURL": "http://testurl.theguardian.com",
"testEnvironmentOptions": {
"url": "http://testurl.theguardian.com"
},
"transformIgnorePatterns": [
"/node_modules/(?!(@guardian|lodash-es)/)"
"/node_modules/(?!(@guardian|lodash-es|preact)/)"
]
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion static/src/javascripts/lib/$$.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class $$ {
css(styles: CSS.Properties): $$ {
Object.entries(styles).forEach(([prop, val]) => {
this.#elements.forEach((element) =>
element.style.setProperty(prop, val),
element.style.setProperty(prop, String(val)),
);
});
return this;
Expand Down
2 changes: 1 addition & 1 deletion static/src/javascripts/lib/dynamic-import-init.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
interface Window {
guardianPolyfilledImport: <T extends unknown>(url: string) => Promise<T>;
guardianPolyfilledImport: <T>(url: string) => Promise<T>;
}
3 changes: 2 additions & 1 deletion static/src/javascripts/lib/fetch-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ const fetchJson = async (
resource: string,
init: RequestInit = {},
): Promise<unknown> => {
if (typeof resource !== 'string')
if (typeof resource !== 'string') {
throw new Error('First argument should be of type `string`');
}

let path = resource;
if (isPathAbsoluteURL(path)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ const trackPerformance = (
timingLabel,
};

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- extra safety if undefined
// @ts-expect-error -- no-unnecessary-condition error
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- extra safety if ga is undefined
if (window.ga ?? false) {
sendPerformanceEvent(event);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ jest.mock('common/modules/commercial/build-page-targeting', () => ({
getPageTargeting: jest.fn(() => ({ key: 'value' })),
}));

jest.mock('@guardian/commercial', () => ({
...jest.requireActual('@guardian/commercial'),
getPermutivePFPSegments: jest.fn(() => [42]),
}));
jest.mock(
'@guardian/commercial',
(): jest.Mock =>
({
...jest.requireActual('@guardian/commercial'),
getPermutivePFPSegments: jest.fn(() => [42]),
} as unknown as jest.Mock),
);

jest.mock('lib/config', () => ({
get: jest.fn((key: string, fallback?: unknown) => {
Expand All @@ -31,23 +35,27 @@ jest.mock('lib/config', () => ({
}),
}));

jest.mock('@guardian/libs', () => ({
...jest.requireActual('@guardian/libs'),
onConsentChange: jest.fn((callback: OnConsentChangeCallback) =>
callback({
tcfv2: {
consents: { 1: true },
gdprApplies: true,
eventStatus: 'tcloaded',
vendorConsents: { abc: true },
tcString: 'testTcString',
addtlConsent: 'testaddtlConsent',
},
canTarget: true,
framework: 'tcfv2',
}),
),
}));
jest.mock(
'@guardian/libs',
() =>
({
...jest.requireActual('@guardian/libs'),
onConsentChange: jest.fn((callback: OnConsentChangeCallback) =>
callback({
tcfv2: {
consents: { 1: true },
gdprApplies: true,
eventStatus: 'tcloaded',
vendorConsents: { abc: true },
tcString: 'testTcString',
addtlConsent: 'testaddtlConsent',
},
canTarget: true,
framework: 'tcfv2',
}),
),
} as unknown as jest.Mock),
);

jest.mock('common/modules/commercial/commercial-features', () => ({
commercialFeatures: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import { hasRequiredConsents } from './hasRequiredConsents';
const brazeVendorId = '5ed8c49c4b8ce4571c7ad801';

let mockOnConsentChangeResult: ConsentState | undefined;
jest.mock('@guardian/libs', () => ({
...jest.requireActual('@guardian/libs'),
onConsentChange: (callback: OnConsentChangeCallback) => {
if (mockOnConsentChangeResult) {
callback(mockOnConsentChangeResult);
}
},
}));
jest.mock(
'@guardian/libs',
() =>
({
...jest.requireActual('@guardian/libs'),
onConsentChange: (callback: OnConsentChangeCallback) => {
if (mockOnConsentChangeResult) {
callback(mockOnConsentChangeResult);
}
},
} as unknown as jest.Mock),
);

afterEach(() => {
mockOnConsentChangeResult = undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ const requestNewData = () => {
},
)
.then((response) => {
if (!validateResponse(response))
if (!validateResponse(response)) {
throw new Error('invalid response');
}
return response;
})
.then(persistResponse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const supportDotcomComponentsUrl = config.get('page.isDev')
? `https://contributions.code.dev-guardianapis.com`
: `https://contributions.guardianapis.com`;

export const dynamicImport = async <T extends unknown>(
export const dynamicImport = async <T>(
url: string,
name: string,
): Promise<React.FC<T>> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ describe('Search tool', () => {

sut.pushData();

jest.runTimersToTime(1);
jest.advanceTimersByTime(1);
expect(sut.destroy).not.toHaveBeenCalled();

jest.runTimersToTime(51);
jest.advanceTimersByTime(51);
expect(sut.destroy).toHaveBeenCalled();
});

Expand Down
2 changes: 1 addition & 1 deletion static/src/javascripts/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ type ComscoreGlobals = {

type AdBlockers = {
active: boolean | undefined;
onDetect: function[];
onDetect: Array<(value: boolean) => void>;
};

/**
Expand Down
Loading
Loading