Skip to content

Commit ad9efb5

Browse files
sookburtsookburt
andauthored
Fix lint no unnecessary conditions in requests.ts (#1388)
* add prune-suppression script * remove unnecessary condition --------- Co-authored-by: sookburt <“sue.burt@guardian.co.uk”>
1 parent f71a9b1 commit ad9efb5

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

eslint-suppressions.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
{
2-
"src/dotcom/requests.ts": {
3-
"@typescript-eslint/no-unnecessary-condition": {
4-
"count": 1
5-
}
6-
},
72
"src/server/api/ampEpicRouter.ts": {
83
"@typescript-eslint/no-unsafe-assignment": {
94
"count": 3

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"publish-dry-run": "pnpm publish --dry-run",
2323
"publish": "pnpm publish",
2424
"lint": "eslint .",
25+
"prune-lint-suppressions": "pnpm lint --prune-suppressions",
2526
"prettier:check": "prettier --check ./src",
2627
"prettier:fix": "prettier --write ./src",
2728
"test": "export stage=DEV; jest",

src/dotcom/requests.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { URLSearchParams } from 'url';
12
import type {
23
BannerPayload,
34
BannerProps,
@@ -25,15 +26,8 @@ export interface ModuleDataResponse<PROPS> {
2526
type ModuleType = 'epic' | 'liveblog-epic' | 'banner' | 'header' | 'gutter-liveblog';
2627

2728
const getForcedVariant = (type: ModuleType): string | null => {
28-
if (URLSearchParams) {
29-
const params = new URLSearchParams(window.location.search);
30-
const value = params.get(`force-${type}`);
31-
if (value) {
32-
return value;
33-
}
34-
}
35-
36-
return null;
29+
const params = new URLSearchParams(window.location.search);
30+
return params.get(`force-${type}`);
3731
};
3832

3933
type Payload = EpicPayload | BannerPayload | HeaderPayload | GutterPayload;

0 commit comments

Comments
 (0)