Skip to content
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 cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "jest",
"test-update": "jest -u",
"format": "prettier --write \"{lib,bin}/**/*.ts\"",
"lint": "eslint lib/** bin/** --ext .ts --no-error-on-unmatched-pattern",
"lint": "eslint lib/** bin/** --no-error-on-unmatched-pattern",
"synth": "cdk synth --path-metadata false --version-reporting false",
"diff": "cdk diff --path-metadata false --version-reporting false"
},
Expand Down
45 changes: 28 additions & 17 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,38 +1,48 @@
import guardian from '@guardian/eslint-config';
import globals from 'globals';

export default [
{
ignores: [
'node_modules',
'dist',
'server-dist',

'customize.js',
'rollup.config.js',
'webpack.*js',
'cdk',
],
},
...guardian.configs.recommended,
...guardian.configs.jest,
{
ignores: ['eslint.config.mjs'],
Copy link
Member Author

Choose a reason for hiding this comment

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

it fails to parse this file because we have sourceType: 'commonjs'

languageOptions: {
Copy link
Member Author

Choose a reason for hiding this comment

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

globals: {
...globals.jest,
...globals.browser,
...globals.node,
},
ecmaVersion: 5,
sourceType: 'commonjs',
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: './',
},
},
rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
curly: 2,
'@typescript-eslint/no-inferrable-types': [
Copy link
Member Author

Choose a reason for hiding this comment

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

this was causing an error, but I think it's no longer needed anyway

'error',
{
ignoreParameters: true,
},
],
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'after-used',
ignoreRestSiblings: true,
},
],
// '@typescript-eslint/no-unused-vars': [
Copy link
Member Author

Choose a reason for hiding this comment

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

we've temporarily added a more general "off" for this rule below

// 'error',
// {
// args: 'after-used',
// ignoreRestSiblings: true,
// },
// ],

// potentially to fix later see https://trello.com/c/lc8lG7Zj
// potentially to fix later see https://trello.com/c/lc8lG7Zj
'@typescript-eslint/naming-convention': 'off',
'@eslint-community/eslint-comments/require-description': 'off',
'@typescript-eslint/ban-types': 'off',
Expand All @@ -44,7 +54,6 @@ export default [
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
Expand All @@ -53,6 +62,8 @@ export default [
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/await-thenable': 'off',
},
},
];
];
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"build-dotcom-types": "tsc --project tsconfig.types.json",
"publish-dry-run": "pnpm publish --dry-run",
"publish": "pnpm publish",
"lint": "eslint 'src/**/*.{ts,tsx}'",
Copy link
Member Author

Choose a reason for hiding this comment

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

no need to specify the path here

"lint": "eslint .",
"test": "export stage=DEV; jest",
"riffraff": "node-riffraff-artifact"
},
Expand Down Expand Up @@ -52,6 +52,7 @@
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-react": "^7.33.2",
"fishery": "^0.3.0",
"globals": "15.14.0",
"inquirer": "^7.0.3",
"jest": "^29.7.0",
"nodemon": "^3.1.7",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/dotcom/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { getEpicViewLog, logEpicView } from '../shared/lib/viewLog';
Copy link
Member Author

Choose a reason for hiding this comment

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

we export all of shared/lib/viewLog further down

