Skip to content

Commit

Permalink
fix some lints
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Feb 14, 2025
1 parent d2845ef commit 055e9c5
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 47 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"site": "yarn site:only",
"site:only": "pushd site && bundle exec jekyll serve -I -l && popd",
"format": "eslint --fix && prettier . --write",
"lint": "eslint && prettier . --check",
"lint": "eslint --quiet && prettier . --check",
"jest": "node --experimental-vm-modules ./node_modules/.bin/jest",
"test": "yarn jest test/ && yarn lint && yarn schema && yarn jest examples/ && yarn test:runtime",
"test:cover": "yarn jest --collectCoverage test/",
Expand Down
2 changes: 1 addition & 1 deletion src/compile/data/lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class LookupNode extends DataFlowNode {

try {
selCmpt = model.getSelectionComponent(varName(selName), selName);
} catch (e) {
} catch {
throw new Error(log.message.cannotLookupVariableParameter(selName));
}

Expand Down
1 change: 0 additions & 1 deletion src/compile/legend/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ function getLegendDefWithScale(model: UnitModel, channel: NonPositionScaleChanne
return {[channel]: scale};
}

// eslint-disable-next-line @typescript-eslint/ban-types
function isExplicit<T extends string | number | object | boolean>(
value: T,
property: keyof LegendComponentProps,
Expand Down
4 changes: 2 additions & 2 deletions src/compile/scale/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,10 @@ function getOffsetRange(channel: string, model: UnitModel, offsetScaleType: Scal
const bandPositionOffsetExpr = bandPositionOffset !== 0 ? ` + ${bandPositionOffset}` : '';
if (padding) {
const startRatio = isSignalRef(padding)
? `${padding.signal}/2` + bandPositionOffsetExpr
? `${padding.signal}/2${bandPositionOffsetExpr}`
: `${padding / 2 + bandPositionOffset}`;
const endRatio = isSignalRef(padding)
? `(1 - ${padding.signal}/2)` + bandPositionOffsetExpr
? `(1 - ${padding.signal}/2)${bandPositionOffsetExpr}`
: `${1 - padding / 2 + bandPositionOffset}`;
return [{signal: `${startRatio} * (${duration})`}, {signal: `${endRatio} * (${duration})`}];
}
Expand Down
4 changes: 2 additions & 2 deletions src/compile/selection/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function parseSelectionPredicate(

try {
selCmpt = model.getSelectionComponent(vname, name);
} catch (e) {
} catch {
// If a selection isn't found, treat as a variable parameter and coerce to boolean.
return `!!${vname}`;
}
Expand Down Expand Up @@ -128,7 +128,7 @@ export function parseSelectionExtent(model: Model, name: string, extent: Paramet

try {
selCmpt = model.getSelectionComponent(vname, name);
} catch (e) {
} catch {
// If a selection isn't found, treat it as a variable parameter.
return vname;
}
Expand Down
8 changes: 3 additions & 5 deletions src/compile/selection/toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ const toggle: SelectionCompiler<'point'> = {
const tpl = selCmpt.name + TUPLE;
const signal = selCmpt.name + TOGGLE;

return (
`${signal} ? null : ${tpl}, ` +
(selCmpt.resolve === 'global' ? `${signal} ? null : true, ` : `${signal} ? null : {unit: ${unitName(model)}}, `) +
`${signal} ? ${tpl} : null`
);
return `${signal} ? null : ${tpl}, ${
selCmpt.resolve === 'global' ? `${signal} ? null : true, ` : `${signal} ? null : {unit: ${unitName(model)}}, `
}${signal} ? ${tpl} : null`;
},
};

Expand Down
8 changes: 3 additions & 5 deletions src/compile/selection/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ const translate: SelectionCompiler<'interval'> = {
on: [
{
events: events.map((e) => e.between[0]),
update:
'{x: x(unit), y: y(unit)' +
(x !== undefined ? `, extent_x: ${boundScales ? domain(model, X) : `slice(${x.signals.visual})`}` : '') +
(y !== undefined ? `, extent_y: ${boundScales ? domain(model, Y) : `slice(${y.signals.visual})`}` : '') +
'}',
update: `{x: x(unit), y: y(unit)${
x !== undefined ? `, extent_x: ${boundScales ? domain(model, X) : `slice(${x.signals.visual})`}` : ''
}${y !== undefined ? `, extent_y: ${boundScales ? domain(model, Y) : `slice(${y.signals.visual})`}` : ''}}`,
},
],
},
Expand Down
6 changes: 2 additions & 4 deletions src/compile/selection/zoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ const zoom: SelectionCompiler<'interval'> = {
events,
update: !boundScales
? `{x: x(unit), y: y(unit)}`
: '{' +
[sx ? `x: invert(${sx}, x(unit))` : '', sy ? `y: invert(${sy}, y(unit))` : '']
: `{${[sx ? `x: invert(${sx}, x(unit))` : '', sy ? `y: invert(${sy}, y(unit))` : '']
.filter((expr) => expr)
.join(', ') +
'}',
.join(', ')}}`,
},
],
},
Expand Down
1 change: 0 additions & 1 deletion src/compile/split.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {deepEqual, duplicate, getFirstDefined, keys} from '../util.js';
* This is important for scale/axis/legend merging as
* we want to prioritize properties that users explicitly specified.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
export class Split<T extends object> {
constructor(
public readonly explicit: Partial<T> = {},
Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,9 @@ export function stripAndRedirectConfig(config: Config<SignalRef>) {

// Remove empty config objects.
for (const prop in config) {
// @ts-ignore
// @ts-expect-error(TS7053)
if (isObject(config[prop]) && isEmpty(config[prop])) {
// @ts-ignore
// @ts-expect-error(TS7053)
delete config[prop];
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export type DataSource = UrlData | InlineData | NamedData;

export type Data = DataSource | Generator;

// eslint-disable-next-line @typescript-eslint/ban-types
export type InlineDataset = number[] | string[] | boolean[] | object[] | string | object;

export interface DataBase {
Expand Down Expand Up @@ -209,8 +208,7 @@ export interface SphereGenerator extends GeneratorBase {
/**
* Generate sphere GeoJSON data for the full globe.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
sphere: true | {};
sphere: true;
}

export interface GraticuleGenerator extends GeneratorBase {
Expand Down
4 changes: 1 addition & 3 deletions src/predicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,7 @@ export function fieldFilterExpression(predicate: FieldPredicate, useInRange = tr
const upper = isSignalRef(range) ? {signal: `${range.signal}[1]`} : range[1];

if (lower !== null && upper !== null && useInRange) {
return (
'inrange(' + fieldExpr + ', [' + predicateValueExpr(lower, unit) + ', ' + predicateValueExpr(upper, unit) + '])'
);
return `inrange(${fieldExpr}, [${predicateValueExpr(lower, unit)}, ${predicateValueExpr(upper, unit)}])`;
}

const exprs = [];
Expand Down
10 changes: 3 additions & 7 deletions src/timeunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,9 @@ export function timeUnitToString(tu: TimeUnit | TimeUnitTransformParams) {
);
} else {
// when maxbins is specified instead of units
return (
(utc ? 'utc' : '') +
'timeunit' +
keys(rest)
.map((p) => varName(`_${p}_${rest[p]}`))
.join('')
);
return `${utc ? 'utc' : ''}timeunit${keys(rest)
.map((p) => varName(`_${p}_${rest[p]}`))
.join('')}`;
}
}

Expand Down
10 changes: 0 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3673,11 +3673,6 @@ dot-prop@^9.0.0:
dependencies:
type-fest "^4.18.2"

dotenv@^16.4.7:
version "16.4.7"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.7.tgz#0e20c5b82950140aa99be360a8a5f52335f53c26"
integrity sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==

duplexer@^0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6"
Expand Down Expand Up @@ -5889,11 +5884,6 @@ mkdirp@^1.0.3:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==

mkdirp@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-3.0.1.tgz#e44e4c5607fb279c168241713cc6e0fea9adcb50"
integrity sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==

mrmime@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/mrmime/-/mrmime-2.0.0.tgz#151082a6e06e59a9a39b46b3e14d5cfe92b3abb4"
Expand Down

0 comments on commit 055e9c5

Please sign in to comment.