chore: tidy

This commit is contained in:
cha0s 2023-12-02 06:02:56 -06:00
parent a899cf627f
commit 6249effb69
27 changed files with 3 additions and 53 deletions

View File

@ -9,13 +9,11 @@ export function replaceInParent(parent, replaced, replacing) {
if (Array.isArray(parent[key])) { if (Array.isArray(parent[key])) {
for (let j = 0; j < parent[key].length; ++j) { for (let j = 0; j < parent[key].length; ++j) {
if (replaced === parent[key][j]) { if (replaced === parent[key][j]) {
// eslint-disable-next-line no-param-reassign
parent[key][j] = replacing; parent[key][j] = replacing;
} }
} }
} }
else if (replaced === parent[key]) { else if (replaced === parent[key]) {
// eslint-disable-next-line no-param-reassign
parent[key] = replacing; parent[key] = replacing;
} }
} }

View File

@ -15,7 +15,6 @@ const letterCount = (node) => {
}; };
const decorateWithLetters = (resolver) => (node, ancestors) => { const decorateWithLetters = (resolver) => (node, ancestors) => {
/* eslint-disable no-param-reassign */
if ('text' === node.type) { if ('text' === node.type) {
const letters = node.value const letters = node.value
.replace(/\s/g, '\u00A0') .replace(/\s/g, '\u00A0')
@ -89,7 +88,6 @@ const decorateWithLetters = (resolver) => (node, ancestors) => {
}); });
}; };
} }
/* eslint-enable no-param-reassign */
}; };
const lettersFor = (node) => { const lettersFor = (node) => {

View File

@ -49,7 +49,6 @@ export default (flecks) => {
if (this.$$letters.length > 0) { if (this.$$letters.length > 0) {
this.showThisLetter(); this.showThisLetter();
this.$$words.forEach((word) => { this.$$words.forEach((word) => {
// eslint-disable-next-line no-param-reassign
word.parentNode = this.entity.node; word.parentNode = this.entity.node;
}); });
} }

View File

@ -12,10 +12,8 @@ const createWord = async (letters, flecks) => {
}, },
}); });
for (let i = 0; i < letters.length; ++i) { for (let i = 0; i < letters.length; ++i) {
/* eslint-disable no-param-reassign */
letters[i].parentNode = word.node; letters[i].parentNode = word.node;
letters[i].isBehaving = true; letters[i].isBehaving = true;
/* eslint-enable no-param-reassign */
} }
const {tick} = word; const {tick} = word;
word.tick = function T(elapsed) { word.tick = function T(elapsed) {

View File

@ -13,9 +13,7 @@ export default class ArbitraryComponent extends BaseComponent {
} }
const results = super.allocateMany(count); const results = super.allocateMany(count);
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
count -= results.length; count -= results.length; while (count--) {
// eslint-disable-next-line no-param-reassign
while (count--) {
results.push(this.data.push(new this.Instance()) - 1); results.push(this.data.push(new this.Instance()) - 1);
} }
return results; return results;

View File

@ -13,7 +13,6 @@ export default class Serializer {
const viewMethod = Schema.viewMethodFromType(type); const viewMethod = Schema.viewMethodFromType(type);
let value; let value;
if (viewMethod) { if (viewMethod) {
// eslint-disable-next-line no-param-reassign
value = view[`get${viewMethod}`](cursor, true); value = view[`get${viewMethod}`](cursor, true);
cursor += Schema.sizeOfType(type); cursor += Schema.sizeOfType(type);
} }
@ -31,7 +30,6 @@ export default class Serializer {
default: break; default: break;
} }
} }
// eslint-disable-next-line no-param-reassign
destination[key] = value; destination[key] = value;
} }
} }

View File

