Skip to content

Commit

Permalink
refactor: 💡 Run linter on codebase
Browse files Browse the repository at this point in the history
✅ Closes: #151
  • Loading branch information
MadejaMaciej committed Apr 17, 2024
1 parent 3263c98 commit ffa19ab
Show file tree
Hide file tree
Showing 131 changed files with 3,725 additions and 2,867 deletions.
77 changes: 38 additions & 39 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
// Here we can disable eslint, as this is config that does not support ES6 modules. Disabling the rule.
const { version } = require('jest/package.json');
const { version } = require("jest/package.json");

module.exports = {
parser: '@typescript-eslint/parser',
parser: "@typescript-eslint/parser",
extends: [
'airbnb-base',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:jest/recommended',
'plugin:jest/style',
'plugin:prettier/recommended',
"airbnb-base",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:jest/style",
"plugin:prettier/recommended",
],
plugins: ['jest', '@typescript-eslint', 'prettier'],
plugins: ["jest", "@typescript-eslint", "prettier"],
globals: {
fetch: true,
},
parserOptions: {
allowImportExportEverywhere: true,
requireConfigFile: false,
ecmaVersion: 2022,
sourceType: 'module',
sourceType: "module",
},
env: {
node: true,
jest: true,
'jest/globals': true,
"jest/globals": true,
es6: true,
},
settings: {
Expand All @@ -33,46 +32,46 @@ module.exports = {
},
},
rules: {
'class-methods-use-this': 'warn',
'consistent-return': 'warn',
'global-require': 'warn',
'import/no-extraneous-dependencies': 'warn',
'max-classes-per-file': 'off',
'no-continue': 'warn',
'no-underscore-dangle': 'warn',
'no-use-before-define': 'warn',
'no-return-assign': 'warn',
'no-shadow': 'warn',
camelcase: 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'import/no-unused-modules': [1, { unusedExports: true }],
'import/no-unresolved': 'off',
'import/extensions': 'off',
'no-restricted-syntax': [
'error',
"class-methods-use-this": "warn",
"consistent-return": "warn",
"global-require": "warn",
"import/no-extraneous-dependencies": "warn",
"max-classes-per-file": "off",
"no-continue": "warn",
"no-underscore-dangle": "warn",
"no-use-before-define": "warn",
"no-return-assign": "warn",
"no-shadow": "warn",
camelcase: "warn",
"@typescript-eslint/no-explicit-any": "warn",
"import/no-unused-modules": [1, { unusedExports: true }],
"import/no-unresolved": "off",
"import/extensions": "off",
"no-restricted-syntax": [
"error",
{
selector: 'ForInStatement',
selector: "ForInStatement",
message:
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
"for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.",
},
{
selector: 'LabeledStatement',
selector: "LabeledStatement",
message:
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
"Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
},
{
selector: 'WithStatement',
selector: "WithStatement",
message:
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
"`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
},
],
semi: ['off', 'never'],
'prettier/prettier': [
'error',
semi: ["off", "never"],
"prettier/prettier": [
"error",
{
printWidth: 100,
singleQuote: true,
endOfLine: 'auto',
endOfLine: "auto",
},
],
},
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Lost Dutchman Mine Change Log
0.2.2 April 21, 2024
-------------------

- Ref #151: Run linter and formatter on codebases (MadejaMaciej)

- Bug #116: Add favicon in web version (MadejaMaciej)
- Bug #115: Change app icon in build (MadejaMaciej)
- Bug #111: Fix sounds on web version (MadejaMaciej)
Expand Down
16 changes: 0 additions & 16 deletions code-desktop/.eslintrc.json

This file was deleted.

37 changes: 21 additions & 16 deletions code-desktop/forge.config.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
import type { ForgeConfig } from '@electron-forge/shared-types';
import { MakerSquirrel } from '@electron-forge/maker-squirrel';
import { MakerZIP } from '@electron-forge/maker-zip';
import { MakerDeb } from '@electron-forge/maker-deb';
import { MakerRpm } from '@electron-forge/maker-rpm';
import { AutoUnpackNativesPlugin } from '@electron-forge/plugin-auto-unpack-natives';
import { WebpackPlugin } from '@electron-forge/plugin-webpack';
import { FusesPlugin } from '@electron-forge/plugin-fuses';
import { FuseV1Options, FuseVersion } from '@electron/fuses';
import type { ForgeConfig } from "@electron-forge/shared-types";
import { MakerSquirrel } from "@electron-forge/maker-squirrel";
import { MakerZIP } from "@electron-forge/maker-zip";
import { MakerDeb } from "@electron-forge/maker-deb";
import { MakerRpm } from "@electron-forge/maker-rpm";
import { AutoUnpackNativesPlugin } from "@electron-forge/plugin-auto-unpack-natives";
import { WebpackPlugin } from "@electron-forge/plugin-webpack";
import { FusesPlugin } from "@electron-forge/plugin-fuses";
import { FuseV1Options, FuseVersion } from "@electron/fuses";

import { mainConfig } from './webpack.main.config';
import { rendererConfig } from './webpack.renderer.config';
import { mainConfig } from "./webpack.main.config";
import { rendererConfig } from "./webpack.renderer.config";

const config: ForgeConfig = {
packagerConfig: {
asar: true,
},
rebuildConfig: {},
makers: [new MakerSquirrel({}), new MakerZIP({}, ['darwin']), new MakerRpm({}), new MakerDeb({})],
makers: [
new MakerSquirrel({}),
new MakerZIP({}, ["darwin"]),
new MakerRpm({}),
new MakerDeb({}),
],
plugins: [
new AutoUnpackNativesPlugin({}),
new WebpackPlugin({
Expand All @@ -25,11 +30,11 @@ const config: ForgeConfig = {
config: rendererConfig,
entryPoints: [
{
html: './src/index.html',
js: './src/renderer.ts',
name: 'main_window',
html: "./src/index.html",
js: "./src/renderer.ts",
name: "main_window",
preload: {
js: './src/preload.ts',
js: "./src/preload.ts",
},
},
],
Expand Down
26 changes: 13 additions & 13 deletions code-desktop/incrementVersion.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const prompt = require('prompt-sync')();
const versiony = require('versiony');
const prompt = require("prompt-sync")();
const versiony = require("versiony");

const version = prompt('Is it 1) Major 2) Minor 3) Patch? Default is Patch. ');
const version = prompt("Is it 1) Major 2) Minor 3) Patch? Default is Patch. ");

switch(version) {
case '1':
versiony.from('package.json').major().minor(0).patch(0).to();
break;
case '2':
versiony.from('package.json').minor().patch(0).to();
break;
default:
versiony.from('package.json').patch().to();
};
switch (version) {
case "1":
versiony.from("package.json").major().minor(0).patch(0).to();
break;
case "2":
versiony.from("package.json").minor().patch(0).to();
break;
default:
versiony.from("package.json").patch().to();
}
24 changes: 12 additions & 12 deletions code-desktop/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script>
const l = window.location.href;
const s = l.split('index.html')[0];
window.location.href = s + 'main_window/index.html'
</script>
<!-- the document has no actual content; neither character encoding nor styles and scripts are needed -->
</head>
<body>
<!-- no body content in case of redirect -->
</body>
</html>
<head>
<script>
const l = window.location.href;
const s = l.split("index.html")[0];
window.location.href = s + "main_window/index.html";
</script>
<!-- the document has no actual content; neither character encoding nor styles and scripts are needed -->
</head>
<body>
<!-- no body content in case of redirect -->
</body>
</html>
25 changes: 17 additions & 8 deletions code-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,42 @@
"asar": true,
"mac": {
"category": "public.app-category.games",
"target": ["dmg", "zip"],
"target": [
"dmg",
"zip"
],
"icon": "./src/favicon512.png"
},
"linux":{
"linux": {
"category": "Game",
"target": ["deb", "tar.gz"],
"target": [
"deb",
"tar.gz"
],
"icon": "./src/favicon.png"
},
"win":{
"win": {
"publisherName": "Niner Games",
"target": ["msi", "zip"],
"target": [
"msi",
"zip"
],
"icon": "./src/favicon.png"
}
},
"scripts": {
"dev": "electron-forge start",
"build": "electron-forge make",
"build:web:mac": "electron-forge make && cp index.html ./.webpack/arm64/renderer && cp ./src/favicon512.png ./.webpack/arm64/renderer/main_window/favicon.png",
"build:web:linux": "electron-forge make && cp index.html ./.webpack/renderer && cp ./src/favicon.png ./.webpack/renderer/main_window",
"build:web:linux": "electron-forge make && cp index.html ./.webpack/x64/renderer && cp ./src/favicon.png ./.webpack/x64/renderer/main_window",
"build:web:win": "electron-forge make && copy index.html ./.webpack/x64/renderer && copy ./src/favicon.png ./.webpack/x64/renderer/main_window",
"build:dir": "electron-builder --dir",
"build:dist": "electron-builder",
"copy:redirection:mac": "cp index.html ./.webpack/arm64/renderer",
"copy:redirection:linux": "cp index.html ./.webpack/renderer",
"copy:redirection:linux": "cp index.html ./.webpack/x64/renderer",
"copy:redirection:win": "copy index.html ./.webpack/x64/renderer",
"copy:favicon:mac": "cp ./src/favicon512.png ./.webpack/arm64/renderer/main_window/favicon.png",
"copy:favicon:linux": "cp ./src/favicon.png ./.webpack/renderer/main_window",
"copy:favicon:linux": "cp ./src/favicon.png ./.webpack/x64/renderer/main_window",
"copy:favicon:win": "copy ./src/favicon.png ./.webpack/x64/renderer/main_window",
"publish": "electron-forge publish",
"test": "jest",
Expand Down
20 changes: 10 additions & 10 deletions code-desktop/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { createRoot } from 'react-dom/client';
import Main from './components/Main';
import { createRoot } from "react-dom/client";
import Main from "./components/Main";

const el = document.getElementById('root');
const el = document.getElementById("root");

if (el) {
// If the root element is found, render the app into it
const root = createRoot(el);
root.render(<Main />);
// If the root element is found, render the app into it
const root = createRoot(el);
root.render(<Main />);
} else {
// If the root element is not found, create a new one
const root = createRoot(document.body);
root.render(<Main />);
}
// If the root element is not found, create a new one
const root = createRoot(document.body);
root.render(<Main />);
}
25 changes: 11 additions & 14 deletions code-desktop/src/classes/character.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
class Character {
constructor() {

if (this) {
this.start();
requestAnimationFrame(this.update);
}
constructor() {
if (this) {
this.start();
requestAnimationFrame(this.update);
}
}

start() {

}
start() {}

update(tick: number) {
if (this) {
requestAnimationFrame(this.update);
}
update(tick: number) {
if (this) {
requestAnimationFrame(this.update);
}
}
}

export default Character;
export default Character;
Loading

0 comments on commit ffa19ab

Please sign in to comment.