chroe: devops (#180)

* ci: add dependencies about lint tool

* ci: replace eslint with prettier

* ci: add husky, cz and commitlint

* style: lint fix via prettier

* ci: add prettier and check-types to github workflow

'
This commit is contained in:
Hayden
2023-10-13 11:16:36 +08:00
committed by GitHub
parent 4d1dfa676f
commit 7de192d486
105 changed files with 2615 additions and 1823 deletions

View File

@ -1,5 +1,6 @@
import trinoSQL from '../../../src/parser/trinosql';
import { TrinoSqlListener } from '../../../src/lib/trinosql/TrinoSqlListener';
import { ParseTreeListener } from 'antlr4ts/tree';
describe('trino SQL Listener Tests', () => {
const expectTableName = 'user1';
@ -11,14 +12,13 @@ describe('trino SQL Listener Tests', () => {
test('Listener enterTableName', async () => {
let result = '';
class MyListener implements TrinoSqlListener {
enterTableName = (ctx): void => {
result = ctx.text.toLowerCase();
};
}
const listenTableName = new MyListener();
await parser.listen(listenTableName, parserTree);
await parser.listen(listenTableName as ParseTreeListener, parserTree);
expect(result).toBe(expectTableName);
});
});

View File

@ -1,11 +1,11 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
table: readSQL(__dirname, 'alter_table.sql'),
view: readSQL(__dirname, 'alter_view.sql'),
schema: readSQL(__dirname, 'alter_schema.sql'),
materializedView: readSQL(__dirname, 'alter_materialized_view.sql')
materializedView: readSQL(__dirname, 'alter_materialized_view.sql'),
};
describe('TrinoSQL Alter Statements Syntax Tests', () => {
@ -19,16 +19,15 @@ describe('TrinoSQL Alter Statements Syntax Tests', () => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.schema.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
features.materializedView.forEach((sql) => {
});
features.materializedView.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
});

View File

@ -1,9 +1,8 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
analyze: readSQL(__dirname, 'analyze.sql'),
};
describe('TrinoSQL Analyze Statements Syntax Tests', () => {
@ -15,4 +14,3 @@ describe('TrinoSQL Analyze Statements Syntax Tests', () => {
});
});
});

View File

@ -1,9 +1,8 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
call: readSQL(__dirname, 'call.sql'),
};
describe('TrinoSQL Call Statements Syntax Tests', () => {
@ -15,4 +14,3 @@ describe('TrinoSQL Call Statements Syntax Tests', () => {
});
});
});

View File

