Skip to content

Commit

Permalink
🐝 no-constant-binary-expression eslint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed May 26, 2024
1 parent 3bc1a35 commit 79ba85b
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module.exports = {
"react/no-unescaped-entities": ["warn", { forbid: [">", "}"] }],
"react/prop-types": "warn",
"@typescript-eslint/no-floating-promises": "error",
"no-constant-binary-expression": "error"
},
settings: {
"import/resolver": {
Expand Down
2 changes: 1 addition & 1 deletion adminSiteClient/GrapherConfigGridEditorTypesAndUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export function fetchVariablesParametersFromQueryString(
offset: Number.parseInt(params.offset ?? "0"),
filterQuery: filterQuery ?? filterExpressionNoFilter,
sortByColumn: params.sortByColumn ?? "id",
sortByAscending: params.sortByAscending === "true" ?? false,
sortByAscending: params.sortByAscending === "true",
}
}

Expand Down
2 changes: 1 addition & 1 deletion adminSiteClient/SuggestedChartRevisionApproverPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export class SuggestedChartRevisionApproverPage extends React.Component<{
this.currentSuggestedChartRevision.suggestedConfig.subtitle =
subtitle
this.gptNumDisp = this.gptNum + 1
this.gptNum = this.gptNumDisp % suggestions?.length ?? 1
this.gptNum = this.gptNumDisp % suggestions?.length || 1
this.usingGPT = true
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/@ourworldindata/grapher/src/controls/ShareMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class ShareMenu extends React.Component<ShareMenuProps, ShareMenuState> {
title="Tweet a link"
data-track-note="chart_share_twitter"
href={twitterHref}
rel="noopener"
rel="noreferrer noopener"
>
<span className="icon">
<FontAwesomeIcon icon={faXTwitter} />
Expand All @@ -215,7 +215,7 @@ export class ShareMenu extends React.Component<ShareMenuProps, ShareMenuState> {
title="Share on Facebook"
data-track-note="chart_share_facebook"
href={facebookHref}
rel="noopener"
rel="noreferrer noopener"
>
<span className="icon">
<FontAwesomeIcon icon={faFacebook} />
Expand Down Expand Up @@ -262,7 +262,7 @@ export class ShareMenu extends React.Component<ShareMenuProps, ShareMenuState> {
target="_blank"
title="Edit chart"
href={editUrl}
rel="noopener"
rel="noreferrer noopener"
>
<span className="icon">
<FontAwesomeIcon icon={faEdit} />
Expand Down
4 changes: 2 additions & 2 deletions packages/@ourworldindata/grapher/src/core/Grapher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -816,12 +816,12 @@ export class Grapher
}

private get isStaging(): boolean {
if (typeof location === undefined) return false
if (typeof location === "undefined") return false
return location.host.includes("staging")
}

private get isLocalhost(): boolean {
if (typeof location === undefined) return false
if (typeof location === "undefined") return false
return location.host.includes("localhost")
}

Expand Down
2 changes: 1 addition & 1 deletion settings/clientSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const GOOGLE_TAG_MANAGER_ID: string =
process.env.GOOGLE_TAG_MANAGER_ID ?? ""

export const TOPICS_CONTENT_GRAPH: boolean =
process.env.TOPICS_CONTENT_GRAPH === "true" ?? false
process.env.TOPICS_CONTENT_GRAPH === "true"

export const GDOCS_CLIENT_EMAIL: string = process.env.GDOCS_CLIENT_EMAIL ?? ""
export const GDOCS_BASIC_ARTICLE_TEMPLATE_URL: string =
Expand Down
10 changes: 4 additions & 6 deletions settings/serverSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ export const DATA_API_FOR_ADMIN_UI: string | undefined =
serverSettings.DATA_API_FOR_ADMIN_UI
export const BAKED_BASE_URL: string = clientSettings.BAKED_BASE_URL

export const VITE_PREVIEW: boolean =
serverSettings.VITE_PREVIEW === "true" ?? false
export const VITE_PREVIEW: boolean = serverSettings.VITE_PREVIEW === "true"

export const ADMIN_BASE_URL: string = clientSettings.ADMIN_BASE_URL

export const BAKED_GRAPHER_URL: string =
serverSettings.BAKED_GRAPHER_URL ?? `${BAKED_BASE_URL}/grapher`

export const OPTIMIZE_SVG_EXPORTS: boolean =
serverSettings.OPTIMIZE_SVG_EXPORTS === "true" ?? false
serverSettings.OPTIMIZE_SVG_EXPORTS === "true"

export const GITHUB_USERNAME: string =
serverSettings.GITHUB_USERNAME ?? "owid-test"
Expand Down Expand Up @@ -85,7 +84,7 @@ export const SESSION_COOKIE_AGE: number =
export const ALGOLIA_SECRET_KEY: string =
serverSettings.ALGOLIA_SECRET_KEY ?? ""
export const ALGOLIA_INDEXING: boolean =
serverSettings.ALGOLIA_INDEXING === "true" ?? false
serverSettings.ALGOLIA_INDEXING === "true"

// Wordpress target setting
export const HTTPS_ONLY: boolean = serverSettings.HTTPS_ONLY !== "false" ?? true

Check failure on line 90 in settings/serverSettings.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected constant nullishness on the left-hand side of a `??` expression

Check failure on line 90 in settings/serverSettings.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected constant nullishness on the left-hand side of a `??` expression
Expand All @@ -97,8 +96,7 @@ export const UNCATEGORIZED_TAG_ID: number =
parseIntOrUndefined(serverSettings.UNCATEGORIZED_TAG_ID) ?? 375

// Should the static site output be baked when relevant database items change
export const BAKE_ON_CHANGE: boolean =
serverSettings.BAKE_ON_CHANGE === "true" ?? false
export const BAKE_ON_CHANGE: boolean = serverSettings.BAKE_ON_CHANGE === "true"
export const DEPLOY_QUEUE_FILE_PATH: string =
serverSettings.DEPLOY_QUEUE_FILE_PATH ?? `${BASE_DIR}/.queue`
export const DEPLOY_PENDING_FILE_PATH: string =
Expand Down

0 comments on commit 79ba85b

Please sign in to comment.