Skip to content

Commit e2145e3

Browse files
authored
Turn on excludeNotExported (chartjs#7121)
1 parent 2e5b072 commit e2145e3

32 files changed

+79
-117
lines changed

babel.config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"presets": ["@babel/preset-env"],
33
"plugins": [
4-
"@babel/plugin-transform-object-assign",
5-
"@babel/plugin-proposal-class-properties"
4+
"@babel/plugin-proposal-class-properties",
5+
"@babel/plugin-transform-object-assign"
66
],
77
"env": {
88
"test": {

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint-disable import/no-commonjs */
22

3+
const babel = require('rollup-plugin-babel');
34
const commonjs = require('rollup-plugin-commonjs');
45
const resolve = require('rollup-plugin-node-resolve');
56
const builds = require('./rollup.config');
6-
const babel = require('rollup-plugin-babel');
77

88
module.exports = function(karma) {
99
const args = karma.args || {};

src/controllers/controller.bar.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function isFloatBar(custom) {
179179
return custom && custom.barStart !== undefined && custom.barEnd !== undefined;
180180
}
181181

182-
class BarController extends DatasetController {
182+
export default class BarController extends DatasetController {
183183

184184
/**
185185
* Overriding primitive data parsing since we support mixed primitive/array
@@ -510,5 +510,3 @@ BarController.prototype._dataElementOptions = [
510510
'maxBarThickness',
511511
'minBarLength'
512512
];
513-
514-
export default BarController;

src/controllers/controller.bubble.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ defaults.set('bubble', {
3030
}
3131
});
3232

33-
class BubbleController extends DatasetController {
33+
export default class BubbleController extends DatasetController {
3434

3535
/**
3636
* Parse array of objects
@@ -186,6 +186,3 @@ BubbleController.prototype._dataElementOptions = [
186186
'pointStyle',
187187
'rotation'
188188
];
189-
190-
191-
export default BubbleController;

src/controllers/controller.doughnut.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function getRatioAndOffset(rotation, circumference, cutout) {
128128
return {ratioX, ratioY, offsetX, offsetY};
129129
}
130130

131-
class DoughnutController extends DatasetController {
131+
export default class DoughnutController extends DatasetController {
132132

133133
constructor(chart, datasetIndex) {
134134
super(chart, datasetIndex);
@@ -356,5 +356,3 @@ DoughnutController.prototype._dataElementOptions = [
356356
'hoverBorderColor',
357357
'hoverBorderWidth',
358358
];
359-
360-
export default DoughnutController;

src/controllers/controller.horizontalBar.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ defaults.set('horizontalBar', {
4040
}
4141
});
4242

43-
class HorizontalBarController extends BarController {
43+
export default class HorizontalBarController extends BarController {
4444

4545
/**
4646
* @private
@@ -56,5 +56,3 @@ class HorizontalBarController extends BarController {
5656
return this._cachedMeta.yAxisID;
5757
}
5858
}
59-
60-
export default HorizontalBarController;

src/controllers/controller.line.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defaults.set('line', {
2424
}
2525
});
2626

27-
class LineController extends DatasetController {
27+
export default class LineController extends DatasetController {
2828

2929
constructor(chart, datasetIndex) {
3030
super(chart, datasetIndex);
@@ -195,5 +195,3 @@ LineController.prototype._dataElementOptions = {
195195
radius: 'pointRadius',
196196
rotation: 'pointRotation'
197197
};
198-
199-
export default LineController;

src/controllers/controller.polarArea.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function getStartAngleRadians(deg) {
8888
return toRadians(deg) - 0.5 * Math.PI;
8989
}
9090

91-
class PolarAreaController extends DatasetController {
91+
export default class PolarAreaController extends DatasetController {
9292

9393
constructor(chart, datasetIndex) {
9494
super(chart, datasetIndex);
@@ -243,5 +243,3 @@ PolarAreaController.prototype._dataElementOptions = [
243243
'hoverBorderColor',
244244
'hoverBorderWidth'
245245
];
246-
247-
export default PolarAreaController;

src/controllers/controller.radar.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defaults.set('radar', {
1818
}
1919
});
2020

21-
class RadarController extends DatasetController {
21+
export default class RadarController extends DatasetController {
2222

2323
/**
2424
* @private
@@ -147,5 +147,3 @@ RadarController.prototype._dataElementOptions = {
147147
radius: 'pointRadius',
148148
rotation: 'pointRotation'
149149
};
150-
151-
export default RadarController;

src/core/core.adapters.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function abstract() {
2424
* @memberof Chart._adapters._date
2525
*/
2626

27-
class DateAdapter {
27+
export class DateAdapter {
2828

2929
constructor(options) {
3030
this.options = options || {};

src/core/core.animation.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const interpolators = {
1919
}
2020
};
2121

22-
class Animation {
22+
export default class Animation {
2323
constructor(cfg, target, prop, to) {
2424
const currentValue = target[prop];
2525

@@ -80,5 +80,3 @@ class Animation {
8080
me._target[prop] = me._fn(from, to, factor);
8181
}
8282
}
83-
84-
export default Animation;

src/core/core.animator.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ function drawFPS(chart, count, date, lastDate) {
1818
ctx.restore();
1919
}
2020

21-
class Animator {
21+
/**
22+
* Please use the module's default export which provides a singleton instance
23+
*/
24+
export class Animator {
2225
constructor() {
2326
this._request = null;
2427
this._charts = new Map();
@@ -220,6 +223,5 @@ class Animator {
220223
}
221224
}
222225

223-
const instance = new Animator();
224-
225-
export default instance;
226+
// singleton instance
227+
export default new Animator();

src/core/core.controller.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,17 @@ function getCanvas(item) {
173173
return item;
174174
}
175175

176-
class Chart {
176+
export default class Chart {
177+
177178
static version = version;
178179

180+
/**
181+
* NOTE(SB) We actually don't use this container anymore but we need to keep it
182+
* for backward compatibility. Though, it can still be useful for plugins that
183+
* would need to work on multiple charts?!
184+
*/
185+
static instances = {};
186+
179187
constructor(item, config) {
180188
const me = this;
181189

@@ -1073,12 +1081,3 @@ class Chart {
10731081
return changed;
10741082
}
10751083
}
1076-
1077-
/**
1078-
* NOTE(SB) We actually don't use this container anymore but we need to keep it
1079-
* for backward compatibility. Though, it can still be useful for plugins that
1080-
* would need to work on multiple charts?!
1081-
*/
1082-
Chart.instances = {};
1083-
1084-
export default Chart;

src/core/core.datasetController.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ function getFirstScaleId(chart, axis) {
210210
return Object.keys(scales).filter(key => scales[key].axis === axis).shift();
211211
}
212212

213-
class DatasetController {
213+
export default class DatasetController {
214+
215+
static extend = helpers.inherits;
214216

215217
constructor(chart, datasetIndex) {
216218
this.chart = chart;
@@ -829,7 +831,7 @@ class DatasetController {
829831
const chart = me.chart;
830832
const datasetOpts = me._config;
831833
// @ts-ignore
832-
const options = chart.options.elements[me.datasetElementType.prototype._type] || {};
834+
const options = chart.options.elements[me.datasetElementType._type] || {};
833835
const elementOptions = me._datasetElementOptions;
834836
const values = {};
835837
const context = me._getContext(undefined, active);
@@ -863,7 +865,7 @@ class DatasetController {
863865
const chart = me.chart;
864866
const datasetOpts = me._config;
865867
// @ts-ignore
866-
const options = chart.options.elements[me.dataElementType.prototype._type] || {};
868+
const options = chart.options.elements[me.dataElementType._type] || {};
867869
const elementOptions = me._dataElementOptions;
868870
const values = {};
869871
const context = me._getContext(index, active);
@@ -1128,8 +1130,6 @@ class DatasetController {
11281130
}
11291131
}
11301132

1131-
DatasetController.extend = helpers.inherits;
1132-
11331133
/**
11341134
* Element type used to generate a meta dataset (e.g. Chart.element.Line).
11351135
*/
@@ -1170,5 +1170,3 @@ DatasetController.prototype._dataElementOptions = [
11701170
'borderWidth',
11711171
'pointStyle'
11721172
];
1173-
1174-
export default DatasetController;

src/core/core.defaults.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import {merge} from '../helpers/helpers.core';
22

3-
class Defaults {
3+
/**
4+
* Please use the module's default export which provides a singleton instance
5+
*/
6+
export class Defaults {
47
constructor() {
58
this.color = 'rgba(0,0,0,0.1)';
69
this.elements = {};
@@ -35,7 +38,6 @@ class Defaults {
3538
/**
3639
* @param {string} scope
3740
* @param {*} values
38-
* @private
3941
*/
4042
set(scope, values) {
4143
return merge(this[scope] || (this[scope] = {}), values);

src/core/core.element.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import {inherits} from '../helpers/helpers.core';
22
import {isNumber} from '../helpers/helpers.math';
33

4-
class Element {
4+
export default class Element {
5+
6+
static extend = inherits;
57

68
/**
79
* @param {object} [cfg] optional configuration
@@ -27,6 +29,3 @@ class Element {
2729
return isNumber(this.x) && isNumber(this.y);
2830
}
2931
}
30-
31-
Element.extend = inherits;
32-
export default Element;

src/core/core.plugins.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defaults.set('plugins', {});
1414
* @namespace Chart.plugins
1515
* @since 2.1.0
1616
*/
17-
class PluginService {
17+
export class PluginService {
1818
constructor() {
1919
/**
2020
* Globally registered plugins.

src/core/core.scale.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function skip(ticks, newTicks, spacing, majorStart, majorEnd) {
223223
}
224224
}
225225

226-
class Scale extends Element {
226+
export default class Scale extends Element {
227227

228228
// eslint-disable-next-line max-statements
229229
constructor(cfg) {
@@ -1572,5 +1572,3 @@ class Scale extends Element {
15721572
}
15731573

15741574
Scale.prototype._draw = Scale.prototype.draw;
1575-
1576-
export default Scale;

src/elements/element.arc.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ function drawBorder(ctx, vm, arc) {
8484
ctx.stroke();
8585
}
8686

87-
class Arc extends Element {
87+
export default class Arc extends Element {
88+
89+
static _type = 'arc';
8890

8991
constructor(cfg) {
9092
super();
@@ -184,7 +186,3 @@ class Arc extends Element {
184186
ctx.restore();
185187
}
186188
}
187-
188-
Arc.prototype._type = 'arc';
189-
190-
export default Arc;

src/elements/element.line.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ function _getInterpolationMethod(options) {
196196
return _pointInLine;
197197
}
198198

199-
class Line extends Element {
199+
export default class Line extends Element {
200+
201+
static _type = 'line';
200202

201203
constructor(cfg) {
202204
super();
@@ -355,7 +357,3 @@ class Line extends Element {
355357
ctx.restore();
356358
}
357359
}
358-
359-
Line.prototype._type = 'line';
360-
361-
export default Line;

src/elements/element.point.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ defaults.set('elements', {
1818
}
1919
});
2020

21-
class Point extends Element {
21+
export default class Point extends Element {
22+
23+
static _type = 'point';
2224

2325
constructor(cfg) {
2426
super();
@@ -89,7 +91,3 @@ class Point extends Element {
8991
return options.radius + options.hitRadius;
9092
}
9193
}
92-
93-
Point.prototype._type = 'point';
94-
95-
export default Point;

src/elements/element.rectangle.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ function inRange(bar, x, y) {
126126
&& (skipY || y >= bounds.top && y <= bounds.bottom);
127127
}
128128

129-
class Rectangle extends Element {
129+
export default class Rectangle extends Element {
130+
131+
static _type = 'rectangle';
130132

131133
constructor(cfg) {
132134
super();
@@ -194,7 +196,3 @@ class Rectangle extends Element {
194196
return axis === 'x' ? this.width / 2 : this.height / 2;
195197
}
196198
}
197-
198-
Rectangle.prototype._type = 'rectangle';
199-
200-
export default Rectangle;

src/plugins/plugin.legend.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ function getBoxWidth(labelOpts, fontSize) {
9595
labelOpts.boxWidth;
9696
}
9797

98-
/**
99-
* IMPORTANT: this class is exposed publicly as Chart.Legend, backward compatibility required!
100-
*/
101-
class Legend extends Element {
98+
export class Legend extends Element {
10299

103100
constructor(config) {
104101
super();

0 commit comments

Comments
 (0)