@ -1,9 +1,8 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
comment: readSQL(__dirname, 'comment.sql'),
};
describe('TrinoSQL Comment Statements Syntax Tests', () => {
@ -15,4 +14,3 @@ describe('TrinoSQL Comment Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
commit: readSQL(__dirname, 'commit.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Commit Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
table: readSQL(__dirname, 'create_table.sql'),
@ -12,7 +12,7 @@ const features = {
describe('TrinoSQL Create Statements Syntax Tests', () => {
const parser = new TrinoSQL();
features.table.forEach((sql) => {
features.table.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
@ -21,28 +21,26 @@ describe('TrinoSQL Create Statements Syntax Tests', () => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.schema.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.tableAsSelect.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.role.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.materializedView.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
deallocatePrepare: readSQL(__dirname, 'deallocate_prepare.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL deallocatePrepare Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
delete: readSQL(__dirname, 'delete.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Delete Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
deny: readSQL(__dirname, 'deny.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Deny Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
describe: readSQL(__dirname, 'describe.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Describe Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
table: readSQL(__dirname, 'drop_table.sql'),
@ -12,7 +12,7 @@ const features = {
describe('TrinoSQL Drop Statements Syntax Tests', () => {
const parser = new TrinoSQL();
features.table.forEach((sql) => {
features.table.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
@ -21,28 +21,26 @@ describe('TrinoSQL Drop Statements Syntax Tests', () => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.schema.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.column.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.role.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.materializedView.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
execute: readSQL(__dirname, 'execute.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Execute Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
explain: readSQL(__dirname, 'explain.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Explain Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
grant: readSQL(__dirname, 'grant.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Grant Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
insertIntoTable: readSQL(__dirname, 'insert_into.sql'),
@ -13,4 +13,3 @@ describe('TrinoSQL Insert Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
matchRecognize: readSQL(__dirname, 'match_recognize.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Match Recognize Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
merge: readSQL(__dirname, 'merge.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Merge Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
prepare: readSQL(__dirname, 'prepare.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Prepare Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
refreshMaterializedView: readSQL(__dirname, 'refresh_materialized_view.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Refresh Materialized View Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
resetSession: readSQL(__dirname, 'reset_session.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Reset Session Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
revoke: readSQL(__dirname, 'revoke.sql'),
@ -20,4 +20,3 @@ describe('TrinoSQL Revoke Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
rollbackTransaction: readSQL(__dirname, 'rollback_transaction.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Rollback Transaction Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
select: readSQL(__dirname, 'select.sql'),
@ -13,12 +13,12 @@ const features = {
selectWithFetch: readSQL(__dirname, 'select_with_fetch.sql'),
selectWithUNNEST: readSQL(__dirname, 'select_with_ unnest.sql'),
selectWithExists: readSQL(__dirname, 'select_with_exists.sql'),
selectWithUnion: readSQL(__dirname, 'select_with_union.sql')
selectWithUnion: readSQL(__dirname, 'select_with_union.sql'),
};
describe('TrinoSQL Select Statements Syntax Tests', () => {
const parser = new TrinoSQL();
features.select.forEach((sql) => {
features.select.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
@ -27,57 +27,56 @@ describe('TrinoSQL Select Statements Syntax Tests', () => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.selectWithSetOperations.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.selectWithSubQueries.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.selectWithTableSample.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.selectWithRowType.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.selectWithOffset.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.selectWithJoin.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.selectWithFetch.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.selectWithUNNEST.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
features.selectWithExists.forEach((sql) => {
});
features.selectWithExists.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
features.selectWithUnion.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
role: readSQL(__dirname, 'set_role.sql'),
@ -32,4 +32,3 @@ describe('TrinoSQL Set Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
tables: readSQL(__dirname, 'show_tables.sql'),
@ -75,4 +75,3 @@ describe('TrinoSQL Show Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
startTransaction: readSQL(__dirname, 'start_transaction.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Start Transaction Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
truncateTable: readSQL(__dirname, 'truncate_table.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Truncate Table Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
update: readSQL(__dirname, 'update.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Update Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
use: readSQL(__dirname, 'use.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Use Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
values: readSQL(__dirname, 'values.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Values Statements Syntax Tests', () => {
});
});
});

View File

@ -1,5 +1,5 @@
import TrinoSQL from "../../../../src/parser/trinosql";
import { readSQL } from "../../../helper";
import TrinoSQL from '../../../../src/parser/trinosql';
import { readSQL } from '../../../helper';
const features = {
windowWithRowPatternRecognition: readSQL(__dirname, 'window_with_row_pattern_recognition.sql'),
@ -14,4 +14,3 @@ describe('TrinoSQL Window With Row Pattern Recognition Statements Syntax Tests',
});
});
});

View File

@ -13,13 +13,13 @@ describe('trino SQL Visitor Tests', () => {
test('Visitor visitTableName', () => {
let result = '';
class MyVisitor extends AbstractParseTreeVisitor<any> implements TrinoSqlVisitor<any>{
class MyVisitor extends AbstractParseTreeVisitor<any> implements TrinoSqlVisitor<any> {
protected defaultResult() {
return result;
}
visitTableName = (ctx): void => {
result = ctx.text.toLowerCase();
}
};
}
const visitor: any = new MyVisitor();
visitor.visit(parserTree);