Skip to content

Commit 7edfbc7

Browse files
committed
feat(core): migrate to typescript
Also, add dx tools
1 parent 0cc2ad1 commit 7edfbc7

22 files changed

+2733
-62
lines changed

.eslintignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Build files
2+
dist
3+
4+
#prettier config
5+
prettier.config.cjs
6+
7+
# lint-staged config
8+
lint-staged.config.cjs
9+
10+
# commitlint config
11+
commitlint.config.cjs

.eslintrc.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true
5+
},
6+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
7+
// Specifying Parser
8+
"parser": "@typescript-eslint/parser",
9+
"parserOptions": {
10+
"ecmaVersion": "latest",
11+
"sourceType": "module",
12+
"tsconfigRootDir": ".",
13+
"project": ["./tsconfig.json"]
14+
},
15+
// Configuring third-party plugins
16+
"plugins": ["@typescript-eslint"],
17+
// Resolve imports
18+
"rules": {
19+
"linebreak-style": "off",
20+
// Disallow the `any` type.
21+
"@typescript-eslint/no-explicit-any": "warn",
22+
"@typescript-eslint/ban-types": [
23+
"error",
24+
{
25+
"extendDefaults": true,
26+
"types": {
27+
"{}": false
28+
}
29+
}
30+
],
31+
"react-hooks/exhaustive-deps": "off",
32+
// Enforce the use of the shorthand syntax.
33+
"object-shorthand": "error",
34+
"no-console": "warn"
35+
}
36+
}

.github/ISSUE_TEMPLATE.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!--
2+
Thank you for contributing by opening an issue! Please take a moment to review our Code of Conduct (found in the CODE_OF_CONDUCT.md file) to keep the community approachable and respectful.
3+
4+
For bug reports, please fill out the information below to help us understand the issue and address it in a timely manner. We value your feedback and contributions.
5+
-->
6+
7+
# Brief Description
8+
<!-- A brief description of the issue.-->
9+
10+
## Environment
11+
12+
- `@smakss/random-string` version:
13+
- Framework version (`react`, `react-native`, `Next.js`, `Remix` etc.`):
14+
- `node.js` version:
15+
- `npm` (or `yarn`) version:
16+
17+
## Code Snippet
18+
<!-- Please provide any relevant code snippets or examples here -->
19+
20+
```javascript
21+
// Your code here
22+
```
23+
24+
## Steps to Reproduce
25+
<!-- What steps did we need to take to encounter the problem? -->
26+
27+
## Expected Behavior
28+
<!-- What you expected to happen -->
29+
30+
## Actual Behavior
31+
<!-- What actually happened. Include the full error message/screenshots/anything that might help understanding the issue -->
32+
33+
## Reproduction Repository
34+
<!--
35+
If possible, please provide a repository link where the issue can be reproduced. A minimal test case would be greatly appreciated and can significantly speed up the resolution process.
36+
-->
37+
38+
## Problem Description
39+
<!-- A clear and concise description of what the problem is. Include any additional context that might help us understand the issue. -->
40+
41+
## Suggested Solution
42+
<!-- If you have any suggestion on how to fix the issue please provide it here. If not, just leave this section blank. -->

.github/workflows/ci.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: PR Checks
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 1
15+
16+
- name: Print head and base refs
17+
run: |
18+
echo "Head ref: ${{ github.head_ref }}"
19+
echo "Base ref: ${{ github.base_ref }}"
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: "18"
25+
26+
- name: Cache dependencies
27+
uses: actions/cache@v3
28+
with:
29+
path: |
30+
**/node_modules
31+
key: ${{ runner.os }}-node-18-yarn-${{ hashFiles('**/yarn.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-node-18-yarn-
34+
35+
- name: Install dependencies
36+
run: yarn install
37+
38+
- name: Type check
39+
run: yarn typecheck
40+
41+
- name: Check code quality
42+
run: |
43+
yarn lint
44+
yarn format:check
45+
yarn run --if-present generate
46+
47+
- name: Security Audit
48+
run: yarn audit --level moderate || true
49+
continue-on-error: true
50+
51+
- name: Security Audit Summary
52+
if: success() || failure()
53+
run: yarn audit --summary
54+
55+
- name: Archive production artifacts
56+
uses: actions/upload-artifact@v3
57+
with:
58+
name: build-artifacts
59+
path: ./build/
60+
61+
- name: Error handling
62+
if: failure()
63+
run: echo "CI failed. Please check the logs."

.github/workflows/npm-publish.yml

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3-
4-
name: "@smakss/random-string"
1+
name: "@smakss/react-scroll-direction"
52

63
on:
74
release:
@@ -14,32 +11,64 @@ jobs:
1411
- uses: actions/checkout@v3
1512
- uses: actions/setup-node@v3
1613
with:
17-
node-version: 16
14+
node-version: 18
15+
- run: yarn
16+
- run: yarn generate
17+
- uses: actions/upload-artifact@v3
18+
with:
19+
name: built-package
20+
path: |
21+
./path-to-your-build-folder
22+
package.json
1823
1924
publish-npm:
2025
needs: build
2126
runs-on: ubuntu-latest
2227
steps:
2328
- uses: actions/checkout@v3
29+
- uses: actions/download-artifact@v3
30+
with:
31+
name: built-package
2432
- uses: actions/setup-node@v3
2533
with:
26-
node-version: 16
34+
node-version: 18
2735
registry-url: https://registry.npmjs.org/
2836
scope: "@smakss"
29-
- run: npm publish
37+
- run: yarn install
38+
- run: yarn generate
39+
- run: |
40+
if grep -q "beta" package.json; then
41+
echo "Publishing Beta to npm"
42+
npm publish --tag beta
43+
else
44+
echo "Publishing Release to npm"
45+
npm publish
46+
fi
3047
env:
31-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
48+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
3249
3350
publish-gpr:
3451
needs: build
3552
runs-on: ubuntu-latest
3653
steps:
3754
- uses: actions/checkout@v3
55+
- uses: actions/download-artifact@v3
56+
with:
57+
name: built-package
3858
- uses: actions/setup-node@v3
3959
with:
40-
node-version: 16
60+
node-version: 18
4161
registry-url: https://npm.pkg.github.com/
4262
scope: "@smakss"
43-
- run: npm publish
63+
- run: yarn install
64+
- run: yarn generate
65+
- run: |
66+
if grep -q "beta" package.json; then
67+
echo "Publishing Beta to GitHub Package Registry"
68+
npm publish --tag beta
69+
else
70+
echo "Publishing Release to GitHub Package Registry"
71+
npm publish
72+
fi
4473
env:
4574
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Logs
2+
logs
3+
*.log
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Dependency directories
8+
node_modules
9+
10+
# Generate output
11+
dist
12+
13+
# Stores VSCode versions used for testing VSCode extensions
14+
.vscode-test
15+
16+
# yarn v2
17+
.yarn/cache
18+
.yarn/unplugged
19+
.yarn/build-state.yml
20+
.yarn/install-state.gz

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn commitlint --edit ${1}

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn lint-staged

.prettierignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package.json
2+
.cache
3+
.shadowenv.d
4+
.vscode
5+
build
6+
dist
7+
node_modules
8+
public
9+
.github
10+
tmp
11+
*.yml
File renamed without changes.

0 commit comments

Comments
 (0)