Skip to content

Commit

Permalink
Add svelte eslint plugin
Browse files Browse the repository at this point in the history
Update enemies initialization
Debug application build
Fix linters errors
  • Loading branch information
UstymUkhman committed Dec 27, 2022
1 parent 2a6205c commit 3bc92df
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 53 deletions.
18 changes: 16 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["svelte3", "@typescript-eslint"],

"extends": [
"plugin:@typescript-eslint/recommended",
Expand All @@ -12,23 +13,36 @@
"sourceType": "module"
},

"plugins": ["@typescript-eslint"],
"overrides": [{
"processor": "svelte3/svelte3",
"files": ["*.svelte"]
}],

"rules": {
"@typescript-eslint/no-unused-vars": [2, {"vars": "local", "args": "after-used"}],
"@typescript-eslint/no-unused-vars": [2, {
"vars": "local", "args": "after-used"
}],

"@typescript-eslint/no-redeclare": 2,
"@typescript-eslint/no-namespace": 0,

"generator-star-spacing": 0,
"quotes": [2, "single"],
"no-unused-vars": 0,

"no-redeclare": 0,
"comma-dangle": 2,
"no-debugger": 1,

"no-console": 0,
"no-undef": 0,
"semi": 2
},

"settings": {
"svelte3/typescript": true
},

"globals": {
"navigator": false,
"document": false,
Expand Down
32 changes: 16 additions & 16 deletions .stylelintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@
"extends": "stylelint-config-standard",

"overrides": [{
"files": ["**/*.svelte"],
"customSyntax": "postcss-html"
"customSyntax": "postcss-html",
"files": ["**/*.svelte"]
}],

"rules": {
"at-rule-no-unknown": [true, {
"ignoreAtRules": [
"at-root", "include", "use", "mixin", "function",
"content", "for", "each", "if", "else", "return"
]
}],

"selector-pseudo-class-no-unknown": [true, {
"ignorePseudoClasses": ["global", "export"]
}],

"no-invalid-position-at-import-rule": null,
"block-closing-brace-newline-after": null,
"declaration-empty-line-before": null,
"selector-no-qualifying-type": null,
"function-comma-space-after": null,
"comment-empty-line-before": null,
"at-rule-empty-line-before": null,

"number-no-trailing-zeros": null,
"color-function-notation": null,
"rule-empty-line-before": null,
"length-zero-no-unit": null,
"function-name-case": null,
"color-hex-length": null,
"max-nesting-depth": 3,

"at-rule-no-unknown": [true, {
"ignoreAtRules": [
"at-root", "include", "use", "mixin", "function",
"content", "for", "each", "if", "else", "return"
]
}],

"selector-pseudo-class-no-unknown": [true, {
"ignorePseudoClasses": [
"global", "export"
]
}]
"import-notation": null,
"max-nesting-depth": 3
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"electron": "^21.1.1",
"electron-builder": "^23.6.0",
"eslint": "^8.25.0",
"eslint-plugin-svelte3": "^4.0.0",
"fake-indexeddb": "^4.0.0",
"jest-canvas-mock": "^2.4.0",
"jsdom": "^20.0.1",
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions src/components/map/BorderRifle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@
borderRotation = angle - playerRotation;
}
$: (angle => {
if (!playerRotation) return;
updateBorderRotation();
})(angle);
$: (playerRotation => {
if (!angle) return;
updateBorderRotation();
})(playerRotation);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
$: (_ => playerRotation && updateBorderRotation())(angle);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
$: (_ => angle && updateBorderRotation())(playerRotation);
</script>

<style lang="scss">
Expand Down
2 changes: 1 addition & 1 deletion src/components/map/Map.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
}
function drawBounds (): void {
context = map.getContext('2d') as CanvasRenderingContext2D;
const nBounds = getNormalizedBounds();
context = map.getContext('2d')!;
context.strokeStyle = '#000';
context.lineWidth = 2.0;
Expand Down
2 changes: 1 addition & 1 deletion src/components/menu/Screen.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
dispatch('hide');
await tick();
dispatch('update', false)
dispatch('update', false);
}
function settingsUpdated (): void {
Expand Down
2 changes: 1 addition & 1 deletion src/components/overlay/Raindrops.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
const height = Viewport.size.height;
const width = Viewport.size.width;
// @ts-expect-error
// @ts-expect-error - Optional:
let canvas: HTMLCanvasElement;
export let updating = false;
let visible = false;
Expand Down
15 changes: 1 addition & 14 deletions src/components/scss/animations.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
@use "sass:math";

/* @keyframes loading {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
} */

@keyframes shoot {
0% {
transform: scale(1);
Expand All @@ -30,6 +16,7 @@

@keyframes pulse {
0% {
// stylelint-disable-next-line function-no-unknown
transform: scale(math.div(1, 3));
opacity: 1;
}
Expand Down
1 change: 1 addition & 0 deletions src/components/scss/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
}

@mixin font-size ($size) {
// stylelint-disable-next-line function-no-unknown
letter-spacing: string.unquote("0.#{$size}rem");
line-height: #{$size}vw;
font-size: #{$size}vw;
Expand Down
11 changes: 4 additions & 7 deletions src/managers/Enemies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ export default class Enemies
private spawnedEnemies = 0;

public constructor (private readonly envMap: Texture) {
(new Enemy).loadCharacter(envMap).then(model =>
this.enemyModel = model
);
(new Enemy).loadCharacter(envMap).then(model => {
this.enemyModel = model;
this.spawnEnemy([0.0, 0.0]);
});

this.addEvents();
}
Expand Down Expand Up @@ -87,10 +88,6 @@ export default class Enemies
}
}

public spawnFirst (): void {
this.spawnEnemy([0.0, 0.0]);
}

public spawnMultiple (x: number, z: number, enemies = 2): void {
const spawned = this.enemies.length - 1;
enemies = Math.min(Configs.Gameplay.maxEnemies - spawned, enemies);
Expand Down
3 changes: 1 addition & 2 deletions src/managers/MainLoop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,13 @@ export default class MainLoop
this.player.setPistol(this.level.walls, this.pistol);
Physics.setCharacter(this.player.collider, 90);

this.enemies = new Enemies(envMap);
this.player.addRifle(this.rifle);
this.enemies.spawnFirst();

this.createRandomCoords();
RAF.add(this.loop);
});

this.enemies = new Enemies(envMap);
this.pistol = new Pistol(envMap);
this.rifle = new Rifle(envMap);
}
Expand Down

0 comments on commit 3bc92df

Please sign in to comment.