8000 build: eslint-plugin-markdown@2.2.1 · mysqljs/sqlstring@2a652cd · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a652cd

Browse files
committed
build: eslint-plugin-markdown@2.2.1
1 parent 321f26a commit 2a652cd

File tree

3 files changed

+18
-29
lines changed

3 files changed

+18
-29
lines changed

.eslintrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
"env": {
33
"node": true
44
},
5+
"plugins": [
6+
"markdown"
7+
],
8+
"overrides": [
9+
{
10+
"files": "**/*.md",
11+
"processor": "markdown/markdown"
12+
},
13+
{
14+
"files": "**/*.md/*.js",
15+
"rules": {
16+
"no-undef": 0,
17+
"no-unused-vars": 0
18+
}
19+
}
20+
],
521
"rules": {
622
"comma-dangle": [2, "never"],
723
"comma-spacing": ["error", { "before": false, "after": true }],

README.md

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ $ npm install sqlstring
1616

1717
## Usage
1818

19-
<!-- eslint-disable no-undef, no-unused-vars -->
2019

2120
```js
2221
var SqlString = require('sqlstring');
@@ -32,8 +31,6 @@ In order to avoid SQL Injection attacks, you should always escape any user
3231
provided data before using it inside a SQL query. You can do so using the
3332
`SqlString.escape()` method:
3433

35-
<!-- eslint-disable no-undef -->
36-
3734
```js
3835
var userId = 'some user provided value';
3936
var sql = 'SELECT * FROM users WHERE id = ' + SqlString.escape(userId);
@@ -43,8 +40,6 @@ console.log(sql); // SELECT * FROM users WHERE id = 'some user provided value'
4340
Alternatively, you can use `?` characters as placeholders for values you would
4441
like to have escaped like this:
4542

46-
<!-- eslint-disable no-undef -->
47-
4843
```js
4944
var userId = 1;
5045
var sql = SqlString.format('SELECT * FROM users WHERE id = ?', [userId]);
@@ -55,8 +50,6 @@ Multiple placeholders are mapped to values in the same order as passed. For exam
5550
in the following query `foo` equals `a`, `bar` equals `b`, `baz` equals `c`, and
5651
`id` will be `userId`:
5752

58-
<!-- eslint-disable no-undef -->
59-
6053
```js
6154
var userId = 1;
6255
var sql = SqlString.format('UPDATE users SET foo = ?, bar = ?, baz = ? WHERE id = ?',
@@ -93,8 +86,6 @@ Different value types are escaped differently, here is how:
9386

9487
You may have noticed that this escaping allows you to do neat things like this:
9588

96-
<!-- eslint-disable no-undef -->
97-
9889
```js
9990
var post = {id: 1, title: 'Hello MySQL'};
10091
var sql = SqlString.format('INSERT INTO posts SET ?', post);
@@ -103,8 +94,6 @@ console.log(sql); // INSERT INTO posts SET `id` = 1, `title` = 'Hello MySQL'
10394

10495
And the `toSqlString` method allows you to form complex queries with functions:
10596

106-
<!-- eslint-disable no-undef -->
107-
10897
```js
10998
var CURRENT_TIMESTAMP = { toSqlString: function() { return 'CURRENT_TIMESTAMP()'; } };
11099
var sql = SqlString.format('UPDATE posts SET modified = ? WHERE id = ?', [CURRENT_TIMESTAMP, 42]);
@@ -118,8 +107,6 @@ placeholder, useful for using functions as dynamic values:
118107
**Caution** The string provided to `SqlString.raw()` will skip all escaping
119108
functions when used, so be careful when passing in unvalidated input.
120109

121-
<!-- eslint-disable no-undef -->
122-
123110
```js
124111
var CURRENT_TIMESTAMP = SqlString.raw('CURRENT_TIMESTAMP()');
125112
var sql = SqlString.format('UPDATE posts SET modified = ? WHERE id = ?', [CURRENT_TIMESTAMP, 42]);
@@ -129,8 +116,6 @@ console.log(sql); // UPDATE posts SET modified = CURRENT_TIMESTAMP() WHERE id =
129116
If you feel the need to escape queries by yourself, you can also use the escaping
130117
function directly:
131118

132-
<!-- eslint-disable no-undef -->
133-
134119
```js
135120
var sql = 'SELECT * FROM posts WHERE title=' + SqlString.escape('Hello MySQL');
136121
console.log(sql); // SELECT * FROM posts WHERE title='Hello MySQL'
@@ -141,8 +126,6 @@ console.log(sql); // SELECT * FROM posts WHERE title='Hello MySQL'
141126
If you can't trust an SQL identifier (database / table / column name) because it is
142127
provided by a user, you should escape it with `SqlString.escapeId(identifier)` like this:
143128

144-
<!-- eslint-disable no-undef -->
145-
146129
```js
147130
var sorter = 'date';
148131
var sql = 'SELECT * FROM posts ORDER BY ' + SqlString.escapeId(sorter);
@@ -151,8 +134,6 @@ console.log(sql); // SELECT * FROM posts ORDER BY `date`
151134

152135
It also supports adding qualified identifiers. It will escape both parts.
153136

154-
<!-- eslint-disable no-undef -->
155-
156137
```js
157138
var sorter = 'date';
158139
var sql = 'SELECT * FROM posts ORDER BY ' + SqlString.escapeId('posts.' + sorter);
@@ -162,8 +143,6 @@ console.log(sql); // SELECT * FROM posts ORDER BY `posts`.`date`
162143
If you do not want to treat `.` as qualified identifiers, you can set the second
163144
argument to `true` in order to keep the string as a literal identifier:
164145

165-
<!-- eslint-disable no-undef -->
166-
167146
```js
168147
var sorter = 'date.2';
169148
var sql = 'SELECT * FROM posts ORDER BY ' + SqlString.escapeId(sorter, true);
@@ -173,8 +152,6 @@ console.log(sql); // SELECT * FROM posts ORDER BY `date.2`
173152
Alternatively, you can use `??` characters as placeholders for identifiers you would
174153
like to have escaped like this:
175154

176-
<!-- eslint-disable no-undef -->
177-
178155
```js
179156
var userId = 1;
180157
var columns = ['username', 'email'];
@@ -190,8 +167,6 @@ When you pass an Object to `.escape()` or `.format()`, `.escapeId()` is used to
190167
You can use `SqlString.format` to prepare a query with multiple insertion points,
191168
utilizing the proper escaping for ids and values. A simple example of this follows:
192169

193-
<!-- eslint-disable no-undef -->
194-
195170
```js
196171
var userId = 1;
197172
var inserts = ['users', 'id', userId];
@@ -208,8 +183,6 @@ location-specific/timezone-aware `Date`.
208183
This can be further combined with the `SqlString.raw()` helper to generate SQL
209184
that includes MySQL functions as dynamic vales:
210185

211-
<!-- eslint-disable no-undef -->
212-
213186
```js
214187
var userId = 1;
215188
var data = { email: 'foobar@example.com', modified: SqlString.raw('NOW()') };

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"beautify-benchmark": "0.2.4",
2323
"benchmark": "2.1.4",
2424
"eslint": "7.32.0",
25-
"eslint-plugin-markdown": "1.0.2",
25+
"eslint-plugin-markdown": "2.2.1",
2626
"nyc": "15.1.0",
2727
"urun": "0.0.8",
2828
"utest": "0.0.8"
@@ -39,7 +39,7 @@
3939
},
4040
"scripts": {
4141
"bench": "node benchmark/index.js",
42-
"lint": "eslint --plugin markdown --ext js,md .",
42+
"lint": "eslint .",
4343
"test": "node test/run.js",
4444
"test-ci": "nyc --reporter=lcovonly --reporter=text npm test",
4545
"test-cov": "nyc --reporter=html --reporter=text npm test"

0 commit comments

Comments
 (0)
0