Create a patch from staged changes
git diff --cached > something.patch
Apply patch
git apply /path/to/some-changes.patch
Create a patch from staged changes
git diff --cached > something.patch
Apply patch
git apply /path/to/some-changes.patch
module.exports = (results) => { | |
const byRuleId = results.reduce((map, current) => { | |
current.messages.forEach(({ ruleId, line, column }) => { | |
if (!map[ruleId]) { | |
map[ruleId] = []; | |
} | |
const occurrence = `${current.filePath}:${line}:${column}`; | |
map[ruleId].push(occurrence); | |
}); |
const logMiddleWare = store => next => action => { | |
if (action.type.includes('SET_SOME_DATA')) { | |
console.log(`%c ${action.type}`, 'background: #222; color: #00ffcc'); | |
} | |
next(action); | |
} |
class Person { | |
name: string | |
age: number | |
constructor(name: string, age: number) { | |
this.name = name; | |
this.age = age; | |
} | |
} | |
class Fruit { | |
ripe: boolean; |
const BookContextProvider = ({ children }) => { | |
// ... | |
// add | |
const getBooks = async () => { | |
const res = await fetch( | |
'https://jsonplaceholder.typicode.com/posts?_start=2&_limit=5' | |
); | |
const data = await res.json(); |
const UserPropsInjectorMiddleware = (store: any) => (next: any) => (action: any) => { | |
// This will append userProps to all the actions called | |
// Store used here is an immutable state object, so store.getState() | |
// is an immutable object and need to use 'get' method to get attributes | |
// use store.getState().userData if it is a plain object | |
action.userProps = store.getState().get('userData') | |
const result = next(action) | |
return result | |
} | |
export default UserPropsInjectorMiddleware; |
import * as React from 'react' | |
interface Props { | |
children: React.ReactNode; | |
type: 'desktop' | 'mobile' | 'tablet'; | |
} | |
interface State { | |
width: number; | |
} | |
export const tabWidth = 992; | |
export const mobWidth = 767; |