Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jupl committed Jun 17, 2020
0 parents commit 71feb66
Show file tree
Hide file tree
Showing 17 changed files with 9,876 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# For more information visit http://editorconfig.org/
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict'

module.exports = {
extends: './node_modules/@jupl/ts/lint',
ignorePatterns: ['.parcel-cache/', 'dist/'],
}
4 changes: 4 additions & 0 deletions .esmrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"await": true,
"cache": false
}
115 changes: 115 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
.parcel-cache

# Created by https://www.toptal.com/developers/gitignore/api/node
# Edit at https://www.toptal.com/developers/gitignore?templates=node

### Node ###
# 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
.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

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# End of https://www.toptal.com/developers/gitignore/api/node
5 changes: 5 additions & 0 deletions .postcssrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": {
"postcss-preset-env": {}
}
}
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict'

module.exports = require('@jupl/ts/format')
21 changes: 21 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.rulers": [79],
"telemetry.enableCrashReporter": false,
"telemetry.enableTelemetry": false,
"typescript.format.enable": false,
"typescript.tsdk": "node_modules/typescript/lib",
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[javascriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
}
}
11 changes: 11 additions & 0 deletions ava.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** Ava configuration. */
// eslint-disable-next-line import/no-default-export
export default {
extensions: ['js', 'ts', 'tsx'],
require: [
'esm',
'tsconfig-paths/register',
'ts-node/register/transpile-only',
'source-map-support/register',
],
}
12 changes: 12 additions & 0 deletions nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict'

module.exports = {
branches: 100,
'check-coverage': true,
exclude: ['test{,-*}.{j,t}s{x,}', '**/*{.,-}test.{j,t}s{x,}'],
extends: '@istanbuljs/nyc-config-typescript',
functions: 100,
lines: 100,
require: ['esm'],
statements: 100,
}
47 changes: 47 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"private": true,
"scripts": {
"build": "yarn run clean && parcel build src/+dist/*",
"build:prod": "cross-env NODE_ENV=production yarn run build --no-source-maps",
"build:watch": "parcel watch src/+dist/*",
"clean": "trash .parcel-cache dist",
"coverage": "nyc ava",
"coverage:report": "nyc --reporter=lcov --reporter=text ava",
"lint": "tsc && yarn run lint:file .",
"lint:file": "eslint --ext .js,.ts,.tsx",
"lint:fix": "yarn run lint:fix:file .",
"lint:fix:file": "yarn run lint:file --fix",
"server": "parcel serve src/+dist/*",
"start": "yarn run build:prod",
"test": "ava",
"test:update": "yarn run test --update-snapshots",
"test:watch": "yarn run test --watch"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@jupl/ts": "^0.2.6",
"@types/react": "^16.9.36",
"@types/react-dom": "^16.9.8",
"@types/recoil": "^0.0.1",
"ava": "^3.5.0",
"cross-env": "^7.0.1",
"eslint": "^6.8.0",
"esm": "^3.2.25",
"nyc": "^15.0.0",
"parcel": "^2.0.0-nightly.296",
"postcss-modules": "^2.0.0",
"postcss-preset-env": "^6.7.0",
"prettier": "^2.0.5",
"sass": "^1.26.8",
"source-map-support": "^0.5.16",
"trash-cli": "^3.0.0",
"ts-node": "^8.6.2",
"tsconfig-paths": "^3.9.0",
"typescript": "^3.8.3"
},
"dependencies": {
"react": "^16.13.1",
"react-dom": "^16.13.1",
"recoil": "^0.0.8"
}
}
14 changes: 14 additions & 0 deletions src/+dist/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="minimum-scale=1, initial-scale=1, width=device-width"
/>
<title>Application</title>
<link rel="stylesheet" href="~/src/main/index.scss" />
<script defer src="~/src/main/index.tsx"></script>
</head>
<body></body>
</html>
23 changes: 23 additions & 0 deletions src/common/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
interface GetRootOptions {
id?: string
parent?: HTMLElement
tag?: keyof HTMLElementTagNameMap
}

/**
* Get root element to host the application.
* @return HTML element mounted to document.
*/
export const getRoot = ({
id = 'root',
parent = document.body,
tag = 'div',
}: GetRootOptions = {}) => {
let root = parent.querySelector(`#${id}`)
if (!root) {
root = document.createElement(tag)
root.id = id // eslint-disable-line functional/immutable-data
parent.appendChild(root)
}
return root
}
7 changes: 7 additions & 0 deletions src/main/components/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

/**
* Render main application.
* @return React component
*/
export const MainApp = () => <>Hello, world.</>
1 change: 1 addition & 0 deletions src/main/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Start writing!
12 changes: 12 additions & 0 deletions src/main/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react'
import {RecoilRoot} from 'recoil'
import {render} from 'react-dom'
import {getRoot} from '~/src/common/util'
import {MainApp} from './components/app'

render(
<RecoilRoot>
<MainApp />
</RecoilRoot>,
getRoot(),
)
9 changes: 9 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "@jupl/ts",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": ["*"]
}
}
}
Loading

0 comments on commit 71feb66

Please sign in to comment.