Skip to content

Instantly share code, notes, and snippets.

Joe Lencioni lencioni

Block or report user

Report or block lencioni

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lencioni
lencioni / array.includes.js
Last active Jan 11, 2020
Webpack module replacements for shims/polyfill packages
View array.includes.js
module.exports = function arrayIncludes(arr, search, fromIndex) {
return arr.includes(search, fromIndex);
};
@lencioni
lencioni / propTypes.diff
Created Aug 22, 2018
react-dates propTypes removal diff
View propTypes.diff
diff -bur esm-before/components/CalendarDay.js esm/components/CalendarDay.js
--- esm-before/components/CalendarDay.js 2018-08-22 15:21:46.000000000 -0700
+++ esm/components/CalendarDay.js 2018-08-22 15:22:02.000000000 -0700
@@ -25,7 +25,7 @@
import { DAY_SIZE } from '../constants';
-var propTypes = forbidExtraProps(_objectAssign({}, withStylesPropTypes, {
+var propTypes = process.env.NODE_ENV !== "production" ? forbidExtraProps(_objectAssign({}, withStylesPropTypes, {
day: momentPropTypes.momentObj,
@lencioni
lencioni / dynamic-import-requires-webpack-chunkname-test.js
Last active Mar 22, 2018
dynamic-import-requires-webpack-chunkname ESLint rule
View dynamic-import-requires-webpack-chunkname-test.js
/**
* @fileoverview dynamicImport requires a leading comment with the webpackChunkName
* @author Kimberly Strauch
* @copyright 2018 Kimberly Strauch. All rights reserved.
* See LICENSE file in root directory for full license.
*/
'use strict';
const rule = require('../../../lib/rules/dynamic-import-requires-webpack-chunkname');
@lencioni
lencioni / find-nearly-empty-directories.sh
Created Aug 31, 2017
Script to help find nearly empty directories
View find-nearly-empty-directories.sh
#!/bin/sh
# Find directories that only contain a single .eslintrc file.
# Adapted from https://superuser.com/a/727070
# Enable double glob to find hidden files
shopt -s dotglob
# Loop through every subdirectory.
# Currently need to tweak this line and run it for every level of directory
@lencioni
lencioni / story.js
Created May 18, 2017
Building Storybook stories with allExamples.js
View story.js
import { storiesOf, action } from '@kadira/storybook';
import { browserDLSExamples } from '../examples/allExamples';
import fixtures from '../examples/fixtures';
const { DLSExamples, DLSComponents } = browserDLSExamples();
Object.entries(DLSExamples).forEach(([name, examplesFunc]) => {
let story = storiesOf(name, module);
@lencioni
lencioni / allExamples.js
Created May 18, 2017
Slurping up all examples and components with webpack
View allExamples.js
// Keep track of all DLS components:
const DLSComponents = {};
// Keep track of all DLS examples:
const DLSExamples = {};
function requireComponent(srcFile, requireFn) {
// Extract the component name from the file name:
let componentName = path.basename(srcFile, '.jsx');
// Handle ComponentName/index.jsx:
@lencioni
lencioni / Button_example.jsx
Last active May 18, 2017
Button example file
View Button_example.jsx
import React from 'react';
export default ({ Button }, { action, fixtures }) => ({
// Optional property that can be used to mark related components in Storybook
tags: ['tag1', 'tag2'],
// Optional property for some Markdown that will show up in the Usage tab in
// Storybook
usage: `
Button documentation in Markdown.
@lencioni
lencioni / AsyncComponent.jsx
Created Jan 8, 2017
<AsyncComponent> at Airbnb used for Webpack code splitting
View AsyncComponent.jsx
// Usage:
//
// function loader() {
// return new Promise((resolve) => {
// if (process.env.LAZY_LOAD) {
// require.ensure([], (require) => {
// resolve(require('./SomeComponent').default);
// });
// }
// });
@lencioni
lencioni / find-dead-js-modules.sh
Last active Jun 26, 2017 — forked from trotzig/find-dead-js-modules.sh
This script will find javascript modules that aren't currently used in your application.
View find-dead-js-modules.sh
#!/bin/bash
# Make the script fail on the first error encountered.
set -euo pipefail
# Create a temp folder that we can use to store files in.
if [ "$(uname -s)" = "Darwin" ]; then
tmp_dir=$(mktemp -d -t find-dead-modules.XXXXXXXX)
else
tmp_dir=$(mktemp -d --tmpdir find-dead-modules.XXXXXXXX)
@lencioni
lencioni / countTests.sh
Last active May 31, 2016
Count the number of JavaScript tests in a git repo every day
View countTests.sh
#!/bin/bash
echo '"days ago","tests"' > testCounts.csv
for i in $(seq 1 365);
do
git checkout "$(git rev-list -n 1 --before="$i days ago" origin/master)"
matches=$(\
find spec/javascripts -name "*.js" -o -name "*.jsx" | \
You can’t perform that action at this time.