Skip to content

Commit 44acbfd

Browse files
committed
Making linter happy
1 parent beaaf67 commit 44acbfd

12 files changed

+65
-54
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- v1-dependencies-
2828

2929
- run: npm install
30-
- run: npm install plotly.js # peer dependency
30+
- run: npm install plotly.js-dist # peer dependency
3131

3232
- save_cache:
3333
paths:

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Changed
66
- Upgraded to angular 10.0
77
- Moving to angular library format
8+
- Changing `plotly_click` event to `plotlyClick` for consistence among other event names
89

910

1011
## [2.0.0] - 2020-02-28

FAQ.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ It's possible disable some plotly events returning `false` in its event. Please
77

88

99

10-
## Why using `(plotly_click)` instead of `(click)`?
10+
## Why using `(plotlyClick)` instead of `(click)`?
1111

12-
Angular uses the `(click)` directive to itself. If we use the `click` name as event alias to `plotly_click` we might get unexpected behaviour from both angular and plotly.js. We believe it is simpler to just avoid using the same name is better.
12+
Angular uses the `(click)` directive to itself. If we use the `click` name as event alias to `plotlyClick` we might get unexpected behaviour from both angular and plotly.js. We believe it is simpler to just avoid using the same name is better.
1313
Please see issue: https://github.com/plotly/angular-plotly.js/issues/63
1414

