joereynolds / joereynolds/sql-lint
New option `--fix` to format SQL
- Dominant language
- TypeScript
- Stars
- 459
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Description
This will be a biggie but here's some of what needs to be done.
- [x] - New option `--fix`. Upon being called, it will spit out the formatted SQL to stdout
- [ ] - Tests to make sure it is being formatted correctly
- [ ] - Find a semi-authoritative answer on what SQL should look like (maybe look at Dbeaver for inspiration [here](https://github.com/dbeaver/dbeaver/tree/devel/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/sql/format))
- From looking at how dbeaver does it, it looks like it does the following.
- Keywords are on their own line
- functions are on the same line as the rest of the content
- Indentation is 4 spaces
- Statements are terminated with `;`
- Statements are separated by 1 newline
- Not dbeaver but we should set a hard limit of 120 chars?
- [ ] - Some form of integration with ALE (See #30) so that we can call `:ALEFix`
- [x] - A new file `fixer.ts`. For now, house everything in here until we work out what it is we're doing
### Formatting rules/assumptions
- Keywords are on their own line
- functions are on the same line as the rest of the content
- Indentation is 4 spaces
- Statements are terminated with `;`
- Statements are separated by 1 newline
- Hard limit of 120 chars?
- A space should follow a comma in an argument list
- No trailing whitespace
### Tests
- [x] - Test a keyword is on its own line
- [ ] - Test a join (with and without LEFT/RIGHT/OUTER etc...) is on its own line
- [ ] - Test indentation is in multiples of 4
- [ ] - Test multiple statements are separated by 1 new lines
- [ ] - Test a function is on the same line as it's argument(s)
- [ ] - Test code wraps at some line length (120?)
- [ ] - Spaces come after commas in argument lists
- [ ] - Trailing whitespace is removed from queries
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.