Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

To claim this, I am signing this object:

const fs = require('fs')
const path = require('path')
const traverse = require('traverse')
const setupTestsFile = fs.existsSync(
path.resolve(__dirname, 'src/setupTests.ts')
)
? '<rootDir>/src/setupTests.ts'
: undefined
{
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
"testPathIgnorePatterns": [
"<rootDir>/src/",
"<rootDir>/build/",
"<rootDir>/dist/",
@babie
babie / config-overrides.js
Created May 26, 2018 20:35
Transform aws-sam & create-react-app codes from JavaScript to TypeScript
const fs = require('fs')
const path = require('path')
const appDirectory = fs.realpathSync(process.cwd())
const resolveApp = relativePath => path.resolve(appDirectory, relativePath)
module.exports = {
webpack: (config, env) => ({
...config,
entry: [resolveApp('src/server.ts')],
{
"rulesDirectory": ["tslint-plugin-prettier"],
"plugins": ["prettier"],
"extends": [
"tslint-config-airbnb",
"tslint-config-standard",
"tslint-config-prettier"
],
"linterOptions": {
"exclude": ["config/**/*.js", "node_modules/**/*.ts"]
{
"extends": ["airbnb", "standard", "prettier"],
"plugins": ["react", "mocha", "standard", "prettier"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"mocha": true,
@babie
babie / settings.json
Last active May 25, 2018 16:58
tslint and prettier settings for vscode
// Place your settings in this file to overwrite the default settings
{
"javascript.validate.enable": false,
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000,
"eslint.enable": true,
"eslint.autoFixOnSave": false,
"eslint.alwaysShowStatus": true,
"tslint.enable": true,
"tslint.autoFixOnSave": false,
@babie
babie / keybindings.json
Last active May 23, 2018 14:02
vscode user keybindings
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "ctrl+shift+tab",
"command": "workbench.action.previousEditor"
},
{
"key": "ctrl+tab",
"command": "workbench.action.nextEditor"
},
@babie
babie / base64.js
Last active October 5, 2017 18:57
ダサい。助けてくれ……できれば async/await で……→こんな感じか?
export function encode (blob) {
return new Promise((resolve) => {
const r = new FileReader()
r.onload = () => {
const dataURL = r.result
const base64 = dataURL.split(',', 2)[1]
resolve(base64)
}
r.readAsDataURL(blob)
@babie
babie / authorization.js
Created July 30, 2017 07:33
Authorization and default currentUser prop by HOC
import React, { Component } from 'react'
import { connect } from 'react-redux'
const Authorization = (allowRoles) => {
return (WrappedComponent) => {
class WithAuthorization extends Component {
render () {
const { role } = this.props.currentUser
if (allowRoles.includes(role)) {
return <WrappedComponent {...this.props} />