Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSisb committed Jul 24, 2019
0 parents commit ec6f106
Show file tree
Hide file tree
Showing 474 changed files with 13,317 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{tf,tfvars}]
indent_size = 2

[makefile]
indent_size = 4
indent_style = tab

[*.sh]
indent_size = 4
indent_style = tab
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules/**
/bower_components/**
/packages/**/node_modules/**
**/lib/**
rollup.config.js
79 changes: 79 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Based on https://github.com/iamturns/create-exposed-app/blob/master/.eslintrc.js
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
plugins: ['@typescript-eslint', 'eslint-comments', 'jest', 'promise', 'unicorn', 'emotion'],
extends: [
'airbnb-typescript',
'plugin:@typescript-eslint/recommended',
'plugin:eslint-comments/recommended',
'plugin:jest/recommended',
'plugin:promise/recommended',
'plugin:unicorn/recommended',
'prettier',
'prettier/react',
'prettier/@typescript-eslint',
],
env: {
node: true,
browser: true,
jest: true,
},
rules: {
// Too restrictive, writing ugly code to defend against a very unlikely scenario: https://eslint.org/docs/rules/no-prototype-builtins
'no-prototype-builtins': 'off',
// https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
'import/prefer-default-export': 'off',
'import/no-default-export': 'error',
// Too restrictive: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/destructuring-assignment.md
'react/destructuring-assignment': 'off',
// No jsx extension: https://github.com/facebook/create-react-app/issues/87#issuecomment-234627904
'react/jsx-filename-extension': 'off',
// Use function hoisting to improve code readability
'no-use-before-define': ['error', {functions: false, classes: true, variables: true}],
// Makes no sense to allow type inferrence for expression parameters, but require typing the response
'@typescript-eslint/explicit-function-return-type': [
'error',
{allowExpressions: true, allowTypedFunctionExpressions: true},
],
'@typescript-eslint/no-use-before-define': [
'error',
{functions: false, classes: true, variables: true, typedefs: true},
],
// Common abbreviations are known and readable
'unicorn/prevent-abbreviations': 'off',
// We don't really have a style yet. To be discussed
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/filename-case.md
'unicorn/filename-case': 'off',
// This rule tells people to do something (import foo = require('foo')) which doesn't work
// with babel compiled typescript.
'@typescript-eslint/no-var-requires': 'off',
// Enforce template strings for styles over objects for consistent codebase
'emotion/syntax-preference': [2, 'string'],
// PropTypes are useless with typescript
'react/prop-types': 'off',
// Avoid having to redefine story deps for this monorepo
// https://github.com/benmosher/eslint-plugin-import/issues/458#issuecomment-468235671
'import/no-extraneous-dependencies': context => [
'error',
{
devDependencies: true,
packageDir: [context.getFilename(), __dirname],
},
],

'no-useless-constructor': 'off',
eqeqeq: ['error', 'smart'],
'no-plusplus': 'off',
'consistent-return': 'off',
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'],
},
},
},
};
78 changes: 78 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# 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

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://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/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# gatsby files
.cache/
public

# next.js build output
.next

# Apple gunk
.DS_Store

.jest-coverage
.jest-cache
**/lib/*
**/dist/*
packages/**/docs
**/paste-icons/react/*
*.tsbuildinfo
package-lock.json
tools/.cache/packages.json
53 changes: 53 additions & 0 deletions .jest/resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const cachedPackages = require('../tools/.cache/packages.json');

/**
* Holds information about every @paste package in our repo
* Our cache doesn't include the entry points in the location, so
* we loop over the packages, get the entry point from the 'main' field,
* and update the location property.
*
* Shape:
* {
* '@paste/button': {
* name: '@paste/button',
version: '0.1.2',
private: false,
location: '/Users/username/paste/packages/paste-core/components/button/dist/index.js'
}
* }
*/
const keyedPackages = cachedPackages.reduce((acc, currentPackage) => {
const packageJson = require(`${currentPackage.location}/package.json`);

// If there's no main entrypoint, don't update the location path.
// Note: the icons package doesn't have a main entrypoint
if (packageJson.main == null) {
acc[currentPackage.name] = currentPackage;
} else {
// Make sure to set the location to the dist/main entrypoint.
acc[currentPackage.name] = {
...currentPackage,
location: `${currentPackage.location}/${packageJson.main}`,
};
}
return acc;
}, {});

