Skip to content

Commit

Permalink
chore: Fix ESLint warnings
Browse files Browse the repository at this point in the history
Add exports to class declarations
Remove unused variables
Fix `any` types
Fix `moduleResolution` in examples
Format `jsconfig.json` `includes` entry for CLI
  • Loading branch information
petarvujovic98 committed Sep 22, 2022
1 parent a9cb69d commit b6a3866
Show file tree
Hide file tree
Showing 30 changed files with 45 additions and 37 deletions.
2 changes: 1 addition & 1 deletion examples/src/clean-state.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NearBindgen, call, view, near } from "near-sdk-js";

@NearBindgen({})
class CleanState {
export class CleanState {
@call({})
clean({ keys }) {
keys.forEach((key) => near.storageRemove(key));
Expand Down
4 changes: 2 additions & 2 deletions examples/src/counter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NearBindgen, near, call, view, initialize } from "near-sdk-js";
import { NearBindgen, near, call, view } from "near-sdk-js";
import { isUndefined } from "lodash-es";

@NearBindgen({})
class Counter {
export class Counter {
constructor() {
this.count = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/src/counter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { NearBindgen, near, call, view, initialize } from "near-sdk-js";
import { NearBindgen, near, call, view } from "near-sdk-js";
import { isUndefined } from "lodash-es";
import { log } from "./log";

@NearBindgen({})
class Counter {
export class Counter {
count = 0;

@call({})
Expand Down
2 changes: 1 addition & 1 deletion examples/src/cross-contract-call.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NearBindgen, call, view, initialize, near, bytes } from "near-sdk-js";

@NearBindgen({ requireInit: true })
class OnCall {
export class OnCall {
constructor() {
this.personOnCall = "";
this.statusMessageContract = "";
Expand Down
2 changes: 1 addition & 1 deletion examples/src/fungible-token-helper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NearBindgen, call, view } from "near-sdk-js";

@NearBindgen({})
class FungibleTokenHelper {
export class FungibleTokenHelper {
constructor() {
this.data = "";
}
Expand Down
2 changes: 1 addition & 1 deletion examples/src/fungible-token-lockable.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Account {
}

@NearBindgen({ initRequired: true })
class LockableFungibleToken {
export class LockableFungibleToken {
constructor() {
this.accounts = new LookupMap("a"); // Account ID -> Account mapping
this.totalSupply = 0; // Total supply of the all tokens
Expand Down
4 changes: 2 additions & 2 deletions examples/src/fungible-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "near-sdk-js";

@NearBindgen({ initRequired: true })
class FungibleToken {
export class FungibleToken {
constructor() {
this.accounts = new LookupMap("a");
this.totalSupply = 0;
Expand Down Expand Up @@ -40,7 +40,7 @@ class FungibleToken {
this.totalSupply = newSupply.toString();
}

internalTransfer({ senderId, receiverId, amount, memo }) {
internalTransfer({ senderId, receiverId, amount, memo: _ }) {
assert(senderId != receiverId, "Sender and receiver should be different");
let amountInt = BigInt(amount);
assert(amountInt > 0n, "The amount should be a positive number");
Expand Down
2 changes: 1 addition & 1 deletion examples/src/log.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { near } from "near-sdk-js";

export function log(msg: any) {
export function log(msg: unknown) {
near.log(msg);
}
2 changes: 1 addition & 1 deletion examples/src/non-fungible-token-receiver.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NearBindgen, call, near, assert, initialize } from "near-sdk-js";

@NearBindgen({ requireInit: true })
class NftContract {
export class NftContract {
constructor() {
this.nonFungibleTokenAccountId = "";
}
Expand Down
12 changes: 9 additions & 3 deletions examples/src/non-fungible-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Token {
}

@NearBindgen({ requireInit: true })
class NftContract {
export class NftContract {
constructor() {
this.owner_id = "";
this.owner_by_id = new LookupMap("a");
Expand All @@ -29,7 +29,13 @@ class NftContract {
this.owner_by_id = new LookupMap(owner_by_id_prefix);
}

internalTransfer({ sender_id, receiver_id, token_id, approval_id, memo }) {
internalTransfer({
sender_id,
receiver_id,
token_id,
approval_id: _ai,
memo: _m,
}) {
let owner_id = this.owner_by_id.get(token_id);

assert(owner_id !== null, "Token not found");
Expand Down Expand Up @@ -125,7 +131,7 @@ class NftContract {
}

@call({})
nftMint({ token_id, token_owner_id, token_metadata }) {
nftMint({ token_id, token_owner_id, token_metadata: _ }) {
let sender_id = near.predecessorAccountId();
assert(sender_id === this.owner_id, "Unauthorized");
assert(this.owner_by_id.get(token_id) === null, "Token ID must be unique");
Expand Down
3 changes: 2 additions & 1 deletion examples/src/parking-lot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ class Engine {
}

@NearBindgen({})
class ParkingLot {
export class ParkingLot {
cars: LookupMap<CarSpecs>;

constructor() {
this.cars = new LookupMap<CarSpecs>("a");
}
Expand Down
2 changes: 1 addition & 1 deletion examples/src/status-message-collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "near-sdk-js";

@NearBindgen({})
class StatusMessage {
export class StatusMessage {
constructor() {
this.records = new UnorderedMap("a");
this.uniqueValues = new LookupSet("b");
Expand Down
2 changes: 1 addition & 1 deletion examples/src/status-message.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NearBindgen, call, view, near } from "near-sdk-js";

@NearBindgen({})
class StatusMessage {
export class StatusMessage {
constructor() {
this.records = {};
}
Expand Down
1 change: 1 addition & 0 deletions examples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"experimentalDecorators": true,
"target": "es2020",
"moduleResolution": "node",
"noEmit": true
},
"exclude": ["node_modules"]
Expand Down
2 changes: 1 addition & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"exclude": ["node_modules"],
"include": ["cli/*.js"]
"include": ["cli"]
}
2 changes: 1 addition & 1 deletion tests/__tests__/test_promise_api.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ test("promise delete account", async (t) => {
});

test("promise batch function call weight", async (t) => {
const { ali, caller2Contract, calleeContract } = t.context.accounts;
const { ali, caller2Contract } = t.context.accounts;
let r = await ali.callRaw(
caller2Contract,
"test_promise_batch_call_weight",
Expand Down
4 changes: 2 additions & 2 deletions tests/src/bigint-serialization.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { near, NearBindgen, call, view, initialize } from "near-sdk-js";
import { near, NearBindgen, call, view } from "near-sdk-js";

@NearBindgen({})
class BigIntSerializationTest {
export class BigIntSerializationTest {
bigintField: bigint;

constructor() {
Expand Down
2 changes: 1 addition & 1 deletion tests/src/decorators/payable.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { near, NearBindgen, call, view } from "near-sdk-js";

@NearBindgen({})
class PayableTest {
export class PayableTest {
value: string;

constructor() {
Expand Down
2 changes: 1 addition & 1 deletion tests/src/decorators/private.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { near, NearBindgen, call, view } from "near-sdk-js";

@NearBindgen({})
class PrivateTest {
export class PrivateTest {
value: string;

constructor() {
Expand Down
2 changes: 1 addition & 1 deletion tests/src/decorators/require_init_false.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { near, NearBindgen, call, view, initialize } from "near-sdk-js";

@NearBindgen({ requireInit: false })
class NBTest {
export class NBTest {
status: string;

constructor() {
Expand Down
2 changes: 1 addition & 1 deletion tests/src/decorators/require_init_true.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { near, NearBindgen, call, view, initialize } from "near-sdk-js";

@NearBindgen({ requireInit: true })
class NBTest {
export class NBTest {
status: string;

constructor() {
Expand Down
2 changes: 1 addition & 1 deletion tests/src/function-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NearBindgen, call, view, near } from "near-sdk-js";
* Simple contract to test function parameters
*/
@NearBindgen({})
class FunctionParamsTestContract {
export class FunctionParamsTestContract {
constructor() {
this.val1 = "default1";
this.val2 = "default2";
Expand Down
4 changes: 2 additions & 2 deletions tests/src/highlevel-promise.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NearBindgen, call, view, NearPromise, near, bytes } from "near-sdk-js";
import { NearBindgen, call, NearPromise, near, bytes } from "near-sdk-js";
import { PublicKey } from "near-sdk-js/lib/types";

function callingData() {
Expand All @@ -15,7 +15,7 @@ function arrayN(n) {
}

@NearBindgen({})
class HighlevelPromiseContract {
export class HighlevelPromiseContract {
@call({})
test_promise_batch_stake() {
let promise = NearPromise.new("highlevel-promise.test.near").stake(
Expand Down
2 changes: 1 addition & 1 deletion tests/src/lookup-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NearBindgen, call, view, LookupMap } from "near-sdk-js";
import { House, Room } from "./model.js";

@NearBindgen({})
class LookupMapTestContract {
export class LookupMapTestContract {
constructor() {
this.lookupMap = new LookupMap("a");
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/lookup-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NearBindgen, call, view, LookupSet } from "near-sdk-js";
import { House, Room } from "./model.js";

@NearBindgen({})
class LookupSetTestContract {
export class LookupSetTestContract {
constructor() {
this.lookupSet = new LookupSet("a");
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/public-key.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { near, bytes, types } from "near-sdk-js";
import { near, bytes } from "near-sdk-js";
import { CurveType, PublicKey } from "near-sdk-js/lib/types";
import { assert } from "near-sdk-js/lib/utils";

Expand Down
2 changes: 1 addition & 1 deletion tests/src/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NearBindgen, view } from "near-sdk-js";

@NearBindgen({})
class TypeScriptTestContract {
export class TypeScriptTestContract {
@view({})
bigint() {
// JSON.stringify cannot seriaize a BigInt, need manually toString
Expand Down
4 changes: 2 additions & 2 deletions tests/src/unordered-map.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NearBindgen, call, view, UnorderedMap, near } from "near-sdk-js";
import { NearBindgen, call, view, UnorderedMap } from "near-sdk-js";
import { House, Room } from "./model.js";

@NearBindgen({})
class UnorderedMapTestContract {
export class UnorderedMapTestContract {
constructor() {
this.unorderedMap = new UnorderedMap("a");
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/unordered-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NearBindgen, call, view, UnorderedSet } from "near-sdk-js";
import { House, Room } from "./model.js";

@NearBindgen({})
class UnorderedSetTestContract {
export class UnorderedSetTestContract {
constructor() {
this.unorderedSet = new UnorderedSet("a");
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NearBindgen, call, view, Vector } from "near-sdk-js";
import { House, Room } from "./model.js";

@NearBindgen({})
class VectorTestContract {
export class VectorTestContract {
constructor() {
this.vector = new Vector("a");
}
Expand Down

0 comments on commit b6a3866

Please sign in to comment.