Skip to content

Commit

Permalink
Merge branch 'main' into al-add-daily-check-for-guardian-apps
Browse files Browse the repository at this point in the history
  • Loading branch information
akinsola-guardian committed Jan 12, 2024
2 parents 6a6b1d4 + 100b0a6 commit edee7a7
Show file tree
Hide file tree
Showing 27 changed files with 78 additions and 60 deletions.
15 changes: 12 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,26 @@ module.exports = {
jest: true,
browser: true,
},
extends: ['@guardian/eslint-config-typescript'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'@guardian/eslint-config-typescript',
],
globals: { __PACKAGE_VERSION__: 'readonly' },
ignorePatterns: ['dist', 'coverage', 'cdk', 'monitoring', '*.ts', '*.*.ts'],
rules: {
// a lot of the 3rd party code uses these
'no-underscore-dangle': 0,
},

parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 6,
project: 'tsconfig.json',
sourceType: 'module',
},
overrides: [
{
// tests and config files sometimes do unorthodox things, and that's ok
files: ['**/*.test.*', '*.config.js'],
rules: {
'@typescript-eslint/no-unsafe-return': 0,
Expand Down
10 changes: 7 additions & 3 deletions cdk/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ module.exports = {
node: true,
jest: true,
},
extends: ['@guardian/eslint-config-typescript'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'@guardian/eslint-config-typescript',
],
parserOptions: {
ecmaVersion: 2020,
tsconfigRootDir: __dirname,
sourceType: 'module',
project: ['./tsconfig.eslint.json'],
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/no-inferrable-types': 0,
'import/no-namespace': 2,
},
ignorePatterns: ['**/*.js', 'node_modules'],
ignorePatterns: ['node_modules'],
};
2 changes: 1 addition & 1 deletion cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"devDependencies": {
"@guardian/eslint-config-typescript": "^7.0.0",
"@guardian/prettier": "^5.0.0",
"@guardian/tsconfig": "^0.2.0",
"@guardian/tsconfig": "^0.2.0",
"@types/jest": "^29.5.5",
"@types/node": "20.8.2",
"aws-cdk": "2.95.1",
Expand Down
2 changes: 1 addition & 1 deletion cdk/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.json",
"include": ["lib/**/*", "bin/**/*"],
"include": ["lib/**/*", "bin/**/*", ".eslintrc.js"],
"exclude": ["node_modules"]
}
3 changes: 2 additions & 1 deletion cdk/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"node_modules",
"cdk.out",
"lib/**/*.test.ts",
"lib/**/__snapshots__/**"
"lib/**/__snapshots__/**",
"**/*.d.ts"
]
}
10 changes: 7 additions & 3 deletions monitoring/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ module.exports = {
node: true,
jest: true,
},
extends: ['@guardian/eslint-config-typescript'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'@guardian/eslint-config-typescript',
],
parserOptions: {
ecmaVersion: 2020,
tsconfigRootDir: __dirname,
sourceType: 'module',
project: ['./tsconfig.eslint.json'],
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/no-inferrable-types': 0,
'import/no-namespace': 2,
},
ignorePatterns: ['**/*.js', 'node_modules'],
ignorePatterns: ['node_modules', 'dist'],
};
2 changes: 1 addition & 1 deletion monitoring/localRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type LocalRunCliArguments = {

class NoArgumentsError extends Error {
constructor(
message: string = 'Arguments provided are missing or incorrect',
message = 'Arguments provided are missing or incorrect',
) {
super(message);
this.name = 'NoArgumentsError';
Expand Down
2 changes: 1 addition & 1 deletion monitoring/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
"overrides": {
"clone-deep": "4.0.1"
}
}
}
7 changes: 4 additions & 3 deletions monitoring/src/check-page/common-functions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {
PutMetricDataCommandInput} from '@aws-sdk/client-cloudwatch';
PutMetricDataCommandInput
} from '@aws-sdk/client-cloudwatch';
import {
CloudWatchClient,
PutMetricDataCommand
Expand Down Expand Up @@ -365,7 +366,7 @@ export const sendMetricData = async (
log_info(`config.platform.toUpperCase() ${config.platform.toUpperCase()})`);
const region = config.region;
const client = new CloudWatchClient({ region: region });
const params: PutMetricDataCommandInput = {
const params = {
MetricData: [
{
MetricName: 'CmpLoadingTime',
Expand Down Expand Up @@ -399,7 +400,7 @@ export const sendMetricData = async (
},
],
Namespace: 'Application',
};
} satisfies PutMetricDataCommandInput;

const command = new PutMetricDataCommand(params);

Expand Down
4 changes: 2 additions & 2 deletions monitoring/src/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ConfigWrapper', () => {
describe('generateConfig', () => {
let awsRegion: AwsRegionOpt = AWS_REGIONS.US_WEST_1;
let jurisdiction: JurisdictionOpt = JURISDICTIONS.CCPA;
const stage: string = 'code';
const stage = 'code';
it('should assign jurisdiction if there is an awsRegion and no jurisdiction ', () => {
jurisdiction = undefined;
awsRegion = AWS_REGIONS.US_WEST_1;
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('ConfigWrapper', () => {
describe('run', () => {
const awsRegion: AwsRegionOpt = AWS_REGIONS.US_WEST_1;
const jurisdiction: JurisdictionOpt = JURISDICTIONS.CCPA;
const stage: string = 'code';
const stage = 'code';

it('should call config.checkFunction if config is defined', async () => {
const configWrapper = new ConfigWrapper(
Expand Down
2 changes: 1 addition & 1 deletion monitoring/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig.json",
"include": ["src/**/*", "*.ts", "node_modules/puppeteer-core/**/*"],
"include": ["src/**/*", "*.ts", ".eslintrc.js"],
"exclude": ["node_modules"]
}
2 changes: 1 addition & 1 deletion monitoring/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@guardian/tsconfig",
"include": ["./*.ts"],
"include": ["./**/*.ts"],
"compilerOptions": {
"moduleResolution": "node",
"module": "commonjs",
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
"@babel/preset-typescript": "^7.23.2",
"@babel/runtime": "^7.23.2",
"@changesets/cli": "^2.26.2",
"@guardian/eslint-config": "^4.0.0",
"@guardian/eslint-config-typescript": "^6.0.0",
"@guardian/eslint-config-typescript": "^7.0.0",
"@guardian/libs": "15.0.0",
"@guardian/prettier": "^4.0.0",
"@guardian/tsconfig": "^0.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/aus/api.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getUSPData } from './api';
import { getUSPData } from './api.ts';

jest.mock('../sourcepoint', () => ({
sourcepointLibraryLoaded: Promise.resolve(),
Expand Down
4 changes: 2 additions & 2 deletions src/aus/getConsentState.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ausData from './__fixtures__/api.getUSPData.json';
import { getUSPData } from './api';
import { getConsentState } from './getConsentState';
import { getUSPData } from './api.ts';
import { getConsentState } from './getConsentState.ts';

jest.mock('./api');
getUSPData.mockResolvedValue(ausData);
Expand Down
2 changes: 1 addition & 1 deletion src/ccpa/api.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getUSPData } from './api';
import { getUSPData } from './api.ts';

it('calls the correct IAB api with the correct methods', async () => {
expect(getUSPData()).rejects.toThrow();
Expand Down
4 changes: 2 additions & 2 deletions src/ccpa/getConsentState.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import uspData from './__fixtures__/api.getUSPData.json';
import { getUSPData } from './api';
import { getConsentState } from './getConsentState';
import { getUSPData } from './api.ts';
import { getConsentState } from './getConsentState.ts';

jest.mock('./api');
getUSPData.mockResolvedValue(uspData);
Expand Down
2 changes: 1 addition & 1 deletion src/disable.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { disable, enable, isDisabled } from './disable';
import { disable, enable, isDisabled } from './disable.ts';

describe('Disabling consent management', () => {
it('should be enabled by default', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/getConsentFor.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// cSpell:ignore doesnotexist

import { getConsentFor } from './getConsentFor';
import { getConsentFor } from './getConsentFor.ts';

const vendorOne = 'd3b07384d113edec49eaa623';
const vendorAlt = 'c157a79031e1c40f85931829';
Expand Down
2 changes: 1 addition & 1 deletion src/getFramework.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getFramework } from './getFramework';
import { getFramework } from './getFramework.ts';

/* cSpell:disable */
const countries = {
Expand Down
12 changes: 6 additions & 6 deletions src/index.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import waitForExpect from 'wait-for-expect';
import { CMP as actualCMP } from './cmp';
import { disable, enable } from './disable';
import { getCurrentFramework } from './getCurrentFramework';
import { cmp } from '.';
import { CMP as actualCMP } from './cmp.ts';
import { disable, enable } from './disable.ts';
import { getCurrentFramework } from './getCurrentFramework.ts';
import { cmp } from './index.ts';

const CMP = {
init: jest.spyOn(actualCMP, 'init'),
Expand Down Expand Up @@ -102,12 +102,12 @@ describe('hotfix cmp.init', () => {
};

jest.resetModules();
import('.').then((module) => {
import('./index.ts').then((module) => {
expect(module.cmp).toEqual(mockCmp);

delete window.guCmpHotFix;
jest.resetModules();
import('.');
import('./index.ts');
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/onConsentChange.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import waitForExpect from 'wait-for-expect';
import ausData from './aus/__fixtures__/api.getUSPData.json';
import uspData from './ccpa/__fixtures__/api.getUSPData.json';
import { setCurrentFramework } from './getCurrentFramework';
import { _, invokeCallbacks, onConsentChange } from './onConsentChange';
import { setCurrentFramework } from './getCurrentFramework.ts';
import { _, invokeCallbacks, onConsentChange } from './onConsentChange.ts';
import customVendorConsents from './tcfv2/__fixtures__/api.getCustomVendorConsents.json';
import tcData from './tcfv2/__fixtures__/api.getTCData.json';

Expand Down
4 changes: 2 additions & 2 deletions src/sourcepoint.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import http from 'http';
import url from 'url';
import { ACCOUNT_ID, ENDPOINT } from './lib/sourcepointConfig';
import { init } from './sourcepoint';
import { ACCOUNT_ID, ENDPOINT } from './lib/sourcepointConfig.ts';
import { init } from './sourcepoint.ts';

const frameworks = ['tcfv2', 'ccpa', 'aus'];

Expand Down
2 changes: 1 addition & 1 deletion src/tcfv2/api.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCustomVendorConsents, getTCData } from './api';
import { getCustomVendorConsents, getTCData } from './api.ts';

it('calls the correct IAB api with the correct methods', async () => {
expect(getTCData()).rejects.toThrow();
Expand Down
4 changes: 2 additions & 2 deletions src/tcfv2/getConsentState.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import customVendorConsents from './__fixtures__/api.getCustomVendorConsents.json';
import tcData from './__fixtures__/api.getTCData.json';
import { getCustomVendorConsents, getTCData } from './api';
import { getConsentState } from './getConsentState';
import { getCustomVendorConsents, getTCData } from './api.ts';
import { getConsentState } from './getConsentState.ts';

jest.mock('./api');
getTCData.mockReturnValue(Promise.resolve(tcData));
Expand Down
2 changes: 1 addition & 1 deletion src/vendors.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import { TCFV2VendorIDs } from './vendors';
import { TCFV2VendorIDs } from './vendors.ts';

const cmpBaseUrl = 'cdn.privacy-mgmt.com';
const guardianId = '5ec67f5bb8e05c4a1160fda1';
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1491,23 +1491,23 @@
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.44.0.tgz#961a5903c74139390478bdc808bcde3fc45ab7af"
integrity sha512-Ag+9YM4ocKQx9AarydN0KY2j0ErMHNIocPDrVo8zAE44xLTjEtz81OdR68/cydGtk6m6jDb5Za3r2useMzYmSw==

"@guardian/eslint-config-typescript@^6.0.0":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@guardian/eslint-config-typescript/-/eslint-config-typescript-6.0.0.tgz#a2080acca102f7d77e5173dcc9a751209a695ff1"
integrity sha512-L1KpAnxLw9fX5YW0PrMRdirZVkb/IK5s/JBIE61Gx8AxIa3PNTnVS/v6xS/okbBb1nXa30xV2ty0RX6CG78t8A==
"@guardian/eslint-config-typescript@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@guardian/eslint-config-typescript/-/eslint-config-typescript-7.0.0.tgz#b16fab129fb6e7fe9343143d9bdcbe1867117ab8"
integrity sha512-2XsjhVRmIK0nvjGHDcvTjMd4DNHsSHIkqDRc4cGEAUcKdPgXEtuWyxQeWEdBBvqLo0aNj6PH3ekyWpPsgZKo8g==
dependencies:
"@guardian/eslint-config" "4.0.0"
"@guardian/eslint-config" "5.0.0"
"@typescript-eslint/eslint-plugin" "5.59.9"
"@typescript-eslint/parser" "5.59.9"
eslint-import-resolver-typescript "3.5.5"
eslint-plugin-import "2.27.5"

"@guardian/eslint-config@4.0.0", "@guardian/eslint-config@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@guardian/eslint-config/-/eslint-config-4.0.0.tgz#6beb3ae4eec73418ee18a83160d87565a2ae3d0a"
integrity sha512-OAazxlXgYjggVNE7scoSgb1g+CIz/yfhPenEKGSTM5fejeTRZNwfFPDcVl4h4jY5/17aCUxaLxG+Nc0r4V94kQ==
"@guardian/eslint-config@5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@guardian/eslint-config/-/eslint-config-5.0.0.tgz#a9652f78f057fa4f35420fea8f8e807737ae15d1"
integrity sha512-llm15aCWBFJQbMg/Douqf+fjvMC9qrcc2AfievoAoiHD/VGQf8ouR4ss2/X1i+2r3gcwYDZlvCOarXeXnIbZ+w==
dependencies:
eslint-config-prettier "8.5.0"
eslint-config-prettier "8.8.0"
eslint-plugin-eslint-comments "3.2.0"
eslint-plugin-import "2.27.5"

Expand Down Expand Up @@ -4171,10 +4171,10 @@ escodegen@^2.0.0:
optionalDependencies:
source-map "~0.6.1"

eslint-config-prettier@8.5.0:
version "8.5.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz#5a81680ec934beca02c7b1a61cf8ca34b66feab1"
integrity sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==
eslint-config-prettier@8.8.0:
version "8.8.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz#bfda738d412adc917fd7b038857110efe98c9348"
integrity sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==

eslint-import-resolver-node@^0.3.7:
version "0.3.7"
Expand Down

1 comment on commit edee7a7

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 92.45% 245/265
🟢 Branches 83.19% 94/113
🟢 Functions 90% 63/70
🟢 Lines 92.19% 236/256

Test suite run success

328 tests passing in 16 suites.

Report generated by 🧪jest coverage report action from edee7a7

Please sign in to comment.