Skip to content

feat: support cjs and esm both by tshy #33

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

Merged
merged 7 commits into from
Mar 23, 2025
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
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ name: CI

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
Job:
name: Node.js
uses: node-modules/github-actions/.github/workflows/node-test-mysql.yml@master
with:
os: 'ubuntu-latest'
version: '16, 18, 20, 22'
version: '18, 20, 22'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release

on:
push:
branches: [ master ]
branches: [master]

jobs:
release:
Expand Down
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
142 changes: 142 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"env": {
"node": true,
"mocha": true
},
"categories": {
"correctness": "error",
"perf": "error",
"nursery": "error",
"restriction": "error",
"style": "error",
"pedantic": "error",
"suspicious": "error"
},
"plugins": [
"import",
"typescript",
"unicorn",
"jsdoc",
"node",
"promise",
"oxc"
],
"rules": {
// eslint
"constructor-super": "error",
"getter-return": "error",
"no-undef": "error",
"no-unreachable": "error",
"no-var": "error",
"no-eq-null": "error",
"no-await-in-loop": "allow",
"eqeqeq": ["error", "smart"],
"init-declarations": "allow",
"curly": "allow",
"no-ternary": "allow",
"max-params": ["error", 5],
"no-await-expression-member": "error",
"no-continue": "allow",
"guard-for-in": "allow",
"func-style": "allow",
"sort-imports": "allow",
"yoda": "allow",
"sort-keys": "allow",
"no-magic-numbers": "allow",
"no-duplicate-imports": "error",
"no-multi-assign": "error",
"func-names": "error",
"default-param-last": "error",
"prefer-object-spread": "error",
"no-undefined": "allow",
"no-plusplus": "allow",
// maybe warn
"no-console": "warn",
"no-extraneous-class": "allow",
"no-empty-function": "error",
"max-depth": ["error", 6],
"max-lines-per-function": "allow",
"no-lonely-if": "error",
"max-lines": "allow",
"require-await": "allow",
"max-nested-callbacks": ["error", 5],
"max-classes-per-file": "allow",
"radix": "allow",
"no-negated-condition": "error",
"no-else-return": "error",
"no-throw-literal": "error",

// import
"import/exports-last": "allow",
"import/max-dependencies": "allow",
"import/no-cycle": "error",
"import/no-anonymous-default-export": "allow",
"import/no-namespace": "error",
"import/named": "error",
"import/export": "error",
"import/no-default-export": "allow",
"import/unambiguous": "error",

// promise
"promise/no-return-wrap": "error",
"promise/param-names": "error",
"promise/prefer-await-to-callbacks": "error",
"promise/prefer-await-to-then": "error",
"promise/prefer-catch": "error",
"promise/no-return-in-finally": "error",
"promise/avoid-new": "error",

// unicorn
"unicorn/error-message": "error",
"unicorn/no-null": "allow",
"unicorn/filename-case": "allow",
"unicorn/prefer-structured-clone": "error",
"unicorn/prefer-logical-operator-over-ternary": "error",
"unicorn/prefer-number-properties": "error",
"unicorn/prefer-array-some": "error",
"unicorn/prefer-string-slice": "error",
// "unicorn/no-null": "error",
"unicorn/throw-new-error": "error",
"unicorn/catch-error-name": "allow",
"unicorn/prefer-spread": "allow",
"unicorn/numeric-separators-style": "error",
"unicorn/prefer-string-raw": "error",
"unicorn/text-encoding-identifier-case": "error",
"unicorn/no-array-for-each": "error",
"unicorn/explicit-length-check": "error",
"unicorn/no-lonely-if": "error",
"unicorn/no-useless-undefined": "allow",
"unicorn/prefer-date-now": "error",
"unicorn/no-static-only-class": "allow",
"unicorn/no-typeof-undefined": "error",
"unicorn/prefer-negative-index": "error",
"unicorn/no-anonymous-default-export": "allow",

// oxc
"oxc/no-map-spread": "error",
"oxc/no-rest-spread-properties": "allow",
"oxc/no-optional-chaining": "allow",
"oxc/no-async-await": "allow",

// typescript
"typescript/explicit-function-return-type": "allow",
"typescript/consistent-type-imports": "error",
"typescript/consistent-type-definitions": "error",
"typescript/consistent-indexed-object-style": "allow",
"typescript/no-inferrable-types": "error",
"typescript/array-type": "error",
"typescript/no-non-null-assertion": "error",
"typescript/no-explicit-any": "error",
"typescript/no-import-type-side-effects": "error",
"typescript/no-dynamic-delete": "error",
"typescript/prefer-ts-expect-error": "error",
"typescript/ban-ts-comment": "error",
"typescript/prefer-enum-initializers": "error",

// jsdoc
"jsdoc/require-returns": "allow",
"jsdoc/require-param": "allow"
},
"ignorePatterns": ["index.d.ts", "test/fixtures/**", "__snapshots__"]
}
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "es5",
"tabWidth": 2,
"arrowParens": "avoid"
}
87 changes: 41 additions & 46 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,116 +2,111 @@

