Skip to content

Commit

Permalink
Bump nopt to v5 + eslint rules cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
piwysocki authored and adrianmroz-allegro committed Nov 30, 2022
1 parent 3a31cdb commit 8c55a84
Show file tree
Hide file tree
Showing 15 changed files with 561 additions and 2,230 deletions.
2,750 changes: 542 additions & 2,208 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"lz-string": "1.4.4",
"moment-timezone": "0.5.27",
"node-spawn-server": "1.0.1",
"nopt": "4.0.1",
"nopt": "5.0.0",
"numbro": "2.3.6",
"plywood": "0.21.2",
"plywood-base-api": "0.2.8",
Expand Down Expand Up @@ -135,7 +135,6 @@
"@types/moment-timezone": "0.5.12",
"@types/nock": "9.1.3",
"@types/node": "14.0.4",
"@types/nopt": "3.0.29",
"@types/randomstring": "1.1.6",
"@types/react": "16.14.24",
"@types/react-copy-to-clipboard": "4.3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/grid-lines/grid-lines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import "./grid-lines.scss";
export interface GridLinesProps {
orientation: "horizontal" | "vertical";
stage: Stage;
ticks: Array<unknown>;
ticks: unknown[];
scale: Unary<unknown, number>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import { Binary } from "../../../common/utils/functional/functional";
import { StringValue } from "./string-value";
import "./string-values-list.scss";

function filterRows(rows: Array<unknown>, searchText: string): Array<unknown> {
function filterRows(rows: unknown[], searchText: string): unknown[] {
if (!searchText) return rows;
const searchTextLower = searchText.toLowerCase();
return rows.filter(d => String(d).toLowerCase().indexOf(searchTextLower) !== -1);
}

function prependPromotedValues(rows: Array<unknown>, promoted: Set<unknown>): Array<unknown> {
function prependPromotedValues(rows: unknown[], promoted: Set<unknown>): unknown[] {
return [
...promoted,
...rows.filter(value => !promoted.contains(value))
Expand All @@ -48,7 +48,7 @@ interface RowsListProps {

export const StringValuesList: React.FunctionComponent<RowsListProps> = props => {
const { onRowSelect, filterMode, dataset, dimension, searchText, promotedValues, selectedValues } = props;
const rowValues: Array<unknown> = dataset.data.map(d => d[dimension.name]);
const rowValues: unknown[] = dataset.data.map(d => d[dimension.name]);
const values = prependPromotedValues(rowValues, promotedValues);
const matchingValues = filterRows(values, searchText);
if (searchText && matchingValues.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/utils/dom/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function isInside(child: Element, parent: Element | Text): boolean {
export function findParentWithClass(child: Element, className: string): Element {
while (child) {
if (child.classList.contains(className)) return child;
child = <Element> child.parentNode;
child = (child.parentNode as Element);
}
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/utils/test-utils/get-caller-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

function getStack(): any[] {
const ErrorConstructor = <any> Error;
const ErrorConstructor = Error as any;

const origPrepareStackTrace = ErrorConstructor.prepareStackTrace;

Expand Down
6 changes: 3 additions & 3 deletions src/client/utils/test-utils/jsdom-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
import * as jsdom from "jsdom";

const kickstart = () => {
const g: any = <any> global;
const g: any = global as any;
const document = jsdom.jsdom("<!doctype html><html><body></body></html>");
g.document = document;
g.window = (<any> document).defaultView;
g.window = (document as any).defaultView;
g.navigator = {
userAgent: "testing"
};
};

const cleanup = () => {
const g: any = <any> global;
const g: any = global as any;
delete g.document;
delete g.window;
delete g.navigator;
Expand Down
2 changes: 1 addition & 1 deletion src/common/models/essence/essence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { Resolve, VisualizationManifest } from "../visualization-manifest/visual
import { VisualizationSettings } from "../visualization-settings/visualization-settings";

function constrainDimensions(dimensions: OrderedSet<string>, dataCube: ClientDataCube): OrderedSet<string> {
return <OrderedSet<string>> dimensions.filter(dimensionName => Boolean(findDimensionByName(dataCube.dimensions, dimensionName)));
return dimensions.filter(dimensionName => Boolean(findDimensionByName(dataCube.dimensions, dimensionName))) as OrderedSet<string>;
}

export interface VisualizationAndResolve {
Expand Down
2 changes: 1 addition & 1 deletion src/common/models/refresh-rule/refresh-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class RefreshRule implements Instance<RefreshRuleValue, RefreshRuleJS> {
rule: parameters.rule
};
if (parameters.time) {
value.time = new Date(<any> parameters.time);
value.time = new Date(parameters.time as any);
}
return new RefreshRule(value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils/array/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function insert<T>(array: T[], index: number, element: T): T[] {
return [...array.slice(0, index), element, ...array.slice(index)];
}

export function shallowEqualArrays(a: Array<unknown>, b: Array<unknown>): boolean {
export function shallowEqualArrays(a: unknown[], b: unknown[]): boolean {
if (a === b) return true;
if (!a || !b) return false;
if (b.length !== a.length) return false;
Expand Down
4 changes: 2 additions & 2 deletions src/common/utils/general/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ export function inlineVars(obj: any, vs: Record<string, string>): any {
}));
}

export function ensureOneOf(value: unknown, values: Array<unknown>, messagePrefix: string): void {
export function ensureOneOf(value: unknown, values: unknown[], messagePrefix: string): void {
if (values.indexOf(value) !== -1) return;
const isMessage = isTruthy(value) ? `'${value}'` : "not defined";
throw new Error(`${messagePrefix} must be one of '${values.join("', '")}' (is ${isMessage})`);
}

export function optionalEnsureOneOf(value: unknown, values: Array<unknown>, messagePrefix: string): void {
export function optionalEnsureOneOf(value: unknown, values: unknown[], messagePrefix: string): void {
if (!isTruthy(value)) return;
if (values.indexOf(value) !== -1) return;
throw new Error(`${messagePrefix} must be one of '${values.join("', '")}' (is '${value}')`);
Expand Down
2 changes: 1 addition & 1 deletion src/common/view-definitions/version-4/filter-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const stringFilterClauseConverter: FilterDefinitionConversion<StringFilterClause
if (action === null) {
throw Error(`String filter action cannot be empty. Dimension: ${dimension}`);
}
if (!(<any> Object).values(StringFilterAction).includes(action)) {
if (!(Object as any).values(StringFilterAction).includes(action)) {
throw Error(`Unknown string filter action. Dimension: ${dimension}`);
}
if (action in [StringFilterAction.CONTAINS, StringFilterAction.MATCH] && values.length !== 1) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/plywood/plywood.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function plywoodRouter(settingsManager: Pick<SettingsManager, "anchorPath
} catch (error) {
console.log("error:", error.message);
if (error.hasOwnProperty("stack")) {
console.log((<any> error).stack);
console.log((error as any).stack);
}
res.status(500).send({
error: "could not compute",
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/shorten/shorten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function shortenRouter(settings: Pick<AppSettings, "customization">, isTr
} catch (error) {
console.log("error:", error.message);
if (error.hasOwnProperty("stack")) {
console.log((<any> error).stack);
console.log((error as any).stack);
}
res.status(500).send({
error: "could not shorten url",
Expand Down
4 changes: 1 addition & 3 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,11 @@
"jsx-no-string-ref": false, // passing string refs is discouraged in React now
"jsx-wrap-multiline": false, // enforce wrapping of multiline jsx elements in parens (React's de facto standard)
"max-classes-per-file": false, // disallow multiple classes in a single file
"no-angle-bracket-type-assertion": false, // enforce consistent "as X" type assertion style, "<X>" style is not compatible with TSX
"no-conditional-assignment": false, // disallow assignment in conditional condition statements
"no-empty": false, // disallow empty function / method bodies
"no-empty-interface": false, // disallow empty named interfaces, replace with {}
"no-shadowed-variable": false, // disallow variable shadowing
"no-unused-expression": false, // disallow unused expressions, currently many "to.be.true" expectations trigger it
"variable-name": false, // enforce consistent variable naming
"array-type": false // use either T[] or Array for arrays
"variable-name": false // enforce consistent variable naming
}
}

0 comments on commit 8c55a84

Please sign in to comment.