Skip to content

Commit

Permalink
fix: Fix linting errors and ESLint config
Browse files Browse the repository at this point in the history
Add ignore comments to empty functions
Add CLI files to top level `jsconfig.json`
Add top level `jsconfig.json` to ESLint config
Add `counter.js` example to examples `jsconfig.json`
  • Loading branch information
petarvujovic98 committed Sep 20, 2022
1 parent 58f0966 commit e0c4ceb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
13 changes: 11 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: ["./tsconfig.json", "./**/{t,j}sconfig.json"],
project: ["./{t,j}sconfig.json", "./**/{t,j}sconfig.json"],
},
plugins: ["@typescript-eslint"],
rules: {
Expand All @@ -32,6 +32,15 @@ module.exports = {
},
},
],
ignorePatterns: ["./**/node_modules", "node_modules", "./**/lib", "lib"],
ignorePatterns: [
"./**/node_modules",
"node_modules",
"./**/lib",
"lib",
"./**/build",
"build",
"./**/deps",
"deps",
],
rules: {},
};
3 changes: 2 additions & 1 deletion examples/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"compilerOptions": {
"experimentalDecorators": true
},
"exclude": ["node_modules"]
"exclude": ["node_modules"],
"files": ["src/counter.js"]
}
4 changes: 4 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"exclude": ["node_modules"],
"include": ["cli/*.js"]
}
9 changes: 9 additions & 0 deletions src/near-bindgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ type EmptyParameterObject = Record<never, never>;
// ) => void;

export function initialize(_empty: EmptyParameterObject) {
/* eslint-disable @typescript-eslint/no-empty-function, @typescript-eslint/ban-types */
return function (
_target: any,
_key: string | symbol,
_descriptor: TypedPropertyDescriptor<Function>
): void {};
/* eslint-enable @typescript-eslint/no-empty-function, @typescript-eslint/ban-types */
}

export function call({
Expand All @@ -23,11 +25,13 @@ export function call({
privateFunction?: boolean;
payableFunction?: boolean;
}) {
/* eslint-disable @typescript-eslint/ban-types */
return function (
_target: any,
_key: string | symbol,
descriptor: TypedPropertyDescriptor<Function>
): void {
/* eslint-enable @typescript-eslint/ban-types */
const originalMethod = descriptor.value;

descriptor.value = function (...args: unknown[]) {
Expand All @@ -46,11 +50,13 @@ export function call({
}

export function view(_empty: EmptyParameterObject) {
/* eslint-disable @typescript-eslint/no-empty-function, @typescript-eslint/ban-types */
return function (
_target: any,
_key: string | symbol,
_descriptor: TypedPropertyDescriptor<Function>
): void {};
/* eslint-enable @typescript-eslint/no-empty-function, @typescript-eslint/ban-types */
}

export function NearBindgen({
Expand All @@ -69,6 +75,7 @@ export function NearBindgen({
return rawState ? this._deserialize(rawState) : null;
}

/* eslint-disable-next-line @typescript-eslint/ban-types */
static _saveToStorage(obj: Object): void {
near.storageWrite("STATE", this._serialize(obj));
}
Expand All @@ -77,10 +84,12 @@ export function NearBindgen({
return JSON.parse(near.input() || "{}");
}

/* eslint-disable-next-line @typescript-eslint/ban-types */
static _serialize(value: Object): string {
return JSON.stringify(value);
}

/* eslint-disable-next-line @typescript-eslint/ban-types */
static _deserialize(value: string): Object {
return JSON.parse(value);
}
Expand Down

0 comments on commit e0c4ceb

Please sign in to comment.