Skip to content

Instantly share code, notes, and snippets.

View jtomaszewski's full-sized avatar

Jacek Tomaszewski jtomaszewski

View GitHub Profile
@jtomaszewski
jtomaszewski / 015-disable_bitcode_on_ios.sh
Last active January 5, 2016 07:59
hooks/after_platform_add/015-disable_bitcode_on_ios.sh
#!/bin/sh
# Exit, if there's no ios here.
[[ $CORDOVA_PLATFORMS == *"ios"* ]] || exit 0
# This is needed until https://github.com/Wizcorp/phonegap-facebook-plugin/issues/1116 gets fixed.
XCCONFIG_FILE="platforms/ios/cordova/build.xcconfig"
if ! cat $XCCONFIG_FILE | grep -q "ENABLE_BITCODE"; then
echo "\nENABLE_BITCODE = NO" >> $XCCONFIG_FILE
fi

Code formatting & linting

In Recruitee, enforce correct formatting of our files with js-beautify for all src/ng2/**/*.html files and prettier for all **/*.{ts,js,css,less} files.

We also lint all **/*.ts files (and components' .html templates) code style with TSLint, although during the automatic linting, we ignore legacy files listed in ./tslint.without-legacy.json.

During npm install, husky automatically sets up a pre-commit hook in this repository, that will check your code before each commit and fail if it's wrong. If you want to skip the pre-commit hook, you can run git commit --no-verify.

Additionally, our CI will also check your code with npm run format-test && npm run lint command and fail if it's badly formatted or its' non-legacy fi

<div class="sidebar">
<my-search-page-sidebar
[filters]="state.filters"
(filtersChange)="changeFilters($event)">
</my-search-page-sidebar>
</div>
<div class="content">
<h2>Search</h2>
<my-search-page-query-input
[value]="state.query"
// wrong (impure)
class DateTimePickerComponent {
timeZone: string = "Europe/Warsaw";
constructor(private account: AccountService) {
if (this.account.currentUser) {
this.timeZone = this.account.currentUser.timeZone;
}
}
flatten = array => {
return array.reduce((sum, x) => {
if (Array.isArray(x)) {
return [...sum, ...flatten(x)];
} else {
return [...sum, x];
}
}, [])
};
@jtomaszewski
jtomaszewski / rt-stateful-component.ts
Created January 11, 2019 11:05
Example implementation of StatefulComponent in Angular
// Code authored by [Recruitee](https://recruitee.com)
// License: MIT
import { Injectable, ChangeDetectorRef } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
const immutableStateInvariantMiddleware = process.env.NODE_ENV !== 'production'
? require('redux-immutable-state-invariant').default
: null;
export interface RtStatefulComponent<State> {

Code formatting & linting

In AppUnite, we enforce proper code style by:

  1. formatting of all our **/*.{js,jsx,ts,tsx,css,less,scss} files with prettier,

  2. linting all **/*.js files with ESLint,

  3. linting all **/*.ts files with TSLint.

@jtomaszewski
jtomaszewski / axe.js
Last active March 11, 2019 22:41 — forked from donaldpipowitch/axe.js
aXe based a11y checks in your CI for Storybook
/* eslint-disable no-await-in-loop */
/* eslint-disable no-restricted-syntax */
// eslint-disable-next-line import/no-extraneous-dependencies
const puppeteer = require('puppeteer');
const { green, red, cyan, grey, bold } = require('chalk');
const url = 'http://localhost:9001/iframe.html';
function runAxe() {
return new Promise((resolve, reject) =>
// Action creator function
function fetchArticles(params = {}) {
return dispatch => {
dispatch({ type: 'FETCH_ARTICLES_START', params });
ArticlesService.getArticles(params).then(
response => {
dispatch({
type: 'FETCH_ARTICLES_SUCCESS',
data: response.data
});
import { call, put, takeLatest } from "redux-saga/effects";
// Action creator function
function fetchArticles(params) {
return { type: FETCH_ARTICLES, params };
}
// Sagas
function* fetchArticlesSaga() {
yield takeLatest(FETCH_ARTICLES, triggerFetchArticles);