/**
* We're creating our own module resolver for jest because it is having a
* very hard time finding our monorepo packages. When we import a `@paste`
* package we use our own module resolution, otherwise we use the default
* node one.
*
* @param {string} package
* @param {*} details
*/
function customResolver(package, details) {
if (package.includes('@paste/')) {
return keyedPackages[package].location;
}

return details.defaultResolver(package, details);
}

module.exports = customResolver;
7 changes: 7 additions & 0 deletions .jest/setupFilesAfterEnv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const emotion = require('emotion');
const {createSerializer} = require('jest-emotion');
const Enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');

expect.addSnapshotSerializer(createSerializer(emotion));
Enzyme.configure({adapter: new Adapter()});
25 changes: 25 additions & 0 deletions .jest/transform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const babelOptions = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
'@babel/typescript',
'@babel/react',
[
'@emotion/babel-preset-css-prop',
{
sourceMap: false,
autoLabel: true,
labelFormat: '[local]',
cssPropOptimization: false,
},
],
],
plugins: ['macros', '@babel/proposal-class-properties', '@babel/proposal-object-rest-spread'],
};
module.exports = require('babel-jest').createTransformer(babelOptions);
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.md
*.mdx
*.json
docs
lib/
dist/
public/
__IconList.tsx
*.d.ts
17 changes: 17 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"printWidth": 120,
"trailingComma": "es5",
"bracketSpacing": false,
"singleQuote": true,
"jsxBracketSameLine": false,
"tabWidth": 2,
"overrides": [
{
"files": "*.yml",
"options": {
"parser": "yaml",
"singleQuote": false
}
}
]
}
5 changes: 5 additions & 0 deletions .storybook/addons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import '@storybook/addon-links/register';
/* Ordering of imports here sets the order of tabs in the UI */
import '@storybook/addon-knobs/register';
import 'storybook-readme/register';
import '@storybook/addon-actions/register';
30 changes: 30 additions & 0 deletions .storybook/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const getPresets = isDev => [
'env',
'@babel/preset-react',
'@babel/preset-typescript',
[
// Automatically includes the 'emotion' preset.
'@emotion/babel-preset-css-prop',
{
sourceMap: isDev,
autoLabel: isDev,
labelFormat: '[local]',
cssPropOptimization: !isDev,
},
],
];

const BASE_PLUGINS = ['macros', '@babel/proposal-class-properties', '@babel/proposal-object-rest-spread'];

module.exports = {
env: {
production: {
presets: getPresets(true),
plugins: BASE_PLUGINS,
},
development: {
presets: getPresets(false),
plugins: BASE_PLUGINS,
},
},
};
26 changes: 26 additions & 0 deletions .storybook/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const {addDecorator, addParameters, configure} = require('@storybook/react');
const {withThemeProvider} = require('./withThemePovider');
const requireContext = require('require-context.macro');
import {addReadme} from 'storybook-readme';

addParameters({
isFullScreen: false,
showNav: true,
showPanel: true,
panelPosition: 'bottom',
sortStoriesByKind: false,
hierarchySeparator: /\/|\./,
hierarchyRootSeparator: /\|/,
sidebarAnimations: true,
enableShortcuts: true,
});
addDecorator(withThemeProvider);
addDecorator(addReadme);

const req = requireContext('../packages/', true, /\.stories.tsx?$/);

function loadStories() {
req.keys().forEach(filename => req(filename));
}

configure(loadStories, module);
1 change: 1 addition & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<link rel="stylesheet" type="text/css" href="//cloud.typography.com/6230892/752864/css/fonts.css" />
Loading

0 comments on commit ec6f106

Please sign in to comment.