From e0c4cebb1338f7386246ac20d7ee1c1c05f6b898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petar=20Vujovi=C4=87?= Date: Tue, 20 Sep 2022 14:15:15 +0200 Subject: [PATCH] fix: Fix linting errors and ESLint config 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` --- .eslintrc.cjs | 13 +++++++++++-- examples/jsconfig.json | 3 ++- jsconfig.json | 4 ++++ src/near-bindgen.ts | 9 +++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 jsconfig.json diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 64dc898f..c4c1b4d0 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -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: { @@ -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: {}, }; diff --git a/examples/jsconfig.json b/examples/jsconfig.json index a6d61863..b3bd1bff 100644 --- a/examples/jsconfig.json +++ b/examples/jsconfig.json @@ -2,5 +2,6 @@ "compilerOptions": { "experimentalDecorators": true }, - "exclude": ["node_modules"] + "exclude": ["node_modules"], + "files": ["src/counter.js"] } diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 00000000..f85e2a8d --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,4 @@ +{ + "exclude": ["node_modules"], + "include": ["cli/*.js"] +} diff --git a/src/near-bindgen.ts b/src/near-bindgen.ts index 475c384d..770c2301 100644 --- a/src/near-bindgen.ts +++ b/src/near-bindgen.ts @@ -9,11 +9,13 @@ type EmptyParameterObject = Record; // ) => 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 ): void {}; + /* eslint-enable @typescript-eslint/no-empty-function, @typescript-eslint/ban-types */ } export function call({ @@ -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 ): void { + /* eslint-enable @typescript-eslint/ban-types */ const originalMethod = descriptor.value; descriptor.value = function (...args: unknown[]) { @@ -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 ): void {}; + /* eslint-enable @typescript-eslint/no-empty-function, @typescript-eslint/ban-types */ } export function NearBindgen({ @@ -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)); } @@ -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); }