From a535cdfeff58b970bb09d7e9e063b94f278011b0 Mon Sep 17 00:00:00 2001 From: Kaoru Kawashima <8354804+altoinu@users.noreply.github.com> Date: Wed, 29 Jan 2025 14:35:36 -0500 Subject: [PATCH 01/19] initial setup - gitignore, readme, react, eslint, prettier, vite, import sort, base html/jsx --- README.md | 27 + septa-fare-calculator/.gitignore | 66 + septa-fare-calculator/.nvmrc | 1 + septa-fare-calculator/.prettierignore | 3 + septa-fare-calculator/.prettierrc.mjs | 24 + septa-fare-calculator/{ => data}/fares.json | 0 septa-fare-calculator/eslint.config.mjs | 18 + septa-fare-calculator/index.html | 4 +- septa-fare-calculator/package-lock.json | 5046 ++++++++++++++++++ septa-fare-calculator/package.json | 42 + septa-fare-calculator/src/Main.jsx | 22 + septa-fare-calculator/src/Main.module.css | 3 + septa-fare-calculator/src/hooks/useFetch.js | 125 + septa-fare-calculator/src/index.jsx | 10 + septa-fare-calculator/src/types/HTTPError.js | 19 + septa-fare-calculator/vite.config.js | 7 + 16 files changed, 5416 insertions(+), 1 deletion(-) create mode 100644 README.md create mode 100644 septa-fare-calculator/.gitignore create mode 100644 septa-fare-calculator/.nvmrc create mode 100644 septa-fare-calculator/.prettierignore create mode 100644 septa-fare-calculator/.prettierrc.mjs rename septa-fare-calculator/{ => data}/fares.json (100%) create mode 100644 septa-fare-calculator/eslint.config.mjs create mode 100644 septa-fare-calculator/package-lock.json create mode 100644 septa-fare-calculator/package.json create mode 100644 septa-fare-calculator/src/Main.jsx create mode 100644 septa-fare-calculator/src/Main.module.css create mode 100644 septa-fare-calculator/src/hooks/useFetch.js create mode 100644 septa-fare-calculator/src/index.jsx create mode 100644 septa-fare-calculator/src/types/HTTPError.js create mode 100644 septa-fare-calculator/vite.config.js diff --git a/README.md b/README.md new file mode 100644 index 000000000..ca6644a1e --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# thinkcompany-code-challenges/septa-fare-calculator + +SEPTA Rail Fare Calculator Challenge for Think Company. + +For more info: https://github.com/thinkcompany/code-challenges/tree/master/septa-fare-calculator + +## Node stuff + +- Node.js (v23.5.0) and npm [https://nodejs.org/](https://nodejs.org/) + +## Initial set up + +``` +npm install +``` + +## To run + +``` +npm run dev +``` + +## Lint + +``` +npm run lint:fix +``` diff --git a/septa-fare-calculator/.gitignore b/septa-fare-calculator/.gitignore new file mode 100644 index 000000000..43d37f4bf --- /dev/null +++ b/septa-fare-calculator/.gitignore @@ -0,0 +1,66 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/bower_components +/.pnp +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/versions + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build +/dist +/docs + +# misc, OS files +Thumbs.db +ehthumbs.db +Desktop.ini +.DS_Store +._* +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* +logs + +# env files (can opt-in for committing if needed) +.env* + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts + +# editors +*~ +*.swp +*.tmproj +*.tmproject +*.sublime-* +.idea +.idea/ +/.project +.project/ +.settings/ +.vscode/ +.sass-cache + +# Yeoman meta-data +.yo-rc.json diff --git a/septa-fare-calculator/.nvmrc b/septa-fare-calculator/.nvmrc new file mode 100644 index 000000000..dd6db9f49 --- /dev/null +++ b/septa-fare-calculator/.nvmrc @@ -0,0 +1 @@ +23.5.0 \ No newline at end of file diff --git a/septa-fare-calculator/.prettierignore b/septa-fare-calculator/.prettierignore new file mode 100644 index 000000000..1b8ac8894 --- /dev/null +++ b/septa-fare-calculator/.prettierignore @@ -0,0 +1,3 @@ +# Ignore artifacts: +build +coverage diff --git a/septa-fare-calculator/.prettierrc.mjs b/septa-fare-calculator/.prettierrc.mjs new file mode 100644 index 000000000..dd8ef5dae --- /dev/null +++ b/septa-fare-calculator/.prettierrc.mjs @@ -0,0 +1,24 @@ +const prettierConfig = { + arrowParens: "always", + bracketSpacing: true, + bracketSameLine: false, + endOfLine: "lf", + htmlWhitespaceSensitivity: "css", + insertPragma: false, + jsxSingleQuote: false, + printWidth: 80, + proseWrap: "preserve", + quoteProps: "as-needed", + requirePragma: false, + semi: true, + singleQuote: false, + tabWidth: 2, + trailingComma: "all", + useTabs: false, + // prettier-plugin-sort-imports options + sortingMethod: "alphabetical", + plugins: ["./node_modules/prettier-plugin-sort-imports/dist/index.js"], +}; + +export default prettierConfig; +// trailingComma: "es5", diff --git a/septa-fare-calculator/fares.json b/septa-fare-calculator/data/fares.json similarity index 100% rename from septa-fare-calculator/fares.json rename to septa-fare-calculator/data/fares.json diff --git a/septa-fare-calculator/eslint.config.mjs b/septa-fare-calculator/eslint.config.mjs new file mode 100644 index 000000000..90d452046 --- /dev/null +++ b/septa-fare-calculator/eslint.config.mjs @@ -0,0 +1,18 @@ +import pluginJs from "@eslint/js"; +import eslint from "@eslint/js"; +import eslintConfigPrettier from "eslint-config-prettier"; +import pluginReact from "eslint-plugin-react"; +import globals from "globals"; + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + { + files: ["**/*.{js,mjs,cjs,jsx}"], + languageOptions: { globals: globals.browser }, + }, + pluginJs.configs.recommended, + eslint.configs.recommended, + pluginReact.configs.flat.recommended, + pluginReact.configs.flat["jsx-runtime"], + eslintConfigPrettier, +]; diff --git a/septa-fare-calculator/index.html b/septa-fare-calculator/index.html index ba1a762c9..9b7e346d4 100644 --- a/septa-fare-calculator/index.html +++ b/septa-fare-calculator/index.html @@ -5,6 +5,8 @@