Skip to content

Commit f930f6e

Browse files
authored
documentation: update documentation path pattern and add all *.md to lint checker (#2049)
* documentation: move to `documentation` * documentation: update the README documentation links * documentation: update the zh-cn README documentation links * documentation: update the Readme documentation links * documentation: change the README documentation links to local branch * documentation: change the Promise-Wrapper links to local branch * documentation: change the zh-cn README documentation links to local branch * documentation: change the documentation Readme links to local branch * documentation: update the Promise-Wrapper link * documentation: update the documentation link to `en` * fix: eslint markdown rules * fix: check for README.md in `lint:docs` script
1 parent d3dd182 commit f930f6e

13 files changed

+52
-46
lines changed

.eslintrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@
4646
"prettier"
4747
],
4848
"plugins": ["@typescript-eslint"]
49+
},
50+
{
51+
"files": ["**/*.md/*js"],
52+
"rules": {
53+
"no-undef": "off",
54+
"no-unused-vars": "off",
55+
"no-console": "off",
56+
"no-unused-labels": "off",
57+
"strict": "off",
58+
"prefer-arrow-callback": "off"
59+
},
60+
"parserOptions": {
61+
"sourceType": "module"
62+
}
4963
}
5064
]
5165
}

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
[![Windows Build][appveyor-image]][appveyor-url]
99
[![License][license-image]][license-url]
1010

11-
English | [简体中文](./documentation_zh-cn/)
11+
English | [简体中文](./documentation/zh-cn/)
1212

