Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segmentio/ts-mysql-plugin
A typescript language service plugin that gives superpowers to SQL tagged template literals.
https://github.com/segmentio/ts-mysql-plugin
Last synced: 3 months ago
JSON representation
A typescript language service plugin that gives superpowers to SQL tagged template literals.
- Host: GitHub
- URL: https://github.com/segmentio/ts-mysql-plugin
- Owner: segmentio
- License: mit
- Created: 2020-01-03T18:59:11.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-02T23:29:46.000Z (about 1 year ago)
- Last Synced: 2024-05-21T12:13:17.804Z (6 months ago)
- Language: TypeScript
- Size: 65.4 MB
- Stars: 317
- Watchers: 12
- Forks: 9
- Open Issues: 17
-
Metadata Files:
- Readme: readme.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-typescript-ecosystem - ts-mysql-plugin - A TypeScript Language Service Plugin that gives superpowers to SQL tagged template literals. (Language service plugins / Optimization)
README
# ts-mysql-plugin
![Alt Text](https://github.com/segmentio/ts-mysql-plugin/workflows/CI/badge.svg)
A typescript language service plugin that gives superpowers to SQL tagged template literals. Specifically aimed at the MySQL syntax.
![Alt Text](https://github.com/segmentio/ts-mysql-plugin/raw/master/.github/demo.gif)
## Features
- Autocomplete for MySQL keywords
- Autocomplete for table names and column names (powered by your schema)
- Hover documentation for MySQL keywords
- Hover documentation for tables and columns (powered by your schema)
- Diagnostics for MySQL syntax errors
- Diagnostics for invalid table names and column names (powered by your schema)
- Diagnostics for invalid column types (powered by your schema)
- Works in all major editors (VSCode, Sublime Text, Atom, etc.)## Installing
Step 1: Yarn.
```sh
yarn add --dev ts-mysql-plugin
```Step 2: TS Config.
Add the plugin to your compiler options in `tsconfig.json`. Note that `databaseUri` is optional, but recommended.
```json
{
"compilerOptions": {
"plugins": [
{
"name": "ts-mysql-plugin",
"databaseUri": "mysql://USER@HOST/DB_NAME"
}
]
}
}
```You can also optionally configure the MySQL version for the plugin to use (defaults to 5.7.12) This will ensure that the MySQL parser correctly notifies you about syntax errors for your version.
```json
{
"mySQLVersion": "5.7.12"
}
```You can also optionally override the default tags ("SQL" and "sql") by adding a "tags" array to the config. For example, if you want the plugin to activate only on "Sql" tags:
```json
{
"tags": ["Sql"]
}
```If you add `@ts-mysql-plugin ignore` in a comment at the top of a file, then the plugin will skip the file.
## Developing
Run the following:
```shell
yarn install
yarn build
```## Testing
Assuming you've run all the steps in the "Development" section, then run the following:
```shell
cd e2e
yarn install
docker-compose up -d
cd ..
yarn test
```## Related
- [ts-mysql-parser](https://github.com/stevenmiller888/ts-mysql-parser) - A standalone, grammar-complete MySQL parser
- [ts-mysql-analyzer](https://github.com/stevenmiller888/ts-mysql-analyzer) - A MySQL query analyzer
- [ts-mysql-autocomplete](https://github.com/stevenmiller888/ts-mysql-autocomplete) - An autocomplete engine for MySQL queries## License
[MIT](https://tldrlegal.com/license/mit-license)