Skip to content

Commit

Permalink
Merge PR #487: Use NodeNext for Typescript module resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
nene authored Oct 3, 2022
2 parents 3070430 + 2a442c9 commit ad8dd40
Show file tree
Hide file tree
Showing 141 changed files with 619 additions and 622 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"prefer-template": "off",
"default-case": "off",
"import/prefer-default-export": "off",
"import/extensions": ["error", "always"],
"prettier/prettier": ["error"],
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/comma-dangle": "off",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"ts-loader": "^9.3.1",
"ttypescript": "^1.5.13",
"typescript": "^4.7.4",
"webpack": "^5.64.1",
"webpack": "^5.74.0",
"webpack-cli": "^4.9.1",
"webpack-merge": "^5.8.0"
},
Expand All @@ -168,7 +168,7 @@
"src/**/*.ts"
],
"moduleNameMapper": {
"src/(.*)": "<rootDir>/src/$1"
"^\\.(.+)\\.js": ".$1"
}
}
}
8 changes: 4 additions & 4 deletions src/FormatOptions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// import only type to avoid ESLint no-cycle rule producing an error
import type { SqlLanguage } from './sqlFormatter';
import { ParamItems } from './formatter/Params';
import Formatter from './formatter/Formatter';
import { ParamTypes } from './lexer/TokenizerOptions';
import type { SqlLanguage } from './sqlFormatter.js';
import { ParamItems } from './formatter/Params.js';
import Formatter from './formatter/Formatter.js';
import { ParamTypes } from './lexer/TokenizerOptions.js';

export type IndentStyle = 'standard' | 'tabularLeft' | 'tabularRight';

Expand Down
18 changes: 9 additions & 9 deletions src/formatter/ExpressionFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FormatOptions } from 'src/FormatOptions';
import { equalizeWhitespace, isMultiline } from 'src/utils';
import { FormatOptions } from '../FormatOptions.js';
import { equalizeWhitespace, isMultiline } from '../utils.js';

import Params from 'src/formatter/Params';
import { isTabularStyle } from 'src/formatter/config';
import { TokenType } from 'src/lexer/token';
import Params from './Params.js';
import { isTabularStyle } from './config.js';
import { TokenType } from '../lexer/token.js';
import {
AllColumnsAsteriskNode,
ArraySubscriptNode,
Expand All @@ -28,11 +28,11 @@ import {
CaseExpressionNode,
CaseWhenNode,
CaseElseNode,
} from 'src/parser/ast';
} from '../parser/ast.js';

import Layout, { WS } from './Layout';
import toTabularFormat, { isTabularToken } from './tabularStyle';
import InlineLayout, { InlineLayoutError } from './InlineLayout';
import Layout, { WS } from './Layout.js';
import toTabularFormat, { isTabularToken } from './tabularStyle.js';
import InlineLayout, { InlineLayoutError } from './InlineLayout.js';