13-
> MySQL client for Node.js with focus on performance. Supports prepared statements, non-utf8 encodings, binary log protocol, compression, ssl [much more](https://github.com/sidorares/node-mysql2/tree/master/documentation)
13+
> MySQL client for Node.js with focus on performance. Supports prepared statements, non-utf8 encodings, binary log protocol, compression, ssl [much more](./documentation/en)
1414
1515
__Table of contents__
1616

@@ -32,14 +32,14 @@ MySQL2 project is a continuation of [MySQL-Native][mysql-native]. Protocol parse
3232
MySQL2 is mostly API compatible with [mysqljs][node-mysql] and supports majority of features. MySQL2 also offers these additional features
3333

3434
- Faster / Better Performance
35-
- [Prepared Statements](https://github.com/sidorares/node-mysql2/tree/master/documentation/Prepared-Statements.md)
35+
- [Prepared Statements](./documentation/en/Prepared-Statements.md)
3636
- MySQL Binary Log Protocol
37-
- [MySQL Server](https://github.com/sidorares/node-mysql2/tree/master/documentation/MySQL-Server.md)
37+
- [MySQL Server](./documentation/en/MySQL-Server.md)
3838
- Extended support for Encoding and Collation
39-
- [Promise Wrapper](https://github.com/sidorares/node-mysql2/tree/master/documentation/Promise-Wrapper.md)
39+
- [Promise Wrapper](./documentation/en/Promise-Wrapper.md)
4040
- Compression
41-
- SSL and [Authentication Switch](https://github.com/sidorares/node-mysql2/tree/master/documentation/Authentication-Switch.md)
42-
- [Custom Streams](https://github.com/sidorares/node-mysql2/tree/master/documentation/Extras.md)
41+
- SSL and [Authentication Switch](./documentation/en/Authentication-Switch.md)
42+
- [Custom Streams](./documentation/en/Extras.md)
4343
- [Pooling](#using-connection-pools)
4444

4545
## Installation
@@ -145,18 +145,18 @@ You can use the pool in the same way as connections (using `pool.query()` and `p
145145
```js
146146
// For pool initialization, see above
147147
pool.query("SELECT field FROM atable", function(err, rows, fields) {
148-
// Connection is automatically released when query resolves
148+
// Connection is automatically released when query resolves
149149
})
150150
```
151151

152152
Alternatively, there is also the possibility of manually acquiring a connection from the pool and returning it later:
153153
```js
154154
// For pool initialization, see above
155155
pool.getConnection(function(err, conn) {
156-
// Do something with the connection
157-
conn.query(/* ... */);
158-
// Don't forget to release the connection when finished!
159-
pool.releaseConnection(conn);
156+
// Do something with the connection
157+
conn.query(/* ... */);
158+
// Don't forget to release the connection when finished!
159+
pool.releaseConnection(conn);
160160
})
161161
```
162162

@@ -204,6 +204,7 @@ async function main() {
204204
const promisePool = pool.promise();
205205
// query database using promises
206206
const [rows,fields] = await promisePool.query("SELECT 1");
207+
}
207208
```
208209

209210
MySQL2 exposes a .promise() function on Connections, to "upgrade" an existing non-promise connection to use promise
@@ -258,7 +259,7 @@ If you find any other incompatibility with [Node MySQL][node-mysql], Please repo
258259

259260
## Documentation
260261

261-
You can find more detailed documentation [here](https://github.com/sidorares/node-mysql2/tree/master/documentation). You should also check various code [examples](https://github.com/sidorares/node-mysql2/tree/master/examples) to understand advanced concepts.
262+
You can find more detailed documentation [here](./documentation/en). You should also check various code [examples](./examples) to understand advanced concepts.
262263

263264
## Acknowledgements
264265

documentation/.eslintrc

Lines changed: 0 additions & 10 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

documentation/Promise-Wrapper.md renamed to documentation/en/Promise-Wrapper.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ co(function * () {
5757
yield c.end();
5858
});
5959
```
60-
Examples in [/examples/promise-co-await](https://github.com/sidorares/node-mysql2/tree/master/examples/promise-co-await)
60+
Examples in [/examples/promise-co-await](../../examples/promise-co-await)

documentation/Readme.md renamed to documentation/en/Readme.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88

99
Not only `Node-MySQL2` offers better performance over `node-mysql`, we also support these additional features.
1010

11-
- [Prepared Statements](https://github.com/sidorares/node-mysql2/tree/master/documentation/Prepared-Statements.md)
12-
- [Promise Wrapper](https://github.com/sidorares/node-mysql2/tree/master/documentation/Promise-Wrapper.md)
13-
- [Authentication Switch](https://github.com/sidorares/node-mysql2/tree/master/documentation/Authentication-Switch.md)
14-
- [More Features](https://github.com/sidorares/node-mysql2/tree/master/documentation/Extras.md)
15-
- [MySQL Server](https://github.com/sidorares/node-mysql2/tree/master/documentation/MySQL-Server.md)
11+
- [Prepared Statements](./Prepared-Statements.md)
12+
- [Promise Wrapper](./Promise-Wrapper.md)
13+
- [Authentication Switch](./Authentication-Switch.md)
14+
- [More Features](./Extras.md)
15+
- [MySQL Server](./MySQL-Server.md)
1616
- Pooling
1717
- SSL
1818
- MySQL Compression
1919
- Binary Log Protocol Client
2020

2121
## Examples
2222

23-
Please check these [examples](https://github.com/sidorares/node-mysql2/tree/master/documentation/Examples.md) for `node-mysql2`.
23+
Please check these [examples](./Examples.md) for `node-mysql2`.
2424

2525

2626
## Known incompatibilities with `node-mysql`
@@ -48,4 +48,4 @@ You need to check corresponding field's zeroFill flag and convert to string manu
4848
- https://gist.github.com/sidorares/ffe9ee9c423f763e3b6b
4949
- `npm run benchmarks`
5050
- [node-mysql-benchmarks](https://github.com/mscdex/node-mysql-benchmarks)
51-
- try to run example [benchmarks](https://github.com/sidorares/node-mysql2/tree/master/benchmarks) on your system
51+
- try to run example [benchmarks](../../benchmarks) on your system

documentation_zh-cn/README.md renamed to documentation/zh-cn/README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
[![Windows Build][appveyor-image]][appveyor-url]
99
[![License][license-image]][license-url]
1010

11-
[English](../README.md) | 简体中文
11+
[English](../..) | 简体中文
1212

13-
> 适用于Node.js的MySQL客户端,专注于性能优化。支持SQL预处理、非UTF-8编码支持、二进制文件编码支持、压缩和SSL等等 [查看更多](https://github.com/sidorares/node-mysql2/tree/master/documentation)
13+
> 适用于Node.js的MySQL客户端,专注于性能优化。支持SQL预处理、非UTF-8编码支持、二进制文件编码支持、压缩和SSL等等 [查看更多](../en)
1414
1515
__目录__
1616

@@ -32,14 +32,14 @@ MySQL2 项目是 [MySQL-Native][mysql-native] 的延续。 协议解析器代码
3232
MySQL2 大部分 API 与 [mysqljs][node-mysql] 兼容,并支持大部分功能。 MySQL2 还提供了更多的附加功能
3333

3434
- 更快、更好的性能
35-
- [支持预处理](https://github.com/sidorares/node-mysql2/tree/master/documentation/Prepared-Statements.md)
35+
- [支持预处理](../en/documentation/en/Prepared-Statements.md)
3636
- MySQL二进制日志协议
37-
- [MySQL Server](https://github.com/sidorares/node-mysql2/tree/master/documentation/MySQL-Server.md)
37+
- [MySQL Server](../en/documentation/en/MySQL-Server.md)
3838
- 对编码和排序规则有很好的支持
39-
- [Promise封装](https://github.com/sidorares/node-mysql2/tree/master/documentation/Promise-Wrapper.md)
39+
- [Promise封装](../en/documentation/en/Promise-Wrapper.md)
4040
- 支持压缩
41-
- SSL 和 [Authentication Switch](https://github.com/sidorares/node-mysql2/tree/master/documentation/Authentication-Switch.md)
42-
- [自定义流](https://github.com/sidorares/node-mysql2/tree/master/documentation/Extras.md)
41+
- SSL 和 [Authentication Switch](../en/documentation/en/Authentication-Switch.md)
42+
- [自定义流](../en/documentation/en/Extras.md)
4343
- [连接池](#using-connection-pools)
4444

4545
## 安装
@@ -143,18 +143,18 @@ const pool = mysql.createPool({
143143
```js
144144
// For pool initialization, see above
145145
pool.query("SELECT field FROM atable", function(err, rows, fields) {
146-
// Connection is automatically released when query resolves
146+
// Connection is automatically released when query resolves
147147
})
148148
```
149149

150150
或者,也可以手动从池中获取连接并稍后返回:
151151
```js
152152
// For pool initialization, see above
153153
pool.getConnection(function(err, conn) {
154-
// Do something with the connection
155-
conn.query(/* ... */);
156-
// Don't forget to release the connection when finished!
157-
pool.releaseConnection(conn);
154+
// Do something with the connection
155+
conn.query(/* ... */);
156+
// Don't forget to release the connection when finished!
157+
pool.releaseConnection(conn);
158158
})
159159
```
160160

@@ -202,6 +202,7 @@ async function main() {
202202
const promisePool = pool.promise();
203203
// query database using promises
204204
const [rows,fields] = await promisePool.query("SELECT 1");
205+
}
205206
```
206207

207208
MySQL2 在 Connections 上公开了一个 .promise*()函数,以“升级”现有的 non-promise 连接以使用 Promise
@@ -254,7 +255,7 @@ MySQL2大部分的API与 [Node MySQL][node-mysql] 基本上相同,你应该查
254255

255256
## 文档
256257

257-
你可以在[这里](https://github.com/sidorares/node-mysql2/tree/master/documentation)获得更多的详细文档,并且你应该查阅各种代码[示例](https://github.com/sidorares/node-mysql2/tree/master/examples)来获得更高级的概念。
258+
你可以在[这里](../en/documentation/en)获得更多的详细文档,并且你应该查阅各种代码[示例](../en/examples)来获得更高级的概念。
258259

259260
## 鸣谢
260261

lib/commands/query.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Query extends Command {
3737

3838
then() {
3939
const err =
40-
"You have tried to call .then(), .catch(), or invoked await on the result of query that is not a promise, which is a programming error. Try calling con.promise().query(), or require('mysql2/promise') instead of 'mysql2' for a promise-compatible version of the query interface. To learn how to use async/await or Promises check out documentation at https://www.npmjs.com/package/mysql2#using-promise-wrapper, or the mysql2 documentation at https://github.com/sidorares/node-mysql2/tree/master/documentation/Promise-Wrapper.md";
40+
"You have tried to call .then(), .catch(), or invoked await on the result of query that is not a promise, which is a programming error. Try calling con.promise().query(), or require('mysql2/promise') instead of 'mysql2' for a promise-compatible version of the query interface. To learn how to use async/await or Promises check out documentation at https://www.npmjs.com/package/mysql2#using-promise-wrapper, or the mysql2 documentation at https://github.com/sidorares/node-mysql2/tree/master/documentation/en/Promise-Wrapper.md";
4141
// eslint-disable-next-line
4242
console.log(err);
4343
throw new Error(err);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"scripts": {
1111
"lint": "npm run lint:docs && npm run lint:code",
1212
"lint:code": "eslint index.js promise.js \"lib/**/*.js\" \"test/**/*.js\" \"benchmarks/**/*.js\"",
13-
"lint:docs": "eslint Contributing.md \"documentation/**/*.md\" \"examples/*.js\"",
13+
"lint:docs": "eslint Contributing.md README.md \"documentation/**/*.md\" \"examples/*.js\"",
1414
"test": "node ./test/run.js",
1515
"test:tsc-build": "cd \"test/tsc-build\" && npx tsc -p \"tsconfig.json\"",
1616
"coverage-test": "c8 -r cobertura -r lcov -r text node ./test/run.js",

0 commit comments

Comments
 (0)