Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: tooling update to kick off development again #75

Merged
merged 4 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .eslintignore

This file was deleted.

25 changes: 0 additions & 25 deletions .eslintrc.json

This file was deleted.

25 changes: 13 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 21
- run: yarn install --frozen-lockfile
- uses: pnpm/action-setup@v2
with:
version: 8
run_install: |
- recursive: true
args: [--strict-peer-dependencies]
- name: Build
run: yarn build
- name: EsLint
run: yarn lint
- name: Prettier
run: yarn prettier:check
- name: Install gzip-size-cli
run: yarn global add gzip-size-cli
- name: Check Gzipped Size
run: yarn run gzip-size
run: pnpm build
- name: biome lint check
run: pnpm lint
- name: biome format check
run: pnpm format:check
- name: Check Minified and Brotlied Code Size
run: yarn run code-size
run: pnpm run code-size
- name: Test
run: yarn test
run: pnpm test
- name: deploy test report
if: ${{ github.ref == 'refs/heads/main' }}
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules
dist
dist-ssr
*.local
pnpm-lock.yaml

# Editor directories and files
.vscode/*
Expand Down
19 changes: 0 additions & 19 deletions .prettierignore

This file was deleted.

19 changes: 0 additions & 19 deletions .prettierrc.json

This file was deleted.

35 changes: 35 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"organizeImports": {
"enabled": true
},
"files": {
"include": ["src/**/*.ts", "test/**/*.ts"]
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off"
},
"style": {
"noNonNullAssertion": "off"
},
"complexity": {
"noForEach": "off"
}
}
},
"formatter": {
"enabled": true
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"semicolons": "asNeeded",
"indentStyle": "space",
"indentWidth": 2
}
}
}
2 changes: 0 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
[![GitHub stars](https://img.shields.io/github/stars/omarluq/stimulus-store?style=flat)](https://github.com/omarluq/stimulus-store/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/omarluq/stimulus-store?style=flat)](https://github.com/omarluq/stimulus-store/network/members)
[![GitHub watchers](https://img.shields.io/github/watchers/omarluq/stimulus-store?style=flat)](https://github.com/omarluq/stimulus-store/watchers)
[![ESLint](https://img.shields.io/badge/-ESLint-4B32C3&logo=eslint)](https://eslint.org)
[![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)
[![Type Definitions](https://img.shields.io/npm/types/stimulus-store)](https://www.typescriptlang.org)
[![jest](https://jestjs.io/img/jest-badge.svg)](https://jestjs.io/)
[![Maintainability](https://api.codeclimate.com/v1/badges/a99a88d28ad37a79dbf6/maintainability)](https://codeclimate.com/github/omarluq/stimulus-store/maintainability)
Expand Down
2 changes: 0 additions & 2 deletions docs/README.old.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
[![Top Language](https://img.shields.io/github/languages/top/omarluq/stimulus-store)](https://github.com/omarluq/stimulus-store)
[![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest)
[![npm downloads](https://img.shields.io/npm/dm/stimulus-store.svg)](https://www.npmjs.com/package/stimulus-store)
[![ESLint](https://img.shields.io/badge/-ESLint-4B32C3&logo=eslint)](https://github.com/omarluq/stimulus-store)
[![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![GitHub Actions](https://github.com/omarluq/stimulus-store/actions/workflows/test.yml/badge.svg)](https://github.com/omarluq/stimulus-store/actions)
[![Last Commit](https://img.shields.io/github/last-commit/omarluq/stimulus-store)](https://github.com/omarluq/stimulus-store/commits/main)
[![Pull Requests](https://img.shields.io/github/issues-pr/omarluq/stimulus-store)](https://github.com/omarluq/stimulus-store/pulls)
Expand Down
6 changes: 0 additions & 6 deletions docs/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
<img src="https://img.shields.io/github/watchers/omarluq/stimulus-store" alt="GitHub watchers" />
</a>
<!-- Development Standards Badges -->
<a style="text-decoration: none;" target="_blank" href="https://eslint.org">
<img src="https://img.shields.io/badge/-ESLint-4B32C3&logo=eslint" alt="ESLint" />
</a>
<a style="text-decoration: none;" target="_blank" href="https://prettier.io">
<img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg" alt="Prettier" />
</a>
<a style="text-decoration: none;" target="_blank" href="https://www.typescriptlang.org">
<img src="https://img.shields.io/npm/types/stimulus-store" alt="Type Definitions" />
</a>
Expand Down
25 changes: 9 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
"scripts": {
"build": "rollup -c --bundleConfigAsCjs",
"test": "jest --reporters default jest-stare",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prettier:check": "prettier --check .",
"prettier:write": "prettier --write .",
"lint": "biome lint .",
"lint:fix": "biome check --apply .",
"lint:fix:unsafe": "biome check --apply-unsafe .",
"format:check": "biome format .",
"format:write": "biome format --write .",
"code-size": "npx size-limit",
"gzip-size:cjs": "gzip-size ./dist/bundle.cjs.js | bash ./scripts/check-size.sh",
"gzip-size:esm": "gzip-size ./dist/bundle.esm.js | bash ./scripts/check-size.sh",
"gzip-size": "yarn run gzip-size:cjs && yarn run gzip-size:esm",
"changelog": "git-chglog -o docs/CHANGELOG.md",
"husky:prepare": "husky install",
"docs": "docsify serve docs"
Expand All @@ -55,6 +53,7 @@
],
"license": "MIT",
"devDependencies": {
"@biomejs/biome": "1.5.3",
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@hotwired/stimulus": "^3.2.2",
Expand All @@ -65,16 +64,11 @@
"@size-limit/preset-small-lib": "^11.0.0",
"@types/jest": "^29.5.10",
"@types/node": "^20.10.0",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"all-contributors-cli": "^6.26.1",
"eslint": "^8.54.0",
"gzip-size": "^7.0.0",
"husky": "^8.0.3",
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
"jest-stare": "^2.5.1",
"prettier": "^3.1.0",
"rollup": "^4.5.1",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-copy": "^3.5.0",
Expand All @@ -98,12 +92,11 @@
"size-limit": [
{
"path": "./dist/bundle.cjs.js",
"limit": "1.09 KB"
"limit": "1.2 KB"
},
{
"path": "./dist/bundle.esm.js",
"limit": "1.04 KB"
"limit": "1.2 KB"
}
],
"private": false
]
}
45 changes: 0 additions & 45 deletions scripts/check-size.sh

This file was deleted.

3 changes: 1 addition & 2 deletions src/errors/createStoreErrorHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export function checkTypeConstructor(type: string): void {
export function handleStoreSetError(error: unknown): never {
if (error instanceof Error) {
throw new Error(`Failed to create store: ${error.message}`)
} else {
throw new Error('An unknown error occurred while creating the store')
}
throw new Error('An unknown error occurred while creating the store')
}
7 changes: 5 additions & 2 deletions src/errors/storeErrorHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
* @param {new (...args: unknown[]) => unknown} type - The type constructor for the expected type.
* @throws {Error} If the value is not of the expected type.
*/
export function checkValue(value: unknown, type: new (...args: unknown[]) => unknown): void {
export function checkValue(
value: unknown,
type: new (...args: unknown[]) => unknown,
): void {
if (Object.getPrototypeOf(value).constructor !== type) {
throw new Error(`Value '${value}' must be of type ${type.name}`)
}
Expand All @@ -16,5 +19,5 @@ export function checkValue(value: unknown, type: new (...args: unknown[]) => unk
* @throws {Error} A new error with a message indicating that the promise failed to resolve.
*/
export function handlePromiseError(error: unknown): never {
throw new Error('Failed to resolve promise:\n' + error)
throw new Error(`Failed to resolve promise:\n${error}`)
}
8 changes: 5 additions & 3 deletions src/errors/useStoreErrorHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
export function checkStores(stores: unknown): void {
if (!stores) {
throw new Error(
`'useStore' was called on a controller without a 'stores' static property. The 'stores' property is undefined.`
`'useStore' was called on a controller without a 'stores' static property. The 'stores' property is undefined.`,
)
}

if (!Array.isArray(stores)) {
throw new Error(`'useStore' was called on a controller with a 'stores' static property that is not an array.`)
throw new Error(
`'useStore' was called on a controller with a 'stores' static property that is not an array.`,
)
}

if (stores.length === 0) {
throw new Error(
`'useStore' was called on a controller with an empty 'stores' static property. The 'stores' array should contain at least one store.`
`'useStore' was called on a controller with an empty 'stores' static property. The 'stores' array should contain at least one store.`,
)
}
}
7 changes: 5 additions & 2 deletions src/errors/useStoreWarningHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
* @param {boolean} isWarned - A flag indicating if the warning has already been logged.
* @returns {boolean} Returns true if the warning was logged, otherwise returns the original `isWarned` value.
*/
export function warnDirectAccess(camelizedName: string, isWarned: boolean): boolean {
export function warnDirectAccess(
camelizedName: string,
isWarned: boolean,
): boolean {
if (!isWarned) {
console.warn(
`Warning: You are accessing the '${camelizedName}' instance directly. Consider using 'on${
camelizedName.charAt(0).toUpperCase() + camelizedName.slice(1)
}Update' and '${camelizedName}Value' instead.`
}Update' and '${camelizedName}Value' instead.`,
)
return true
}
Expand Down
Loading
Loading