Skip to content

Commit

Permalink
feat(typescript): convert to typescript
Browse files Browse the repository at this point in the history
update tests to tsx
match types version with dep versions
generic type
change to main/types to exports
change build to dist
change target to es6
update types/react to 18 to provide modern context type
switched to vitest and react-testing-library
updated to stricter eslint
update to react@17
install and enforce prettier during testing

fixed snapshot

removed timezone from setup
  • Loading branch information
xAndreiLi authored and ali589 committed Dec 12, 2024
1 parent 95702fd commit b8b1a31
Show file tree
Hide file tree
Showing 17 changed files with 23,614 additions and 18,280 deletions.
6 changes: 2 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"presets": [
"amex"
]
}
"presets": ["amex", "@babel/preset-typescript"]
}
55 changes: 53 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
{
"extends": "amex"
}
"extends": ["amex", "plugin:@typescript-eslint/recommended", "prettier"],
"settings": { "import/resolver": { "typescript": {} } },
"parserOptions": {
"project": true,
"extraFileExtensions": [".json"]
},
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"ignorePatterns": ["dist/**/*", "commitlint.config.js"],
"overrides": [
{
"files": ["__tests__/**"],
"extends": [
"amex/test",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"import/extensions": [
"error",
"ignorePackages",
{
"ts": "never",
"tsx": "never",
"js": "never",
"jsx": "never"
}
]
}
},
{
"files": ["src/**"],
"extends": [
"amex",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/strict-type-checked",
"prettier"
],
"rules": {
"import/extensions": [
"error",
"ignorePackages",
{
"ts": "never",
"tsx": "never",
"js": "never",
"jsx": "never"
}
]
}
}
]
}
2 changes: 2 additions & 0 deletions .github/workflows/health-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
run: npm ci
env:
NODE_ENV: development
- name: Build
run: npm run build
- name: Run Test Script
run: npm test
env:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
node-version-file: ".nvmrc"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Release
env:
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
run: npm ci
env:
NODE_ENV: development
- name: Build
run: npm run build
- name: Unit Tests
run: npm run test:unit
env:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
test-results
.jest-cache
coverage
dist
3 changes: 0 additions & 3 deletions __tests__/.eslintrc.json

This file was deleted.

31 changes: 0 additions & 31 deletions __tests__/__snapshots__/index.spec.jsx.snap

This file was deleted.

115 changes: 0 additions & 115 deletions __tests__/index.spec.jsx

This file was deleted.

6 changes: 6 additions & 0 deletions __tests__/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { afterEach } from "vitest";
import { cleanup } from "@testing-library/react";

afterEach(() => {
cleanup();
});
40 changes: 40 additions & 0 deletions __tests__/unit/__snapshots__/index.spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`createSharedReactContext > should not return the same context object if the key does not match 1`] = `
<body>
<div>
<div
data-testid="consumerDiv"
id="value"
>
default
</div>
</div>
</body>
`;

exports[`createSharedReactContext > should return the same context object if the key matches 1`] = `
<body>
<div>
<div
data-testid="consumerDiv"
id="value"
>
context value
</div>
</div>
</body>
`;

exports[`createSharedReactContext > should use the same default value from first call 1`] = `
<body>
<div>
<div
data-testid="consumerDiv"
id="value"
>
default
</div>
</div>
</body>
`;
Loading

0 comments on commit b8b1a31

Please sign in to comment.