Make code prettier
This updates ESLint and our shared eslint-config-openlayers to use Prettier. Most formatting changes were automatically applied with this:
npm run lint -- --fix
A few manual changes were required:
* In `examples/offscreen-canvas.js`, the `//eslint-disable-line` comment needed to be moved to the appropriate line to disable the error about the `'worker-loader!./offscreen-canvas.worker.js'` import.
* In `examples/webpack/exapmle-builder.js`, spaces could not be added after a couple `function`s for some reason. While editing this, I reworked `ExampleBuilder` to be a class.
* In `src/ol/format/WMSGetFeatureInfo.js`, the `// @ts-ignore` comment needed to be moved down one line so it applied to the `parsersNS` argument.
This commit is contained in:
@@ -1,39 +1,36 @@
|
||||
import RegularShape from '../../../../src/ol/style/RegularShape.js';
|
||||
import Fill from '../../../../src/ol/style/Fill.js';
|
||||
import RegularShape from '../../../../src/ol/style/RegularShape.js';
|
||||
import Stroke from '../../../../src/ol/style/Stroke.js';
|
||||
|
||||
|
||||
describe('ol.style.RegularShape', function() {
|
||||
|
||||
describe('#constructor', function() {
|
||||
|
||||
it('can use rotateWithView', function() {
|
||||
describe('ol.style.RegularShape', function () {
|
||||
describe('#constructor', function () {
|
||||
it('can use rotateWithView', function () {
|
||||
const style = new RegularShape({
|
||||
rotateWithView: true,
|
||||
radius: 0
|
||||
radius: 0,
|
||||
});
|
||||
expect(style.getRotateWithView()).to.be(true);
|
||||
});
|
||||
|
||||
it('can use radius', function() {
|
||||
it('can use radius', function () {
|
||||
const style = new RegularShape({
|
||||
radius: 5,
|
||||
radius2: 10
|
||||
radius2: 10,
|
||||
});
|
||||
expect(style.getRadius()).to.eql(5);
|
||||
expect(style.getRadius2()).to.eql(10);
|
||||
});
|
||||
|
||||
it('can use radius1 as an alias for radius', function() {
|
||||
it('can use radius1 as an alias for radius', function () {
|
||||
const style = new RegularShape({
|
||||
radius1: 5,
|
||||
radius2: 10
|
||||
radius2: 10,
|
||||
});
|
||||
expect(style.getRadius()).to.eql(5);
|
||||
expect(style.getRadius2()).to.eql(10);
|
||||
});
|
||||
|
||||
it('creates a canvas (no fill-style)', function() {
|
||||
it('creates a canvas (no fill-style)', function () {
|
||||
const style = new RegularShape({radius: 10});
|
||||
expect(style.getImage()).to.be.an(HTMLCanvasElement);
|
||||
expect(style.getSize()).to.eql([21, 21]);
|
||||
@@ -46,12 +43,12 @@ describe('ol.style.RegularShape', function() {
|
||||
expect(style.getHitDetectionImageSize()).to.eql([21, 21]);
|
||||
});
|
||||
|
||||
it('creates a canvas (transparent fill-style)', function() {
|
||||
it('creates a canvas (transparent fill-style)', function () {
|
||||
const style = new RegularShape({
|
||||
radius: 10,
|
||||
fill: new Fill({
|
||||
color: 'transparent'
|
||||
})
|
||||
color: 'transparent',
|
||||
}),
|
||||
});
|
||||
expect(style.getImage()).to.be.an(HTMLCanvasElement);
|
||||
expect(style.getSize()).to.eql([21, 21]);
|
||||
@@ -64,12 +61,12 @@ describe('ol.style.RegularShape', function() {
|
||||
expect(style.getHitDetectionImageSize()).to.eql([21, 21]);
|
||||
});
|
||||
|
||||
it('creates a canvas (non-transparent fill-style)', function() {
|
||||
it('creates a canvas (non-transparent fill-style)', function () {
|
||||
const style = new RegularShape({
|
||||
radius: 10,
|
||||
fill: new Fill({
|
||||
color: '#FFFF00'
|
||||
})
|
||||
color: '#FFFF00',
|
||||
}),
|
||||
});
|
||||
expect(style.getImage()).to.be.an(HTMLCanvasElement);
|
||||
expect(style.getSize()).to.eql([21, 21]);
|
||||
@@ -82,19 +79,19 @@ describe('ol.style.RegularShape', function() {
|
||||
expect(style.getHitDetectionImageSize()).to.eql([21, 21]);
|
||||
});
|
||||
|
||||
it('sets default displacement [0, 0]', function() {
|
||||
it('sets default displacement [0, 0]', function () {
|
||||
const style = new RegularShape({
|
||||
radius: 5
|
||||
radius: 5,
|
||||
});
|
||||
expect(style.getDisplacement()).to.an('array');
|
||||
expect(style.getDisplacement()[0]).to.eql(0);
|
||||
expect(style.getDisplacement()[1]).to.eql(0);
|
||||
});
|
||||
|
||||
it('can use offset', function() {
|
||||
it('can use offset', function () {
|
||||
const style = new RegularShape({
|
||||
radius: 5,
|
||||
displacement: [10, 20]
|
||||
displacement: [10, 20],
|
||||
});
|
||||
expect(style.getDisplacement()).to.an('array');
|
||||
expect(style.getDisplacement()[0]).to.eql(10);
|
||||
@@ -102,32 +99,31 @@ describe('ol.style.RegularShape', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#clone', function() {
|
||||
|
||||
it('creates a new ol.style.RegularShape', function() {
|
||||
describe('#clone', function () {
|
||||
it('creates a new ol.style.RegularShape', function () {
|
||||
const original = new RegularShape({
|
||||
points: 5
|
||||
points: 5,
|
||||
});
|
||||
const clone = original.clone();
|
||||
expect(clone).to.be.an(RegularShape);
|
||||
expect(clone).to.not.be(original);
|
||||
});
|
||||
|
||||
it('copies all values', function() {
|
||||
it('copies all values', function () {
|
||||
const original = new RegularShape({
|
||||
fill: new Fill({
|
||||
color: '#319FD3'
|
||||
color: '#319FD3',
|
||||
}),
|
||||
points: 5,
|
||||
radius: 4,
|
||||
radius2: 6,
|
||||
angle: 1,
|
||||
stroke: new Stroke({
|
||||
color: '#319FD3'
|
||||
color: '#319FD3',
|
||||
}),
|
||||
rotation: 2,
|
||||
rotateWithView: true,
|
||||
displacement: [10, 20]
|
||||
displacement: [10, 20],
|
||||
});
|
||||
original.setOpacity(0.5);
|
||||
original.setScale(1.5);
|
||||
@@ -141,20 +137,22 @@ describe('ol.style.RegularShape', function() {
|
||||
expect(original.getRotation()).to.eql(clone.getRotation());
|
||||
expect(original.getRotateWithView()).to.eql(clone.getRotateWithView());
|
||||
expect(original.getScale()).to.eql(clone.getScale());
|
||||
expect(original.getStroke().getColor()).to.eql(clone.getStroke().getColor());
|
||||
expect(original.getStroke().getColor()).to.eql(
|
||||
clone.getStroke().getColor()
|
||||
);
|
||||
expect(original.getDisplacement()[0]).to.eql(clone.getDisplacement()[0]);
|
||||
expect(original.getDisplacement()[1]).to.eql(clone.getDisplacement()[1]);
|
||||
});
|
||||
|
||||
it('the clone does not reference the same objects as the original', function() {
|
||||
it('the clone does not reference the same objects as the original', function () {
|
||||
const original = new RegularShape({
|
||||
fill: new Fill({
|
||||
color: '#319FD3'
|
||||
color: '#319FD3',
|
||||
}),
|
||||
stroke: new Stroke({
|
||||
color: '#319FD3'
|
||||
color: '#319FD3',
|
||||
}),
|
||||
displacement: [0, 5]
|
||||
displacement: [0, 5],
|
||||
});
|
||||
const clone = original.clone();
|
||||
expect(original.getFill()).to.not.be(clone.getFill());
|
||||
@@ -163,9 +161,12 @@ describe('ol.style.RegularShape', function() {
|
||||
|
||||
clone.getFill().setColor('#012345');
|
||||
clone.getStroke().setColor('#012345');
|
||||
expect(original.getFill().getColor()).to.not.eql(clone.getFill().getColor());
|
||||
expect(original.getStroke().getColor()).to.not.eql(clone.getStroke().getColor());
|
||||
expect(original.getFill().getColor()).to.not.eql(
|
||||
clone.getFill().getColor()
|
||||
);
|
||||
expect(original.getStroke().getColor()).to.not.eql(
|
||||
clone.getStroke().getColor()
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user