export { getWeeklyArticleHistory, incrementWeeklyArticleCount } from '../shared/lib/history';
export {
replaceNonArticleCountPlaceholders,
Expand Down
9 changes: 4 additions & 5 deletions src/dotcom/requests.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import {
import type {
BannerPayload,
BannerProps,
EpicPayload,
EpicProps,
HeaderPayload,
HeaderProps,
GutterPayload,
GutterProps,
HeaderPayload,
HeaderProps,
} from '../shared/types';

import { TestTracking } from '../shared/types/abTests/shared';
import type { TestTracking } from '../shared/types/abTests/shared';

export interface ModuleData<PROPS> {
name: string;
Expand Down
4 changes: 2 additions & 2 deletions src/server/bandit/banditSelection.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EpicTest } from '../../shared/types';
import { BanditData } from './banditData';
import type { EpicTest } from '../../shared/types';
import type { BanditData } from './banditData';
import { selectVariantWithHighestMean } from './banditSelection';

const epicTest: EpicTest = {
Expand Down
2 changes: 1 addition & 1 deletion src/server/factories/bannerDesign.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BannerDesignFromTool, HexColour } from '../../shared/types';
import { Factory } from 'fishery';
import type { BannerDesignFromTool, HexColour } from '../../shared/types';

const hexColourStringRegex = /^([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
const stringToHexColour = (colourString: string): HexColour => {
Expand Down
2 changes: 1 addition & 1 deletion src/server/factories/bannerVariant.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BannerVariant } from '../../shared/types';
import { Factory } from 'fishery';
import type { BannerVariant } from '../../shared/types';

export default Factory.define<BannerVariant>(() => ({
name: 'Example Banner Variant',
Expand Down
2 changes: 1 addition & 1 deletion src/server/factories/epicVariant.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EpicVariant } from '../../shared/types';
import { Factory } from 'fishery';
import type { EpicVariant } from '../../shared/types';

export default Factory.define<EpicVariant>(() => ({
name: 'Example Variant',
Expand Down
6 changes: 3 additions & 3 deletions src/server/factories/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { register } from 'fishery';
import bannerDesign from './bannerDesign';
import bannerVariant from './bannerVariant';
import epicVariant from './epicVariant';
import targeting from './targeting';
import test from './test';
import epicVariant from './epicVariant';
import bannerVariant from './bannerVariant';
import bannerDesign from './bannerDesign';

export const factories = register({
targeting,
Expand Down
2 changes: 1 addition & 1 deletion src/server/factories/targeting.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EpicTargeting } from '../../shared/types';
import { Factory } from 'fishery';
import type { EpicTargeting } from '../../shared/types';

export default Factory.define<EpicTargeting>(() => ({
contentType: 'Article',
Expand Down
2 changes: 1 addition & 1 deletion src/server/factories/test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EpicTest } from '../../shared/types';
import { Factory } from 'fishery';
import type { EpicTest } from '../../shared/types';

export default Factory.define<EpicTest>(({ factories }) => ({
channel: 'Epic',
Expand Down
6 changes: 3 additions & 3 deletions src/server/lib/ab.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EpicTest } from '../../shared/types';
import { selectVariantUsingMVT, withinRange, selectWithSeed, selectVariant } from './ab';
import type { EpicTest } from '../../shared/types';
import { selectVariant, selectVariantUsingMVT, selectWithSeed, withinRange } from './ab';

const test: EpicTest = {
channel: 'Epic',
Expand Down Expand Up @@ -119,7 +119,7 @@ describe('withinRange', () => {

describe('selectWithSeed', () => {
it('should evenly distribute to the variants', () => {
const variantCounts: { [key: string]: number } = {
const variantCounts: Record<string, number> = {
control: 0,
v1: 0,
};
Expand Down
2 changes: 1 addition & 1 deletion src/server/lib/history.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { ArticlesViewedSettings } from '../../shared/types';
import {
getArticleViewCountByMultipleTagForWeeks,
getArticleViewCountForWeeks,
getArticleViewCounts,
getWeeksInWindow,
historyWithinArticlesViewedSettings,
} from './history';
import { ArticlesViewedSettings } from '../../shared/types';

describe('getArticleViewCountForWeeks', () => {
// Pass the current date into the tested function so the checks can be made
Expand Down
7 changes: 4 additions & 3 deletions src/server/lib/targetingTesting.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { selectTargetingTest, TargetingTest } from './targetingTesting';
import { BannerTargeting } from '../../shared/types';
import type { BannerTargeting } from '../../shared/types';
import type { TargetingTest } from './targetingTesting';
import { selectTargetingTest } from './targetingTesting';

const bannerTargetingTests: TargetingTest<BannerTargeting>[] = [
const bannerTargetingTests: Array<TargetingTest<BannerTargeting>> = [
{
channel: 'Banner1',
name: 'BannerTargetingTest',
Expand Down
4 changes: 2 additions & 2 deletions src/server/roulette/rouletteSelection.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { EpicTest } from '../../shared/types';
import type { BanditData } from '../bandit/banditData';
import { selectVariantUsingRoulette } from './rouletteSelection';
import { EpicTest } from '../../shared/types';
import { BanditData } from '../bandit/banditData';

const epicTest: EpicTest = {
channel: 'Epic',
Expand Down
8 changes: 4 additions & 4 deletions src/server/signin-gate/lib.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
guDefaultShouldShowTheGate,
buildAuxiaProxyGetTreatmentsResponseData,
buildGetTreatmentsRequestPayload,
guGateAsAnAuxiaAPIUserTreatment,
buildLogTreatmentInteractionRequestPayload,
guDefaultGateGetTreatmentsResponseData,
guDefaultShouldShowTheGate,
guGateAsAnAuxiaAPIUserTreatment,
isValidContentType,
isValidSection,
isValidTagIdCollection,
buildAuxiaProxyGetTreatmentsResponseData,
buildLogTreatmentInteractionRequestPayload,
} from './lib';

describe('guDefaultShouldShowTheGate', () => {
Expand Down
9 changes: 5 additions & 4 deletions src/server/tests/amp/ampEpicSelection.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { TickerCountType, TickerEndType, TickerSettings } from '../../../shared/types';
import { AmpVariantAssignments } from '../../lib/ampVariantAssignments';
import { AMPEpic, AmpEpicTest } from './ampEpicModels';
import { selectAmpEpic } from './ampEpicSelection';
import type { TickerSettings } from '../../../shared/types';
import { TickerCountType, TickerEndType } from '../../../shared/types';
import type { AmpVariantAssignments } from '../../lib/ampVariantAssignments';
import { TickerDataProvider } from '../../lib/fetchTickerData';
import type { AMPEpic, AmpEpicTest } from './ampEpicModels';
import { selectAmpEpic } from './ampEpicSelection';

const tickerSettings: TickerSettings = {
endType: TickerEndType.unlimited,
Expand Down
4 changes: 2 additions & 2 deletions src/server/tests/banners/bannerSelection.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BannerTargeting, BannerTest } from '../../../shared/types';
import type { BannerTargeting, BannerTest } from '../../../shared/types';
import type { BanditData } from '../../bandit/banditData';
import { BannerDeployTimesProvider } from './bannerDeployTimes';
import { canShowBannerAgain, selectBannerTest } from './bannerSelection';
import { BanditData } from '../../bandit/banditData';

const getBannerDeployTimesReloader = (date: string) =>
new BannerDeployTimesProvider({
Expand Down
5 changes: 3 additions & 2 deletions src/server/tests/banners/channelBannerTests.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getDesignForVariant } from './channelBannerTests';
import type { BannerDesignFromTool} from '../../../shared/types';
import { BannerTemplate } from '../../../shared/types';
import { factories } from '../../factories/';
import { BannerDesignFromTool, BannerTemplate } from '../../../shared/types';
import { getDesignForVariant } from './channelBannerTests';

describe('getDesignForVariant', () => {
it('returns undefined if the variant specifies a template', () => {
Expand Down
13 changes: 7 additions & 6 deletions src/server/tests/epics/epicSelection.test.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import {
import type {
ArticlesViewedSettings,
DeviceType,
EpicTargeting,
EpicTest,
EpicVariant,
SecondaryCtaType,
UserDeviceType,
UserDeviceType} from '../../../shared/types';
import {
SecondaryCtaType
} from '../../../shared/types';
import { SuperModeArticle } from '../../lib/superMode';
import type { BanditData } from '../../bandit/banditData';
import type { SuperModeArticle } from '../../lib/superMode';
import {
correctSignedInStatusFilter,
deviceTypeMatchesFilter,
findTestAndVariant,
getUserCohorts,
hasCountryCode,
inCorrectCohort,
isNotExpired,
isCountryTargetedForEpic,
isNotExpired,
withinArticleViewedSettings,
withinMaxViews,
} from './epicSelection';
import { BanditData } from '../../bandit/banditData';

const variantDefault: EpicVariant = {
name: 'control-example-1',
Expand Down
2 changes: 1 addition & 1 deletion src/server/tests/epics/epicTests.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EpicVariant } from '../../../shared/types';
import type { EpicVariant } from '../../../shared/types';
import { variantHasArticleCountCopy } from './epicTests';

const baseVariant: EpicVariant = {
Expand Down
2 changes: 1 addition & 1 deletion src/server/tests/epics/momentumTest.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EpicTargeting, EpicTest } from '../../../shared/types';
import type { EpicTargeting, EpicTest } from '../../../shared/types';
import {
getCategoriesForThreeMonths,
getThreeMonthsHistory,
Expand Down
2 changes: 1 addition & 1 deletion src/server/tests/gutters/gutterSelection.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
GutterTargeting,
GutterTest,
GutterTestSelection,
Expand Down
2 changes: 1 addition & 1 deletion src/server/tests/headers/headerSelection.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
HeaderTargeting,
HeaderTest,
HeaderTestSelection,
Expand Down
1 change: 1 addition & 0 deletions src/server/utils/removeNullValues.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { removeNullValues } from './removeNullValues';

const test = {
falsyObjects: {
undefinedField: undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/server/utils/withNowAs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// tests include async code so really it is not very robust.
export const withNowAs = <T>(now: Date, fn: () => T): T => {
const old = Date.now;
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
Date.now = () => now.valueOf(); // override
const got = fn();
Date.now = old;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/lib/geolocation.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getCountryName, getLocalCurrencySymbol, addRegionIdToSupportUrl } from './geolocation';
import { addRegionIdToSupportUrl, getCountryName, getLocalCurrencySymbol } from './geolocation';

describe('getLocalCurrencySymbol', () => {
const currencySymbolTests = [
Expand Down
2 changes: 1 addition & 1 deletion src/shared/lib/placeholders.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Prices } from '../types';
import {
containsNonArticleCountPlaceholder,
getDate,
getDayOfWeek,
replaceNonArticleCountPlaceholders,
} from './placeholders';
import { Prices } from '../types';

describe('containsNonArticleCountPlaceholder', () => {
it('returns true if string contains placeholder (that is not %%ARTICLE_COUNT%%)', () => {
Expand Down
Loading