Skip to content

Commit

Permalink
refactor: small code simplificiations
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Dec 15, 2023
1 parent 12788a5 commit 2a425fc
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"typescript.referencesCodeLens.enabled": true,
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
Expand Down
2 changes: 1 addition & 1 deletion src/compile/data/assemble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function makeWalkTree(data: VgData[]) {
if (node.parent instanceof SourceNode && !dataSource.source) {
// If node's parent is a root source and the data source does not refer to another data source, use normal format parse
dataSource.format = {
...(dataSource.format ?? {}),
...dataSource.format,
parse: node.assembleFormatParse()
};

Expand Down
2 changes: 1 addition & 1 deletion src/compile/data/calculate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ export class CalculateNode extends DataFlowNode {
}

export function sortArrayIndexField(fieldDef: TypedFieldDef<string>, channel: SingleDefChannel, opt?: FieldRefOption) {
return vgField(fieldDef, {prefix: channel, suffix: 'sort_index', ...(opt ?? {})});
return vgField(fieldDef, {prefix: channel, suffix: 'sort_index', ...opt});
}
2 changes: 1 addition & 1 deletion src/compile/facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function facetSortFieldName(
sort: EncodingSortField<string>,
opt?: FieldRefOption
) {
return vgField(sort, {suffix: `by_${vgField(fieldDef)}`, ...(opt ?? {})});
return vgField(sort, {suffix: `by_${vgField(fieldDef)}`, ...opt});
}

export class FacetModel extends ModelWithField {
Expand Down
2 changes: 1 addition & 1 deletion src/compile/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export abstract class Model {
return {
width: this.getSizeSignalRef('width'),
height: this.getSizeSignalRef('height'),
...(encodeEntry ?? {})
...encodeEntry
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/compile/projection/assemble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function assembleProjectionForModel(model: Model): VgProjection[] {
{
name,
// translate to center by default
...{translate: {signal: '[width / 2, height / 2]'}},
translate: {signal: '[width / 2, height / 2]'},
// parameters, overwrite default translate if specified
...projection
}
Expand Down
4 changes: 2 additions & 2 deletions src/compile/projection/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ function parseUnitProjection(model: UnitModel): ProjectionComponent {
const projComp = new ProjectionComponent(
model.projectionName(true),
{
...(replaceExprRef(model.config.projection) ?? {}),
...(proj ?? {})
...replaceExprRef(model.config.projection),
...proj
},
size,
data
Expand Down
2 changes: 1 addition & 1 deletion src/compile/selection/scales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const scaleBindings: SelectionCompiler<'interval'> = {
// Nested signals need only push to top-level signals with multiview displays.
if (model.parent && !isTopLevelLayer(model)) {
for (const proj of selCmpt.scales) {
const signal: any = signals.filter(s => s.name === proj.signals.data)[0];
const signal: any = signals.find(s => s.name === proj.signals.data);
signal.push = 'outer';
delete signal.value;
delete signal.update;
Expand Down

0 comments on commit 2a425fc

Please sign in to comment.