Skip to content

Commit 90ee93e

Browse files
committed
Initial commit
0 parents  commit 90ee93e

32 files changed

+20467
-0
lines changed

.drone.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
kind: pipeline
3+
type: docker
4+
name: template
5+
6+
steps:
7+
- name: npm_auth
8+
image: robertstettner/drone-npm-auth
9+
settings:
10+
token:
11+
from_secret: npm_token
12+
13+
- name: build
14+
image: node:latest
15+
commands:
16+
- yarn install
17+
- yarn build
18+
19+
- name: publish
20+
image: node:latest
21+
environment:
22+
GH_TOKEN:
23+
from_secret: github_token
24+
commands:
25+
- npm publish --access public
26+
- yarn deploy-storybook --ci
27+
when:
28+
ref:
29+
- refs/tags/v*
30+
31+
- name: code-analysis
32+
image: committed/drone-sonarqube-node
33+
environment:
34+
SONAR_HOST:
35+
from_secret: sonar_host
36+
SONAR_TOKEN:
37+
from_secret: sonar_token
38+
settings:
39+
exclusions: '**/node_modules/**/*,**/dist/**/*.js'
40+
when:
41+
branch:
42+
- master
43+
event:
44+
exclude:
45+
- pull_request
46+
47+
- name: slack
48+
image: plugins/slack
49+
settings:
50+
channel: group-ci
51+
webhook:
52+
from_secret: slack_webhook
53+
template:
54+
from_secret: slack_template
55+
when:
56+
status:
57+
- failure
58+
59+
- name: announce
60+
image: plugins/slack
61+
settings:
62+
channel: group-dev
63+
webhook:
64+
from_secret: slack_webhook
65+
template: >
66+
:tada: New version ${DRONE_TAG} of `@committed/template` available
67+
when:
68+
ref:
69+
- refs/tags/v*
70+
status:
71+
- success

.eslintrc.js

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es6: true,
5+
node: true,
6+
jest: true,
7+
},
8+
ignorePatterns: ['setupTests.tsx','*.test.ts*', '*.stories.tsx'],
9+
extends: [
10+
// non-ts recommended rules
11+
'eslint:recommended',
12+
// remove non-ts rules covered by typescript-eslint
13+
'plugin:@typescript-eslint/eslint-recommended',
14+
// ts recommended rules
15+
// can be slow
16+
'plugin:@typescript-eslint/recommended',
17+
// ts recommended rules that require tsconfig.json to be specified in parserOptions.project
18+
// can be slow
19+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
20+
'prettier/@typescript-eslint',
21+
22+
'plugin:react/recommended',
23+
'plugin:security/recommended',
24+
// remove rules covered by prettier
25+
'prettier/@typescript-eslint',
26+
'plugin:prettier/recommended',
27+
],
28+
globals: {
29+
Atomics: 'readonly',
30+
SharedArrayBuffer: 'readonly',
31+
},
32+
parser: '@typescript-eslint/parser',
33+
parserOptions: {
34+
ecmaFeatures: {
35+
jsx: true,
36+
modules: true,
37+
},
38+
ecmaVersion: 2018,
39+
sourceType: 'module',
40+
project: ['./tsconfig.json'],
41+
},
42+
plugins: ['react', '@typescript-eslint'],
43+
rules: {
44+
'@typescript-eslint/ban-ts-ignore': 'off',
45+
'@typescript-eslint/ban-types': 'warn',
46+
'@typescript-eslint/interface-name-prefix': 'off',
47+
'@typescript-eslint/naming-convention': [
48+
'warn',
49+
{
50+
selector: 'function',
51+
format: ['camelCase', 'PascalCase'],
52+
},
53+
],
54+
'@typescript-eslint/no-base-to-string': 'warn',
55+
'@typescript-eslint/no-empty-function': 'warn',
56+
'@typescript-eslint/no-explicit-any': 'warn',
57+
'@typescript-eslint/no-floating-promises': 'error',
58+
'@typescript-eslint/no-implied-eval': 'warn',
59+
'@typescript-eslint/no-inferrable-types': 'warn',
60+
'@typescript-eslint/no-misused-promises': 'error',
61+
'@typescript-eslint/no-non-null-assertion': 'warn',
62+
'@typescript-eslint/no-throw-literal': 'warn',
63+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn',
64+
'@typescript-eslint/no-unnecessary-condition': 'warn',
65+
'@typescript-eslint/no-unnecessary-qualifier': 'warn',
66+
'@typescript-eslint/no-unnecessary-type-arguments': 'warn',
67+
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
68+
'@typescript-eslint/no-unsafe-assignment': 'warn',
69+
'@typescript-eslint/no-unsafe-call': 'warn',
70+
'@typescript-eslint/no-unsafe-member-access': 'warn',
71+
'@typescript-eslint/no-unsafe-return': 'warn',
72+
'@typescript-eslint/no-unused-vars-experimental': 'off',
73+
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
74+
'@typescript-eslint/prefer-readonly': 'warn',
75+
// Ideally this would be on, but it has too many false positives. Should apply to arrays but seems to apply to everything, potentially a bug
76+
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
77+
'@typescript-eslint/prefer-reduce-type-parameter': 'warn',
78+
'@typescript-eslint/prefer-regexp-exec': 'warn',
79+
'@typescript-eslint/promise-function-async': 'error',
80+
'@typescript-eslint/promise-function-async': 'error',
81+
'@typescript-eslint/require-array-sort-compare': 'warn',
82+
// require-await is incompatible with promise-function-async
83+
'@typescript-eslint/require-await': 'off',
84+
'@typescript-eslint/restrict-plus-operands': 'warn',
85+
'@typescript-eslint/restrict-template-expressions': [
86+
'warn',
87+
{
88+
allowNumber: true,
89+
allowBoolean: true,
90+
allowNullable: false,
91+
},
92+
],
93+
'@typescript-eslint/strict-boolean-expressions': 'warn',
94+
'@typescript-eslint/switch-exhaustiveness-check': 'warn',
95+
// TODO: We use this in mocks in .spec.ts, perhaps syntax is incorrect?
96+
'@typescript-eslint/unbound-method': 'off',
97+
'react/jsx-pascal-case': [
98+
'warn',
99+
{
100+
ignore: [
101+
'h1',
102+
'h2',
103+
'h3',
104+
'h4',
105+
'h5',
106+
'h6',
107+
'd1',
108+
'd2',
109+
'd3',
110+
'd4',
111+
'd5',
112+
'd6',
113+
],
114+
},
115+
],
116+
},
117+
}

