From e7c1f95dd2cddb321503fad5daf78332d9a510f2 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sat, 13 Feb 2021 09:16:41 -0500 Subject: [PATCH] updated lint rules --- .eslintrc.json | 19 +++++++++++++++++-- demo/gl-bench.js | 2 ++ package.json | 13 ++++++++----- src/age/age.ts | 2 +- src/emotion/emotion.ts | 2 +- src/gender/gender.ts | 2 +- src/gesture/gesture.ts | 2 +- src/handpose/handpipeline.ts | 2 -- src/human.ts | 1 - src/profile.ts | 2 +- 10 files changed, 32 insertions(+), 15 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 4be59b55..47a0e3fa 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -8,8 +8,11 @@ "jquery": true, "es2020": true }, + "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": 2020 }, - "plugins": [ ], + "plugins": [ + "@typescript-eslint" + ], "extends": [ "eslint:recommended", "plugin:import/errors", @@ -17,6 +20,8 @@ "plugin:node/recommended", "plugin:promise/recommended", "plugin:json/recommended-with-comments", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", "airbnb-base" ], "ignorePatterns": [ "dist", "assets", "media", "models", "node_modules" ], @@ -29,6 +34,7 @@ "import/no-absolute-path": "off", "import/no-extraneous-dependencies": "off", "import/prefer-default-export": "off", + "import/no-unresolved": "off", "max-len": [1, 275, 3], "newline-per-chained-call": "off", "no-async-promise-executor": "off", @@ -48,6 +54,10 @@ "node/no-unpublished-import": "off", "node/no-unpublished-require": "off", "node/no-unsupported-features/es-syntax": "off", + "node/no-missing-import": ["error", { + "allowModules": [], + "tryExtensions": [".js", ".json", ".ts"] + }], "node/shebang": "off", "object-curly-newline": "off", "prefer-destructuring": "off", @@ -55,6 +65,11 @@ "promise/always-return": "off", "promise/catch-or-return": "off", "promise/no-nesting": "off", - "radix": "off" + "radix": "off", + "lines-between-class-members": "off", + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/explicit-module-boundary-types": "off", + "@typescript-eslint/no-explicit-any": "off" } } \ No newline at end of file diff --git a/demo/gl-bench.js b/demo/gl-bench.js index 72ffffcb..90b5839a 100644 --- a/demo/gl-bench.js +++ b/demo/gl-bench.js @@ -44,7 +44,9 @@ class GLBench { constructor(gl, settings = {}) { this.css = UICSS; this.svg = UISVG; + // eslint-disable-next-line @typescript-eslint/no-empty-function this.paramLogger = () => {}; + // eslint-disable-next-line @typescript-eslint/no-empty-function this.chartLogger = () => {}; this.chartLen = 20; this.chartHz = 20; diff --git a/package.json b/package.json index 5767bab3..7909d0fa 100644 --- a/package.json +++ b/package.json @@ -32,25 +32,28 @@ "@tensorflow/tfjs-layers": "^3.0.0", "@tensorflow/tfjs-node": "^3.0.0", "@tensorflow/tfjs-node-gpu": "^3.0.0", + "@types/node": "^14.14.27", + "@typescript-eslint/eslint-plugin": "^4.15.0", + "@typescript-eslint/parser": "^4.15.0", "@vladmandic/pilogger": "^0.2.14", "chokidar": "^3.5.1", "dayjs": "^1.10.4", - "esbuild": "^0.8.43", - "eslint": "^7.19.0", + "esbuild": "^0.8.45", + "eslint": "^7.20.0", "eslint-config-airbnb-base": "^14.2.1", "eslint-plugin-import": "^2.22.1", "eslint-plugin-json": "^2.1.2", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-promise": "^4.3.1", "rimraf": "^3.0.2", "seedrandom": "^3.0.5", "simple-git": "^2.34.2", "tslib": "^2.1.0", - "typescript": "^4.2.0-dev.20210208" + "typescript": "^4.3.0-dev.20210213" }, "scripts": { "start": "node --trace-warnings --unhandled-rejections=strict --trace-uncaught --no-deprecation src/node.js", - "lint": "eslint src/*.js demo/*.js", + "lint": "eslint src demo server", "dev": "npm install && node server/serve.js", "build": "rimraf dist/* && rimraf types/* && node server/build.js && node server/changelog.js", "update": "npm update --depth 20 --force && npm dedupe && npm prune && npm audit" diff --git a/src/age/age.ts b/src/age/age.ts index 3b8deac9..f3da1f43 100644 --- a/src/age/age.ts +++ b/src/age/age.ts @@ -1,6 +1,6 @@ import { log } from '../log'; import * as tf from '../../dist/tfjs.esm.js'; -import * as profile from '../profile.js'; +import * as profile from '../profile'; let model; let last = { age: 0 }; diff --git a/src/emotion/emotion.ts b/src/emotion/emotion.ts index 99cc9968..eb6b5115 100644 --- a/src/emotion/emotion.ts +++ b/src/emotion/emotion.ts @@ -1,6 +1,6 @@ import { log } from '../log'; import * as tf from '../../dist/tfjs.esm.js'; -import * as profile from '../profile.js'; +import * as profile from '../profile'; const annotations = ['angry', 'disgust', 'fear', 'happy', 'sad', 'surprise', 'neutral']; let model; diff --git a/src/gender/gender.ts b/src/gender/gender.ts index d905bf04..d829804e 100644 --- a/src/gender/gender.ts +++ b/src/gender/gender.ts @@ -1,6 +1,6 @@ import { log } from '../log'; import * as tf from '../../dist/tfjs.esm.js'; -import * as profile from '../profile.js'; +import * as profile from '../profile'; let model; let last = { gender: '' }; diff --git a/src/gesture/gesture.ts b/src/gesture/gesture.ts index a966158a..1f47b970 100644 --- a/src/gesture/gesture.ts +++ b/src/gesture/gesture.ts @@ -62,7 +62,7 @@ export const hand = (res) => { if (!res) return []; const gestures: Array<{ hand: number, gesture: string }> = []; for (let i = 0; i < res.length; i++) { - const fingers: Array<{ name: string, position: number }> = []; + const fingers: Array<{ name: string, position: number }> = []; for (const [finger, pos] of Object.entries(res[i]['annotations'])) { // @ts-ignore if (finger !== 'palmBase') fingers.push({ name: finger.toLowerCase(), position: pos[0] }); // get tip of each finger diff --git a/src/handpose/handpipeline.ts b/src/handpose/handpipeline.ts index be2c995b..3d8ea872 100644 --- a/src/handpose/handpipeline.ts +++ b/src/handpose/handpipeline.ts @@ -1,8 +1,6 @@ import * as tf from '../../dist/tfjs.esm.js'; import * as box from './box'; import * as util from './util'; -// eslint-disable-next-line no-unused-vars -import { log } from '../log'; // const PALM_BOX_SHIFT_VECTOR = [0, -0.4]; const PALM_BOX_ENLARGE_FACTOR = 5; // default 3 diff --git a/src/human.ts b/src/human.ts index 301fe3f1..12aa8094 100644 --- a/src/human.ts +++ b/src/human.ts @@ -15,7 +15,6 @@ import * as profile from './profile'; import * as config from '../config'; import * as sample from './sample'; import * as app from '../package.json'; -import { NodeFileSystem } from '@tensorflow/tfjs-node/dist/io/file_system'; // helper function: gets elapsed time on both browser and nodejs const now = () => { diff --git a/src/profile.ts b/src/profile.ts index 2b0bd8fb..8f6ebd9d 100644 --- a/src/profile.ts +++ b/src/profile.ts @@ -2,7 +2,7 @@ import { log } from './log'; export const data = {}; -export function run(name, raw) { +export function run(name: string, raw: any) { if (!raw || !raw.kernels) return; const maxResults = 5; const time = raw.kernels