@ -46,7 +46,6 @@ export default (flecks) => {
if (entity.hasTickers()) { if (entity.hasTickers()) {
this.$$entityTickers.push(entity.tick); this.$$entityTickers.push(entity.tick);
} }
// eslint-disable-next-line no-param-reassign
entity.list = this; entity.list = this;
entity.emit('addedToList'); entity.emit('addedToList');
entity.once('destroying', () => this.onEntityDestroying(entity)); entity.once('destroying', () => this.onEntityDestroying(entity));
@ -161,7 +160,6 @@ export default (flecks) => {
if ('web' !== process.env.FLECKS_CORE_BUILD_TARGET) { if ('web' !== process.env.FLECKS_CORE_BUILD_TARGET) {
this.$$informedEntities.delete(entity); this.$$informedEntities.delete(entity);
} }
// eslint-disable-next-line no-param-reassign
entity.list = null; entity.list = null;
entity.emit('removedFromList', this); entity.emit('removedFromList', this);
delete this.$$entities[uuid]; delete this.$$entities[uuid];

View File

@ -25,7 +25,6 @@ export default (flecks) => class Spawner extends decorate(Trait) {
// eslint-disable-next-line class-methods-use-this // eslint-disable-next-line class-methods-use-this
augmentJSONWithPosition(json, position) { augmentJSONWithPosition(json, position) {
/* eslint-disable no-param-reassign */
if (!json.traits) { if (!json.traits) {
json.traits = {}; json.traits = {};
} }
@ -39,7 +38,6 @@ export default (flecks) => class Spawner extends decorate(Trait) {
json.traits.Positioned.state.x, json.traits.Positioned.state.x,
json.traits.Positioned.state.y, json.traits.Positioned.state.y,
] = position; ] = position;
/* eslint-enable no-param-reassign */
return json; return json;
} }

View File

@ -28,14 +28,12 @@ const Stage = forwardRef(({
deltaX, deltaX,
deltaY, deltaY,
} = event; } = event;
/* eslint-disable no-param-reassign */
if (-1 !== ['touchstart', 'touchmove'].indexOf(event.type)) { if (-1 !== ['touchstart', 'touchmove'].indexOf(event.type)) {
clientX = event.touches[0].clientX; clientX = event.touches[0].clientX;
deltaX = event.touches[0].deltaX; deltaX = event.touches[0].deltaX;
clientY = event.touches[0].clientY; clientY = event.touches[0].clientY;
deltaY = event.touches[0].deltaY; deltaY = event.touches[0].deltaY;
} }
/* eslint-enable no-param-reassign */
const {left, top} = event.target.getBoundingClientRect(); const {left, top} = event.target.getBoundingClientRect();
Object.defineProperty( Object.defineProperty(
event, event,
@ -73,12 +71,10 @@ const Stage = forwardRef(({
if (!renderable) { if (!renderable) {
return; return;
} }
/* eslint-disable no-param-reassign */
renderable.scale = [scale, scale]; renderable.scale = [scale, scale];
if (centered) { if (centered) {
renderable.position = Vector.scale(size, 0.5); renderable.position = Vector.scale(size, 0.5);
} }
/* eslint-enable no-param-reassign */
}, [centered, renderable, scale, size]); }, [centered, renderable, scale, size]);
useEffect(() => { useEffect(() => {
if (!renderer) { if (!renderer) {

View File

@ -32,7 +32,6 @@ export default class Container extends Renderable {
return; return;
} }
const {parent} = child; const {parent} = child;
// eslint-disable-next-line no-param-reassign
child.parent = this; child.parent = this;
child.emit('parentChanged', parent, child.parent); child.emit('parentChanged', parent, child.parent);
this.isDirty = true; this.isDirty = true;

View File

@ -153,7 +153,6 @@ export default (flecks) => {
this.$$images = images; this.$$images = images;
this.$$sprites = await mapValuesAsync(this.$$images, async (image) => new Sprite(image)); this.$$sprites = await mapValuesAsync(this.$$images, async (image) => new Sprite(image));
Object.keys(this.$$sprites).forEach((key) => { Object.keys(this.$$sprites).forEach((key) => {
// eslint-disable-next-line no-param-reassign
this.$$sprites[key].position = this.offsetFor(key); this.$$sprites[key].position = this.offsetFor(key);
}); });
} }

View File

@ -16,7 +16,6 @@ export default class InputPacket extends Packet {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
const {action} = data[i]; const {action} = data[i];
const actionId = this.actionIds[action]; const actionId = this.actionIds[action];
// eslint-disable-next-line no-param-reassign
data[i].action = actionId; data[i].action = actionId;
} }
return data; return data;
@ -29,7 +28,6 @@ export default class InputPacket extends Packet {
static unpack(data) { static unpack(data) {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
const actionId = data[i].action; const actionId = data[i].action;
// eslint-disable-next-line no-param-reassign
data[i].action = this.idActions[actionId]; data[i].action = this.idActions[actionId];
} }
return data; return data;

View File

@ -34,14 +34,12 @@ export default (key) => (Superclass) => {
); );
PackedVectorPacket.pack = key PackedVectorPacket.pack = key
? (data) => { ? (data) => {
// eslint-disable-next-line no-param-reassign
data[key] = packToUint32(data[key]); data[key] = packToUint32(data[key]);
return Superclass.pack(data); return Superclass.pack(data);
} }
: (data) => packToUint32(data); : (data) => packToUint32(data);
PackedVectorPacket.unpack = key PackedVectorPacket.unpack = key
? (data) => { ? (data) => {
// eslint-disable-next-line no-param-reassign
data[key] = unpackFromUint32(data[key]); data[key] = unpackFromUint32(data[key]);
return Superclass.unpack(data); return Superclass.unpack(data);
} }

View File

@ -153,10 +153,8 @@ export function cross(l, r) {
// avocado> Vector.dot [2, 3], [4, 5] // avocado> Vector.dot [2, 3], [4, 5]
// 23 // 23
export function dot(l, r) { export function dot(l, r) {
if (!r) { // eslint-disable-next-line no-param-reassign
// eslint-disable-next-line no-param-reassign if (!r) r = l;
r = l;
}
return l[0] * r[0] + l[1] * r[1]; return l[0] * r[0] + l[1] * r[1];
} }

View File

@ -22,7 +22,6 @@ export default class AbstractWorld extends decorate(Class) {
associateBodyWithEntity(body, entity) { associateBodyWithEntity(body, entity) {
this.entities.set(body, entity); this.entities.set(body, entity);
this.entitiesList.push(entity); this.entitiesList.push(entity);
// eslint-disable-next-line no-param-reassign
body.position = entity.position; body.position = entity.position;
} }
@ -35,7 +34,6 @@ export default class AbstractWorld extends decorate(Class) {
this.entitiesList.splice(index, 1); this.entitiesList.splice(index, 1);
} }
} }
// eslint-disable-next-line no-param-reassign
body.world = null; body.world = null;
} }

View File

@ -27,7 +27,6 @@ export default class World extends AbstractWorld {
addToQuadTree(body) { addToQuadTree(body) {
const {aabb} = body; const {aabb} = body;
const expandedAabb = Rectangle.expand(aabb, [32, 32]); const expandedAabb = Rectangle.expand(aabb, [32, 32]);
// eslint-disable-next-line no-param-reassign
body.quadTreeAabb = expandedAabb; body.quadTreeAabb = expandedAabb;
this.quadTree.add(body, expandedAabb); this.quadTree.add(body, expandedAabb);
} }
@ -48,7 +47,6 @@ export default class World extends AbstractWorld {
removeFromQuadTree(body) { removeFromQuadTree(body) {
this.quadTree.remove(body); this.quadTree.remove(body);
// eslint-disable-next-line no-param-reassign
body.quadTreeAabb = []; body.quadTreeAabb = [];
} }

View File

@ -9,13 +9,11 @@ export default (EntityList) => class PhysicsEntityList extends EntityList {
} }
onEntityAdded(entity) { onEntityAdded(entity) {
// eslint-disable-next-line no-param-reassign
entity.world = this.$$world; entity.world = this.$$world;
} }
// eslint-disable-next-line class-methods-use-this // eslint-disable-next-line class-methods-use-this
onEntityRemoved(entity) { onEntityRemoved(entity) {
// eslint-disable-next-line no-param-reassign
entity.world = null; entity.world = null;
} }

View File

@ -25,7 +25,6 @@ export default (Room) => class PhysicsRoom extends Room {
this.world = world; this.world = world;
this.entityList.world = world; this.entityList.world = world;
this.tiles.forEach((tiles) => { this.tiles.forEach((tiles) => {
// eslint-disable-next-line no-param-reassign
tiles.world = world; tiles.world = world;
}); });
if (Vector.isZero(this.size)) { if (Vector.isZero(this.size)) {
@ -54,7 +53,6 @@ export default (Room) => class PhysicsRoom extends Room {
})), })),
]; ];
bounds.forEach((bound) => { bounds.forEach((bound) => {
// eslint-disable-next-line no-param-reassign
bound.static = true; bound.static = true;
world.addBody(bound); world.addBody(bound);
}); });

View File

@ -261,13 +261,11 @@ export default (flecks) => class Emitter extends decorate(Trait) {
return; return;
} }
particle.body.setPosition([particle.p.x, particle.p.y]); particle.body.setPosition([particle.p.x, particle.p.y]);
/* eslint-disable no-param-reassign */
particle.body.opacity = particle.alpha; particle.body.opacity = particle.alpha;
if (particle.particle.scale) { if (particle.particle.scale) {
particle.body.visibleScale = [particle.scale, particle.scale]; particle.body.visibleScale = [particle.scale, particle.scale];
} }
particle.body.rotation = particle.rotation * PI_180; particle.body.rotation = particle.rotation * PI_180;
/* eslint-enable no-param-reassign */
} }
packetsFor() { packetsFor() {

View File

@ -50,7 +50,6 @@ const Number = ({
input.removeEventListener('wheel', onWheel, {passive: false}); input.removeEventListener('wheel', onWheel, {passive: false});
}; };
}); });
// eslint-disable-next-line no-param-reassign
step = parser(step); step = parser(step);
return ( return (
<div className="number"> <div className="number">

View File

@ -5,7 +5,6 @@ import SynchronizedPacket from './synchronized';
export default class SynchronizedCreatePacket extends SynchronizedPacket { export default class SynchronizedCreatePacket extends SynchronizedPacket {
static pack(data) { static pack(data) {
// eslint-disable-next-line no-param-reassign
data.spec = msgpack.encode(data.spec); data.spec = msgpack.encode(data.spec);
return data; return data;
} }
@ -21,7 +20,6 @@ export default class SynchronizedCreatePacket extends SynchronizedPacket {
} }
static unpack(data) { static unpack(data) {
// eslint-disable-next-line no-param-reassign
data.spec = msgpack.decode(data.spec); data.spec = msgpack.decode(data.spec);
return data; return data;
} }

View File

@ -4,7 +4,6 @@ export default (flecks) => class SynchronizedUpdatePacket extends SynchronizedPa
static pack(data) { static pack(data) {
const {Bundle} = flecks.get('$flecks/socket.packets'); const {Bundle} = flecks.get('$flecks/socket.packets');
// eslint-disable-next-line no-param-reassign
data.packets = Bundle.encode(data.packets); data.packets = Bundle.encode(data.packets);
return data; return data;
} }
@ -21,7 +20,6 @@ export default (flecks) => class SynchronizedUpdatePacket extends SynchronizedPa
static unpack(data) { static unpack(data) {
const {Bundle} = flecks.get('$flecks/socket.packets'); const {Bundle} = flecks.get('$flecks/socket.packets');
// eslint-disable-next-line no-param-reassign
data.packets = Bundle.decode(data.packets); data.packets = Bundle.decode(data.packets);
return data; return data;
} }

View File

@ -175,7 +175,6 @@ export default (flecks) => class Animated extends decorate(Trait) {
: 'hideAnimation'; : 'hideAnimation';
this[method](key); this[method](key);
if (this.entity.is('Directional')) { if (this.entity.is('Directional')) {
// eslint-disable-next-line no-param-reassign
animation.direction = this.entity.direction; animation.direction = this.entity.direction;
} }
}); });
@ -203,7 +202,6 @@ export default (flecks) => class Animated extends decorate(Trait) {
(animation) => new AnimationView(animation), (animation) => new AnimationView(animation),
); );
Object.entries(animationViews).forEach(([key, animationView]) => { Object.entries(animationViews).forEach(([key, animationView]) => {
// eslint-disable-next-line no-param-reassign
animationView.position = this.offsetFor(key); animationView.position = this.offsetFor(key);
}); });
this.$$animations = animations; this.$$animations = animations;

