This repository has been archived by the owner on Jul 6, 2022. It is now read-only.
forked from sql-formatter-org/sql-formatter
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR (#27) * configure for typescript * prettier * convert to typescript * add default options * fix uppercase default for tests add count keyword * sort and dedupe keywords * add support for escaped keywords as identifiers * fix keyword identifier for non critical tests * add @typescript-eslint/eslint-plugin * fix webpack * add basic alias processing missing double word case * add missing keywords to redshift fix column alias edge case * add alias tests * ♻️ * fix handling of never alias option * prettier check * add newline for itemCount setting * add newline for lineWidth * update newline hybrid rule logic * implement newline mode tests * ♻️ * prettier check * add eslint-config-airbnb-typescript * add @typescript-eslint/parser * fix eslint errors * convert relevant import to type imports * remove ts extension from import in test files * remove sqlformatter d ts * add dense operator option * add operator test * add NewlineMode enum * move types to types file * add AliasMode enum * convert enums into string enums * ♻️ * add semicolon newline option * add unit test for semicolon newline * add maxLength function * add tabulation function * add KeywordMode type * add keyword style examples * remove TopLevelIndents and merge reserved token logic * add basic 10-space keyword positioning * add support for multi item clauses * add support for long keywords * add unit tests for tenSpace modes fix block end index logic * add tests to accept tenSpace modes * fix ON keyword * fix bug with TopLevelIndent on nested blocks starting with FROM ( * add commaPosition option * add post format method * add basic tabular mode * add formatting for comma before column * add unit test for comma modes fix tabular option * add tests for accepting comma modes * add AliasPosition flag * add basic tabular alias function * add unit tests for alias position fix alias joining * add tests for accepting tabular aliases * switch delta from unit test as potential keyword * fix regex flags * fix alias tests * add tests for aliasPosition x keywordPosition edge cases * limit keywordPosition to standard and tenSpace * add test case for long keywords * move keywords that should be in reservedNewlineWords * dedupe keywords * update redshift keywords * split reserved words into categories add links to docs * update Db2 keywords * update MariaDb keywords * update MySql keywords * update N1ql keywords * update Postgres keywords * update Spark keywords * update TSQL keywords * update union/intersect/except lists * split reservedDependentClause from reservedNewline * fix case statements to support dependent clause * update dependent clauses for remaining messages * fix tests and keyword discrepancies * rename TopLevelWord to Command * rename TopLevelNoIndent to Binary Command * move joins to BinaryCommands * rename Newline words to Logical Operators * rename reservedWords to Keywords * rename openParen to Block Start * rename closeParen to Block End * move Logical Operator down * add comments for reserved word categories * fix PlSql test with CROSS/OUTER APPLY * convert all members for formatters classes to static * add paren options type * add basic formatting for open paren position * add basic close paren position formatting * add test for open and close paren position * decline reservedFunctionParens and functionParenSpace * convert token type into TokenType enum * use TypeToken enum to build mapped Regex table * simplify tokenizer class * simplify isToken * update Tokenizer with PR comments * rename isTopLevel to IsCommand * add flag to toggle breaking before boolean operator * support break after operator add test * update tests with static class members * Update Db2FormatterTest.js * add changelog * update README * update package.json * fix semicolonNewline type * Create dependabot.yml * update sqlfmt node script to use config file * add changelog * Create dependabot.yml * update README * update package.json * fix semicolonNewline type
- Loading branch information
1 parent
3cd6d98
commit 84b513e
Showing
88 changed files
with
19,977 additions
and
16,479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"presets": ["@babel/preset-env"], | ||
"plugins": ["@babel/plugin-proposal-class-properties", "add-module-exports"] | ||
"presets": ["@babel/preset-env", "@babel/preset-typescript"], | ||
"plugins": ["@babel/plugin-proposal-class-properties", "add-module-exports"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,41 @@ | ||
{ | ||
"parser": "babel-eslint", | ||
"extends": ["airbnb-base", "prettier"], | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"prettier/prettier": ["error"], | ||
"curly": ["error", "all"], | ||
"require-unicode-regexp": ["error"], | ||
"func-names": "error", | ||
"no-useless-concat": "off", | ||
"class-methods-use-this": "off", | ||
"no-param-reassign": "off", | ||
"prefer-template": "off", | ||
"no-plusplus": "off", | ||
"no-else-return": "off", | ||
"no-use-before-define": "off" | ||
}, | ||
"env": { | ||
"jest": true | ||
} | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { "project": "./tsconfig.json", "ecmaVersion": 6, "sourceType": "module" }, | ||
"extends": ["airbnb-base", "airbnb-typescript/base", "plugin:import/typescript", "prettier"], | ||
"plugins": ["@typescript-eslint", "prettier"], | ||
"rules": { | ||
"class-methods-use-this": "off", | ||
"curly": ["error", "all"], | ||
"eqeqeq": "warn", | ||
"func-names": "error", | ||
"no-continue": "off", | ||
"no-param-reassign": "off", | ||
"no-plusplus": "off", | ||
"no-else-return": "off", | ||
"no-use-before-define": "warn", | ||
"no-useless-concat": "off", | ||
"prefer-template": "off", | ||
"prettier/prettier": ["error"], | ||
"@typescript-eslint/comma-dangle": "off", | ||
"@typescript-eslint/indent": "off", | ||
"@typescript-eslint/lines-between-class-members": "off", | ||
"@typescript-eslint/naming-convention": "warn", | ||
"@typescript-eslint/no-unused-vars": "warn", | ||
"@typescript-eslint/quotes": [ | ||
"warn", | ||
"single", | ||
{ "avoidEscape": true, "allowTemplateLiterals": true } | ||
], | ||
"@typescript-eslint/semi": "warn" | ||
}, | ||
"settings": { | ||
"import/resolver": { | ||
"node": { | ||
"extensions": [".js", ".ts"] | ||
} | ||
} | ||
}, | ||
"env": { | ||
"jest": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
/dist | ||
/lib | ||
/node_modules | ||
yarn.lock | ||
LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
{ | ||
"printWidth": 100, | ||
"singleQuote": true | ||
"printWidth": 100, | ||
"singleQuote": true, | ||
"arrowParens": "avoid", | ||
"semi": true, | ||
"bracketSpacing": true, | ||
"useTabs": true, | ||
"tabWidth": 2, | ||
"endOfLine": "auto" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# CHANGELOG | ||
|
||
## NEXT [5.0.0] : 2021-11-03 | ||
|
||
### Added | ||
|
||
New Features: | ||
|
||
- added option `aliasAs` to toggle use of AS in column, table, query aliases | ||
- modes: always (SELECT and table), select (SELECT only), never | ||
- added option `newline` to specify rules for inserting newlines within SQL Statements | ||
- modes: \ | ||
always (break before all arguments) \ | ||
lineWidth (break after line exceeds lineWidth) \ | ||
itemCount (break after n items) \ | ||
hybrid (lineWidth OR itemCount) \ | ||
never (place all Statements on one line) | ||
- added flag `denseOperators` to toggle spaces around binary operators (=, +, %, etc.) | ||
- added flag `semicolonNewline` to toggle placing semicolon on newline vs same line | ||
- added flag `tabulateAlias` for alias tabular mode, aligned on longest line, not including AS | ||
- added option `commaPosition` to specify comma placement within listed Statements | ||
- modes: \ | ||
before(comma goes before column), \ | ||
after(standard), \ | ||
tabular(aligned to longest line) | ||
- added option `keywordPosition` to support vertically aligned keywords | ||
- modes: \ | ||
standard, \ | ||
tenSpaceLeft(left-aligned within keyword column), \ | ||
tenSpaceRight(right-aligned within keyword column) | ||
- added flag `breakBeforeBooleanOperator` to toggle breaking before or after logical operators like AND and OR | ||
- added options `parenOptions` for misc rules regarding parenthesis position | ||
- `openParenNewline` - flag for opening paren on newline or same line | ||
- `closeParenNewline` - flag for closing paren on newline or same line | ||
|
||
Other: | ||
|
||
- added enums for all typed config options | ||
|
||
Files Added: | ||
|
||
- test/comma.js (tests for comma position) | ||
- test/alias.js (tests for alias AS and alias position) | ||
- test/keywordPosition.js (tests for keyword position modes) | ||
- test/newline.js (tests for newline modes) | ||
- test/parenthesis.js (tests for paren positions) | ||
|
||
### Removed | ||
|
||
Files Removed: | ||
|
||
- tokenTypes.ts (token types moved to TokenType enum in token.ts) | ||
- sqlFormatter.d.ts (converted to TypeScript) | ||
|
||
### Updated | ||
|
||
Major changes: | ||
|
||
- converted repo to Typescript | ||
- overhauled Keyword lists for all languages | ||
|
||
Other: | ||
|
||
- added default options for all configs | ||
- updated CLI to use config file | ||
- renamed Keyword categories to semantic Keyword types | ||
- reservedTopLevelWord → reservedCommand | ||
- reservedTopLevelWordNoIndent → reservedBinaryCommand | ||
- reservedNewline → reservedDependentClause & reservedLogicalOperator | ||
- reservedWord → reservedKeyword | ||
- added reservedFunctions | ||
- updated Tokenizer class and token.ts to be more DRY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.