Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Initial skelly
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdeafcafe committed Apr 29, 2020
1 parent 1a2678f commit 9aa7eb9
Show file tree
Hide file tree
Showing 13 changed files with 2,435 additions and 0 deletions.
209 changes: 209 additions & 0 deletions typescript/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
module.exports = {
plugins: [
'@typescript-eslint/eslint-plugin',
'react-hooks',
'react'
],

env: {
node: false,
browser: true
},

globals: {
'Promise': false,
'Set': false,
'window': false
},

parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
project: './tsconfig.json',
tsconfigRootDir: './',

ecmaFeatures: {
'impliedStrict': true,
'jsx': true
},
},

rules: {
'accessor-pairs': 1,
'array-bracket-spacing': 1,
'array-callback-return': 1,
'arrow-body-style': 1,
'arrow-parens': [1, 'as-needed'],
'arrow-spacing': 1,
'block-scoped-var': 1,
'block-spacing': 1,
'brace-style': 1,
'camelcase': 'off',
'comma-dangle': [1, 'always-multiline'],
'comma-spacing': 1,
'comma-style': 1,
'computed-property-spacing': 1,
'consistent-return': 1,
'consistent-this': [1, 'that'],
'curly': [1, 'multi-or-nest', 'consistent'],
'default-case': 1,
'dot-notation': [1, { 'allowPattern': '^[a-z]+(_[a-z]+)+$' }],
'eol-last': 1,
'eqeqeq': [1, 'allow-null'],
'func-names': 1,
'func-style': [1, 'declaration', { 'allowArrowFunctions': true }],
'generator-star-spacing': [1, { 'before': false, 'after': true }],
'global-require': 1,
'guard-for-in': 1,
'handle-callback-err': 1,
'id-blacklist': [1, 'err', 'cb', 'data'],
'indent': 'off',
'jsx-quotes': 1,
'key-spacing': 1,
'keyword-spacing': 1,
'linebreak-style': 1,
'lines-around-comment': 1,
'max-depth': 1,
'max-len': [1, 120, 2],
'max-nested-callbacks': [1, 3],
'max-statements-per-line': 1,
'new-parens': 1,
'newline-per-chained-call': 1,
'no-alert': 1,
'no-array-constructor': 'off',
'no-await-in-loop': 1,
'no-bitwise': 1,
'no-caller': 1,
'no-catch-shadow': 1,
'no-confusing-arrow': 0,
'no-div-regex': 1,
'no-duplicate-imports': 1,
'no-else-return': 1,
'no-empty-function': 1,
'no-eval': 1,
'no-extend-native': 1,
'no-extra-bind': 1,
'no-extra-label': 1,
'no-floating-decimal': 1,
'no-implicit-coercion': 1,
'no-implicit-globals': 1,
'no-implied-eval': 1,
'no-invalid-this': 0,
'no-iterator': 1,
'no-label-var': 1,
'no-lone-blocks': 1,
'no-lonely-if': 1,
'no-loop-func': 1,
'no-magic-numbers': 0,
'no-mixed-requires': 1,
'no-mixed-spaces-and-tabs': 1,
'no-multi-spaces': 1,
'no-multi-str': 1,
'no-multiple-empty-lines': [1, { 'max': 1 }],
'no-native-reassign': 1,
'no-negated-condition': 1,
'no-nested-ternary': 1,
'no-new': 1,
'no-new-func': 1,
'no-new-object': 1,
'no-new-require': 1,
'no-new-wrappers': 1,
'no-octal-escape': 1,
'no-param-reassign': [1, { 'props': true }],
'no-path-concat': 1,
'no-plusplus': [1, { 'allowForLoopAfterthoughts': true }],
'no-process-env': 1,
'no-process-exit': 1,
'no-proto': 1,
'no-return-assign': 1,
'no-script-url': 1,
'no-self-compare': 1,
'no-sequences': 1,
'no-shadow-restricted-names': 1,
'no-spaced-func': 1,
'no-sync': 1,
'no-throw-literal': 1,
'no-trailing-spaces': 1,
'no-undef-init': 1,
'no-undefined': 1,
'no-unmodified-loop-condition': 1,
'no-unneeded-ternary': 1,
'no-unsafe-finally': 1,
'no-unused-expressions': 1,
'no-use-before-define': [1, { 'functions': false }],
'no-useless-catch': 0,
'no-useless-call': 1,
'no-useless-computed-key': 1,
'no-useless-concat': 1,
'no-useless-constructor': 1,
'no-useless-escape': 1,
'no-useless-vars': 0,
'no-var': 1,
'no-warning-comments': 1,
'no-whitespace-before-property': 1,
'no-with': 1,
'object-shorthand': 1,
'one-var': [1, 'never'],
'operator-assignment': 1,
'operator-linebreak': [1, 'none'],
'padded-blocks': [1, 'never'],
'padding-line-between-statements': [
'error',
{ 'blankLine': 'always', 'prev': ['const', 'let', 'var'], 'next': '*'},
{ 'blankLine': 'any', 'prev': ['const', 'let', 'var'], 'next': ['const', 'let', 'var']},
{ 'blankLine': 'always', 'prev': '*', 'next': 'return' }
],
'prefer-arrow-callback': 1,
'prefer-const': 1,
'prefer-rest-params': 1,
'prefer-spread': 1,
'prefer-template': 1,
'quote-props': [1, 'consistent-as-needed'],
'quotes': [1, 'single'],
'radix': 1,
'require-yield': 1,
'semi': [1, 'always'],
'sort-imports': [1, { 'memberSyntaxSortOrder': ['single', 'all', 'multiple', 'none'] }],
'space-before-blocks': 1,
'space-before-function-paren': [1, {'anonymous': 'always', 'named': 'never'}],
'space-in-parens': 1,
'space-infix-ops': 1,
'space-unary-ops': 1,
'spaced-comment': 1,
'template-curly-spacing': 1,
'vars-on-top': 1,
'wrap-iife': 1,
'wrap-regex': 1,
'yield-star-spacing': 1,
'yoda': 1,

'react/jsx-uses-react': 2,
'react/jsx-uses-vars': 2,
'react/no-multi-comp': 0,
'react/prop-types': 0,

'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/ban-types': 'error',
'@typescript-eslint/camelcase': 'error',
'@typescript-eslint/class-name-casing': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/indent': [1, 'tab', { 'SwitchCase': 1 }],
'@typescript-eslint/interface-name-prefix': [1, 'never'],
'@typescript-eslint/member-delimiter-style': 'error',
'@typescript-eslint/member-naming': 'off',
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-parameter-properties': 'error',
'@typescript-eslint/triple-slash-reference': [1, { "path": "never", "types": "never", "lib": "never" }],
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-use-before-define': [1, { 'functions': false }],
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/type-annotation-spacing': 'error'
},
};
6 changes: 6 additions & 0 deletions typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
yarn-*.log

