https://github.com/antonniklasson/eslint-plugin-knex
Lint rule(s) for Knex.js
https://github.com/antonniklasson/eslint-plugin-knex
eslint eslint-plugin eslint-plugin-knex eslint-rules knex knexjs
Last synced: 6 months ago
JSON representation
Lint rule(s) for Knex.js
- Host: GitHub
- URL: https://github.com/antonniklasson/eslint-plugin-knex
- Owner: AntonNiklasson
- Created: 2020-11-24T16:48:04.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-03-12T13:21:27.000Z (over 1 year ago)
- Last Synced: 2025-03-26T13:45:27.021Z (7 months ago)
- Topics: eslint, eslint-plugin, eslint-plugin-knex, eslint-rules, knex, knexjs
- Language: JavaScript
- Homepage:
- Size: 114 KB
- Stars: 9
- Watchers: 1
- Forks: 8
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# eslint-plugin-knex
[](https://badge.fury.io/js/eslint-plugin-knex)
## Installation
```
npm install -D eslint-plugin-knex
yarn add -D eslint-plugin-knex
```## Usage
In your eslint config file:
```
{
"plugins": ["knex"],
"rules": {
"knex/avoid-injections": "error"
}
}
```## Settings
You can configure what names you intend to use for the knex client. Make sure to
include the library itself (`knex`), but also transaction variables (`trx`,
`transaction`).```
{
"settings": {
"knex": {
"builderName": "^(knex|transaction)$"
}
}
}
```## Rules
### `knex/avoid-injections`
Avoid some issues related to SQL injection by disallowing plain strings as the query argument to the raw queries. Check out [the tests](https://github.com/AntonNiklasson/eslint-plugin-knex/blob/master/rules/avoid-injections.test.js) to get a sense for what is valid and not.