.github/workflows/main.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
on: [push]
3+
jobs:
4+
build:
5+
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }}
6+
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
node: ['14.x']
11+
os: [ubuntu-latest]
12+
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v2
16+
17+
- name: Use Node ${{ matrix.node }}
18+
uses: actions/setup-node@v1
19+
with:
20+
node-version: ${{ matrix.node }}
21+
22+
- name: Install deps and build (with cache)
23+
uses: bahmutov/npm-install@v1
24+
25+
- name: Lint
26+
run: yarn lint
27+
28+
- name: Test
29+
run: yarn test --ci --coverage --maxWorkers=2
30+
31+
- name: Build
32+
run: yarn build

.github/workflows/size.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: size
2+
on: [pull_request]
3+
jobs:
4+
size:
5+
runs-on: ubuntu-latest
6+
env:
7+
CI_JOB_NUMBER: 1
8+
steps:
9+
- uses: actions/checkout@v1
10+
- uses: andresz1/size-limit-action@v1
11+
with:
12+
github_token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
# See https://help.github.com/ignore-files/ for more about ignoring files.
3+
4+
# dependencies
5+
node_modules
6+
7+
# builds
8+
build
9+
dist
10+
.rpt2_cache
11+
lib
12+
lib-esm
13+
_bundles
14+
docs
15+
16+
# misc
17+
.cache
18+
.DS_Store
19+
.env
20+
.env.local
21+
.env.development.local
22+
.env.test.local
23+
.env.production.local
24+
25+
npm-debug.log*
26+
yarn-debug.log*
27+
yarn-error.log*
28+
29+
.docz
30+
.vscode

.npmignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.*
2+
**/tsconfig.json
3+
**/webpack.config.js
4+
node_modules
5+
src
6+
stories
7+
example
8+
lib
9+
lib-esm
10+
_bundles
11+
tsdx.config.js

.prettierignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dist
2+
.rpt2_cache
3+
lib
4+
lib-esm
5+
_bundles
6+
docs

.storybook/main.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
3+
addons: [
4+
'@storybook/addon-links',
5+
{
6+
name: '@storybook/addon-essentials',
7+
options: {
8+
backgrounds: false,
9+
},
10+
},
11+
],
12+
// https://storybook.js.org/docs/react/configure/typescript#mainjs-configuration
13+
typescript: {
14+
check: true, // type-check stories during Storybook build
15+
}
16+
}

.storybook/preview.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// https://storybook.js.org/docs/react/writing-stories/parameters#global-parameters
2+
export const parameters = {
3+
// https://storybook.js.org/docs/react/essentials/actions#automatically-matching-args
4+
actions: { argTypesRegex: '^on.*' },
5+
};

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Committed Software Ltd
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)