interface ExpressionFormatterParams {
cfg: FormatOptions;
Expand Down
22 changes: 11 additions & 11 deletions src/formatter/Formatter.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { FormatOptions } from 'src/FormatOptions';
import { indentString } from 'src/formatter/config';
import Params from 'src/formatter/Params';
import Tokenizer from 'src/lexer/Tokenizer';
import { FormatOptions } from '../FormatOptions.js';
import { indentString } from './config.js';
import Params from './Params.js';
import Tokenizer from '../lexer/Tokenizer.js';

import { createParser } from 'src/parser/createParser';
import { StatementNode } from 'src/parser/ast';
import { createParser } from '../parser/createParser.js';
import { StatementNode } from '../parser/ast.js';

import formatCommaPositions from './formatCommaPositions';
import formatAliasPositions from './formatAliasPositions';
import ExpressionFormatter, { DialectFormatOptions } from './ExpressionFormatter';
import Layout, { WS } from './Layout';
import Indentation from './Indentation';
import formatCommaPositions from './formatCommaPositions.js';
import formatAliasPositions from './formatAliasPositions.js';
import ExpressionFormatter, { DialectFormatOptions } from './ExpressionFormatter.js';
import Layout, { WS } from './Layout.js';
import Indentation from './Indentation.js';

/** Main formatter class that produces a final output string from list of tokens */
export default class Formatter {
Expand Down
2 changes: 1 addition & 1 deletion src/formatter/Indentation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { last } from 'src/utils';
import { last } from '../utils.js';

const INDENT_TYPE_TOP_LEVEL = 'top-level';
const INDENT_TYPE_BLOCK_LEVEL = 'block-level';
Expand Down
4 changes: 2 additions & 2 deletions src/formatter/InlineLayout.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// eslint-disable-next-line max-classes-per-file
import Indentation from './Indentation';
import Layout, { WS } from './Layout';
import Indentation from './Indentation.js';
import Layout, { WS } from './Layout.js';

/**
* Like Layout, but only formats single-line expressions.
Expand Down
4 changes: 2 additions & 2 deletions src/formatter/Layout.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { last } from 'src/utils';
import { last } from '../utils.js';

import Indentation from './Indentation';
import Indentation from './Indentation.js';

/** Whitespace modifiers to be used with add() method */
export enum WS {
Expand Down
2 changes: 1 addition & 1 deletion src/formatter/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormatOptions } from 'src/FormatOptions';
import { FormatOptions } from '../FormatOptions.js';

// Utility functions for config options

Expand Down
2 changes: 1 addition & 1 deletion src/formatter/formatAliasPositions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { maxLength } from 'src/utils';
import { maxLength } from '../utils.js';

/**
* Handles select alias placement - tabulates if enabled
Expand Down
4 changes: 2 additions & 2 deletions src/formatter/formatCommaPositions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommaPosition } from 'src/FormatOptions';
import { maxLength } from 'src/utils';
import { CommaPosition } from '../FormatOptions.js';
import { maxLength } from '../utils.js';

const PRECEDING_WHITESPACE_REGEX = /^\s+/u;

Expand Down
4 changes: 2 additions & 2 deletions src/formatter/tabularStyle.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IndentStyle } from 'src/FormatOptions';
import { isLogicalOperator, TokenType } from 'src/lexer/token';
import { IndentStyle } from '../FormatOptions.js';
import { isLogicalOperator, TokenType } from '../lexer/token.js';

/**
* When tabular style enabled,
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export * from './sqlFormatter';
export * from './sqlFormatter.js';
export type {
IndentStyle,
KeywordCase,
CommaPosition,
LogicalOperatorNewline,
FormatOptions,
} from './FormatOptions';
export { default as Formatter } from './formatter/Formatter';
export { default as Tokenizer } from './lexer/Tokenizer';
export { expandPhrases } from './expandPhrases';
} from './FormatOptions.js';
export { default as Formatter } from './formatter/Formatter.js';
export { default as Tokenizer } from './lexer/Tokenizer.js';
export { expandPhrases } from './expandPhrases.js';
12 changes: 6 additions & 6 deletions src/languages/bigquery/bigquery.formatter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Formatter from 'src/formatter/Formatter';
import Tokenizer from 'src/lexer/Tokenizer';
import { EOF_TOKEN, isToken, TokenType, Token } from 'src/lexer/token';
import { expandPhrases } from 'src/expandPhrases';
import { keywords } from './bigquery.keywords';
import { functions } from './bigquery.functions';
import Formatter from '../../formatter/Formatter.js';
import Tokenizer from '../../lexer/Tokenizer.js';
import { EOF_TOKEN, isToken, TokenType, Token } from '../../lexer/token.js';
import { expandPhrases } from '../../expandPhrases.js';
import { keywords } from './bigquery.keywords.js';
import { functions } from './bigquery.functions.js';

const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]']);

Expand Down
2 changes: 1 addition & 1 deletion src/languages/bigquery/bigquery.functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const functions = flatKeywordList({
// https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
Expand Down
2 changes: 1 addition & 1 deletion src/languages/bigquery/bigquery.keywords.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const keywords = flatKeywordList({
// https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#reserved_keywords
Expand Down
10 changes: 5 additions & 5 deletions src/languages/db2/db2.formatter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expandPhrases } from 'src/expandPhrases';
import Formatter from 'src/formatter/Formatter';
import Tokenizer from 'src/lexer/Tokenizer';
import { functions } from './db2.functions';
import { keywords } from './db2.keywords';
import { expandPhrases } from '../../expandPhrases.js';
import Formatter from '../../formatter/Formatter.js';
import Tokenizer from '../../lexer/Tokenizer.js';
import { functions } from './db2.functions.js';
import { keywords } from './db2.keywords.js';

const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT]']);

Expand Down
2 changes: 1 addition & 1 deletion src/languages/db2/db2.functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const functions = flatKeywordList({
// https://www.ibm.com/docs/en/db2-for-zos/11?topic=functions-aggregate
Expand Down
2 changes: 1 addition & 1 deletion src/languages/db2/db2.keywords.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const keywords = flatKeywordList({
// https://www.ibm.com/docs/en/db2-for-zos/11?topic=words-reserved#db2z_reservedwords__newresword
Expand Down
10 changes: 5 additions & 5 deletions src/languages/hive/hive.formatter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expandPhrases } from 'src/expandPhrases';
import Formatter from 'src/formatter/Formatter';
import Tokenizer from 'src/lexer/Tokenizer';
import { functions } from './hive.functions';
import { keywords } from './hive.keywords';
import { expandPhrases } from '../../expandPhrases.js';
import Formatter from '../../formatter/Formatter.js';
import Tokenizer from '../../lexer/Tokenizer.js';
import { functions } from './hive.functions.js';
import { keywords } from './hive.keywords.js';

const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT]']);

Expand Down
2 changes: 1 addition & 1 deletion src/languages/hive/hive.functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const functions = flatKeywordList({
// https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF
Expand Down
2 changes: 1 addition & 1 deletion src/languages/hive/hive.keywords.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const keywords = flatKeywordList({
// https://cwiki.apache.org/confluence/display/hive/languagemanual+ddl
Expand Down
12 changes: 6 additions & 6 deletions src/languages/mariadb/mariadb.formatter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expandPhrases } from 'src/expandPhrases';
import Formatter from 'src/formatter/Formatter';
import Tokenizer from 'src/lexer/Tokenizer';
import { EOF_TOKEN, isToken, Token, TokenType } from 'src/lexer/token';
import { keywords } from './mariadb.keywords';
import { functions } from './mariadb.functions';
import { expandPhrases } from '../../expandPhrases.js';
import Formatter from '../../formatter/Formatter.js';
import Tokenizer from '../../lexer/Tokenizer.js';
import { EOF_TOKEN, isToken, Token, TokenType } from '../../lexer/token.js';
import { keywords } from './mariadb.keywords.js';
import { functions } from './mariadb.functions.js';

const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT | DISTINCTROW]']);

Expand Down
2 changes: 1 addition & 1 deletion src/languages/mariadb/mariadb.functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const functions = flatKeywordList({
// https://mariadb.com/kb/en/information-schema-sql_functions-table/
Expand Down
2 changes: 1 addition & 1 deletion src/languages/mariadb/mariadb.keywords.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const keywords = flatKeywordList({
// https://mariadb.com/kb/en/information-schema-keywords-table/
Expand Down
12 changes: 6 additions & 6 deletions src/languages/mysql/mysql.formatter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expandPhrases } from 'src/expandPhrases';
import Formatter from 'src/formatter/Formatter';
import Tokenizer from 'src/lexer/Tokenizer';
import { EOF_TOKEN, isToken, Token, TokenType } from 'src/lexer/token';
import { keywords } from './mysql.keywords';
import { functions } from './mysql.functions';
import { expandPhrases } from '../../expandPhrases.js';
import Formatter from '../../formatter/Formatter.js';
import Tokenizer from '../../lexer/Tokenizer.js';
import { EOF_TOKEN, isToken, Token, TokenType } from '../../lexer/token.js';
import { keywords } from './mysql.keywords.js';
import { functions } from './mysql.functions.js';

const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT | DISTINCTROW]']);

Expand Down
2 changes: 1 addition & 1 deletion src/languages/mysql/mysql.functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const functions = flatKeywordList({
// https://dev.mysql.com/doc/refman/8.0/en/built-in-function-reference.html
Expand Down
2 changes: 1 addition & 1 deletion src/languages/mysql/mysql.keywords.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const keywords = flatKeywordList({
// https://dev.mysql.com/doc/refman/8.0/en/keywords.html
Expand Down
10 changes: 5 additions & 5 deletions src/languages/n1ql/n1ql.formatter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expandPhrases } from 'src/expandPhrases';
import Formatter from 'src/formatter/Formatter';
import Tokenizer from 'src/lexer/Tokenizer';
import { functions } from './n1ql.functions';
import { keywords } from './n1ql.keywords';
import { expandPhrases } from '../../expandPhrases.js';
import Formatter from '../../formatter/Formatter.js';
import Tokenizer from '../../lexer/Tokenizer.js';
import { functions } from './n1ql.functions.js';
import { keywords } from './n1ql.keywords.js';

const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT]']);

Expand Down
2 changes: 1 addition & 1 deletion src/languages/n1ql/n1ql.functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const functions = flatKeywordList({
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/functions.html
Expand Down
2 changes: 1 addition & 1 deletion src/languages/n1ql/n1ql.keywords.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const keywords = flatKeywordList({
// https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/reservedwords.html
Expand Down
14 changes: 7 additions & 7 deletions src/languages/plsql/plsql.formatter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expandPhrases } from 'src/expandPhrases';
import Formatter from 'src/formatter/Formatter';
import { DialectFormatOptions } from 'src/formatter/ExpressionFormatter';
import Tokenizer from 'src/lexer/Tokenizer';
import { EOF_TOKEN, isReserved, isToken, Token, TokenType } from 'src/lexer/token';
import { keywords } from './plsql.keywords';
import { functions } from './plsql.functions';
import { expandPhrases } from '../../expandPhrases.js';
import Formatter from '../../formatter/Formatter.js';
import { DialectFormatOptions } from '../../formatter/ExpressionFormatter.js';
import Tokenizer from '../../lexer/Tokenizer.js';
import { EOF_TOKEN, isReserved, isToken, Token, TokenType } from '../../lexer/token.js';
import { keywords } from './plsql.keywords.js';
import { functions } from './plsql.functions.js';

const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT | UNIQUE]']);

Expand Down
2 changes: 1 addition & 1 deletion src/languages/plsql/plsql.functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const functions = flatKeywordList({
// https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm
Expand Down
2 changes: 1 addition & 1 deletion src/languages/plsql/plsql.keywords.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const keywords = flatKeywordList({
// https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/reservewords.htm
Expand Down
12 changes: 6 additions & 6 deletions src/languages/postgresql/postgresql.formatter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expandPhrases } from 'src/expandPhrases';
import { DialectFormatOptions } from 'src/formatter/ExpressionFormatter';
import Formatter from 'src/formatter/Formatter';
import Tokenizer from 'src/lexer/Tokenizer';
import { functions } from './postgresql.functions';
import { keywords } from './postgresql.keywords';
import { expandPhrases } from '../../expandPhrases.js';
import { DialectFormatOptions } from '../../formatter/ExpressionFormatter.js';
import Formatter from '../../formatter/Formatter.js';
import Tokenizer from '../../lexer/Tokenizer.js';
import { functions } from './postgresql.functions.js';
import { keywords } from './postgresql.keywords.js';

const reservedSelect = expandPhrases(['SELECT [ALL | DISTINCT]']);

Expand Down
2 changes: 1 addition & 1 deletion src/languages/postgresql/postgresql.functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const functions = flatKeywordList({
// https://www.postgresql.org/docs/14/functions.html
Expand Down
2 changes: 1 addition & 1 deletion src/languages/postgresql/postgresql.keywords.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { flatKeywordList } from '../../utils';
import { flatKeywordList } from '../../utils.js';

export const keywords = flatKeywordList({
// https://www.postgresql.org/docs/14/sql-keywords-appendix.html
Expand Down
Loading

0 comments on commit ad8dd40

Please sign in to comment.