Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Certified data prop test #2181

Merged
merged 19 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .eslintrc.cjs
lastmjs marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ module.exports = {
},
plugins: ['@typescript-eslint', 'simple-import-sort'],
rules: {
'no-restricted-syntax': [
'error',
{
selector: "IfStatement[test.type!='BinaryExpression']",
message:
'Conditional expressions must use explicit comparisons (e.g., === or !==).'
}
],
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': 'error',
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
Expand Down
2 changes: 1 addition & 1 deletion benchmark/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ function format_number_to_rust(number: string | number | bigint): string {
(number_is_negative === false && Number(number) < 1) ||
(number_is_negative === true && Number(number) > -1);

if (number_is_decimal_less_than_one) {
if (number_is_decimal_less_than_one === true) {
return number.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function onBeforeExit(paths: [Src, Dest][], actor: UploaderActor): void {
let cleanUpComplete = false;

process.on('beforeExit', async () => {
if (cleanUpComplete) {
if (cleanUpComplete === true) {
// If any async behavior happens in 'beforeExit' then 'beforeExit'
// will run again. This is need to prevent an infinite loop.
// Once clean up is complete we are ready to exit
Expand Down
2 changes: 1 addition & 1 deletion src/lib/experimental/candid/serde/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function decodeSingle(candidType: CandidType, data: ArrayBuffer): any {
// The candid type was AzleVoid if when converted to an Idl Type it is []
const candidTypeWasAzleVoid = Array.isArray(idlType);

if (candidTypeWasAzleVoid) {
if (candidTypeWasAzleVoid === true) {
return undefined;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/experimental/candid/serde/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function encodeSingle(candidType: CandidType, data: any): Uint8Array {
// The candid type was AzleVoid if when converted to an Idl Type it is []
const candidTypeWasAzleVoid = Array.isArray(idlType);

if (candidTypeWasAzleVoid) {
if (candidTypeWasAzleVoid === true) {
return new Uint8Array(IDL.encode([], []));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function serviceCall(
) => {
const encodedArgs = encode(paramCandidTypes, args);

if (notify) {
if (notify === true) {
return (callFunction as NotifyRawFunction)(
canisterId,
methodName,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/experimental/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ if (globalThis._azleInsideCanister === true) {

RegExp.prototype.exec = function (string): RegExpExecArray | null {
const match = originalExec.call(this, string);
if (match) {
if (match !== null) {
RegExp.leftContext = (string ?? '').substring(0, match.index);
}
return match;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/stable/did_file/visitor/visit/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function serviceToCandidString(
postMethodCandidString
);

if (isFirstService) {
if (isFirstService === true) {
return [
`service: ${canisterParamsString} -> {\n${funcStrings}\n}`,
candidTypes
Expand Down
4 changes: 2 additions & 2 deletions src/lib/stable/ic_apis/data_certificate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* When called from a query call, returns the data certificate
* authenticating `certifiedData` set by this canister. Otherwise returns
* `None`.
* @returns the data certificate or None
* `undefined`.
* @returns the data certificate or undefined
*/
export function dataCertificate(): Uint8Array | undefined {
if (
Expand Down
8 changes: 4 additions & 4 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export function runTests(
const { shouldRunTests, shouldRunTypeChecks, shouldRecordBenchmarks } =
processEnvVars();

if (shouldRunTests) {
if (shouldRunTests === true) {
describe(`tests`, tests);
}

if (shouldRunTypeChecks) {
if (shouldRunTypeChecks === true) {
describe(`type checks`, () => {
it('checks types', () => {
try {
Expand All @@ -47,7 +47,7 @@ export function runTests(
});
}

if (shouldRecordBenchmarks && canisterNames !== undefined) {
if (shouldRecordBenchmarks === true && canisterNames !== undefined) {
const canisterNamesArray = Array.isArray(canisterNames)
? canisterNames
: [canisterNames];
Expand Down Expand Up @@ -154,5 +154,5 @@ function processEnvVars(): {
}

function shouldRun(envVar: string, hasOnly: boolean): boolean {
return hasOnly ? envVar === 'only' : envVar !== 'false';
return hasOnly === true ? envVar === 'only' : envVar !== 'false';
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function generateVariableAliasDeclarations(
innerType: CandidDefinition,
api: Api
): string[] {
if (useTypeDeclaration) {
if (useTypeDeclaration === true) {
const type =
api === 'functional'
? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function generateVariableAliasDeclarations(
const fieldVariableAliasDeclarations = fields.flatMap(
(field): string[] => field[1].candidMeta.variableAliasDeclarations
);
if (useTypeDeclaration) {
if (useTypeDeclaration === true) {
const type =
api === 'functional'
? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function generateVariableAliasDeclarations(
const fieldVariableAliasDeclarations = fields.flatMap(
(field) => field.candidMeta.variableAliasDeclarations
);
if (useTypeDeclaration) {
if (useTypeDeclaration === true) {
const type =
api === 'functional'
? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function generateVariableAliasDeclarations(
const fieldVariableAliasDeclarations = fields.flatMap(
(field): string[] => field[1].candidMeta.variableAliasDeclarations
);
if (useTypeDeclaration) {
if (useTypeDeclaration === true) {
const type =
api === 'functional'
? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function generateVariableAliasDeclarations(
innerType: CandidDefinition,
api: Api
): string[] {
if (useTypeDeclaration) {
if (useTypeDeclaration === true) {
const type =
api === 'functional'
? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function generateVariableAliasDeclarations(
const serviceMethodTypeAliasDecls = serviceMethods.flatMap(
(serviceMethod) => serviceMethod.variableAliasDeclarations
);
if (useTypeDeclaration) {
if (useTypeDeclaration === true) {
const type = api === 'functional' ? [] : [`type ${name} = Principal`];
return [
...serviceMethodTypeAliasDecls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function generateVariableAliasDeclarations(
useTypeDeclaration: boolean,
api: Api
): string[] {
if (useTypeDeclaration) {
if (useTypeDeclaration === true) {
if (api === 'class') {
return [
`const ${name} = ${toIDL(candidType)};`,
Expand Down
8 changes: 4 additions & 4 deletions test/property/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function runTests(
console.info('\x1b[31m', `${result.Err}`);
console.info('\x1b[0m');

if (exitProcess) {
if (exitProcess === true) {
process.exit(1);
} else {
return false;
Expand All @@ -78,7 +78,7 @@ export async function runTests(
}
console.info('\x1b[0m');

if (exitProcess) {
if (exitProcess === true) {
process.exit(1);
} else {
return false;
Expand All @@ -95,7 +95,7 @@ export async function runTests(
);
console.info('\x1b[0m');

if (exitProcess) {
if (exitProcess === true) {
process.exit(1);
} else {
return false;
Expand Down Expand Up @@ -148,7 +148,7 @@ export function createSnakeCaseProxy<T extends object>(
: camelToSnakeCase(prop as string);

if (typeof (obj as any)[snakeCaseProp] === 'function') {
if (async) {
if (async === true) {
return async (...args: any[]) => {
const new_args = args.map((value) => {
return convertKeysToSnakeCase(value);
Expand Down
Loading
Loading