Skip to content

Commit c7a85a3

Browse files
authored
Add TypeScript support (#2)
* Converted project to Typescript (#1) * Updated eslint config and README.
1 parent 730c8b2 commit c7a85a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1588
-431
lines changed

.cspell.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"version": "0.2",
3+
"language": "en",
4+
"files": [
5+
"*.md",
6+
"*.js",
7+
"src/**/*.ts",
8+
"test/**/*.spec.ts",
9+
"test/**/*.test-d.ts",
10+
".github/workflows/*.yml"
11+
],
12+
"words": [
13+
"uuidv",
14+
"codecov",
15+
"lcov"
16+
],
17+
"allowCompoundWords": true,
18+
"ignorePaths": [
19+
"package.json",
20+
"package-lock.json",
21+
"yarn.lock",
22+
"tsconfig.json",
23+
"node_modules/**"
24+
],
25+
"ignoreRegExpList": [
26+
"/'[^\\s]{20,}'/",
27+
"/'ABCDEFGHI'/"
28+
]
29+
}

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ end_of_line = lf
88
charset = utf-8
99
insert_final_newline = true
1010

11-
[package.json]
11+
[*.json]
1212
insert_final_newline = false
1313

1414
[*.md]

.eslintignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.nyc_output/
22
.vscode/
3-
coverage/
3+
coverage/
4+
dist/
5+
node_modules/

.eslintrc.js

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,38 @@
11
module.exports = {
2-
env: {
3-
commonjs: true,
4-
es6: true,
5-
node: true,
6-
},
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
plugins: [
5+
'@typescript-eslint'
6+
],
77
extends: [
8-
'google',
8+
'eslint:recommended',
9+
'plugin:@typescript-eslint/eslint-recommended',
10+
'plugin:@typescript-eslint/recommended',
911
],
10-
globals: {
11-
Atomics: 'readonly',
12-
SharedArrayBuffer: 'readonly',
13-
},
14-
parserOptions: {
15-
ecmaVersion: 2018,
12+
rules: {
13+
'no-console': 'error',
14+
'max-len': [ 'error', 120, 2, {
15+
ignoreUrls: true,
16+
ignoreComments: false,
17+
ignoreRegExpLiterals: true,
18+
ignoreStrings: true,
19+
ignoreTemplateLiterals: true,
20+
}],
21+
'semi': [ 'error', 'always' ],
22+
'@typescript-eslint/no-explicit-any': 'off',
1623
},
17-
rules: {
18-
'array-bracket-spacing': [ 'error', 'always' ],
19-
'valid-jsdoc': [ 'error',
20-
{
21-
requireParamDescription: false,
22-
requireReturnDescription: false,
23-
requireReturn: false,
24-
prefer: { returns: 'returns' },
24+
overrides: [
25+
{
26+
files: [ 'test/generate_api_key.spec.ts' ],
27+
rules: {
28+
'@typescript-eslint/no-var-requires': 'off',
29+
'@typescript-eslint/ban-ts-comment': [
30+
'error',
31+
{
32+
'ts-ignore': false,
33+
},
34+
],
2535
},
26-
],
27-
'max-len': [ 'error',
28-
{
29-
code: 85,
30-
tabWidth: 2,
31-
ignoreUrls: true,
32-
},
33-
],
34-
'object-curly-spacing': [ 'error', 'always' ],
35-
'indent': [
36-
'error', 2, {
37-
CallExpression: {
38-
arguments: 'off',
39-
},
40-
},
41-
],
42-
},
43-
};
36+
}
37+
]
38+
};

.github/workflows/coverage.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
pull_request:
6+
types:
7+
- opened
8+
- synchronize
9+
- reopened
10+
- ready_for_review
11+
- converted_to_draft
12+
branches:
13+
- main
14+
15+
permissions:
16+
contents: read
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
coverage:
24+
runs-on: ${{ matrix.os }}
25+
26+
strategy:
27+
matrix:
28+
node-version:
29+
- 14.x
30+
- 16.x
31+
- 18.x
32+
os:
33+
- ubuntu-latest
34+
35+
steps:
36+
- name: ⬇️ Checking out ${{ github.ref_name }}
37+
uses: actions/checkout@v3
38+
39+
- name: ⎔ Using Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
40+
uses: actions/setup-node@v3
41+
with:
42+
node-version: ${{ matrix.node-version }}
43+
- run: npm i -g npm@8
44+
- run: npm -v
45+
46+
- name: 📥 Install dependencies
47+
run: npm install
48+
49+
- name: 📝 Generate coverage report
50+
run: npm run test:cov
51+
52+
- name: 📤 Upload coverage to Coveralls
53+
uses: coverallsapp/github-action@master
54+
with:
55+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
types:
7+
- opened
8+
- synchronize
9+
- reopened
10+
- ready_for_review
11+
- converted_to_draft
12+
branches:
13+
- main
14+
15+
permissions:
16+
contents: read
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
test:
24+
runs-on: ${{ matrix.os }}
25+
26+
strategy:
27+
matrix:
28+
node-version:
29+
- 14.x
30+
- 16.x
31+
- 18.x
32+
os:
33+
- ubuntu-latest
34+
35+
steps:
36+
- name: ⬇️ Checking out ${{ github.ref_name }}
37+
uses: actions/checkout@v3
38+
39+
- name: ⎔ Using Node.js ${{ matrix.node-version }} on ${{ matrix.os }}
40+
uses: actions/setup-node@v3
41+
with:
42+
node-version: ${{ matrix.node-version }}
43+
- run: npm i -g npm@8
44+
- run: npm -v
45+
46+
- name: 📥 Install dependencies
47+
run: npm install
48+
49+
- name: 🧹 Run the linter
50+
run: npm run test:lint
51+
52+
- name: 🔤 Check spelling
53+
run: npm run test:spelling
54+
55+
- name: 🔎 Check the Typescript types
56+
run: npm run test:types
57+
58+
- name: 👟 Run tests
59+
run: |
60+
npm run test:unit
61+
npm run test:unit:build

.mocharc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extension": ["spec.ts"],
3+
"require": ["ts-node/register"],
4+
"reporter": "spec",
5+
"spec": "test/**/*.spec.ts"
6+
}

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v14

.nycrc.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"include": [
3+
"src/**/*.ts"
4+
],
5+
"exclude": [],
6+
"reporter": [
7+
"text",
8+
"html",
9+
"lcovonly"
10+
],
11+
"extension": [
12+
".ts"
13+
],
14+
"all": false,
15+
"cache": true
16+
}

.travis.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
language: node_js
22
node_js:
3-
- "10"
4-
- "11"
5-
- "12"
6-
- "13"
73
- "14"
8-
- "15"
4+
- "16"
95
- "lts/*"
10-
- "node"
116
script:
12-
- npm run test:coverage
7+
- npm run test:lint
8+
- npm run test:spelling
9+
- npm run test:types
10+
- npm run test:cov
1311
after_success:
14-
- npm run test:coveralls
15-
- npm run test:codecov
12+
- npm run test:coveralls

0 commit comments

Comments
 (0)