## [5.0.0](https://github.com/eggjs/egg-mysql/compare/v4.1.0...v5.0.0) (2025-03-08)


### ⚠ BREAKING CHANGES

* drop Node.js < 18 support
* use mysql2 instead of mysql
- drop Node.js < 18 support
- use mysql2 instead of mysql

closes https://github.com/eggjs/egg-mysql/issues/31


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Documentation**
- Updated usage instructions and contributor displays with corrected
typographical errors.
typographical errors.
- **Chores**
- Removed outdated contributor templates and automation workflows.
- Removed outdated contributor templates and automation workflows.
- **Dependencies**
- Migrated to a new database client package and raised the minimum
Node.js version requirement.
Node.js version requirement.
- **Tests**
- Refined error validations in database operations for improved error
reporting.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

### Features

* use @eggjs/rds instead of ali-rds ([#32](https://github.com/eggjs/egg-mysql/issues/32)) ([3093528](https://github.com/eggjs/egg-mysql/commit/30935285268b1c674f9a70b4cb77501f89276467))
- use @eggjs/rds instead of ali-rds ([#32](https://github.com/eggjs/egg-mysql/issues/32)) ([3093528](https://github.com/eggjs/egg-mysql/commit/30935285268b1c674f9a70b4cb77501f89276467))

## [4.1.0](https://github.com/eggjs/egg-mysql/compare/v4.0.0...v4.1.0) (2025-03-08)


### Features

* update [email protected] ([#30](https://github.com/eggjs/egg-mysql/issues/30)) ([31ed369](https://github.com/eggjs/egg-mysql/commit/31ed369d954ce4bded89469907f81dcbde3060df))
- update [email protected] ([#30](https://github.com/eggjs/egg-mysql/issues/30)) ([31ed369](https://github.com/eggjs/egg-mysql/commit/31ed369d954ce4bded89469907f81dcbde3060df))

## [4.0.0](https://github.com/eggjs/egg-mysql/compare/v3.4.0...v4.0.0) (2023-03-06)


### ⚠ BREAKING CHANGES

* drop Node.js < 16 support
- drop Node.js < 16 support

### Features

* refactor with TypeScript ([#27](https://github.com/eggjs/egg-mysql/issues/27)) ([4b7311d](https://github.com/eggjs/egg-mysql/commit/4b7311d2beb43a0338337c7128e016690ea04c9e))
- refactor with TypeScript ([#27](https://github.com/eggjs/egg-mysql/issues/27)) ([4b7311d](https://github.com/eggjs/egg-mysql/commit/4b7311d2beb43a0338337c7128e016690ea04c9e))

## [3.4.0](https://github.com/eggjs/egg-mysql/compare/v3.3.0...v3.4.0) (2023-02-15)


### Features

* **type:** add type definition for mysql.count method ([#26](https://github.com/eggjs/egg-mysql/issues/26)) ([7aef13e](https://github.com/eggjs/egg-mysql/commit/7aef13eb861b41c538d3b3d561c92a666a61110b))
- **type:** add type definition for mysql.count method ([#26](https://github.com/eggjs/egg-mysql/issues/26)) ([7aef13e](https://github.com/eggjs/egg-mysql/commit/7aef13eb861b41c538d3b3d561c92a666a61110b))

## [3.3.0](https://github.com/eggjs/egg-mysql/compare/v3.2.0...v3.3.0) (2022-12-18)


### Features

* upgrade ali-rds v4 ([#24](https://github.com/eggjs/egg-mysql/issues/24)) ([1b129e8](https://github.com/eggjs/egg-mysql/commit/1b129e8f94b0739a5515d5704be301df85f97b30))
- upgrade ali-rds v4 ([#24](https://github.com/eggjs/egg-mysql/issues/24)) ([1b129e8](https://github.com/eggjs/egg-mysql/commit/1b129e8f94b0739a5515d5704be301df85f97b30))

---

3.2.0 / 2022-12-03
==================
# 3.2.0 / 2022-12-03

**features**
* [[`4cf93ce`](http://github.com/eggjs/egg-mysql/commit/4cf93ce5fbeeb3fc734a8e7ba708b27994adad88)] - feat: add more type definition for mysql.get method (#20) (Xin(Khalil) Zhang <<[email protected]>>)

- [[`4cf93ce`](http://github.com/eggjs/egg-mysql/commit/4cf93ce5fbeeb3fc734a8e7ba708b27994adad88)] - feat: add more type definition for mysql.get method (#20) (Xin(Khalil) Zhang <<[email protected]>>)

**fixes**
* [[`d3c8a31`](http://github.com/eggjs/egg-mysql/commit/d3c8a31e02beccc8823820340bda89fe307a34ea)] - fix: remove reckless assertion (#15) (WangJie <<[email protected]>>)

- [[`d3c8a31`](http://github.com/eggjs/egg-mysql/commit/d3c8a31e02beccc8823820340bda89fe307a34ea)] - fix: remove reckless assertion (#15) (WangJie <<[email protected]>>)

**others**
* [[`ed419d6`](http://github.com/eggjs/egg-mysql/commit/ed419d6c51e25fa3ea2a4b91628375d4d4dcb77d)] - 🤖 TEST: Add tsd test (#22) (fengmk2 <<[email protected]>>)
* [[`4137cfc`](http://github.com/eggjs/egg-mysql/commit/4137cfc46e0db04f6122b065516055a99765eb19)] - 📖 DOC: Use async/await isntead of yield (fengmk2 <<[email protected]>>)
* [[`b103400`](http://github.com/eggjs/egg-mysql/commit/b103400c153176bd9c38e35d72aa3a791999ec27)] - 📖 DOC: Update contributors (fengmk2 <<[email protected]>>)
* [[`a67989c`](http://github.com/eggjs/egg-mysql/commit/a67989c4e6c55604d8d61d1af7af9bc5df35df2e)] - 🤖 TEST: Run test on GitHub Action (#19) (fengmk2 <<[email protected]>>)
* [[`3d04360`](http://github.com/eggjs/egg-mysql/commit/3d04360fd7745ef45d32e8e27c5691878d0cd3bf)] - Create codeql-analysis.yml (fengmk2 <<[email protected]>>)

3.1.1 / 2022-06-03
==================
- [[`ed419d6`](http://github.com/eggjs/egg-mysql/commit/ed419d6c51e25fa3ea2a4b91628375d4d4dcb77d)] - 🤖 TEST: Add tsd test (#22) (fengmk2 <<[email protected]>>)
- [[`4137cfc`](http://github.com/eggjs/egg-mysql/commit/4137cfc46e0db04f6122b065516055a99765eb19)] - 📖 DOC: Use async/await isntead of yield (fengmk2 <<[email protected]>>)
- [[`b103400`](http://github.com/eggjs/egg-mysql/commit/b103400c153176bd9c38e35d72aa3a791999ec27)] - 📖 DOC: Update contributors (fengmk2 <<[email protected]>>)
- [[`a67989c`](http://github.com/eggjs/egg-mysql/commit/a67989c4e6c55604d8d61d1af7af9bc5df35df2e)] - 🤖 TEST: Run test on GitHub Action (#19) (fengmk2 <<[email protected]>>)
- [[`3d04360`](http://github.com/eggjs/egg-mysql/commit/3d04360fd7745ef45d32e8e27c5691878d0cd3bf)] - Create codeql-analysis.yml (fengmk2 <<[email protected]>>)

# 3.1.1 / 2022-06-03

**fixes**
* [[`bb7856b`](http://github.com/eggjs/egg-mysql/commit/bb7856bbf8e363f2ee0ce9410204fd227c2ccd08)] - fix: mysql.update missing condition define (#18) (shangwenhe <<[email protected]>>)

3.1.0 / 2022-02-11
==================
- [[`bb7856b`](http://github.com/eggjs/egg-mysql/commit/bb7856bbf8e363f2ee0ce9410204fd227c2ccd08)] - fix: mysql.update missing condition define (#18) (shangwenhe <<[email protected]>>)

# 3.1.0 / 2022-02-11

**features**
* [[`aade70b`](http://github.com/eggjs/egg-mysql/commit/aade70bce78afb39e8e9b3201261bbb8bcf26847)] - feat: add complete typescript typings (#17) (AntiMoron <<[email protected]>>)

- [[`aade70b`](http://github.com/eggjs/egg-mysql/commit/aade70bce78afb39e8e9b3201261bbb8bcf26847)] - feat: add complete typescript typings (#17) (AntiMoron <<[email protected]>>)

**others**
* [[`2e02e40`](http://github.com/eggjs/egg-mysql/commit/2e02e402d6d23740f68ae26c28633303d4d9e206)] - chore: update travis (#16) (TZ | 天猪 <<[email protected]>>)
* [[`89910f6`](http://github.com/eggjs/egg-mysql/commit/89910f6ef17be38b59bc066d754793cc65a84624)] - test: add null query test case (#13) (Century Guo <<[email protected]>>)
* [[`b0dd988`](http://github.com/eggjs/egg-mysql/commit/b0dd988d51b95d576c852d54d26014a845ac2f3d)] - deps: autod (#12) (TZ | 天猪 <<[email protected]>>)
* [[`18b67fd`](http://github.com/eggjs/egg-mysql/commit/18b67fd3e43627ad420ed3df8e8a6e305f5202f6)] - deps: upgrade dependencies (#10) (Haoliang Gao <<[email protected]>>)

3.0.0 / 2017-04-03
==================
- [[`2e02e40`](http://github.com/eggjs/egg-mysql/commit/2e02e402d6d23740f68ae26c28633303d4d9e206)] - chore: update travis (#16) (TZ | 天猪 <<[email protected]>>)
- [[`89910f6`](http://github.com/eggjs/egg-mysql/commit/89910f6ef17be38b59bc066d754793cc65a84624)] - test: add null query test case (#13) (Century Guo <<[email protected]>>)
- [[`b0dd988`](http://github.com/eggjs/egg-mysql/commit/b0dd988d51b95d576c852d54d26014a845ac2f3d)] - deps: autod (#12) (TZ | 天猪 <<[email protected]>>)
- [[`18b67fd`](http://github.com/eggjs/egg-mysql/commit/18b67fd3e43627ad420ed3df8e8a6e305f5202f6)] - deps: upgrade dependencies (#10) (Haoliang Gao <<[email protected]>>)

# 3.0.0 / 2017-04-03

* deps: ali-rds@3 (#9)
- deps: ali-rds@3 (#9)

2.0.0 / 2017-02-09
==================
# 2.0.0 / 2017-02-09

* feat: remove app.instrument and fix test (#5)
- feat: remove app.instrument and fix test (#5)

1.0.1 / 2016-12-30
==================
# 1.0.1 / 2016-12-30

* docs: add app.js and agent.js extend intro (#3)
* docs: add English translation doc (#2)
- docs: add app.js and agent.js extend intro (#3)
- docs: add English translation doc (#2)
Loading