Skip to content

Commit

Permalink
Merge pull request #2774 from owid/prettier-3
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelgerber authored Oct 16, 2023
2 parents aa99a02 + 980eb9a commit b8025f3
Show file tree
Hide file tree
Showing 47 changed files with 160 additions and 107 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,8 @@ The following is an excerpt explaining the origin of this repo and what the alte
> Using our own system has very important advantages:
>
> - **Integration with our global development database**: Our database of global development metrics is integrated into our visualization tool so that when we add and update empirical data the visualizations are all updated. (In contrast to this, a pre-existing tool would make the exploration of a database impossible and would require the preparation of each dataset separately for each visualisation.)
>
> - **Flexibility**: We can use automation to change our entire system all at once. For example, if we decide we want to use a different source referencing style, we could easily update this across hundreds of charts. This makes it possible to scale our publication and to sustainably improve our work without starting from scratch at each round.
>
> - **Risk mitigation**: We hope(!) that Our World in Data is a long-term project and we want the visualizations we produce to continue to be useful and available years from now. An external web service may be shut down or change for reasons we cannot control. We have had this experience in the past and learned our lesson from it.
>
> - **Keeping everything up-to-date**: Because we want to be a useful resource for some time we make sure that we have a technology in place that allows us to keep all of our work up-to-date without starting from scratch each time. We have our global development database directly integrated in the Grapher and as soon as new data becomes available (for example from a UN agency) we can run a script that pulls in that data and updates all the visualizations that present that data.
---
Expand Down
6 changes: 3 additions & 3 deletions adminSiteClient/Forms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ export class BindString extends React.Component<{
@observer
export class BindAutoString<
T extends { [field: string]: any },
K extends Extract<keyof T, string>
K extends Extract<keyof T, string>,
> extends React.Component<{
field: K
store: T
Expand Down Expand Up @@ -843,7 +843,7 @@ class FloatField extends React.Component<FloatFieldProps> {
@observer
export class BindFloat<
T extends { [field: string]: any },
K extends Extract<keyof T, string>
K extends Extract<keyof T, string>,
> extends React.Component<{
field: K
store: T
Expand Down Expand Up @@ -874,7 +874,7 @@ export class BindFloat<
@observer
export class BindAutoFloat<
T extends { [field: string]: any },
K extends Extract<keyof T, string>
K extends Extract<keyof T, string>,
> extends React.Component<{
field: K
store: T
Expand Down
19 changes: 14 additions & 5 deletions adminSiteClient/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,9 @@ main:not(.ChartEditorPage):not(.GdocsEditPage) {

// to override the default annoying blue border from bootstrap on file upload
.custom-file-input:focus ~ .custom-file-control {
box-shadow: 0 0 0 0.075rem #fff, 0 0 0 0.2rem #fff;
box-shadow:
0 0 0 0.075rem #fff,
0 0 0 0.2rem #fff;
}

.TagsIndexPage {
Expand Down Expand Up @@ -1174,7 +1176,9 @@ main:not(.ChartEditorPage):not(.GdocsEditPage) {
padding: 1.2em;
border-radius: 0.4em;
margin: 0.4em 0;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
box-shadow:
0 1px 3px rgba(0, 0, 0, 0.12),
0 1px 2px rgba(0, 0, 0, 0.24);
}
.import-form {
input {
Expand Down Expand Up @@ -1210,7 +1214,9 @@ main:not(.ChartEditorPage):not(.GdocsEditPage) {
border-radius: 0.4rem;
opacity: 0.87;
color: #fff;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
box-shadow:
0 1px 3px rgba(0, 0, 0, 0.12),
0 1px 2px rgba(0, 0, 0, 0.24);
}

.message.bg-warning {
Expand All @@ -1224,7 +1230,9 @@ main:not(.ChartEditorPage):not(.GdocsEditPage) {
padding: 1.2em;
border-radius: 0.4em;
margin: 0.4em 0;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
box-shadow:
0 1px 3px rgba(0, 0, 0, 0.12),
0 1px 2px rgba(0, 0, 0, 0.24);
}
}

Expand Down Expand Up @@ -1272,7 +1280,8 @@ main:not(.ChartEditorPage):not(.GdocsEditPage) {
position: sticky;
top: 0;
z-index: 2;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 3px,
box-shadow:
rgba(0, 0, 0, 0.12) 0px 1px 3px,
rgba(0, 0, 0, 0.24) 0px 1px 2px;
background: #fff;
&.draft {
Expand Down
3 changes: 2 additions & 1 deletion adminSiteClient/styles/react-tag-autocomplete.scss
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@
background: #ffffff;
border: 1px solid #afb8c1;
border-radius: 6px;
box-shadow: rgba(0, 0, 0, 0.1) 0 10px 15px -4px,
box-shadow:
rgba(0, 0, 0, 0.1) 0 10px 15px -4px,
rgba(0, 0, 0, 0.05) 0 4px 6px -2px;
}

Expand Down
4 changes: 2 additions & 2 deletions adminSiteServer/IndexPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export const IndexPage = (props: {
window.admin = new Admin({ username: "${
props.username
}", isSuperuser: ${props.isSuperuser.toString()}, settings: ${JSON.stringify(
{ ENV, GITHUB_USERNAME, DATA_API_FOR_ADMIN_UI }
)}})
{ ENV, GITHUB_USERNAME, DATA_API_FOR_ADMIN_UI }
)}})
admin.start(document.querySelector("#app"), '${props.gitCmsBranchName}')
`

Expand Down
5 changes: 2 additions & 3 deletions adminSiteServer/apiRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1728,9 +1728,8 @@ apiRouter.get(

await Chart.assignTagsForCharts(charts)

const grapherConfig = await getMergedGrapherConfigForVariable(
variableId
)
const grapherConfig =
await getMergedGrapherConfigForVariable(variableId)
if (
grapherConfig &&
(!grapherConfig.dimensions || grapherConfig.dimensions.length === 0)
Expand Down
5 changes: 2 additions & 3 deletions baker/GrapherBaker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,8 @@ export async function renderDataPageV2({
pageGrapher?: GrapherInterface
publishedExplorersBySlug?: Record<string, ExplorerProgram>
}) {
const grapherConfigForVariable = await getMergedGrapherConfigForVariable(
variableId
)
const grapherConfigForVariable =
await getMergedGrapherConfigForVariable(variableId)
const grapher = mergePartialGrapherConfigs(
grapherConfigForVariable,
pageGrapher
Expand Down
5 changes: 2 additions & 3 deletions baker/formatWordpressPost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,8 @@ export const formatWordpressPost = async (
}
})

const dataValuesConfigurationsMap = await extractDataValuesConfiguration(
html
)
const dataValuesConfigurationsMap =
await extractDataValuesConfiguration(html)
const dataValues = new Map<string, DataValueProps>()
for (const [
dataValueConfigurationString,
Expand Down
2 changes: 1 addition & 1 deletion baker/formatting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const parseKeyValueArgs = (text: string): KeyValueProps => {
const [, name, value] = option.match(optionRegex) as [
any,
string,
string
string,
]
let parsedValue
if (value === "" || value === "true") parsedValue = true
Expand Down
11 changes: 6 additions & 5 deletions db/model/Gdoc/rawToEnriched.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1295,11 +1295,12 @@ export function parseFaqs(
id: faq.id,
content: enrichedText,
parseErrors: compact([
...enrichedText.flatMap((block) =>
block?.parseErrors.map((parseError) => ({
...parseError,
message: `Block parse error in faq with id "${faq.id}": ${parseError.message}`,
}))
...enrichedText.flatMap(
(block) =>
block?.parseErrors.map((parseError) => ({
...parseError,
message: `Block parse error in faq with id "${faq.id}": ${parseError.message}`,
}))
),
]),
}
Expand Down
16 changes: 9 additions & 7 deletions devTools/regionsUpdater/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface Entity {
members?: string[]
}

function prettifiedJson(obj: any) {
function prettifiedJson(obj: any): Promise<string> {
// make sure the json we emit is diff-able even after running prettier on the repo
return prettier.format(JSON.stringify(obj), {
parser: "json",
Expand All @@ -70,7 +70,7 @@ function csvToJson(val: string, col: string) {
}
}

function prettifiedTopology(geoJson: FeatureCollection) {
function prettifiedTopology(geoJson: FeatureCollection): Promise<string> {
// make sure the MapTopology.ts file will be diff-able even after running prettier on the repo
let topoData = topology({ world: geoJson }),
arcs = _.remove(topoData.arcs),
Expand All @@ -95,9 +95,11 @@ function prettifiedTopology(geoJson: FeatureCollection) {
tabWidth: 4,
semi: false,
})
.replace(
/^( arcs:\s*\[)\]/m,
`\n // prettier-ignore\n$1\n ${arcJson}\n ]`
.then((formatted) =>
formatted.replace(
/^( arcs:\s*\[)\]/m,
`\n // prettier-ignore\n$1\n ${arcJson}\n ]`
)
)
}

Expand Down Expand Up @@ -258,13 +260,13 @@ async function main() {
})

// generate new MapTopology.ts file and compare to old version
let newTopology = prettifiedTopology(owidGeoJson)
let newTopology = await prettifiedTopology(owidGeoJson)
if (await didChange(GRAPHER_TOPOLOGY_PATH, newTopology)) {
await writeFile(GRAPHER_TOPOLOGY_PATH, newTopology)
}

// generate new regions.json file and compare to old version
let regionsJson = prettifiedJson(entities)
let regionsJson = await prettifiedJson(entities)
if (await didChange(GRAPHER_REGIONS_PATH, regionsJson)) {
await writeFile(GRAPHER_REGIONS_PATH, regionsJson)
let diff = execFileSync("git", [
Expand Down
8 changes: 4 additions & 4 deletions devTools/svgTester/diff-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ async function main(parsedArgs: parseArgs.ParsedArgs) {
<div class="chart-id">${id}</div>
<div class="side-by-side">
<img src="${referenceDir}/${
referenceCsv.get(id)!.svgFilename
}"/>
referenceCsv.get(id)!.svgFilename
}"/>
<img src="${outDir}/${
referenceCsv.get(id)!.svgFilename
}"/>
referenceCsv.get(id)!.svgFilename
}"/>
</div>
</div>
`)
Expand Down
2 changes: 1 addition & 1 deletion devTools/svgTester/diff-template.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<title>SVG Comparison page</title>
Expand Down
5 changes: 2 additions & 3 deletions devTools/svgTester/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,8 @@ export async function loadGrapherConfigAndData(
return { data, metadata }
})

const data: OwidVariableDataMetadataDimensions[] = await Promise.all(
loadDataPromises
)
const data: OwidVariableDataMetadataDimensions[] =
await Promise.all(loadDataPromises)

const variableData = new Map(data.map((d) => [d.metadata.id, d]))

Expand Down
5 changes: 2 additions & 3 deletions devTools/svgTester/verify-graphs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ async function main(parsedArgs: parseArgs.ParsedArgs) {
rawGrapherIds,
inDir
)
const csvContentMap = await utils.getReferenceCsvContentMap(
referenceDir
)
const csvContentMap =
await utils.getReferenceCsvContentMap(referenceDir)

const verifyJobs = directoriesToProcess.map((dir) => ({
dir,
Expand Down
2 changes: 1 addition & 1 deletion explorerAdminClient/ExplorerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class SelectAllHitsCommand extends HotCommand {
number,
number,
number,
number
number,
]
)
)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"p-map": "^4.0.0",
"papaparse": "^5.3.1",
"parsimmon": "^1.18.1",
"prettier": "^2.8.7",
"prettier": "^3.0.3",
"progress": "^2.0.3",
"prompts": "^2.4.0",
"prop-types": "^15.7.2",
Expand Down Expand Up @@ -228,7 +228,6 @@
"@types/jest": "^29.5.5",
"@types/js-yaml": "^4.0.5",
"@types/opener": "^1.4.0",
"@types/prettier": "^2.7.3",
"@types/topojson-server": "^3.0.1",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
Expand All @@ -255,6 +254,7 @@
"react-codemirror2@^7.2.1": "patch:react-codemirror2@npm%3A7.2.1#./.yarn/patches/react-codemirror2-npm-7.2.1-dcadbb9383.patch"
},
"prettier": {
"trailingComma": "es5",
"semi": false
},
"browserslist": [
Expand Down
2 changes: 1 addition & 1 deletion packages/@ourworldindata/core-table/src/CoreTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ interface AdvancedOptions {
// narrow interface for the input rows. This is helpful for OwidTable.
export class CoreTable<
ROW_TYPE extends CoreRow = CoreRow,
COL_DEF_TYPE extends CoreColumnDef = CoreColumnDef
COL_DEF_TYPE extends CoreColumnDef = CoreColumnDef,
> {
private _columns: Map<ColumnSlug, CoreColumn> = new Map()
protected parent?: this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ class BooleanColumn extends AbstractCoreColumn<boolean> {
}

abstract class AbstractColumnWithNumberFormatting<
T extends PrimitiveType
T extends PrimitiveType,
> extends AbstractCoreColumn<T> {
jsType = JsTypes.number

Expand Down
2 changes: 1 addition & 1 deletion packages/@ourworldindata/core-table/src/CoreTableUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export function toleranceInterpolation(
export function interpolateRowValuesWithTolerance<
ValueSlug extends ColumnSlug,
TimeSlug extends ColumnSlug,
Row extends { [key in TimeSlug]?: Time } & { [key in ValueSlug]?: any }
Row extends { [key in TimeSlug]?: Time } & { [key in ValueSlug]?: any },
>(
rowsSortedByTimeAsc: Row[],
valueSlug: ValueSlug,
Expand Down
2 changes: 1 addition & 1 deletion packages/@ourworldindata/grapher/src/color/ColorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function getLeastUsedColor(
)
const mostUnusedColor = minBy(colorCounts, ([, count]) => count) as [
string,
number
number,
]
return mostUnusedColor[0]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ $linkColor: #0645ad;
opacity: 0.95;
padding: 14px;
border-radius: 2px;
box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 2px 0px,
box-shadow:
rgba(0, 0, 0, 0.1) 0px 0px 2px 0px,
rgba(0, 0, 0, 0.25) 0px 2px 2px 0px;

.paletteTitle {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$chart-border-radius: 2px;
// Match chart styles
$chart-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 2px 0px,
$chart-box-shadow:
rgba(0, 0, 0, 0.1) 0px 0px 2px 0px,
rgba(0, 0, 0, 0.25) 0px 2px 2px 0px;
$zindex-dropdown: 100;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
padding: 0.65em;
border-radius: 8px;
background-color: #fff;
box-shadow: 0 15px 40px rgba(0, 0, 0, 0.1), 0 8px 15px rgba(0, 0, 0, 0.08),
box-shadow:
0 15px 40px rgba(0, 0, 0, 0.1),
0 8px 15px rgba(0, 0, 0, 0.08),
0 1px 3px 1px rgba(0, 0, 0, 0.08);

display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ const fullJoinTables = (
// not exist in the first table
const firstTableDuplicateForIndices: [
OwidTable | undefined,
string[] | undefined
string[] | undefined,
] = [tables[0], sharedColumnNames]
const defsToAddPerTable = [firstTableDuplicateForIndices]
.concat(zip(tables, columnsToAddPerTable))
Expand Down
3 changes: 2 additions & 1 deletion packages/@ourworldindata/grapher/src/core/grapher.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ $blue-90: #1d3d63;
$controls-color: #0073e6;
$gray-10: #f7f7f7;
$gray-10: #fafbfd;
$light-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 1px,
$light-shadow:
rgba(0, 0, 0, 0.1) 0px 0px 0px 1px,
rgba(0, 0, 0, 0.08) 0px 2px 2px;
$oxford-blue: #002147;
$text-color: #1d3d63;
Expand Down
Loading

0 comments on commit b8025f3

Please sign in to comment.