Skip to content

Commit

Permalink
fix(typings): ensure abstract repeater typings compat (#418)
Browse files Browse the repository at this point in the history
- resolve out of date deps
  • Loading branch information
bigopon authored Apr 19, 2022
1 parent f1af4aa commit 8a234b5
Show file tree
Hide file tree
Showing 34 changed files with 10,215 additions and 2,223 deletions.
12,293 changes: 10,142 additions & 2,151 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"jasmine-core": "^3.99.1",
"karma": "^6.3.17",
"karma-chrome-launcher": "^3.1.1",
"karma-coverage": "^1.1.2",
"karma-coverage": "^2.2.0",
"karma-jasmine": "^4.0.2",
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.8",
Expand All @@ -80,13 +80,10 @@
"rollup": "^2.70.1",
"standard-version": "^9.3.2",
"ts-loader": "^9.2.8",
"tslib": "^2.3.1",
"typedoc": "^0.22.13",
"typescript": "^4.6.3",
"webpack": "^5.70.0",
"webpack-cli": "^4.9.2"
},
"volta": {
"node": "14.19.1",
"npm": "6.14.16"
}
}
27 changes: 13 additions & 14 deletions src/abstract-repeater.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { View } from 'aurelia-templating';

/**
Expand All @@ -15,7 +16,7 @@ export class AbstractRepeater {
/**
* Returns the number of views the repeater knows about.
*
* @return {Number} the number of views.
* @return the number of views.
*/
viewCount(): number {
throw new Error('subclass must implement `viewCount`');
Expand All @@ -24,7 +25,7 @@ export class AbstractRepeater {
/**
* Returns all of the repeaters views as an array.
*
* @return {Array} The repeater's array of views;
* @return The repeater's array of views;
*/
views(): any[] {
throw new Error('subclass must implement `views`');
Expand All @@ -33,19 +34,19 @@ export class AbstractRepeater {
/**
* Returns a single view from the repeater at the provided index.
*
* @param {Number} index The index of the requested view.
* @param index The index of the requested view.
* @return {View|ViewSlot} The requested view.
*/
view(index): any {
view(index: number): any {
throw new Error('subclass must implement `view`');
}

/**
* Returns the matcher function to be used by the repeater, or null if strict matching is to be performed.
*
* @return {Function|null} The requested matcher function.
* @return The requested matcher function.
*/
matcher() {
matcher(): Function | null {
throw new Error('subclass must implement `matcher`');
}

Expand All @@ -56,7 +57,7 @@ export class AbstractRepeater {
* @param {Object} bindingContext The binding context to bind the new view to.
* @param {Object} overrideContext A secondary binding context that can override the primary context.
*/
addView(bindingContext, overrideContext) {
addView(bindingContext, overrideContext): any {
throw new Error('subclass must implement `addView`');
}

Expand All @@ -68,7 +69,7 @@ export class AbstractRepeater {
* @param {Object} bindingContext The binding context to bind the new view to.
* @param {Object} overrideContext A secondary binding context that can override the primary context.
*/
insertView(index, bindingContext, overrideContext) {
insertView(index, bindingContext, overrideContext): any {
throw new Error('subclass must implement `insertView`');
}

Expand All @@ -78,7 +79,7 @@ export class AbstractRepeater {
* @param {Number} sourceIndex The index of the view to be moved.
* @param {Number} sourceIndex The index where the view should be placed at.
*/
moveView(sourceIndex, targetIndex) {
moveView(sourceIndex, targetIndex): any {
throw new Error('subclass must implement `moveView`');
}

Expand All @@ -88,7 +89,7 @@ export class AbstractRepeater {
* @param {Boolean} skipAnimation Should the removal animation be skipped?
* @return {Promise|null}
*/
removeAllViews(returnToCache?: boolean, skipAnimation?: boolean) {
removeAllViews(returnToCache?: boolean, skipAnimation?: boolean): (any | Promise<any>)[] {
throw new Error('subclass must implement `removeAllViews`');
}

Expand All @@ -98,9 +99,8 @@ export class AbstractRepeater {
* @param {Array} viewsToRemove The array of views to be removed.
* @param {Boolean} returnToCache Should the view be returned to the view cache?
* @param {Boolean} skipAnimation Should the removal animation be skipped?
* @return {Promise|null}
*/
removeViews(viewsToRemove: Array<View>, returnToCache?: boolean, skipAnimation?: boolean) {
removeViews(viewsToRemove: Array<View>, returnToCache?: boolean, skipAnimation?: boolean): (any | Promise<any>)[] {
throw new Error('subclass must implement `removeView`');
}

Expand All @@ -110,9 +110,8 @@ export class AbstractRepeater {
* @param {Number} index The index of the view to be removed.
* @param {Boolean} returnToCache Should the view be returned to the view cache?
* @param {Boolean} skipAnimation Should the removal animation be skipped?
* @return {Promise|null}
*/
removeView(index: number, returnToCache?: boolean, skipAnimation?: boolean) {
removeView(index: number, returnToCache?: boolean, skipAnimation?: boolean): any | Promise<any> {
throw new Error('subclass must implement `removeView`');
}

Expand Down
1 change: 1 addition & 0 deletions src/attr-binding-behavior.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import {DataAttributeObserver, bindingBehavior} from 'aurelia-binding';

@bindingBehavior('attr')
Expand Down
2 changes: 2 additions & 0 deletions src/binding-mode-behaviors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { bindingBehavior, bindingMode } from 'aurelia-binding';
import { mixin } from 'aurelia-metadata';

let modeBindingBehavior = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
bind(binding, source, lookupFunctions) {
binding.originalMode = binding.mode;
binding.mode = this.mode;
},

// eslint-disable-next-line @typescript-eslint/no-unused-vars
unbind(binding, source) {
binding.mode = binding.originalMode;
binding.originalMode = null;
Expand Down
3 changes: 3 additions & 0 deletions src/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export class Compose {
* @param newValue The new value.
* @param oldValue The old value.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
modelChanged(newValue, oldValue) {
this.changes.model = newValue;
requestUpdate(this);
Expand All @@ -203,6 +204,7 @@ export class Compose {
* @param newValue The new value.
* @param oldValue The old value.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
viewChanged(newValue, oldValue) {
this.changes.view = newValue;
requestUpdate(this);
Expand All @@ -213,6 +215,7 @@ export class Compose {
* @param newValue The new value.
* @param oldValue The old value.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
viewModelChanged(newValue, oldValue) {
this.changes.viewModel = newValue;
requestUpdate(this);
Expand Down
2 changes: 1 addition & 1 deletion src/css-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class CSSResource {
load(container: Container): Promise<CSSResource> {
return container.get(Loader)
.loadText(this.address)
.catch(err => null)
.catch(() => null)
.then(text => {
text = fixupCSSUrls(this.address, text);
this._scoped.css = text;
Expand Down
1 change: 1 addition & 0 deletions src/debounce-binding-behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class DebounceBindingBehavior {
};
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
unbind(binding, source) {
// restore the state of the binding.
const methodToRestore = binding.debouncedMethod.originalName;
Expand Down
3 changes: 1 addition & 2 deletions src/focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ export class Focus {

/**
* Invoked everytime the bound value changes.
* @param newValue The new value.
*/
valueChanged(newValue) {
valueChanged() {
if (this.isAttached) {
this._apply();
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/hide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ export class Hide {
/**
* Binds the Hide attribute.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
bind(bindingContext) {
this.valueChanged(this.value);
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
value(value: any) {
throw new Error('Method not implemented.');
}
Expand Down
1 change: 1 addition & 0 deletions src/html-sanitizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class HTMLSanitizer {
* Sanitizes the provided input.
* @param input The input to be sanitized.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
sanitize(input): any {
throw new Error(`To protect the application against a wide variety of sophisticated XSS attacks.
Please see https://aurelia.io/docs/binding/basics#element-content for instructions on how to use a secure solution like DOMPurify or sanitize-html.`);
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { BindingExpression } from 'aurelia-binding';
import { TargetInstruction } from 'aurelia-templating';

Expand Down
1 change: 1 addition & 0 deletions src/null-repeat-strategy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/**
* A strategy for repeating a template over null or undefined (does nothing)
*/
Expand Down
1 change: 1 addition & 0 deletions src/repeat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export class Repeat extends AbstractRepeater {
/**
* Invoked when the underlying inner collection changes.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
handleInnerCollectionMutated(collection, changes) {
if (!this.collectionObserver) {
return;
Expand Down
1 change: 1 addition & 0 deletions src/self-binding-behavior.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { bindingBehavior } from 'aurelia-binding';

function findOriginalEventTarget(event) {
Expand Down
1 change: 1 addition & 0 deletions src/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class Show {
/**
* Binds the Show attribute.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
bind(bindingContext) {
this.valueChanged(this.value);
}
Expand Down
1 change: 1 addition & 0 deletions src/signal-binding-behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class SignalBindingBehavior {
}
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
unbind(binding, source) {
let signals = this.signals;
let name = binding.signalName;
Expand Down
1 change: 1 addition & 0 deletions src/throttle-binding-behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class ThrottleBindingBehavior {
};
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
unbind(binding, source) {
// restore the state of the binding.
let methodToRestore = binding.throttledMethod.originalName;
Expand Down
1 change: 1 addition & 0 deletions src/update-trigger-binding-behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class UpdateTriggerBindingBehavior {
targetObserver.handler = handler;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
unbind(binding, source) {
let targetObserver = binding.targetObserver;
// restore the state of the binding.
Expand Down
13 changes: 7 additions & 6 deletions test/array-repeat-strategy.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import './setup';
import {ObserverLocator, createOverrideContext} from 'aurelia-binding';
import {BoundViewFactory, ViewSlot, ViewFactory, ModuleAnalyzer, TargetInstruction, ViewResources} from 'aurelia-templating';
import {StageComponent} from 'aurelia-testing';
import {Container} from 'aurelia-dependency-injection';
import {Repeat} from '../src/repeat';
import {RepeatStrategyLocator} from '../src/repeat-strategy-locator';
import {ArrayRepeatStrategy} from '../src/array-repeat-strategy';
import {ViewSlotMock, BoundViewFactoryMock, ViewMock, ViewFactoryMock, instructionMock, viewResourcesMock} from './mocks';
import {bootstrap} from 'aurelia-bootstrapper';

describe('ArrayRepeatStrategy', () => {
let repeat, strategy, viewSlot, viewFactory, observerLocator, repeatStrategyLocator, repeatStrategyMock, component;
let repeat;
let strategy;
let viewSlot;
let viewFactory;
let component;

beforeEach(done => {
let aurelia;
let container = new Container();
// let aurelia;
// let container = new Container();
viewSlot = new ViewSlotMock();
viewFactory = new BoundViewFactoryMock();
strategy = new ArrayRepeatStrategy();
Expand Down
1 change: 0 additions & 1 deletion test/compose.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import './setup';
import { TaskQueue } from 'aurelia-task-queue';
import { Compose, ActivationStrategy } from '../src/compose';
import * as LogManager from 'aurelia-logging';
import { View } from 'aurelia-framework';

describe('Compose', () => {
Expand Down
4 changes: 1 addition & 3 deletions test/debounce-binding-behavior.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { Container } from 'aurelia-dependency-injection';
import {
bindingMode,
BindingEngine,
ListenerExpression,
delegationStrategy,
ValueAttributeObserver,
createScopeForTest
} from 'aurelia-binding';
import * as AureliaBinding from 'aurelia-binding';
Expand Down Expand Up @@ -136,7 +134,7 @@ describe('DebounceBindingBehavior', () => {

let viewModel = {
callCount: 0,
handleMouseMove: e => {
handleMouseMove: () => {
viewModel.callCount++;
}
};
Expand Down
2 changes: 1 addition & 1 deletion test/focus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('focus', () => {

function setBindedFocusValue(value) {
focus.value = value;
focus.valueChanged(value);
focus.valueChanged();
}

beforeEach(() => {
Expand Down
8 changes: 4 additions & 4 deletions test/if.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import './setup';
import {If} from '../src/if';
import {BoundViewFactory, ViewSlot, View} from 'aurelia-templating';
import {TaskQueue} from 'aurelia-task-queue';
import {bootstrap} from 'aurelia-bootstrapper';
import {ComponentTester} from 'aurelia-testing';
Expand Down Expand Up @@ -218,7 +217,7 @@ describe('if', () => {
let delay = ms => new Promise(resolve => setTimeout(resolve, ms));

let removeWithAnimation = animationDuration => {
return function(view) {
return function() {
return delay(animationDuration).then(() => {
this.children = [];
});
Expand Down Expand Up @@ -287,7 +286,7 @@ describe('if', () => {
it('should rebind even if the view is visible; issue #317', done => {
let spy;
component.create(bootstrap)
.then(_ => {
.then(() => {
spy = spyOn(model, 'clicked');
model.a = false;
taskQueue.flushMicroTaskQueue();
Expand All @@ -312,7 +311,7 @@ describe('if', () => {

it('should update view when rebound; issue #328', done => {
component.create(bootstrap)
.then(_ => {
.then(() => {
model.a = false;
taskQueue.flushMicroTaskQueue();
return new Promise(r => setTimeout(r, 1));
Expand Down Expand Up @@ -340,6 +339,7 @@ class ViewSlotMock {
}

class ViewMock {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
bind(...args: unknown[]) {}
unbind() {}
returnToCache() {}
Expand Down
Loading

0 comments on commit 8a234b5

Please sign in to comment.