Skip to content

Commit ec98f60

Browse files
committed
Fix linting issues
1 parent 06102fb commit ec98f60

File tree

58 files changed

+253
-458
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+253
-458
lines changed

eslint.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default tseslint.config(
3333
'lib/buildtools/src/build/__test_mocks__',
3434
'lib/lintplugin/dist.js',
3535
'src/**/samples/**',
36+
'src/bundles/scrabble/src/words.json', // Don't lint this because its way too big
3637
'src/java/**',
3738
'package-lock.json' // Just in case someone accidentally creates one
3839
]
@@ -134,6 +135,8 @@ export default tseslint.config(
134135
'jsdoc/require-asterisk-prefix': 'warn',
135136

136137
'@stylistic/brace-style': ['warn', '1tbs', { allowSingleLine: true }],
138+
'@stylistic/function-call-spacing': ['warn', 'never'],
139+
'@stylistic/function-paren-newline': ['warn', 'multiline-arguments'],
137140
'@stylistic/quotes': ['warn', 'single', { avoidEscape: true }],
138141
'@stylistic/semi': ['warn', 'always'],
139142
}
@@ -169,8 +172,6 @@ export default tseslint.config(
169172
'@typescript-eslint/prefer-ts-expect-error': 'warn',
170173
'@typescript-eslint/sort-type-constituents': 'warn',
171174

172-
'@stylistic/function-call-spacing': ['warn', 'never'],
173-
'@stylistic/function-paren-newline': ['warn', 'multiline'],
174175
'@stylistic/type-annotation-spacing': ['warn', { overrides: { colon: { before: false, after: true }}}],
175176
}
176177
},

lib/buildtools/src/build/docs/html.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ export const {
2727
message: `${error}`
2828
};
2929
}
30-
});
30+
}
31+
);

lib/buildtools/src/build/modules/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ export async function buildTabs(resolvedBundles: Record<string, ResolvedBundle>,
3737
}
3838

3939
return runBuilderWithPrebuild(buildTab, prebuildOpts, tab, outDir, undefined);
40-
}));
40+
})
41+
);
4142
}

lib/buildtools/src/commands/__tests__/main.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ describe('Make sure that all subcommands can execute', () => {
99
mainCommand.commands.map(command => test(
1010
`Test ${command.name()}`,
1111
() => expect(command.parseAsync(['--help'], { from: 'user' }))
12-
.commandExit(0))
13-
);
12+
.commandExit(0)
13+
));
1414
});

lib/buildtools/src/commands/__tests__/template.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const mockedAskQuestion = vi.mocked(askQuestion);
4141

