Skip to content

Commit

Permalink
feat: migrate code to ts
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Sep 6, 2021
1 parent 428a8d7 commit a08aaca
Show file tree
Hide file tree
Showing 27 changed files with 4,502 additions and 92 deletions.
1 change: 1 addition & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": ["@commitlint/config-conventional"] }
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
132 changes: 132 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"env": { "node": true },
"extends": [
"plugin:eslint-comments/recommended",
"eslint:recommended",
"plugin:security/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"airbnb-base",
"airbnb-typescript/base",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:prettier/recommended"
],
"ignorePatterns": ["build.ts"],
"parser": "@typescript-eslint/parser",
"parserOptions": { "ecmaVersion": "latest", "project": "tsconfig.json", "sourceType": "module" },
"plugins": ["@typescript-eslint", "simple-import-sort", "prettier"],
"root": true,
"rules": {
"@typescript-eslint/array-type": ["error", { "default": "generic" }],
"@typescript-eslint/ban-tslint-comment": "error",
"@typescript-eslint/brace-style": "error",
"@typescript-eslint/comma-dangle": ["error", "always-multiline"],
"@typescript-eslint/comma-spacing": "error",
"@typescript-eslint/consistent-indexed-object-style": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/default-param-last": "error",
"@typescript-eslint/dot-notation": "error",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/func-call-spacing": "error",
"@typescript-eslint/init-declarations": "error",
"@typescript-eslint/keyword-spacing": "error",
"@typescript-eslint/lines-between-class-members": "error",
"@typescript-eslint/member-delimiter-style": "error",
"@typescript-eslint/member-ordering": "error",
"@typescript-eslint/method-signature-style": "error",
"@typescript-eslint/naming-convention": "error",
"@typescript-eslint/no-base-to-string": "error",
"@typescript-eslint/no-confusing-non-null-assertion": "error",
"@typescript-eslint/no-confusing-void-expression": "error",
"@typescript-eslint/no-dupe-class-members": "error",
"@typescript-eslint/no-duplicate-imports": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-implicit-any-catch": "error",
"@typescript-eslint/no-invalid-this": "error",
"@typescript-eslint/no-invalid-void-type": "error",
"@typescript-eslint/no-loop-func": "error",
"@typescript-eslint/no-loss-of-precision": "error",
"@typescript-eslint/no-parameter-properties": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/no-throw-literal": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-arguments": "error",
"@typescript-eslint/no-unnecessary-type-constraint": "error",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unused-expressions": "error",
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/non-nullable-type-assertion-style": "error",
"@typescript-eslint/object-curly-spacing": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-literal-enum-member": ["error", { "allowBitwiseExpressions": true }],
"@typescript-eslint/prefer-optional-chain": "error",
"@typescript-eslint/prefer-reduce-type-parameter": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/quotes": ["error", "single", { "avoidEscape": true }],
"@typescript-eslint/require-array-sort-compare": ["error", { "ignoreStringArrays": true }],
"@typescript-eslint/return-await": "error",
"@typescript-eslint/semi": "error",
"@typescript-eslint/sort-type-union-intersection-members": "error",
"@typescript-eslint/space-infix-ops": ["error", { "int32Hint": false }],
"@typescript-eslint/switch-exhaustiveness-check": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "error",
"brace-style": "off",
"camelcase": "off",
"comma-dangle": "off",
"comma-spacing": "off",
"default-param-last": "off",
"dot-notation": "off",
"eslint-comments/disable-enable-pair": "off",
"eslint-comments/no-unlimited-disable": "off",
"eslint-comments/no-unused-disable": "error",
"func-call-spacing": "off",
"import/no-extraneous-dependencies": [
"error",
{ "devDependencies": true, "peerDependencies": true }
],
"import/order": "off",
"import/prefer-default-export": "off",
"init-declarations": "off",
"keyword-spacing": "off",
"lines-between-class-members": "off",
"no-console": "off",
"no-dupe-class-members": "off",
"no-duplicate-imports": "off",
"no-empty": ["error", { "allowEmptyCatch": true }],
"no-invalid-this": "off",
"no-loop-func": "off",
"no-loss-of-precision": "off",
"no-param-reassign": "off",
"no-redeclare": "off",
"no-return-await": "off",
"no-return-assign": "off",
"no-shadow": "off",
"no-sequences": "off",
"no-throw-literal": "off",
"no-unused-expressions": "off",
"no-use-before-define": "off",
"no-useless-constructor": "off",
"object-curly-spacing": "off",
"quotes": "off",
"semi": "off",
"security/detect-object-injection": "off",
"simple-import-sort/exports": "error",
"simple-import-sort/imports": [
"error",
{ "groups": [["^.*\\u0000$"], ["^\\u0000"], ["^@?\\w"], ["^"], ["^\\."]] }
],
"space-infix-ops": "off"
},
"settings": { "import/parsers": { "@typescript-eslint/parser": [".ts"] } }
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
Expand Down
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: "daily"
interval: 'daily'
24 changes: 12 additions & 12 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: "CodeQL"
name: 'CodeQL'

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
Expand All @@ -21,16 +21,16 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
language: ['javascript']

steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Checkout Repository
uses: actions/checkout@v2

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
20 changes: 17 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
Expand Down Expand Up @@ -41,8 +42,8 @@ build/Release
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo
Expand Down Expand Up @@ -71,20 +72,23 @@ typings/
# dotenv environment variables file
.env
.env.test
.env.production

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

Expand All @@ -102,3 +106,13 @@ dist

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn
4 changes: 4 additions & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

git status
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint:staged
yarn audit || exit 0
5 changes: 5 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"*": "prettier --write --ignore-unknown",
"package*.json": "prettier-package-json --write",
"!(*build).ts": "eslint --fix --max-warnings 0"
}
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*
*
13 changes: 0 additions & 13 deletions .prettierrc.js

This file was deleted.

13 changes: 13 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 100,
"quoteProps": "as-needed",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"editor.codeActionsOnSave": ["source.fixAll.format", "source.fixAll.eslint"],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": false,
"eslint.packageManager": "yarn",
"eslint.probe": ["typescript"],
"[shellscript]": { "editor.defaultFormatter": "foxundermoon.shell-format" },
"[ignore]": { "editor.defaultFormatter": "foxundermoon.shell-format" }
}
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
script-shell sh
22 changes: 11 additions & 11 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand Down Expand Up @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand Down
11 changes: 11 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

rm -rf dist
mkdir dist

npx tsc
npx esbuild ./dist/index.js --outfile=./dist/index.min.js --minify
rm dist/index.js

cp .npmignore LICENSE README.md dist
cp package-dist.json dist/package.json

0 comments on commit a08aaca

Please sign in to comment.