Skip to content

Commit adf44af

Browse files
erikrasCopilot
andauthored
Convert to TypeScript (#40)
* Convert to TypeScript * Update .babelrc Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent c26b46e commit adf44af

36 files changed

+9984
-15327
lines changed

.babelrc

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,18 @@
44
"@babel/preset-env",
55
{
66
"targets": {
7-
"node": "8"
8-
}
7+
"node": "22"
8+
},
9+
"loose": false
910
}
1011
],
11-
"@babel/preset-flow"
12+
"@babel/preset-typescript"
1213
],
1314
"plugins": [
14-
"@babel/plugin-transform-flow-strip-types",
15-
"@babel/plugin-syntax-dynamic-import",
16-
"@babel/plugin-syntax-import-meta",
17-
"@babel/plugin-proposal-class-properties",
18-
"@babel/plugin-proposal-json-strings",
19-
[
20-
"@babel/plugin-proposal-decorators",
21-
{
22-
"legacy": true
23-
}
24-
],
25-
"@babel/plugin-proposal-function-sent",
26-
"@babel/plugin-proposal-export-namespace-from",
27-
"@babel/plugin-proposal-numeric-separator",
28-
"@babel/plugin-proposal-throw-expressions"
15+
["@babel/plugin-proposal-class-properties", { "loose": false }],
16+
["@babel/plugin-transform-private-methods", { "loose": false }],
17+
["@babel/plugin-transform-private-property-in-object", { "loose": false }],
18+
"@babel/plugin-transform-object-rest-spread",
19+
"@babel/plugin-transform-runtime"
2920
]
3021
}

.eslintrc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,18 @@
22
"extends": "react-app",
33
"rules": {
44
"jsx-a11y/href-no-hash": 0
5-
}
5+
},
6+
"overrides": [
7+
{
8+
"files": [
9+
"**/*.test.ts",
10+
"**/*.test.tsx",
11+
"**/*.spec.ts",
12+
"**/*.spec.tsx"
13+
],
14+
"rules": {
15+
"@typescript-eslint/no-unused-vars": "off"
16+
}
17+
}
18+
]
619
}

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
jobs:
6+
lint:
7+
name: Lint
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Use Node.js ${{ matrix.node_version }}
13+
uses: actions/setup-node@v2
14+
with:
15+
node-version: "22"
16+
- name: Prepare env
17+
run: yarn install --ignore-scripts --frozen-lockfile
18+
- name: Run linter
19+
run: yarn start lint
20+
21+
prettier:
22+
name: Prettier Check
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: Use Node.js ${{ matrix.node_version }}
28+
uses: actions/setup-node@v2
29+
with:
30+
node-version: "22"
31+
- name: Prepare env
32+
run: yarn install --ignore-scripts --frozen-lockfile
33+
- name: Run prettier
34+
run: yarn start prettier
35+
36+
test:
37+
name: Unit Tests
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- uses: actions/checkout@v2
42+
- name: Use Node.js ${{ matrix.node_version }}
43+
uses: actions/setup-node@v2
44+
with:
45+
node-version: "22"
46+
- name: Prepare env
47+
run: yarn install --ignore-scripts --frozen-lockfile
48+
- name: Run unit tests
49+
run: yarn start test
50+
- name: Run code coverage
51+
uses: codecov/[email protected]

.github/workflows/lock.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Lock Threads"
2+
3+
on:
4+
schedule:
5+
- cron: "0 * * * *"
6+
workflow_dispatch:
7+
8+
permissions:
9+
issues: write
10+
pull-requests: write
11+
12+
concurrency:
13+
group: lock
14+
15+
jobs:
16+
action:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: dessant/lock-threads@v3
20+
with:
21+
issue-inactive-days: "365"
22+
issue-lock-reason: "resolved"
23+
pr-inactive-days: "365"
24+
pr-lock-reason: "resolved"

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
*.iml
33
.nyc_output
44
coverage
5-
flow-coverage
65
node_modules
76
dist
87
lib

eslint.config.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import js from '@eslint/js'
2+
import tsPlugin from '@typescript-eslint/eslint-plugin'
3+
import tsParser from '@typescript-eslint/parser'
4+
5+
export default [
6+
js.configs.recommended,
7+
{
8+
files: ['src/**/*.{js,jsx,ts,tsx}'],
9+
languageOptions: {
10+
parser: tsParser,
11+
parserOptions: {
12+
project: './tsconfig.json',
13+
ecmaVersion: 'latest',
14+
sourceType: 'module'
15+
},
16+
globals: {
17+
document: 'readonly'
18+
}
19+
},
20+
plugins: {
21+
'@typescript-eslint': tsPlugin
22+
},
23+
rules: {
24+
...tsPlugin.configs.recommended.rules,
25+
'@typescript-eslint/no-unused-vars': [
26+
'error',
27+
{ argsIgnorePattern: '^_' }
28+
],
29+
'@typescript-eslint/explicit-function-return-type': 'off',
30+
'@typescript-eslint/explicit-module-boundary-types': 'off',
31+
'@typescript-eslint/no-explicit-any': 'off'
32+
}
33+
},
34+
{
35+
files: ['src/**/*.test.{js,jsx,ts,tsx}'],
36+
languageOptions: {
37+
globals: {
38+
describe: 'readonly',
39+
it: 'readonly',
40+
expect: 'readonly',
41+
jest: 'readonly',
42+
beforeEach: 'readonly',
43+
afterEach: 'readonly',
44+
beforeAll: 'readonly',
45+
afterAll: 'readonly',
46+
test: 'readonly',
47+
setTimeout: 'readonly',
48+
global: 'readonly',
49+
document: 'readonly'
50+
// add more Jest/browser globals if needed
51+
}
52+
}
53+
},
54+
{
55+
ignores: [
56+
'dist/**',
57+
'node_modules/**',
58+
'coverage/**',
59+
'eslint.config.js',
60+
'jest.config.js',
61+
'package-scripts.js',
62+
'rollup.config.js'
63+
]
64+
}
65+
]

jest.config.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
1-
module.exports = {
2-
verbose: true,
3-
browser: true,
4-
testURL: 'http://localhost/'
1+
export default {
2+
testEnvironment: 'jsdom',
3+
testEnvironmentOptions: {
4+
url: 'http://localhost'
5+
},
6+
transform: {
7+
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest'
8+
},
9+
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json'],
10+
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
11+
collectCoverageFrom: [
12+
'src/**/*.{js,jsx,ts,tsx}',
13+
'!src/index.ts',
14+
'!src/types.ts'
15+
],
16+
coverageThreshold: {
17+
global: {
18+
branches: 90,
19+
functions: 87,
20+
lines: 93,
21+
statements: 93
22+
}
23+
}
524
}

0 commit comments

Comments
 (0)