Skip to content

Commit 5b5c5d9

Browse files
committed
feat: initial version
0 parents  commit 5b5c5d9

21 files changed

+10485
-0
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
indent_style = space
10+
indent_size = 2

.eslintignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
coverage/**/*
2+
dist/**/*
3+
dist-cjs/**/*
4+
patches/**/*
5+
release.config.js
6+
.eslintrc.js
7+
**/fixtures/**

.eslintrc.js

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
/* eslint-disable no-console */
2+
3+
module.exports = {
4+
plugins: ['@typescript-eslint', 'jest', 'import', 'eslint-comments'],
5+
env: {
6+
browser: true,
7+
node: true,
8+
},
9+
extends: [
10+
'eslint:recommended',
11+
'plugin:@typescript-eslint/eslint-recommended',
12+
'plugin:@typescript-eslint/recommended',
13+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
14+
'prettier/@typescript-eslint',
15+
],
16+
parser: '@typescript-eslint/parser',
17+
parserOptions: {
18+
project: './tsconfig.eslint.json',
19+
tsconfigRootDir: __dirname,
20+
ecmaVersion: 2019,
21+
ecmaFeatures: {
22+
jsx: false,
23+
},
24+
},
25+
overrides: [
26+
{
27+
files: ['**/*.test.ts'],
28+
extends: ['plugin:jest/recommended'],
29+
env: {
30+
'jest/globals': true,
31+
},
32+
rules: {
33+
'jest/no-disabled-tests': 'warn',
34+
'jest/no-focused-tests': 'error',
35+
'jest/no-alias-methods': 'error',
36+
'jest/no-identical-title': 'error',
37+
'jest/no-jasmine-globals': 'error',
38+
'jest/no-jest-import': 'error',
39+
'jest/no-test-prefixes': 'error',
40+
'jest/no-test-return-statement': 'error',
41+
'jest/prefer-to-have-length': 'warn',
42+
'jest/prefer-spy-on': 'error',
43+
'jest/valid-expect': 'error',
44+
'@typescript-eslint/ban-ts-ignore': 'off',
45+
},
46+
},
47+
],
48+
rules: {
49+
'no-var': 'error',
50+
'prefer-const': 'error',
51+
'no-trailing-spaces': 'error',
52+
radix: 'error',
53+
'no-multiple-empty-lines': 'error',
54+
55+
'@typescript-eslint/no-unused-vars': [
56+
'error',
57+
{vars: 'all', args: 'none', varsIgnorePattern: '[iI]gnored'},
58+
],
59+
'@typescript-eslint/consistent-type-definitions': ['warn', 'interface'],
60+
'@typescript-eslint/prefer-optional-chain': 'error',
61+
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
62+
63+
'@typescript-eslint/unbound-method': [
64+
'error',
65+
{
66+
ignoreStatic: true,
67+
},
68+
],
69+
70+
'@typescript-eslint/no-explicit-any': 'error',
71+
'@typescript-eslint/no-non-null-assertion': 'error',
72+
// '@typescript-eslint/no-var-requires': 'off',
73+
'@typescript-eslint/no-use-before-define': 'off',
74+
'@typescript-eslint/unbound-method': 'off',
75+
'@typescript-eslint/explicit-function-return-type': 'off',
76+
'@typescript-eslint/no-parameter-properties': 'off',
77+
78+
// some of these don't work as expected:
79+
'@typescript-eslint/explicit-module-boundary-types': 'off',
80+
'@typescript-eslint/no-unsafe-return': 'off',
81+
'@typescript-eslint/no-unsafe-call': 'off',
82+
'@typescript-eslint/ban-ts-comment': 'off',
83+
'@typescript-eslint/restrict-template-expressions': 'off',
84+
'@typescript-eslint/no-unsafe-assignment': 'off',
85+
'@typescript-eslint/no-unsafe-member-access': 'off',
86+
// '@typescript-eslint/triple-slash-reference': 'off',
87+
88+
// eslint base
89+
//
90+
91+
'comma-dangle': ['error', 'always-multiline'],
92+
curly: ['error', 'multi-line'],
93+
'no-mixed-operators': 'off',
94+
'no-console': 'error',
95+
'no-process-exit': 'error',
96+
97+
//
98+
// eslint-plugin-eslint-comment
99+
//
100+
101+
// require a eslint-enable comment for every eslint-disable comment
102+
'eslint-comments/disable-enable-pair': [
103+
'error',
104+
{
105+
allowWholeFile: true,
106+
},
107+
],
108+
// disallow a eslint-enable comment for multiple eslint-disable comments
109+
'eslint-comments/no-aggregating-enable': 'error',
110+
// disallow duplicate eslint-disable comments
111+
'eslint-comments/no-duplicate-disable': 'error',
112+
// disallow eslint-disable comments without rule names
113+
'eslint-comments/no-unlimited-disable': 'error',
114+
// disallow unused eslint-disable comments
115+
'eslint-comments/no-unused-disable': 'error',
116+
// disallow unused eslint-enable comments
117+
'eslint-comments/no-unused-enable': 'error',
118+
// disallow ESLint directive-comments
119+
'eslint-comments/no-use': [
120+
'error',
121+
{
122+
allow: [
123+
'eslint-disable',
124+
'eslint-disable-line',
125+
'eslint-disable-next-line',
126+
'eslint-enable',
127+
],
128+
},
129+
],
130+
131+
//
132+
// eslint-plugin-import
133+
//
134+
135+
// disallow non-import statements appearing before import statements
136+
'import/first': 'error',
137+
// Require a newline after the last import/require in a group
138+
'import/newline-after-import': 'error',
139+
// Forbid import of modules using absolute paths
140+
'import/no-absolute-path': 'error',
141+
// disallow AMD require/define
142+
'import/no-amd': 'error',
143+
// forbid default exports
144+
'import/no-default-export': 'off',
145+
// Forbid the use of extraneous packages
146+
'import/no-extraneous-dependencies': [
147+
'error',
148+
{
149+
devDependencies: true,
150+
peerDependencies: true,
151+
optionalDependencies: false,
152+
},
153+
],
154+
// Forbid mutable exports
155+
'import/no-mutable-exports': 'error',
156+
// Prevent importing the default as if it were named
157+
'import/no-named-default': 'error',
158+
// Prohibit named exports
159+
'import/no-named-export': 'off', // we want everything to be a named export
160+
// Forbid a module from importing itself
161+
'import/no-self-import': 'error',
162+
// Require modules with a single export to use a default export
163+
'import/prefer-default-export': 'off', // we want everything to be named
164+
},
165+
}

