From 055e9c52652c5e318a2058ce6d9fcc3ec4c389ec Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Thu, 13 Feb 2025 22:27:11 -0500 Subject: [PATCH] fix some lints --- package.json | 2 +- src/compile/data/lookup.ts | 2 +- src/compile/legend/parse.ts | 1 - src/compile/scale/range.ts | 4 ++-- src/compile/selection/parse.ts | 4 ++-- src/compile/selection/toggle.ts | 8 +++----- src/compile/selection/translate.ts | 8 +++----- src/compile/selection/zoom.ts | 6 ++---- src/compile/split.ts | 1 - src/config.ts | 4 ++-- src/data.ts | 4 +--- src/predicate.ts | 4 +--- src/timeunit.ts | 10 +++------- yarn.lock | 10 ---------- 14 files changed, 21 insertions(+), 47 deletions(-) diff --git a/package.json b/package.json index d40ddf8736..489b55a45a 100644 --- a/package.json +++ b/package.json @@ -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/", diff --git a/src/compile/data/lookup.ts b/src/compile/data/lookup.ts index 458fe8c2d4..797197ba3b 100644 --- a/src/compile/data/lookup.ts +++ b/src/compile/data/lookup.ts @@ -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)); } diff --git a/src/compile/legend/parse.ts b/src/compile/legend/parse.ts index d18af0833f..83376d5511 100644 --- a/src/compile/legend/parse.ts +++ b/src/compile/legend/parse.ts @@ -68,7 +68,6 @@ function getLegendDefWithScale(model: UnitModel, channel: NonPositionScaleChanne return {[channel]: scale}; } -// eslint-disable-next-line @typescript-eslint/ban-types function isExplicit( value: T, property: keyof LegendComponentProps, diff --git a/src/compile/scale/range.ts b/src/compile/scale/range.ts index ab431a7b9c..c635d1561d 100644 --- a/src/compile/scale/range.ts +++ b/src/compile/scale/range.ts @@ -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})`}]; } diff --git a/src/compile/selection/parse.ts b/src/compile/selection/parse.ts index 3a95cb79cd..3d1205cbbb 100644 --- a/src/compile/selection/parse.ts +++ b/src/compile/selection/parse.ts @@ -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}`; } @@ -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; } diff --git a/src/compile/selection/toggle.ts b/src/compile/selection/toggle.ts index 94aec6171d..c193fddd60 100644 --- a/src/compile/selection/toggle.ts +++ b/src/compile/selection/toggle.ts @@ -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`; }, }; diff --git a/src/compile/selection/translate.ts b/src/compile/selection/translate.ts index 4a3f0dd696..f6262893da 100644 --- a/src/compile/selection/translate.ts +++ b/src/compile/selection/translate.ts @@ -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})`}` : ''}}`, }, ], }, diff --git a/src/compile/selection/zoom.ts b/src/compile/selection/zoom.ts index 09da941b13..c07deeb87e 100644 --- a/src/compile/selection/zoom.ts +++ b/src/compile/selection/zoom.ts @@ -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(', ')}}`, }, ], }, diff --git a/src/compile/split.ts b/src/compile/split.ts index 117fca71f6..3e23d398f8 100644 --- a/src/compile/split.ts +++ b/src/compile/split.ts @@ -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 { constructor( public readonly explicit: Partial = {}, diff --git a/src/config.ts b/src/config.ts index cba38ce8d8..b487ec1765 100644 --- a/src/config.ts +++ b/src/config.ts @@ -735,9 +735,9 @@ export function stripAndRedirectConfig(config: Config) { // 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]; } } diff --git a/src/data.ts b/src/data.ts index 446eadd93c..34a639c205 100644 --- a/src/data.ts +++ b/src/data.ts @@ -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 { @@ -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 { diff --git a/src/predicate.ts b/src/predicate.ts index 247b345402..d405c4aaab 100644 --- a/src/predicate.ts +++ b/src/predicate.ts @@ -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 = []; diff --git a/src/timeunit.ts b/src/timeunit.ts index 2bacbaeb9f..298bf5ceaa 100644 --- a/src/timeunit.ts +++ b/src/timeunit.ts @@ -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('')}`; } } diff --git a/yarn.lock b/yarn.lock index 81025b2c08..5bf85929d1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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"