4242
function expectCall<T extends(...args: any) => any>(
4343
func: T,
44-
...expected: Parameters<T>[]) {
44+
...expected: Parameters<T>[]
45+
) {
4546
const mocked = vi.mocked(func);
4647

4748
expect(func)

lib/modules-lib/src/type_map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface TypeMapUtilities {
2222
* used to populate it
2323
*/
2424
export default function createTypeMap(): TypeMapUtilities {
25-
const type_map : Record<string, string> = {};
25+
const type_map: Record<string, string> = {};
2626

2727
function registerType(name: string, declaration: string) {
2828
if (name === 'prelude') {

src/bundles/ar/src/AR.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ export function addARObject(arObject: ARObject) {
147147
export function removeARObject(arObject: ARObject) {
148148
const moduleState = getModuleState();
149149
if (!moduleState) return;
150-
moduleState.arObjects = moduleState.arObjects.filter(
151-
(item) => item.id !== arObject.id,
152-
);
150+
moduleState.arObjects = moduleState.arObjects.filter((item) => item.id !== arObject.id,);
153151
callARCallback();
154152
}
155153

@@ -265,9 +263,7 @@ export function setFrontObject(arObject: ARObject | undefined) {
265263
export function getFrontObject() {
266264
const moduleState = getModuleState();
267265
if (!moduleState) return undefined;
268-
return moduleState.arObjects.find(
269-
(arObject) => arObject.id === moduleState.selectedObjectId,
270-
);
266+
return moduleState.arObjects.find((arObject) => arObject.id === moduleState.selectedObjectId,);
271267
}
272268

273269
/**

src/bundles/arcade_2d/src/gameobject.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ export abstract class GameObject implements Transformable, ReplResult {
1818
protected isTransformUpdated: boolean = false;
1919
public readonly id: number;
2020

21-
constructor(
22-
private transformProps: types.TransformProps = DEFAULT_TRANSFORM_PROPS
23-
) {
21+
constructor(private transformProps: types.TransformProps = DEFAULT_TRANSFORM_PROPS) {
2422
this.id = GameObject.gameObjectCount++;
2523
}
2624
setTransform(transformProps: types.TransformProps) {

src/bundles/arcade_2d/src/index.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212
*
1313
* ### WASD input example
1414
* ```
15-
import { create_rectangle, query_position, update_position, update_loop, build_game, input_key_down } from "arcade_2d";
16-
17-
// Create GameObjects outside update_loop(...)
18-
const player = update_position(create_rectangle(100, 100), [300, 300]);
19-
const movement_dist = 10;
20-
21-
function add_vectors(to, from) {
22-
to[0] = to[0] + from[0];
23-
to[1] = to[1] + from[1];
24-
}
25-
26-
update_loop(game_state => {
27-
const new_position = query_position(player);
28-
29-
if (input_key_down("w")) {
15+
* import { create_rectangle, query_position, update_position, update_loop, build_game, input_key_down } from "arcade_2d";
16+
*
17+
* // Create GameObjects outside update_loop(...)
18+
* const player = update_position(create_rectangle(100, 100), [300, 300]);
19+
* const movement_dist = 10;
20+
*
21+
* function add_vectors(to, from) {
22+
* to[0] = to[0] + from[0];
23+
* to[1] = to[1] + from[1];
24+
* }
25+
*
26+
* update_loop(game_state => {
27+
* const new_position = query_position(player);
28+
*
29+
* if (input_key_down("w")) {
3030
add_vectors(new_position, [0, -1 * movement_dist]);
3131
}
3232
if (input_key_down("a")) {
@@ -38,7 +38,7 @@ update_loop(game_state => {
3838
if (input_key_down("d")) {
3939
add_vectors(new_position, [movement_dist, 0]);
4040
}
41-
41+
4242
// Update GameObjects within update_loop(...)
4343
update_position(player, new_position);
4444
});
@@ -48,20 +48,20 @@ build_game();
4848
* ### Draggable objects example
4949
* ```
5050
import { create_sprite, update_position, update_scale, pointer_over_gameobject, input_left_mouse_down, update_to_top, query_pointer_position, update_loop, build_game } from "arcade_2d";
51-
51+
5252
// Using assets
5353
const gameobjects = [
5454
update_position(create_sprite("objects/cmr/splendall.png"), [200, 400]),
5555
update_position(update_scale(create_sprite("avatars/beat/beat.happy.png"), [0.3, 0.3]), [300, 200]),
5656
update_position(update_scale(create_sprite("avatars/chieftain/chieftain.happy.png"), [0.2, 0.2]), [400, 300])];
57-
57+
5858
// Simple dragging function
5959
function drag_gameobject(gameobject) {
6060
if (input_left_mouse_down() && pointer_over_gameobject(gameobject)) {
6161
update_to_top(update_position(gameobject, query_pointer_position()));
6262
}
6363
}
64-
64+
6565
update_loop(game_state => {
6666
for (let i = 0; i < 3; i = i + 1) {
6767
drag_gameobject(gameobjects[i]);
@@ -73,7 +73,7 @@ build_game();
7373
* ### Playing audio example
7474
* ```
7575
import { input_key_down, create_audio, play_audio, update_loop, build_game } from "arcade_2d";
76-
76+
7777
const audio = create_audio("https://labs.phaser.io/assets/audio/SoundEffects/key.wav", 1);
7878
update_loop(game_state => {
7979
// Press space to play audio
@@ -87,15 +87,15 @@ build_game();
8787
*
8888
* ```
8989
import { create_rectangle, update_position, update_color, get_loop_count, set_scale, update_loop, build_game } from "arcade_2d";
90-
90+
9191
const gameobjects = [];
9292
for (let i = 0; i < 100; i = i + 1) {
9393
gameobjects[i] = [];
9494
for (let j = 0; j < 100; j = j + 1) {
9595
gameobjects[i][j] = update_position(create_rectangle(1, 1), [i, j]);
9696
}
9797
}
98-
98+
9999
update_loop(game_state => {
100100
const k = get_loop_count();
101101
for (let i = 0; i < 100; i = i + 1) {
@@ -112,31 +112,31 @@ build_game();
112112
* ```
113113
import { create_rectangle, create_sprite, create_text, query_position, update_color, update_position, update_scale, update_text, update_to_top, set_fps, get_loop_count, enable_debug, debug_log, input_key_down, gameobjects_overlap, update_loop, build_game, create_audio, loop_audio, stop_audio, play_audio } from "arcade_2d";
114114
// enable_debug(); // Uncomment this to see debug info
115-
115+
116116
// Constants
117117
let snake_length = 4;
118118
const food_growth = 4;
119119
set_fps(10);
120-
120+
121121
const snake = [];
122122
const size = 600;
123123
const unit = 30;
124124
const grid = size / unit;
125125
const start_length = snake_length;
126-
126+
127127
// Create Sprite Gameobjects
128128
update_scale(create_sprite("https://labs.phaser.io/assets/games/germs/background.png"), [4, 4]); // Background
129129
const food = create_sprite("https://labs.phaser.io/assets/sprites/tomato.png");
130130
let eaten = true;
131-
131+
132132
for (let i = 0; i < 1000; i = i + 1) {
133133
snake[i] = update_color(update_position(create_rectangle(unit, unit), [-unit / 2, -unit / 2]),
134134
[127 + 128 * math_sin(i / 20), 127 + 128 * math_sin(i / 50), 127 + 128 * math_sin(i / 30), 255]); // Store offscreen
135135
}
136136
const snake_head = update_color(update_position(create_rectangle(unit * 0.9, unit * 0.9), [-unit / 2, -unit / 2]), [0, 0, 0 ,0]); // Head
137-
137+
138138
let move_dir = [unit, 0];
139-
139+
140140
// Other functions
141141
const add_vec = (v1, v2) => [v1[0] + v2[0], v1[1] + v2[1]];
142142
const bound_vec = v => [(v[0] + size) % size, (v[1] + size) % size];
@@ -156,49 +156,49 @@ function input() {
156156
}
157157
}
158158
let alive = true;
159-
159+
160160
// Create Text Gameobjects
161161
const score = update_position(create_text("Score: "), [size - 60, 20]);
162162
const game_text = update_color(update_scale(update_position(create_text(""), [size / 2, size / 2]), [2, 2]), [0, 0, 0, 255]);
163-
163+
164164
// Audio
165165
const eat = create_audio("https://labs.phaser.io/assets/audio/SoundEffects/key.wav", 1);
166166
const lose = create_audio("https://labs.phaser.io/assets/audio/stacker/gamelost.m4a", 1);
167167
const move = create_audio("https://labs.phaser.io/assets/audio/SoundEffects/alien_death1.wav", 1);
168168
const bg_audio = play_audio(loop_audio(create_audio("https://labs.phaser.io/assets/audio/tech/bass.mp3", 0.5)));
169-
169+
170170
// Create Update loop
171171
update_loop(game_state => {
172172
update_text(score, "Score: " + stringify(snake_length - start_length));
173173
if (!alive) {
174174
update_text(game_text, "Game Over!");
175175
return undefined;
176176
}
177-
177+
178178
// Move snake
179179
for (let i = snake_length - 1; i > 0; i = i - 1) {
180180
update_position(snake[i], query_position(snake[i - 1]));
181181
}
182182
update_position(snake[0], query_position(snake_head)); // Update head
183183
update_position(snake_head, bound_vec(add_vec(query_position(snake_head), move_dir))); // Update head
184184
debug_log(query_position(snake[0])); // Head
185-
185+
186186
input();
187-
187+
188188
// Add food
189189
if (eaten) {
190190
update_position(food, [math_floor(math_random() * grid) * unit + unit / 2, math_floor(math_random() * grid) * unit + unit / 2]);
191191
eaten = false;
192192
}
193-
193+
194194
// Eat food
195195
if (get_loop_count() > 1 && gameobjects_overlap(snake_head, food)) {
196196
eaten = true;
197197
snake_length = snake_length + food_growth;
198198
play_audio(eat);
199199
}
200200
debug_log(snake_length); // Score
201-
201+
202202
// Check collision
203203
if (get_loop_count() > start_length) {
204204
for (let i = 0; i < snake_length; i = i + 1) {

src/bundles/arcade_2d/src/phaserScene.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,11 @@ export class PhaserScene extends Phaser.Scene {
201201
shape.radius
202202
));
203203
if (gameObject.getHitboxState().isHitboxActive) {
204-
this.phaserGameObjects[gameObject.id].setInteractive(
205-
new Phaser.Geom.Circle(
206-
shape.radius,
207-
shape.radius,
208-
shape.radius
209-
), Phaser.Geom.Circle.Contains
210-
);
204+
this.phaserGameObjects[gameObject.id].setInteractive(new Phaser.Geom.Circle(
205+
shape.radius,
206+
shape.radius,
207+
shape.radius
208+
), Phaser.Geom.Circle.Contains);
211209
}
212210
}
213211
if (gameObject instanceof TriangleGameObject) {
@@ -223,16 +221,14 @@ export class PhaserScene extends Phaser.Scene {
223221
shape.y3
224222
));
225223
if (gameObject.getHitboxState().isHitboxActive) {
226-
this.phaserGameObjects[gameObject.id].setInteractive(
227-
new Phaser.Geom.Triangle(
228-
shape.x1,
229-
shape.y1,
230-
shape.x2,
231-
shape.y2,
232-
shape.x3,
233-
shape.y3
234-
), Phaser.Geom.Triangle.Contains
235-
);
224+
this.phaserGameObjects[gameObject.id].setInteractive(new Phaser.Geom.Triangle(
225+
shape.x1,
226+
shape.y1,
227+
shape.x2,
228+
shape.y2,
229+
shape.x3,
230+
shape.y3
231+
), Phaser.Geom.Triangle.Contains);
236232
}
237233
}
238234
}
@@ -287,9 +283,7 @@ export class PhaserScene extends Phaser.Scene {
287283
gameState.debugLogArray.push(`${error.name}: ${error.message}`);
288284
} else {
289285
const exceptionError = error as ExceptionError;
290-
gameState.debugLogArray.push(
291-
`Line ${exceptionError.location.start.line}: ${exceptionError.error.name}: ${exceptionError.error.message}`
292-
);
286+
gameState.debugLogArray.push(`Line ${exceptionError.location.start.line}: ${exceptionError.error.name}: ${exceptionError.error.message}`);
293287
}
294288
}
295289
}

0 commit comments

Comments
 (0)