# Parcel
.cache
dist
6 changes: 6 additions & 0 deletions typescript/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<body>
<div id="branch-goes-here-xoxo"></div>
<script src="./src/index.tsx"></script>
</body>
</html>
51 changes: 51 additions & 0 deletions typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "typescript",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"debug": "parcel watch index.html",
"start": "parcel index.html"
},
"browserslist": [
"last 1 Chrome versions"
],
"dependencies": {
"bootstrap": "^4.4.1",
"connected-react-router": "^6.8.0",
"crpc": "^0.2.2",
"history": "^4.10.1",
"jquery": "1.9.1 - 3",
"json-client": "^0.9.3",
"popper.js": "^1.16.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-helmet": "^6.0.0",
"react-redux": "^7.2.0",
"react-router-dom": "5.1.2",
"reactstrap": "^8.4.1",
"redux-devtools-extension": "^2.13.8",
"redux-saga": "^1.1.3",
"styled-components": "^5.1.0",
"typed.js": "^2.0.11",
"typesafe-actions": "^5.1.0"
},
"devDependencies": {
"@types/crpc": "^0.2.1",
"@types/history": "^4.7.5",
"@types/react": "^16.9.34",
"@types/react-dom": "^16.9.7",
"@types/react-helmet": "^5.0.15",
"@types/react-redux": "^7.1.7",
"@types/react-router": "^5.1.7",
"@types/react-router-dom": "^5.1.5",
"@types/reactstrap": "^8.4.2",
"@types/styled-components": "^5.1.0",
"@typescript-eslint/eslint-plugin": "^2.30.0",
"@typescript-eslint/parser": "^2.30.0",
"eslint": "^6.8.0",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^3.0.0",
"typescript": "^3.8.3"
}
}
28 changes: 28 additions & 0 deletions typescript/src/api/branch-client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import crpc, { Client } from "crpc";

interface Options {
services: {
name: string;
baseUrl: string;
key: string;
}[];
}

export default class BranchClient {
private readonly _options: Options;
private readonly _clients: Record<string, Client> = {};

constructor(options: Options) {
this._options = options;

this._options.services.forEach(s => {
this._clients[s.name] = crpc(s.baseUrl, { headers: { authorization: `bearer ${s.key}` } });
});
}

async do<T>(service: string, endpoint: string, version: string, body: Record<string, unknown>) {
const svc = this._clients[service];

return await svc<T>(`${version}/${endpoint}`, body);
}
}
13 changes: 13 additions & 0 deletions typescript/src/containers/AppContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';

const AppContainer: React.FunctionComponent = ({ children }) => {
return (
<React.Fragment>
<header></header>
<main>{children}</main>
<header></header>
</React.Fragment>
);
};

export default AppContainer;
7 changes: 7 additions & 0 deletions typescript/src/containers/Home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

const Home: React.FunctionComponent = () => {
return <p>{'yah boi'}</p>;
};

export default Home;
24 changes: 24 additions & 0 deletions typescript/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* eslint-disable sort-imports */
import { Provider } from 'react-redux';
import React from 'react';
import ReactDOM from 'react-dom';
import Routes from './routes';
import { ThemeProvider } from 'styled-components';
import configureStore from './store';
import { createBrowserHistory } from 'history';
import theme from './theme';
import 'bootstrap/dist/css/bootstrap.min.css';

const history = createBrowserHistory();
const store = configureStore(history);

const AppProvider = (
<Provider store={store}>
<ThemeProvider theme={theme}>
<Routes />
</ThemeProvider>
</Provider>
);

// Render to the DOM
ReactDOM.render(AppProvider, window.document.getElementById('branch-goes-here-xoxo'));
20 changes: 20 additions & 0 deletions typescript/src/routes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import React from 'react';
import Home from './containers/Home';
import AppContainer from './containers/AppContainer';

const Routes: React.FunctionComponent = () => {
return (
<React.Fragment>
<BrowserRouter>
<AppContainer>
<Switch>
<Route path={'/'} component={Home} />
</Switch>
</AppContainer>
</BrowserRouter>
</React.Fragment>
);
};

export default Routes;
Loading

0 comments on commit 9aa7eb9

Please sign in to comment.