Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
Change-type: patch
  • Loading branch information
thgreasi committed Oct 4, 2024
1 parent 394aec4 commit 8b6f93b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 27 deletions.
21 changes: 3 additions & 18 deletions src/AbstractSQLOptimiser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ const Field: MetaMatchFn<FieldNode | ReferencedFieldNode> = (args) => {
};

const AnyNotNullValue = (args: any): boolean => {
return args != null && (args as any) !== 'Null' && args[0] !== 'Null';
return args != null && args !== 'Null' && args[0] !== 'Null';
};

const FieldOp =
Expand Down Expand Up @@ -603,15 +603,7 @@ const typeRules = {
case 'RightJoin':
case 'FullJoin':
case 'CrossJoin':
tables.push(
typeRules[type](rest) as
| FromNode
| InnerJoinNode
| LeftJoinNode
| RightJoinNode
| FullJoinNode
| CrossJoinNode,
);
tables.push(typeRules[type](rest));
break;
case 'Where':
case 'GroupBy':
Expand Down Expand Up @@ -1375,14 +1367,7 @@ const typeRules = {
switch (valuesType) {
case 'SelectQuery':
case 'UnionQuery':
values = [
[
'Values',
typeRules[valuesType](valuesRest) as
| SelectQueryNode
| UnionQueryNode,
],
];
values = [['Values', typeRules[valuesType](valuesRest)]];
break;
default:
values = [['Values', valuesArray.map(Value)] as ValuesNode];
Expand Down
10 changes: 5 additions & 5 deletions src/AbstractSQLRules2SQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type MatchFn = (args: AbstractSqlType[], indent: string) => string;
let fieldOrderings: Binding[] = [];
let fieldOrderingsLookup: Dictionary<number> = {};
let engine: Engines = Engines.postgres;
let noBinds: boolean = false;
let noBinds = false;

export const comparisons = {
Equals: ' = ',
Expand Down Expand Up @@ -669,7 +669,7 @@ const typeRules: Dictionary<MatchFn> = {
SelectQuery: (args, indent) => {
const tables: string[] = [];
const joins: string[] = [];
let select: string = '';
let select = '';
const groups = {
Where: '',
GroupBy: '',
Expand Down Expand Up @@ -869,7 +869,7 @@ const typeRules: Dictionary<MatchFn> = {
checkArgs('Cast', args, 2);
const value = AnyValue(getAbstractSqlQuery(args, 0), indent);
const typeName = args[1] as keyof typeof sbvrTypes;
if (!sbvrTypes[typeName] || !sbvrTypes[typeName].types[engine]) {
if (!sbvrTypes[typeName]?.types[engine]) {
throw new SyntaxError(`Invalid cast type: ${typeName}`);
}
let type: string;
Expand Down Expand Up @@ -1451,7 +1451,7 @@ const typeRules: Dictionary<MatchFn> = {
const tables: string[] = [];
let fields: string[] = [];
let values: string[] = [];
let where: string = '';
let where = '';
for (const arg of args) {
if (!isAbstractSqlQuery(arg)) {
throw new SyntaxError('`UpdateQuery` args must all be arrays');
Expand Down Expand Up @@ -1510,7 +1510,7 @@ const typeRules: Dictionary<MatchFn> = {
},
DeleteQuery: (args, indent) => {
const tables: string[] = [];
let where: string = '';
let where = '';
for (const arg of args) {
if (!isAbstractSqlQuery(arg)) {
throw new SyntaxError('`DeleteQuery` args must all be arrays');
Expand Down
4 changes: 2 additions & 2 deletions src/AbstractSQLSchemaOptimiser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const generateRuleSlug = (

export const optimizeSchema = (
abstractSqlModel: AbstractSqlModel,
createCheckConstraints: boolean = true,
createCheckConstraints = true,
): AbstractSqlModel => {
abstractSqlModel.rules = abstractSqlModel.rules
.map((rule): AbstractSqlQuery | undefined => {
Expand Down Expand Up @@ -126,7 +126,7 @@ export const optimizeSchema = (
);
if (table) {
table.checks ??= [];
table.checks!.push({
table.checks.push({
description: ruleSE,
name: generateRuleSlug(tableName, ruleBody),
abstractSql: whereNode,
Expand Down
2 changes: 1 addition & 1 deletion src/referenced-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export const getRuleReferencedFields: EngineInstance['getRuleReferencedFields']
_.isEqual(ruleBody[2], ['Number', 0]) &&
isSelectQueryNode(ruleBody[1])
) {
const select = ruleBody[1].find(isSelectNode) as SelectNode;
const select = ruleBody[1].find(isSelectNode)!;
select[1] = [];
$getRuleReferencedFields(referencedFields, ruleBody[1], IsSafe.Delete);
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/sbvr/reference-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('reference type', function () {
test = getTestHelpers(typeVocab);
});

it('informative - no foreignKey for reference field', async () => {
it('informative - no foreignKey for reference field', () => {
test(
`\
Expand Down

0 comments on commit 8b6f93b

Please sign in to comment.