diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 0dce8c0..0000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["@babel/env", "@babel/preset-react"] -} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..41ccbc6 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,32 @@ +module.exports = { + env: { + node: true, + browser: true, + "shared-node-browser": true, + es2021: true, + jest: true, + }, + extends: [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:react-hooks/recommended", + ], + overrides: [], + parserOptions: { + ecmaVersion: "latest", + sourceType: "module", + ecmaFeatures: { + jsx: true, + }, + }, + plugins: ["react"], + rules: { + "react/prop-types": "off", + }, + ignorePatterns: ["dist/*"], + settings: { + react: { + version: "detect", + }, + }, +}; diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index c24000e..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "env": { - "node": true, - "browser": true, - "es2021": true, - "shared-node-browser": true, - "jest": true - }, - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:react-hooks/recommended" - ], - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "ecmaVersion": "latest", - "sourceType": "module" - }, - "plugins": ["react"], - "rules": { - "react/prop-types": "off" - }, - "ignorePatterns": ["dist/*"], - "settings": { - "react": { - "version": "detect" - } - } -} diff --git a/.gitignore b/.gitignore index bce4729..8ca7429 100644 --- a/.gitignore +++ b/.gitignore @@ -1,108 +1,8 @@ -PWABuilder/* - -.vscode/* - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file +node_modules +dist +PWA_Builder +PWA_Builder/ +PWA_Builder/* +.vscode/settings.json .env .env.test - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# Next.js build output -.next - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and *not* Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port diff --git a/.prettierignore b/.prettierignore index 5f65c98..8f31331 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,4 @@ TODO.md src/privacy.html -src/App.css +*.css +dist/** diff --git a/.prettierrc.json b/.prettierrc.json index 0967ef4..fbeb22b 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1 +1,4 @@ -{} +{ + "bracketSpacing": false, + "trailingComma": "all" +} diff --git a/.stylelintrc.json b/.stylelintrc.json index eb9a523..010d13b 100644 --- a/.stylelintrc.json +++ b/.stylelintrc.json @@ -2,6 +2,9 @@ "extends": "stylelint-config-standard", "rules": { "selector-class-pattern": null, - "selector-id-pattern": null + "selector-id-pattern": null, + "custom-property-pattern": null, + "keyframes-name-pattern": null, + "declaration-block-no-redundant-longhand-properties": null } } diff --git a/babel.config.json b/babel.config.json new file mode 100644 index 0000000..2250a39 --- /dev/null +++ b/babel.config.json @@ -0,0 +1,13 @@ +{ + "presets": [ + [ + "@babel/preset-env", + { + "targets": { + "node": "current" + } + } + ], + "@babel/preset-react" + ] +} diff --git a/package-lock.json b/package-lock.json index 10aa621..e679a37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,6 @@ "@babel/plugin-syntax-import-assertions": "^7.23.3", "@babel/preset-env": "^7.16.11", "@babel/preset-react": "^7.16.7", - "@eslint/create-config": "github:eslint/create-config", "babel-jest": "^29.7.0", "babel-loader": "^8.2.3", "copy-webpack-plugin": "^10.2.4", @@ -1804,46 +1803,6 @@ "node": ">=10.0.0" } }, - "node_modules/@eslint/create-config": { - "version": "0.4.1", - "resolved": "git+ssh://git@github.com/eslint/create-config.git#561970ef90d631749dbc067706ae06f50852df49", - "dev": true, - "license": "MIT", - "dependencies": { - "@eslint/eslintrc": "^1.0.3", - "cross-spawn": "^7.0.2", - "debug": "^4.0.1", - "enquirer": "^2.3.5", - "js-yaml": "^4.1.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "mri": "^1.2.0", - "semver": "^7.2.1" - }, - "bin": { - "create-config": "bin/create-config.js" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/@eslint/create-config/node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/@eslint/eslintrc": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.3.tgz", @@ -3581,15 +3540,6 @@ "ajv": "^6.9.1" } }, - "node_modules/ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -5114,18 +5064,6 @@ "node": ">=10.13.0" } }, - "node_modules/enquirer": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", - "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", - "dev": true, - "dependencies": { - "ansi-colors": "^4.1.1" - }, - "engines": { - "node": ">=8.6" - } - }, "node_modules/entities": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", @@ -9435,15 +9373,6 @@ "resolved": "https://registry.npmjs.org/mobile-drag-drop/-/mobile-drag-drop-2.3.0-rc.2.tgz", "integrity": "sha512-4rHP0PUeWkSp0O3waNHPQZCHeZnLu8bE59MerWOnZJ249BCyICXL1WWp3xqkMKXEDFYuhfk3bS42bKB9IeN9uw==" }, - "node_modules/mri": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", - "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -14459,32 +14388,6 @@ "integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==", "dev": true }, - "@eslint/create-config": { - "version": "git+ssh://git@github.com/eslint/create-config.git#561970ef90d631749dbc067706ae06f50852df49", - "dev": true, - "from": "@eslint/create-config@github:eslint/create-config", - "requires": { - "@eslint/eslintrc": "^1.0.3", - "cross-spawn": "^7.0.2", - "debug": "^4.0.1", - "enquirer": "^2.3.5", - "js-yaml": "^4.1.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "mri": "^1.2.0", - "semver": "^7.2.1" - }, - "dependencies": { - "semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - } - } - }, "@eslint/eslintrc": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.3.tgz", @@ -15911,12 +15814,6 @@ "dev": true, "requires": {} }, - "ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", - "dev": true - }, "ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -17048,15 +16945,6 @@ "tapable": "^2.2.0" } }, - "enquirer": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", - "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", - "dev": true, - "requires": { - "ansi-colors": "^4.1.1" - } - }, "entities": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", @@ -20260,12 +20148,6 @@ "resolved": "https://registry.npmjs.org/mobile-drag-drop/-/mobile-drag-drop-2.3.0-rc.2.tgz", "integrity": "sha512-4rHP0PUeWkSp0O3waNHPQZCHeZnLu8bE59MerWOnZJ249BCyICXL1WWp3xqkMKXEDFYuhfk3bS42bKB9IeN9uw==" }, - "mri": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", - "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==", - "dev": true - }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", diff --git a/package.json b/package.json index dccc536..c9e557f 100644 --- a/package.json +++ b/package.json @@ -5,14 +5,15 @@ "main": "index.js", "scripts": { "test": "jest", + "compressImages": "for FILE in src/images/background_images_raw/*; do cwebp -q 75 $FILE -o src/images/background_images/$(basename $FILE '.png').webp ; done", + "prebuild": "npm run compressImages", + "build": "webpack", "dev": "webpack-dev-server --mode development", "start": "webpack-dev-server", - "build": "webpack", - "lint": "npx eslint --ignore-path .gitignore .", - "style": "npx stylelint --fix \"**/*.css\"", - "prettier": "npx prettier --ignore-path .gitignore --write .", - "compressImages": "for FILE in src/images/background_images_raw/*; do cwebp -q 75 $FILE -o src/images/background_images/$(basename $FILE '.png').webp ; done", - "prebuild": "npm run compressImages" + "eslint": "npx eslint --ignore-path .gitignore . --fix", + "prettier": "npx prettier --write .", + "style": "npx stylelint '**/*.css' --fix", + "lint": "npm run eslint && npm run prettier && npm run style" }, "repository": { "type": "git", @@ -35,7 +36,6 @@ "@babel/plugin-syntax-import-assertions": "^7.23.3", "@babel/preset-env": "^7.16.11", "@babel/preset-react": "^7.16.7", - "@eslint/create-config": "github:eslint/create-config", "babel-jest": "^29.7.0", "babel-loader": "^8.2.3", "copy-webpack-plugin": "^10.2.4", @@ -53,8 +53,5 @@ "webpack-cli": "^4.9.2", "webpack-dev-server": "^4.7.4", "workbox-webpack-plugin": "^6.5.2" - }, - "jest": { - "verbose": true } } diff --git a/src/App.js b/src/App.js index 4e0d472..d4d740a 100644 --- a/src/App.js +++ b/src/App.js @@ -1,5 +1,4 @@ -import React, { useState } from "react"; -import "./App.css"; +import React, {useState} from "react"; import Inventory from "./components/inventory"; import Location from "./components/location"; import Consequence from "./components/consequence"; @@ -8,13 +7,13 @@ import GameLost from "./components/gameLost"; import Info from "./components/info"; import Restart from "./components/restart"; import Resume from "./components/resume"; -import { reducer } from "./reducer"; -import { init } from "./init"; +import {reducer} from "./reducer"; +import {init} from "./init"; function handleBeforeInstallPrompt( event, setInstallPromptEvent, - setShowInstallButton + setShowInstallButton, ) { console.log("handleBeforeInstallPrompt"); if (event) setInstallPromptEvent(event); @@ -38,28 +37,23 @@ function App() { const [showInstallButton, setShowInstallButton] = React.useState(true); React.useEffect(() => { - window.addEventListener("beforeinstallprompt", (event) => + const listener = (event) => handleBeforeInstallPrompt( event, setInstallPromptEvent, - setShowInstallButton - ) - ); - return () => - window.removeEventListener("beforeinstallprompt", (event) => - handleBeforeInstallPrompt( - event, - setInstallPromptEvent, - setShowInstallButton - ) + setShowInstallButton, ); + + window.addEventListener("beforeinstallprompt", listener); + return () => window.removeEventListener("beforeinstallprompt", listener); }, []); React.useEffect(() => { - window.addEventListener("appinstalled", () => - handleAppInstalled(setInstallPromptEvent, setShowInstallButton) - ); - return () => window.removeEventListener("appinstalled", handleAppInstalled); + const listener = () => + handleAppInstalled(setInstallPromptEvent, setShowInstallButton); + + window.addEventListener("appinstalled", listener); + return () => window.removeEventListener("appinstalled", listener); }, []); React.useLayoutEffect(() => { @@ -81,7 +75,7 @@ function App() { } // If yes, update state - dispatchGameState({ action: "resume", savedState: savedState }); + dispatchGameState({action: "resume", savedState: savedState}); setShowMap(savedState.showMap ?? true); setShowPhoto(savedState.showPhoto ?? true); diff --git a/src/components/consequence.js b/src/components/consequence.js index 979bff1..108c451 100644 --- a/src/components/consequence.js +++ b/src/components/consequence.js @@ -1,7 +1,7 @@ import React from "react"; -import { locations } from "../locations"; +import {locations} from "../locations"; -export default function Consequence({ setCurrentDisplay, gameState }) { +export default function Consequence({setCurrentDisplay, gameState}) { return (
{gameState.consequenceText}
diff --git a/src/components/gameLost.js b/src/components/gameLost.js index 1a64191..303932d 100644 --- a/src/components/gameLost.js +++ b/src/components/gameLost.js @@ -19,7 +19,7 @@ export default function GameLost({ ; } @@ -141,7 +141,7 @@ function MapLocation({ direction, connections, gameState, dispatchGameState }) { ); } -function Map({ gameState, dispatchGameState, setCurrentDisplay, showPhoto }) { +function Map({gameState, dispatchGameState, setCurrentDisplay, showPhoto}) { const connections = locations[gameState.playerLocation].getConnections(gameState); diff --git a/src/components/restart.js b/src/components/restart.js index df75930..97db6eb 100644 --- a/src/components/restart.js +++ b/src/components/restart.js @@ -1,6 +1,6 @@ import React from "react"; -export default function Restart({ setCurrentDisplay, dispatchGameState }) { +export default function Restart({setCurrentDisplay, dispatchGameState}) { return (
Restart?
@@ -8,7 +8,7 @@ export default function Restart({ setCurrentDisplay, dispatchGameState }) {