From c39f9006d93efe8c8579f2564aa3cf7448cf6717 Mon Sep 17 00:00:00 2001
From: Alexander Harding <2166114+aeharding@users.noreply.github.com>
Date: Wed, 21 Jun 2023 17:55:25 -0500
Subject: [PATCH] Add reorganized file structure, add lint and CI
---
.eslintrc | 59 ++
.eslintrc.js | 17 -
.github/workflows/ci.yml | 36 +
capacitor.config.ts | 12 -
cypress.config.ts | 10 -
cypress/e2e/test.cy.ts | 6 -
cypress/fixtures/example.json | 5 -
cypress/support/commands.ts | 37 -
cypress/support/e2e.ts | 20 -
index.html | 2 +-
ionic.config.json | 7 -
package.json | 25 +-
server.mjs | 5 +-
src/ActorRedirect.tsx | 3 +-
src/App.test.tsx | 7 +-
src/App.tsx | 30 +-
src/Auth.tsx | 10 +-
src/Router.tsx | 24 +
src/{Tabs.tsx => TabbedRoutes.tsx} | 26 +-
src/ThemeColorUpdater.tsx | 44 -
src/components/PersonLabel.tsx | 64 --
src/components/PostFilter.tsx | 33 -
src/features/auth/AppContext.tsx | 2 +-
src/features/auth/Login.tsx | 7 +-
src/features/auth/authSlice.ts | 4 +-
.../comment}/Comment.tsx | 30 +-
.../comment}/CommentContent.tsx | 12 +-
.../comment}/CommentHr.tsx | 2 +-
.../comment}/CommentTree.tsx | 9 +-
.../comment}/Comments.tsx | 34 +-
src/features/comment/commentSlice.ts | 4 +-
.../comment/{ => reply}/CommentReply.tsx | 28 +-
.../comment/{ => reply}/ItemReplyingTo.tsx | 8 +-
.../community/MoreActions.tsx | 4 +-
.../community/communitySlice.ts | 14 +-
src/{components => features/labels}/Ago.tsx | 1 -
src/features/labels/Handle.tsx | 24 +
src/{components => features/labels}/Nsfw.tsx | 2 +-
src/{components => features/labels}/Vote.tsx | 13 +-
src/features/labels/img/CommunityIcon.tsx | 67 ++
src/features/labels/links/CommunityLink.tsx | 33 +
src/features/labels/links/PersonLink.tsx | 62 ++
src/features/labels/links/shared.ts | 8 +
.../post/actions/ActionButton.tsx | 0
.../post/actions}/PostActions.tsx | 4 +-
.../post/detail}/Img.tsx | 5 +-
.../post/detail}/PostDetail.tsx | 94 +-
.../post/detail}/Stats.tsx | 6 +-
.../post/detail}/ViewAllComments.tsx | 2 +-
.../post/inFeed}/EndPost.tsx | 7 +-
.../post/inFeed}/Post.tsx | 98 +-
.../post/inFeed}/PostSort.tsx | 4 +-
.../post/inFeed}/Posts.tsx | 25 +-
.../post/inFeed}/PreviewStats.tsx | 8 +-
src/features/post/postSlice.ts | 7 +-
.../post/shared}/Embed.tsx | 0
.../post/{item => shared}/MoreActions.tsx | 37 +-
.../post/shared}/VoteButton.tsx | 12 +-
.../shared}/AppBackButton.tsx | 4 +-
.../shared}/AppContent.tsx | 1 +
.../shared}/DraggingVote.tsx | 3 +-
.../shared}/InlineMarkdown.tsx | 0
.../shared}/Markdown.tsx | 6 +-
.../{profile => user}/PostContext.tsx | 8 +-
src/features/{profile => user}/Profile.tsx | 28 +-
src/features/{profile => user}/Scores.tsx | 2 +-
src/features/{profile => user}/incognito.svg | 0
src/features/user/userSlice.tsx | 2 +-
src/{main.css => index.css} | 2 +-
src/{main.tsx => index.tsx} | 4 +-
.../{Communities.tsx => CommunitiesPage.tsx} | 62 +-
.../{Community.tsx => CommunityPage.tsx} | 15 +-
src/pages/ProfilePage.tsx | 19 +-
src/pages/SettingsPage.tsx | 4 +-
src/pages/SpecialFeedPage.tsx | 4 +-
src/pages/UserPage.tsx | 10 +-
src/pages/settings/InstallAppPage.tsx | 6 +-
src/services/lemmy.ts | 2 +-
src/setupTests.ts | 21 +-
src/store.ts | 2 +-
vite.config.ts | 8 +-
yarn.lock | 989 ++++--------------
82 files changed, 849 insertions(+), 1512 deletions(-)
create mode 100644 .eslintrc
delete mode 100644 .eslintrc.js
create mode 100644 .github/workflows/ci.yml
delete mode 100644 capacitor.config.ts
delete mode 100644 cypress.config.ts
delete mode 100644 cypress/e2e/test.cy.ts
delete mode 100644 cypress/fixtures/example.json
delete mode 100644 cypress/support/commands.ts
delete mode 100644 cypress/support/e2e.ts
delete mode 100644 ionic.config.json
create mode 100644 src/Router.tsx
rename src/{Tabs.tsx => TabbedRoutes.tsx} (91%)
delete mode 100644 src/ThemeColorUpdater.tsx
delete mode 100644 src/components/PersonLabel.tsx
delete mode 100644 src/components/PostFilter.tsx
rename src/{components => features/comment}/Comment.tsx (89%)
rename src/{components => features/comment}/CommentContent.tsx (69%)
rename src/{components => features/comment}/CommentHr.tsx (93%)
rename src/{components => features/comment}/CommentTree.tsx (84%)
rename src/{components => features/comment}/Comments.tsx (85%)
rename src/features/comment/{ => reply}/CommentReply.tsx (84%)
rename src/features/comment/{ => reply}/ItemReplyingTo.tsx (86%)
rename src/{components => features}/community/MoreActions.tsx (96%)
rename src/{components => features}/community/communitySlice.ts (88%)
rename src/{components => features/labels}/Ago.tsx (97%)
create mode 100644 src/features/labels/Handle.tsx
rename src/{components => features/labels}/Nsfw.tsx (91%)
rename src/{components => features/labels}/Vote.tsx (82%)
create mode 100644 src/features/labels/img/CommunityIcon.tsx
create mode 100644 src/features/labels/links/CommunityLink.tsx
create mode 100644 src/features/labels/links/PersonLink.tsx
create mode 100644 src/features/labels/links/shared.ts
rename src/{components => features}/post/actions/ActionButton.tsx (100%)
rename src/{components => features/post/actions}/PostActions.tsx (92%)
rename src/{components => features/post/detail}/Img.tsx (92%)
rename src/{components => features/post/detail}/PostDetail.tsx (73%)
rename src/{components => features/post/detail}/Stats.tsx (87%)
rename src/{components => features/post/detail}/ViewAllComments.tsx (95%)
rename src/{components => features/post/inFeed}/EndPost.tsx (90%)
rename src/{components => features/post/inFeed}/Post.tsx (75%)
rename src/{components => features/post/inFeed}/PostSort.tsx (94%)
rename src/{components => features/post/inFeed}/Posts.tsx (87%)
rename src/{components => features/post/inFeed}/PreviewStats.tsx (78%)
rename src/{components => features/post/shared}/Embed.tsx (100%)
rename src/features/post/{item => shared}/MoreActions.tsx (78%)
rename src/{components => features/post/shared}/VoteButton.tsx (86%)
rename src/{components => features/shared}/AppBackButton.tsx (92%)
rename src/{components => features/shared}/AppContent.tsx (95%)
rename src/{components => features/shared}/DraggingVote.tsx (96%)
rename src/{components => features/shared}/InlineMarkdown.tsx (100%)
rename src/{components => features/shared}/Markdown.tsx (84%)
rename src/features/{profile => user}/PostContext.tsx (84%)
rename src/features/{profile => user}/Profile.tsx (80%)
rename src/features/{profile => user}/Scores.tsx (96%)
rename src/features/{profile => user}/incognito.svg (100%)
rename src/{main.css => index.css} (94%)
rename src/{main.tsx => index.tsx} (75%)
rename src/pages/{Communities.tsx => CommunitiesPage.tsx} (72%)
rename src/pages/{Community.tsx => CommunityPage.tsx} (76%)
diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 0000000000..fd25ec19d4
--- /dev/null
+++ b/.eslintrc
@@ -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
+ }
+ }
+ ]
+}
diff --git a/.eslintrc.js b/.eslintrc.js
deleted file mode 100644
index af472a1f7d..0000000000
--- a/.eslintrc.js
+++ /dev/null
@@ -1,17 +0,0 @@
-module.exports = {
- root: true,
- env: {
- node: true
- },
- 'extends': [
- 'plugin:react/recommended',
- 'eslint:recommended'
- ],
- parserOptions: {
- ecmaVersion: 2020
- },
- rules: {
- 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
- 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
- }
-}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000000..4adec4d4ce
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -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
diff --git a/capacitor.config.ts b/capacitor.config.ts
deleted file mode 100644
index 3fd0a52f40..0000000000
--- a/capacitor.config.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { CapacitorConfig } from '@capacitor/cli';
-
-const config: CapacitorConfig = {
- appId: 'io.ionic.starter',
- appName: 'wefwef',
- webDir: 'dist',
- server: {
- androidScheme: 'https'
- }
-};
-
-export default config;
diff --git a/cypress.config.ts b/cypress.config.ts
deleted file mode 100644
index 5d58e7ab1f..0000000000
--- a/cypress.config.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { defineConfig } from "cypress";
-
-export default defineConfig({
- e2e: {
- baseUrl: "http://localhost:5173",
- setupNodeEvents(on, config) {
- // implement node event listeners here
- },
- },
-});
\ No newline at end of file
diff --git a/cypress/e2e/test.cy.ts b/cypress/e2e/test.cy.ts
deleted file mode 100644
index f6b655f3b1..0000000000
--- a/cypress/e2e/test.cy.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-describe('My First Test', () => {
- it('Visits the app root url', () => {
- cy.visit('/')
- cy.contains('ion-content', 'Tab 1 page')
- })
-})
\ No newline at end of file
diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json
deleted file mode 100644
index 02e4254378..0000000000
--- a/cypress/fixtures/example.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "name": "Using fixtures to represent data",
- "email": "hello@cypress.io",
- "body": "Fixtures are a great way to mock data for responses to routes"
-}
diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts
deleted file mode 100644
index 698b01a42c..0000000000
--- a/cypress/support/commands.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-///
-// ***********************************************
-// This example commands.ts shows you how to
-// create various custom commands and overwrite
-// existing commands.
-//
-// For more comprehensive examples of custom
-// commands please read more here:
-// https://on.cypress.io/custom-commands
-// ***********************************************
-//
-//
-// -- This is a parent command --
-// Cypress.Commands.add('login', (email, password) => { ... })
-//
-//
-// -- This is a child command --
-// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
-//
-//
-// -- This is a dual command --
-// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
-//
-//
-// -- This will overwrite an existing command --
-// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
-//
-// declare global {
-// namespace Cypress {
-// interface Chainable {
-// login(email: string, password: string): Chainable
-// drag(subject: string, options?: Partial): Chainable
-// dismiss(subject: string, options?: Partial): Chainable
-// visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable
-// }
-// }
-// }
\ No newline at end of file
diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts
deleted file mode 100644
index f80f74f8e1..0000000000
--- a/cypress/support/e2e.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-// ***********************************************************
-// This example support/e2e.ts is processed and
-// loaded automatically before your test files.
-//
-// This is a great place to put global configuration and
-// behavior that modifies Cypress.
-//
-// You can change the location of this file or turn off
-// automatically serving support files with the
-// 'supportFile' configuration option.
-//
-// You can read more here:
-// https://on.cypress.io/configuration
-// ***********************************************************
-
-// Import commands.js using ES2015 syntax:
-import './commands'
-
-// Alternatively you can use CommonJS syntax:
-// require('./commands')
\ No newline at end of file
diff --git a/index.html b/index.html
index ad74b59a03..5a3ab170dc 100644
--- a/index.html
+++ b/index.html
@@ -28,6 +28,6 @@
-
+