1515

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Event handlers for specific [`plotly.js` events](https://plot.ly/javascript/plot
147147
| `(autoSize)` | `Function` | `plotly_autosize` | |
148148
| `(beforeExport)` | `Function` | `plotly_beforeexport` | |
149149
| `(buttonClicked)` | `Function` | `plotly_buttonclicked` | |
150-
| `(plotly_click)` | `Function` | `plotly_click` | [why not (click)?](FAQ.md#why-using-plotly_click-instead-of-click) |
150+
| `(plotlyClick)` | `Function` | `plotly_click` | [why not (click)?](FAQ.md#why-using-plotlyclick-instead-of-click) |
151151
| `(clickAnnotation)` | `Function` | `plotly_clickannotation` | |
152152
| `(deselect)` | `Function` | `plotly_deselect` | |
153153
| `(doubleClick)` | `Function` | `plotly_doubleclick` | |

projects/plotly/src/lib/plotly-via-cdn.module.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,41 @@ export type PlotlyBundleName = 'basic' | 'cartesian' | 'geo' | 'gl3d' | 'gl2d' |
1515
exports: [PlotlyComponent],
1616
})
1717
export class PlotlyViaCDNModule {
18-
private static _plotlyBundle?: string = null;
19-
private static _plotlyVersion?: string = 'latest';
18+
private static plotlyBundle?: string = null;
19+
private static plotlyVersion = 'latest';
2020
public static plotlyBundleNames: PlotlyBundleName[] = ['basic', 'cartesian', 'geo', 'gl3d', 'gl2d', 'mapbox', 'finance'];
2121

2222
constructor(public plotlyService: PlotlyService) {
2323
PlotlyService.setModuleName('ViaCDN');
2424
}
2525

26-
static setPlotlyVersion(version: string) {
26+
static setPlotlyVersion(version: string): void {
2727
const isOk = version === 'latest' || /^\d\.\d{1,2}\.\d{1,2}$/.test(version);
2828
if (!isOk) {
2929
throw new Error(`Invalid plotly version. Please set 'latest' or version number (i.e.: 1.4.3)`);
3030
}
3131

3232
PlotlyViaCDNModule.loadViaCDN();
33-
PlotlyViaCDNModule._plotlyVersion = version;
33+
PlotlyViaCDNModule.plotlyVersion = version;
3434
}
3535

36-
static setPlotlyBundle(bundle: PlotlyBundleName) {
36+
static setPlotlyBundle(bundle: PlotlyBundleName): void {
3737
const isOk = bundle === null || PlotlyViaCDNModule.plotlyBundleNames.indexOf(bundle) >= 0;
3838
if (!isOk) {
3939
const names = PlotlyViaCDNModule.plotlyBundleNames.map(n => `"${n}"`).join(', ');
4040
throw new Error(`Invalid plotly bundle. Please set to null for full or ${names} for a partial bundle.`);
4141
}
4242

43-
PlotlyViaCDNModule._plotlyBundle = bundle;
43+
PlotlyViaCDNModule.plotlyBundle = bundle;
4444
}
4545

4646
static loadViaCDN(): void {
4747
PlotlyService.setPlotly('waiting');
4848

4949
const init = () => {
50-
const src = PlotlyViaCDNModule._plotlyBundle == null
51-
? `https://cdn.plot.ly/plotly-${PlotlyViaCDNModule._plotlyVersion}.min.js`
52-
: `https://cdn.plot.ly/plotly-${PlotlyViaCDNModule._plotlyBundle}-${PlotlyViaCDNModule._plotlyVersion}.min.js`;
50+
const src = PlotlyViaCDNModule.plotlyBundle == null
51+
? `https://cdn.plot.ly/plotly-${PlotlyViaCDNModule.plotlyVersion}.min.js`
52+
: `https://cdn.plot.ly/plotly-${PlotlyViaCDNModule.plotlyBundle}-${PlotlyViaCDNModule.plotlyVersion}.min.js`;
5353

5454
const script: HTMLScriptElement = document.createElement('script');
5555
script.type = 'text/javascript';

projects/plotly/src/lib/plotly.component.specs.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ describe('PlotlyComponent', () => {
5656
spyOn(component, 'updatePlot');
5757

5858
component.revision = 0;
59-
component.ngOnChanges({'revision': new SimpleChange(null, component.revision, true)});
59+
component.ngOnChanges({revision: new SimpleChange(null, component.revision, true)});
6060
fixture.detectChanges();
6161
expect(component.updatePlot).not.toHaveBeenCalled();
6262

6363
component.revision = 1;
64-
component.ngOnChanges({'revision': new SimpleChange(0, component.revision, false)});
64+
component.ngOnChanges({revision: new SimpleChange(0, component.revision, false)});
6565
fixture.detectChanges();
6666
expect(component.updatePlot).toHaveBeenCalled();
6767

6868
component.revision = 2;
69-
component.ngOnChanges({'revision': new SimpleChange(1, component.revision, false)});
69+
component.ngOnChanges({revision: new SimpleChange(1, component.revision, false)});
7070
fixture.detectChanges();
7171
expect(component.updatePlot).toHaveBeenCalledTimes(2);
7272
});
@@ -137,7 +137,7 @@ describe('PlotlyComponent', () => {
137137
component.plotlyInstance = document.createElement('div') as any;
138138
component.debug = true;
139139
fixture.detectChanges();
140-
component.ngOnChanges({'debug': new SimpleChange(false, component.debug, false)});
140+
component.ngOnChanges({debug: new SimpleChange(false, component.debug, false)});
141141

142142
expect(component.updatePlot).toHaveBeenCalled();
143143
setTimeout(() => {
@@ -173,7 +173,7 @@ describe('PlotlyComponent', () => {
173173
});
174174

175175
it('should clear all added window events on destroy', async (done) => {
176-
const windowListenerCount = (<any>window).eventListeners().length;
176+
const windowListenerCount = (window as any).eventListeners().length;
177177

178178
// make component responsive via both the lib and the component (at least 2 window events are added)
179179
component.layout = { title: 'responsive', autosize: true };
@@ -187,7 +187,7 @@ describe('PlotlyComponent', () => {
187187
await fixture.whenStable();
188188

189189
// amount of listeners should be the same as before initializing the component
190-
expect((<any>window).eventListeners().length).toEqual(windowListenerCount);
190+
expect((window as any).eventListeners().length).toEqual(windowListenerCount);
191191

192192
done();
193193
});

projects/plotly/src/lib/plotly.component.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* tslint:disable component-selector no-output-native no-conflicting-lifecycle */
2+
13
import {
24
Component,
35
ElementRef,
@@ -43,10 +45,10 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
4345
@Input() style?: { [key: string]: string };
4446

4547
@Input() divId?: string;
46-
@Input() revision: number = 0;
48+
@Input() revision = 0;
4749
@Input() className?: string | string[];
48-
@Input() debug: boolean = false;
49-
@Input() useResizeHandler: boolean = false;
50+
@Input() debug = false;
51+
@Input() useResizeHandler = false;
5052

5153
@Input() updateOnLayoutChange = true;
5254
@Input() updateOnDataChange = true;
@@ -66,7 +68,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
6668
@Output() beforeExport = new EventEmitter();
6769
@Output() buttonClicked = new EventEmitter();
6870
@Output() click = new EventEmitter();
69-
@Output() plotly_click = new EventEmitter();
71+
@Output() plotlyClick = new EventEmitter();
7072
@Output() clickAnnotation = new EventEmitter();
7173
@Output() deselect = new EventEmitter();
7274
@Output() doubleClick = new EventEmitter();
@@ -101,20 +103,20 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
101103
public keyValueDiffers: KeyValueDiffers,
102104
) { }
103105

104-
ngOnInit() {
106+
ngOnInit(): void {
105107
this.createPlot().then(() => {
106108
const figure = this.createFigure();
107109
this.initialized.emit(figure);
108110
});
109111

110112
if (this.click.observers.length > 0) {
111-
const msg = 'DEPRECATED: Reconsider using `(plotly_click)` instead of `(click)` to avoid event conflict. '
113+
const msg = 'DEPRECATED: Reconsider using `(plotlyClick)` instead of `(click)` to avoid event conflict. '
112114
+ 'Please check https://github.com/plotly/angular-plotly.js#FAQ';
113115
console.error(msg);
114116
}
115117
}
116118

117-
ngOnDestroy() {
119+
ngOnDestroy(): void {
118120
if (typeof this.resizeHandler === 'function') {
119121
this.getWindow().removeEventListener('resize', this.resizeHandler as any);
120122
this.resizeHandler = undefined;
@@ -125,7 +127,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
125127
PlotlyService.remove(this.plotlyInstance);
126128
}
127129

128-
ngOnChanges(changes: SimpleChanges) {
130+
ngOnChanges(changes: SimpleChanges): void {
129131
let shouldUpdate = false;
130132

131133
const revision: SimpleChange = changes.revision;
@@ -145,7 +147,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
145147
this.updateWindowResizeHandler();
146148
}
147149

148-
ngDoCheck() {
150+
ngDoCheck(): boolean | void {
149151
if (this.updateOnlyWithRevision) {
150152
return false;
151153
}
@@ -211,7 +213,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
211213

212214
plotlyInstance.on('plotly_click', (data: any) => {
213215
this.click.emit(data);
214-
this.plotly_click.emit(data);
216+
this.plotlyClick.emit(data);
215217
});
216218

217219
this.updateWindowResizeHandler();
@@ -232,7 +234,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
232234
return figure;
233235
}
234236

235-
updatePlot() {
237+
updatePlot(): Promise<any> {
236238
if (!this.plotlyInstance) {
237239
const error = new Error(`Plotly component wasn't initialized`);
238240
this.error.emit(error);
@@ -250,7 +252,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
250252
});
251253
}
252254

253-
updateWindowResizeHandler() {
255+
updateWindowResizeHandler(): void {
254256
if (this.useResizeHandler) {
255257
if (this.resizeHandler === undefined) {
256258
this.resizeHandler = () => this.plotly.resize(this.plotlyInstance);
@@ -264,7 +266,7 @@ export class PlotlyComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
264266
}
265267
}
266268

267-
dataDifferTrackBy(_: number, item: any): any {
269+
dataDifferTrackBy(_: number, item: any): unknown {
268270
const obj = Object.assign({}, item, { uid: '' });
269271
return JSON.stringify(obj);
270272
}

projects/plotly/src/lib/plotly.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
/* tslint:disable no-namespace ban-types */
23
export namespace Plotly {
34
export type Data = any;
45
export type Layout = any;

projects/plotly/src/lib/plotly.module.specs.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PlotlyModule } from "./plotly.module";
1+
import { PlotlyModule } from './plotly.module';
22

33

44
describe('PlotlyModule', () => {
@@ -8,13 +8,15 @@ describe('PlotlyModule', () => {
88
const mod = new PlotlyModule();
99
};
1010

11-
const msg = "Invalid PlotlyJS object. Please check https://github.com/plotly/angular-plotly.js#quick-start"
12-
+ " to see how to add PlotlyJS to your project.";
11+
const msg = 'Invalid PlotlyJS object. Please check https://github.com/plotly/angular-plotly.js#quick-start'
12+
+ ' to see how to add PlotlyJS to your project.';
1313
expect(fn).toThrowError(msg);
1414

1515

1616
const fn2 = () => {
17-
PlotlyModule.plotlyjs = {plot: function() { }};
17+
PlotlyModule.plotlyjs = {
18+
plot(): void {}
19+
};
1820
const mod = new PlotlyModule();
1921
};
2022

projects/plotly/src/lib/plotly.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export class PlotlyModule {
1717

1818
constructor() {
1919
if (!this.isValid()) {
20-
const msg = "Invalid PlotlyJS object. Please check https://github.com/plotly/angular-plotly.js#quick-start"
21-
+ " to see how to add PlotlyJS to your project.";
20+
const msg = 'Invalid PlotlyJS object. Please check https://github.com/plotly/angular-plotly.js#quick-start'
21+
+ ' to see how to add PlotlyJS to your project.';
2222
throw new Error(msg);
2323
}
2424

0 commit comments

Comments
 (0)