.github/dependabot.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for npm
4+
- package-ecosystem: 'npm'
5+
# Look for `package.json` and `lock` files in the `root` directory
6+
directory: '/'
7+
# Check the npm registry for updates every day (weekdays)
8+
schedule:
9+
interval: 'weekly'
10+
11+
# Enable version updates for npm
12+
- package-ecosystem: 'npm'
13+
# Look for `package.json` and `lock` files in the `docgen` directory
14+
directory: '/docgen'
15+
# Check the npm registry for updates every day (weekdays)
16+
schedule:
17+
interval: 'weekly'
18+
19+
# Maintain dependencies for GitHub Actions
20+
- package-ecosystem: 'github-actions'
21+
# Look for `package.json` and `lock` files in the `root` directory
22+
directory: '/'
23+
# Check the npm registry for updates every day (weekdays)
24+
schedule:
25+
interval: 'weekly'

.github/workflows/ci-cd.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- next
8+
pull_request:
9+
branches:
10+
- '**'
11+
12+
jobs:
13+
typecheck:
14+
name: Check types (node ${{ matrix.node }})
15+
runs-on: [ubuntu-latest]
16+
strategy:
17+
matrix:
18+
node: [14]
19+
steps:
20+
- name: Information
21+
if: github.actor == 'github-actions[bot]'
22+
run: echo No need to re-run this job
23+
- uses: actions/checkout@v2
24+
if: github.actor != 'github-actions[bot]'
25+
- name: Cache Dependencies
26+
uses: actions/cache@v2.1.4
27+
id: yarn-cache # use this to check for `cache-hit`
28+
with:
29+
path: |
30+
./node_modules
31+
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-yarn
34+
- uses: actions/setup-node@v2.1.4
35+
if: github.actor != 'github-actions[bot]'
36+
with:
37+
node-version: ${{ matrix.node }}
38+
- name: Install dependencies
39+
if: steps.yarn-cache.outputs.cache-hit != 'true' && github.actor != 'github-actions[bot]'
40+
run: yarn
41+
- name: Check types
42+
if: github.actor != 'github-actions[bot]'
43+
run: yarn ci:test:type
44+
45+
test:
46+
name: Test (node ${{ matrix.node }})
47+
runs-on: [ubuntu-latest]
48+
strategy:
49+
matrix:
50+
node: [14]
51+
steps:
52+
- name: Information
53+
if: github.actor == 'github-actions[bot]'
54+
run: echo No need to re-run this job
55+
- uses: actions/checkout@v2
56+
if: github.actor != 'github-actions[bot]'
57+
with:
58+
# we want git-blame for SonarQube thus need full history
59+
fetch-depth: 0
60+
- name: Cache Dependencies
61+
uses: actions/cache@v2.1.4
62+
id: yarn-cache # use this to check for `cache-hit`
63+
with:
64+
path: |
65+
./node_modules
66+
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
67+
restore-keys: |
68+
${{ runner.os }}-yarn
69+
- uses: actions/setup-node@v2.1.4
70+
if: github.actor != 'github-actions[bot]'
71+
with:
72+
node-version: ${{ matrix.node }}
73+
- name: Install dependencies
74+
if: steps.yarn-cache.outputs.cache-hit != 'true' && github.actor != 'github-actions[bot]'
75+
run: yarn
76+
- name: Lint
77+
if: github.actor != 'github-actions[bot]'
78+
run: yarn ci:test:lint
79+
env:
80+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
81+
- name: Test
82+
if: github.actor != 'github-actions[bot]'
83+
run: yarn ci:test:unit
84+
85+
publish:
86+
name: Publish package
87+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next')
88+
needs:
89+
- typecheck
90+
- test
91+
runs-on: [ubuntu-latest]
92+
steps:
93+
- name: Information
94+
if: github.actor == 'github-actions[bot]'
95+
run: echo No need to re-run this job
96+
- uses: actions/checkout@v2
97+
- name: Cache Dependencies
98+
uses: actions/cache@v2.1.4
99+
id: yarn-cache # use this to check for `cache-hit`
100+
with:
101+
path: |
102+
./node_modules
103+
key: ${{ runner.os }}-${{ hashFiles('yarn.lock') }}
104+
restore-keys: |
105+
${{ runner.os }}-yarn
106+
- uses: actions/setup-node@v2.1.4
107+
with:
108+
node-version: 14
109+
registry-url: https://registry.npmjs.org/
110+
env:
111+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
112+
- name: Install dependencies
113+
if: steps.yarn-cache.outputs.cache-hit != 'true' && github.actor != 'github-actions[bot]'
114+
run: yarn
115+
- name: Build and release
116+
run: |
117+
yarn
118+
./release.sh
119+
env:
120+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
121+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/codeql-analysis.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: 'Code scanning'
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 6 * * 0'
8+
9+
jobs:
10+
CodeQL-Build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v2
16+
with:
17+
# We must fetch at least the immediate parents so that if this is
18+
# a pull request then we can checkout the head.
19+
fetch-depth: 2
20+
21+
# If this run was triggered by a pull request event, then checkout
22+
# the head of the pull request instead of the merge commit.
23+
- run: git checkout HEAD^2
24+
if: ${{ github.event_name == 'pull_request' }}
25+
26+
# Initializes the CodeQL tools for scanning.
27+
- name: Initialize CodeQL
28+
uses: github/codeql-action/init@v1
29+
# Override language selection by uncommenting this and choosing your languages
30+
# with:
31+
# languages: go, javascript, csharp, python, cpp, java
32+
33+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
34+
# If this step fails, then you should remove it and run the build manually (see below)
35+
- name: Autobuild
36+
uses: github/codeql-action/autobuild@v1
37+
38+
# ℹ️ Command-line programs to run using the OS shell.
39+
# 📚 https://git.io/JvXDl
40+
41+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
42+
# and modify them (or add more) to build your code if your project
43+
# uses a compiled language
44+
45+
#- run: |
46+
# make bootstrap
47+
# make release
48+
49+
- name: Perform CodeQL Analysis
50+
uses: github/codeql-action/analyze@v1

0 commit comments

Comments
 (0)