Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
glyph-cat committed May 2, 2024
0 parents commit ba68710
Show file tree
Hide file tree
Showing 314 changed files with 38,334 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json linguist-language=JSON-with-Comments
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ko_fi: glyphcat
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: bug
assignees: ''

---

## Description
(A brief description about the bug)

## Steps to reproduce
1. First, ...
2. Then, ...

## Expected results
(What was expected)

## Actual results
(What actually happened)

## System info
* Package version (Required):
<!-- Version is available in package.json -->
* Build:
<!-- Should be one of `CJS` / `ES` / `MJS` / `UMD` / `UMD_MIN` -->
<!-- Hint: The `BUILD_TYPE` variable can be imported from the package -->
* OS and version (optional):
<!-- If bug is specific to certain OS -->
* Browser and version (optional):
<!-- If bug is specific to certain browser -->

## Reproducible Demo (optional, but strongly advised)
<!-- [Link to reproducible demo](...) -->

<!-- Recommendations for uploading code: -->
<!-- [StackBlitz](https://stackblitz.com) -->
<!-- [CodePen](https://codepen.io) -->
<!-- or create a public repo on [GitHub](https://github.com) -->
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/enhancement-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Enhancement request
about: Suggest an idea for this project
title: "[ENHANCEMENT]"
labels: enhancement
assignees: ''

---

## Description
(Brief description about the suggestion)

## Current Situation
(How something is done now)

## Proposed Changes
(How it could be done differently instead)

## Considerations (optional)

### Pros
* ···
* ···

### Cons
* ···
* ···
56 changes: 56 additions & 0 deletions .github/workflows/code-ql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "CodeQL"

on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "00 10 * * 1"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ["javascript"]

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Logs
logs
*.log
yarn-debug.log*
yarn-error.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Builds
*.tgz
dist
lib

# Dependency directories
node_modules

# Yarn
.yarn-integrity
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Caches
.cache
.eslintcache
temp/

# OS
.DS_Store
thumbs.db

# Special
*.draft*
*.old*
*.scripted*

# Automatically generated
packages/**/LICENSE
34 changes: 34 additions & 0 deletions .vscode/cotton-box.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"folders": [
{
"name": "root",
"path": "..",
},
{
"name": "core",
"path": "../packages/core"
},
{
"name": "react",
"path": "../packages/react"
},
{
"name": "docs",
"path": "../packages/docs"
},
{
"name": "Examples (web)",
"path": "../packages/examples-web"
},
],
"settings": {
"files.associations": {
"*.json": "jsonc"
},
"javascript.format.semicolons": "remove",
"typescript.format.semicolons": "remove",
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single",
"search.useParentIgnoreFiles": true,
}
}
27 changes: 27 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
// Reference: https://cspell.org/configuration
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"language": "en",
"words": [
"clsx",
"codesandbox",
"dispatchable",
"endregion",
"glyphcat",
"hookstate",
"inspectable",
"postlicense",
"postversion",
"reduxjs",
"sandpack",
"subpackage",
"tofix",
"tsdoc",
"unwatch",
"zustand"
],
"flagWords": [],
"enableFiletypes": [
"mdx"
]
}
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"streetsidesoftware.code-spell-checker",
]
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"files.associations": {
"*.json": "jsonc"
},
"javascript.format.semicolons": "remove",
"typescript.format.semicolons": "remove",
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single",
}
13 changes: 13 additions & 0 deletions .vscode/snippets.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"TS expect error on purpose": {
"scope": "typescript,typescriptreact",
"prefix": "@ts-expect-error",
"body": "// @ts-expect-error: Done on purpose to test the error.",
"description": "TS expect error to test error on purpose"
},
"Early exit": {
"scope": "typescript,typescriptreact",
"prefix": "// Early exit",
"body": "// Early exit"
},
}
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

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

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
50 changes: 50 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# CONTRIBUTING

Normally, there would be no need to refer to the written conventions here as
they would have been very obvious upon taking a look at the project structure.
But if ever in doubt, hopefully this file will be able to clarify things.

## Development

* Files and directories should be named using `camel-case`
* Except for API files and directories:
* `MacroCase` should be used for classes, React components, namespaces, etc.
* `camelCase` should be used for functions

## Tests

* There are two types of tests, one in `src` and one in `tests`.
* Tests in `src` are meant for testing internal component — the ones that are not exposed as APIs.
* Tests in `tests` are meant for testing exposed APIs.

### Tests in `src`

* They are plain and simple, no wrappers or helpers are required.
* They should only test what is contained in their folder.

### Tests in `tests`

* They are grouped by types `api`, `constants`, etc. (more might be added in the future if necessary)
* These tests should be run inside the `wrapper` to ensure that the bundled codes produces the desired results
* Preferably, name test files after the name of method to be tested.
* Tests for APIs should have the `API-` prefix; examples:
* `.../Something/API-foo.test.ts`
* `.../Something/API-bar.test.ts`
* Tests for special scenarios should have the `SPECIAL-` prefix; examples:
* `.../Something/SPECIAL-foo.test.ts`
* `.../Something/SPECIAL-bar.test.ts`
* If there is only one test file then `index.test.ts` is fine; examples:
* `.../doSomeThing/index.test.ts`
* `.../doAnotherThing/index.test.ts`

### Other things to take note

* Do not call `expect` conditionally or inside loops
* Note that [`jest/no-conditional-expect`](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-conditional-expect.md) will show an error when `expect` is called conditionally, but not when they are called inside loops.

### Making sure State Managers are disposed after test

1. Perform search in VS Code: `new (Simple|Async)?StateManager` as regex with case sensitivity and only include: `.test.ts`
2. Take note of the search result count
3. Swap the value with `cleanupManager.append(TestState.dispose)` as plain text.
4. Compare the search result count, make sure they are the same as the count in #2.
Loading

0 comments on commit ba68710

Please sign in to comment.