Skip to content

Commit

Permalink
Add reorganized file structure, add lint and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
aeharding committed Jun 21, 2023
1 parent 5667332 commit c39f900
Show file tree
Hide file tree
Showing 82 changed files with 849 additions and 1,512 deletions.
59 changes: 59 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"root": true,
"env": {
"browser": true,
"es2022": true
},
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended"
],
"plugins": ["react", "@typescript-eslint", "@emotion"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"sourceType": "module",
"ecmaVersion": 2022
},
"rules": {
"react/react-in-jsx-scope": "off",
"no-console": ["warn", { "allow": ["warn", "error", "info"] }],
"linebreak-style": ["warn", "unix"],
"react/jsx-fragments": ["warn", "syntax"],
"no-undef": 1,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-empty-interface": 0,
"react/jsx-curly-brace-presence": ["warn", "never"],
"eqeqeq": ["warn", "smart"],
"react/no-unknown-property": ["error", { "ignore": ["css"] }],
"@emotion/no-vanilla": "error",
"@emotion/import-from-emotion": "error",
"@emotion/styled-import": "error",
"@emotion/syntax-preference": [2, "string"],
"@typescript-eslint/no-unused-vars": [
"warn",
{ "destructuredArrayIgnorePattern": "^_" }
]
},
"overrides": [
{
"files": ["**/*.test.ts", "**/*.test.tsx"],
"globals": {
"global": "writable"
},
"env": {
"jest": true
}
},
{
"files": ["server.mjs"],
"env": {
"node": true
}
}
]
}
17 changes: 0 additions & 17 deletions .eslintrc.js

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: ci

permissions: {}

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch: {}

jobs:
ci:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn

- name: 📦 Install dependencies
run: yarn --frozen-lockfile

- name: 🧪 Test project
run: yarn test

- name: 📝 Lint
run: yarn lint

- name: 💪 Type check
run: yarn test:typecheck
12 changes: 0 additions & 12 deletions capacitor.config.ts

This file was deleted.

10 changes: 0 additions & 10 deletions cypress.config.ts

This file was deleted.

6 changes: 0 additions & 6 deletions cypress/e2e/test.cy.ts

This file was deleted.

5 changes: 0 additions & 5 deletions cypress/fixtures/example.json

This file was deleted.

37 changes: 0 additions & 37 deletions cypress/support/commands.ts

This file was deleted.

20 changes: 0 additions & 20 deletions cypress/support/e2e.ts

This file was deleted.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
7 changes: 0 additions & 7 deletions ionic.config.json

This file was deleted.

25 changes: 16 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"build": "vite build",
"preview": "vite preview",
"test": "vitest",
"lint": "eslint"
"test:typecheck": "tsc",
"lint": "eslint src"
},
"dependencies": {
"express": "^4.18.2",
Expand All @@ -19,49 +20,55 @@
"devDependencies": {
"@emotion/babel-plugin": "^11.11.0",
"@emotion/css": "^11.11.2",
"@emotion/eslint-plugin": "^11.11.0",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@ionic/core": "^7.0.14",
"@ionic/react-router": "^7.0.0",
"@ionic/react": "^7.0.14",
"@ionic/react-router": "^7.0.0",
"@reduxjs/toolkit": "^1.9.5",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/js-cookie": "^3.0.3",
"@types/lodash": "^4.14.195",
"@types/react": "^18.2.13",
"@types/react-dom": "^18.2.6",
"@types/react-router-dom": "^5.3.3",
"@types/react-router": "^5.1.20",
"@types/react": "^18.2.13",
"@types/react-router-dom": "^5.3.3",
"@types/ua-parser-js": "^0.7.36",
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"@vitejs/plugin-react": "^4.0.1",
"cypress": "^12.15.0",
"date-fns": "^2.30.0",
"eslint-plugin-react": "^7.32.2",
"eslint": "^8.43.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"ionicons": "^7.1.2",
"js-cookie": "^3.0.5",
"jsdom": "^22.1.0",
"lemmy-js-client": "0.18.0-rc.1",
"lodash": "^4.17.21",
"photoswipe": "^5.3.7",
"prettier": "^2.8.8",
"react": "^18.2.0",
"react-animate-height": "^3.1.1",
"react-dom": "^18.2.0",
"react-markdown": "^8.0.7",
"react-photoswipe-gallery": "^2.2.7",
"react-redux": "^8.1.0",
"react-router-dom": "^5.3.4",
"react-router": "^5.3.4",
"react-router-dom": "^5.3.4",
"react-virtuoso": "^4.3.10",
"react": "^18.2.0",
"remark-gfm": "^3.0.1",
"terser": "^5.18.1",
"typescript": "^5.1.3",
"ua-parser-js": "^1.0.35",
"vite": "^4.3.9",
"vite-plugin-pwa": "^0.16.4",
"vite-plugin-svgr": "^3.2.0",
"vite": "^4.3.9",
"vitest": "^0.32.0"
}
}
5 changes: 3 additions & 2 deletions server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ app.use(
})
);

const PORT = process.env.PORT || 3000;
const PORT = process.env.PORT || 5173;

ViteExpress.listen(app, PORT, () =>
console.log(`Server is listening on port ${PORT}...`)
// eslint-disable-next-line no-console
console.log(`Server is on http://localhost:${PORT}`)
);
3 changes: 2 additions & 1 deletion src/ActorRedirect.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Redirect, useLocation, useParams } from "react-router";
import { useAppSelector } from "./store";
import { jwtIssSelector } from "./features/auth/authSlice";
import React from "react";

interface ActorRedirectProps {
children?: React.ReactNode;
Expand All @@ -14,7 +15,7 @@ export default function ActorRedirect({ children }: ActorRedirectProps) {
if (!iss || !actor) return <>{children}</>;
if (iss === actor) return <>{children}</>;

const [first, second, wrongActor, ...rest] = location.pathname.split("/");
const [first, second, _wrongActor, ...rest] = location.pathname.split("/");

return <Redirect to={[first, second, iss, ...rest].join("/")} push={false} />;
}
7 changes: 3 additions & 4 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import { render } from '@testing-library/react';
import App from './App';
import { render } from "@testing-library/react";
import App from "./App";

test('renders without crashing', () => {
test("renders without crashing", () => {
const { baseElement } = render(<App />);
expect(baseElement).toBeDefined();
});
Loading

0 comments on commit c39f900

Please sign in to comment.