View File

@ -39,7 +39,6 @@ const RoomRenderable = ({camera, styles, room}) => {
return undefined; return undefined;
} }
const halfViewport = Vector.scale(viewSize, 0.5); const halfViewport = Vector.scale(viewSize, 0.5);
// eslint-disable-next-line no-param-reassign
camera.realPosition = camera.position; camera.realPosition = camera.position;
const onCameraRealOffsetChanged = () => { const onCameraRealOffsetChanged = () => {
roomRenderable.renderChunksForExtent(camera.rectangle); roomRenderable.renderChunksForExtent(camera.rectangle);

View File

@ -24,10 +24,8 @@ const RoomUi = forwardRef(
// Manage entities' relationship with the DOM. // Manage entities' relationship with the DOM.
const onEntityAdded = async (entity) => { const onEntityAdded = async (entity) => {
if (entity.is('DomNode')) { if (entity.is('DomNode')) {
/* eslint-disable no-param-reassign */
[entity.domScaleX, entity.domScaleY] = domScale; [entity.domScaleX, entity.domScaleY] = domScale;
entity.parentNode = ref.current.querySelector(`.${styles.entities}`); entity.parentNode = ref.current.querySelector(`.${styles.entities}`);
/* eslint-enable no-param-reassign */
} }
}; };
// Existing entities. // Existing entities.

View File

@ -92,7 +92,6 @@ function TilesPage({
}; };
const visibility = calculateVisibility(mute, solo); const visibility = calculateVisibility(mute, solo);
for (let i = 0; i < visibility.length; i++) { for (let i = 0; i < visibility.length; i++) {
// eslint-disable-next-line no-param-reassign
roomRenderable.tilesRenderables[i].alpha = visibility[i] ? 1 : 0; roomRenderable.tilesRenderables[i].alpha = visibility[i] ? 1 : 0;
} }
}, [mute, roomRenderable, solo]); }, [mute, roomRenderable, solo]);

View File

@ -75,14 +75,12 @@ export default (flecks) => {
} }
onEntityAdded(entity) { onEntityAdded(entity) {
// eslint-disable-next-line no-param-reassign
entity.room = this; entity.room = this;
entity.emit('addedToRoom'); entity.emit('addedToRoom');
this.emit('entityAdded', entity); this.emit('entityAdded', entity);
} }
onEntityRemoved(entity) { onEntityRemoved(entity) {
// eslint-disable-next-line no-param-reassign
entity.room = null; entity.room = null;
entity.emit('removedFromRoom', this); entity.emit('removedFromRoom', this);
this.emit('entityRemoved', entity); this.emit('entityRemoved', entity);