lint: auto remove unused var

This commit is contained in:
林一二 2022-02-20 19:11:20 +08:00
parent ec2b524d43
commit 32f8d1d025
17 changed files with 109 additions and 15 deletions

View file

@ -49,6 +49,7 @@ module.exports = {
}, },
], ],
'react/react-in-jsx-scope': 'off', 'react/react-in-jsx-scope': 'off',
'security-node/detect-unhandled-async-errors': 'off',
'unicorn/prefer-node-protocol': 'off', 'unicorn/prefer-node-protocol': 'off',
'unicorn/prefer-module': 'off', 'unicorn/prefer-module': 'off',
'@typescript-eslint/no-empty-function': 'off', '@typescript-eslint/no-empty-function': 'off',
@ -90,6 +91,8 @@ module.exports = {
semi: [0], semi: [0],
'no-use-before-define': [0], 'no-use-before-define': [0],
'@typescript-eslint/no-use-before-define': [1], '@typescript-eslint/no-use-before-define': [1],
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': ['warn', { vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' }],
}, },
extends: [ extends: [
'eslint:recommended', 'eslint:recommended',
@ -121,6 +124,8 @@ module.exports = {
'react-hooks', 'react-hooks',
'security', 'security',
'security-node', 'security-node',
'autofix',
'unused-imports',
], ],
env: { env: {
browser: true, browser: true,

View file

@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-expressions */ /* eslint-disable @typescript-eslint/no-unused-expressions */
import { setWorldConstructor, Given, Then, When } from '@cucumber/cucumber'; import { setWorldConstructor, Given, Then } from '@cucumber/cucumber';
import { delay } from 'bluebird'; import { delay } from 'bluebird';
import { expect } from 'chai'; import { expect } from 'chai';
import { TidGiWorld } from '../supports/world'; import { TidGiWorld } from '../supports/world';

View file

@ -1,6 +1,5 @@
import { setDefaultTimeout, World } from '@cucumber/cucumber'; import { setDefaultTimeout, World } from '@cucumber/cucumber';
import path from 'path'; import path from 'path';
import { delay } from 'bluebird';
import { Application } from 'spectron'; import { Application } from 'spectron';
// import { keyboard, Key } from '@nut-tree/nut-js'; // import { keyboard, Key } from '@nut-tree/nut-js';

91
package-lock.json generated
View file

@ -112,6 +112,7 @@
"eslint-config-standard-with-typescript": "21.0.1", "eslint-config-standard-with-typescript": "21.0.1",
"eslint-import-resolver-alias": "1.1.2", "eslint-import-resolver-alias": "1.1.2",
"eslint-import-resolver-typescript": "2.5.0", "eslint-import-resolver-typescript": "2.5.0",
"eslint-plugin-autofix": "^1.1.0",
"eslint-plugin-html": "6.2.0", "eslint-plugin-html": "6.2.0",
"eslint-plugin-import": "2.25.4", "eslint-plugin-import": "2.25.4",
"eslint-plugin-node": "11.1.0", "eslint-plugin-node": "11.1.0",
@ -123,6 +124,7 @@
"eslint-plugin-security-node": "1.1.1", "eslint-plugin-security-node": "1.1.1",
"eslint-plugin-typescript-sort-keys": "2.1.0", "eslint-plugin-typescript-sort-keys": "2.1.0",
"eslint-plugin-unicorn": "41.0.0", "eslint-plugin-unicorn": "41.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"event-hooks-webpack-plugin": "2.2.0", "event-hooks-webpack-plugin": "2.2.0",
"fork-ts-checker-webpack-plugin": "7.2.1", "fork-ts-checker-webpack-plugin": "7.2.1",
"graphql-hooks": "5.7.0", "graphql-hooks": "5.7.0",
@ -10309,6 +10311,25 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/eslint-plugin-autofix": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-autofix/-/eslint-plugin-autofix-1.1.0.tgz",
"integrity": "sha512-aKQ7s6CTeJRJgnhSlsGI7kQhnNCa1q3UYBM+9PTEgvdC5b+GjV/SZA233VNqkoBldb7/BkeWBRjorUjxeUfrxA==",
"dev": true,
"dependencies": {
"eslint-rule-composer": "^0.3.0",
"espree": "^9.0.0",
"esutils": "^2.0.2",
"lodash": "^4.17.20",
"string-similarity": "^4.0.3"
},
"engines": {
"node": ">=8"
},
"peerDependencies": {
"eslint": ">= 5.12.1"
}
},
"node_modules/eslint-plugin-es": { "node_modules/eslint-plugin-es": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npm.taobao.org/eslint-plugin-es/download/eslint-plugin-es-3.0.1.tgz", "resolved": "https://registry.npm.taobao.org/eslint-plugin-es/download/eslint-plugin-es-3.0.1.tgz",
@ -10683,6 +10704,36 @@
"regexp-tree": "~0.1.1" "regexp-tree": "~0.1.1"
} }
}, },
"node_modules/eslint-plugin-unused-imports": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-2.0.0.tgz",
"integrity": "sha512-3APeS/tQlTrFa167ThtP0Zm0vctjr4M44HMpeg1P4bK6wItarumq0Ma82xorMKdFsWpphQBlRPzw/pxiVELX1A==",
"dev": true,
"dependencies": {
"eslint-rule-composer": "^0.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^5.0.0",
"eslint": "^8.0.0"
},
"peerDependenciesMeta": {
"@typescript-eslint/eslint-plugin": {
"optional": true
}
}
},
"node_modules/eslint-rule-composer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz",
"integrity": "sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==",
"dev": true,
"engines": {
"node": ">=4.0.0"
}
},
"node_modules/eslint-scope": { "node_modules/eslint-scope": {
"version": "5.1.1", "version": "5.1.1",
"resolved": "https://registry.nlark.com/eslint-scope/download/eslint-scope-5.1.1.tgz", "resolved": "https://registry.nlark.com/eslint-scope/download/eslint-scope-5.1.1.tgz",
@ -20019,6 +20070,12 @@
"node": ">=0.6.19" "node": ">=0.6.19"
} }
}, },
"node_modules/string-similarity": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz",
"integrity": "sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ==",
"dev": true
},
"node_modules/string-width": { "node_modules/string-width": {
"version": "4.2.3", "version": "4.2.3",
"resolved": "https://registry.npmmirror.com/string-width/download/string-width-4.2.3.tgz?cache=0&sync_timestamp=1632420968947&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fstring-width%2Fdownload%2Fstring-width-4.2.3.tgz", "resolved": "https://registry.npmmirror.com/string-width/download/string-width-4.2.3.tgz?cache=0&sync_timestamp=1632420968947&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fstring-width%2Fdownload%2Fstring-width-4.2.3.tgz",
@ -31151,6 +31208,19 @@
} }
} }
}, },
"eslint-plugin-autofix": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-autofix/-/eslint-plugin-autofix-1.1.0.tgz",
"integrity": "sha512-aKQ7s6CTeJRJgnhSlsGI7kQhnNCa1q3UYBM+9PTEgvdC5b+GjV/SZA233VNqkoBldb7/BkeWBRjorUjxeUfrxA==",
"dev": true,
"requires": {
"eslint-rule-composer": "^0.3.0",
"espree": "^9.0.0",
"esutils": "^2.0.2",
"lodash": "^4.17.20",
"string-similarity": "^4.0.3"
}
},
"eslint-plugin-es": { "eslint-plugin-es": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npm.taobao.org/eslint-plugin-es/download/eslint-plugin-es-3.0.1.tgz", "resolved": "https://registry.npm.taobao.org/eslint-plugin-es/download/eslint-plugin-es-3.0.1.tgz",
@ -31422,6 +31492,21 @@
} }
} }
}, },
"eslint-plugin-unused-imports": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-2.0.0.tgz",
"integrity": "sha512-3APeS/tQlTrFa167ThtP0Zm0vctjr4M44HMpeg1P4bK6wItarumq0Ma82xorMKdFsWpphQBlRPzw/pxiVELX1A==",
"dev": true,
"requires": {
"eslint-rule-composer": "^0.3.0"
}
},
"eslint-rule-composer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz",
"integrity": "sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==",
"dev": true
},
"eslint-scope": { "eslint-scope": {
"version": "5.1.1", "version": "5.1.1",
"resolved": "https://registry.nlark.com/eslint-scope/download/eslint-scope-5.1.1.tgz", "resolved": "https://registry.nlark.com/eslint-scope/download/eslint-scope-5.1.1.tgz",
@ -38722,6 +38807,12 @@
"integrity": "sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg== sha1-leL77AQnrhkYSTX4FtdKqkxcGdo=", "integrity": "sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg== sha1-leL77AQnrhkYSTX4FtdKqkxcGdo=",
"dev": true "dev": true
}, },
"string-similarity": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/string-similarity/-/string-similarity-4.0.4.tgz",
"integrity": "sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ==",
"dev": true
},
"string-width": { "string-width": {
"version": "4.2.3", "version": "4.2.3",
"resolved": "https://registry.npmmirror.com/string-width/download/string-width-4.2.3.tgz?cache=0&sync_timestamp=1632420968947&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fstring-width%2Fdownload%2Fstring-width-4.2.3.tgz", "resolved": "https://registry.npmmirror.com/string-width/download/string-width-4.2.3.tgz?cache=0&sync_timestamp=1632420968947&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fstring-width%2Fdownload%2Fstring-width-4.2.3.tgz",

View file

@ -129,6 +129,7 @@
"eslint-config-standard-with-typescript": "21.0.1", "eslint-config-standard-with-typescript": "21.0.1",
"eslint-import-resolver-alias": "1.1.2", "eslint-import-resolver-alias": "1.1.2",
"eslint-import-resolver-typescript": "2.5.0", "eslint-import-resolver-typescript": "2.5.0",
"eslint-plugin-autofix": "^1.1.0",
"eslint-plugin-html": "6.2.0", "eslint-plugin-html": "6.2.0",
"eslint-plugin-import": "2.25.4", "eslint-plugin-import": "2.25.4",
"eslint-plugin-node": "11.1.0", "eslint-plugin-node": "11.1.0",
@ -140,6 +141,7 @@
"eslint-plugin-security-node": "1.1.1", "eslint-plugin-security-node": "1.1.1",
"eslint-plugin-typescript-sort-keys": "2.1.0", "eslint-plugin-typescript-sort-keys": "2.1.0",
"eslint-plugin-unicorn": "41.0.0", "eslint-plugin-unicorn": "41.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"event-hooks-webpack-plugin": "2.2.0", "event-hooks-webpack-plugin": "2.2.0",
"fork-ts-checker-webpack-plugin": "7.2.1", "fork-ts-checker-webpack-plugin": "7.2.1",
"graphql-hooks": "5.7.0", "graphql-hooks": "5.7.0",

View file

@ -2,8 +2,8 @@ import fs from 'fs-extra';
import path from 'path'; import path from 'path';
import { LOCALIZATION_FOLDER } from '@/constants/paths'; import { LOCALIZATION_FOLDER } from '@/constants/paths';
export const supportedLanguagesMap = JSON.parse(fs.readFileSync(path.join(LOCALIZATION_FOLDER, 'supportedLanguages.json'), 'utf-8')) as Record<string, string>; export const supportedLanguagesMap = JSON.parse(fs.readFileSync(path.join(LOCALIZATION_FOLDER, 'supportedLanguages.json'))) as Record<string, string>;
export const tiddlywikiLanguagesMap = JSON.parse(fs.readFileSync(path.join(LOCALIZATION_FOLDER, 'tiddlywikiLanguages.json'), 'utf-8')) as Record< export const tiddlywikiLanguagesMap = JSON.parse(fs.readFileSync(path.join(LOCALIZATION_FOLDER, 'tiddlywikiLanguages.json'))) as Record<
string, string,
string | undefined string | undefined
>; >;

View file

@ -9,7 +9,6 @@ import { ipcMain, protocol, powerMonitor, app } from 'electron';
import settings from 'electron-settings'; import settings from 'electron-settings';
import unhandled from 'electron-unhandled'; import unhandled from 'electron-unhandled';
import { clearMainBindings } from '@services/libs/i18n/i18nMainBindings';
import { buildLanguageMenu } from '@services/menu/buildLanguageMenu'; import { buildLanguageMenu } from '@services/menu/buildLanguageMenu';
import { MainChannel } from '@/constants/channels'; import { MainChannel } from '@/constants/channels';
import { isTest } from '@/constants/environment'; import { isTest } from '@/constants/environment';

View file

@ -1,7 +1,7 @@
/* eslint-disable unicorn/no-useless-undefined */ /* eslint-disable unicorn/no-useless-undefined */
/* eslint-disable @typescript-eslint/strict-boolean-expressions */ /* eslint-disable @typescript-eslint/strict-boolean-expressions */
/* eslint-disable unicorn/no-null */ /* eslint-disable unicorn/no-null */
import React, { useMemo, useCallback } from 'react'; import React, { useCallback } from 'react';
import styled, { css } from 'styled-components'; import styled, { css } from 'styled-components';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';

View file

@ -1,4 +1,4 @@
import React, { useCallback } from 'react'; import React from 'react';
import styled, { css } from 'styled-components'; import styled, { css } from 'styled-components';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';

View file

@ -12,7 +12,6 @@ import CssBaseline from '@material-ui/core/CssBaseline';
import { I18nextProvider } from 'react-i18next'; import { I18nextProvider } from 'react-i18next';
import 'typeface-roboto/index.css'; import 'typeface-roboto/index.css';
import { WindowNames, IPreferenceWindowMeta } from '@services/windows/WindowProperties';
import { useThemeObservable } from '@services/theme/hooks'; import { useThemeObservable } from '@services/theme/hooks';
import { darkTheme, lightTheme } from '@services/theme/defaultTheme'; import { darkTheme, lightTheme } from '@services/theme/defaultTheme';
import { initI18N } from './i18n'; import { initI18N } from './i18n';

View file

@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-misused-promises */ /* eslint-disable @typescript-eslint/no-misused-promises */
/* eslint-disable @typescript-eslint/require-await */ /* eslint-disable @typescript-eslint/require-await */
import { Menu, MenuItemConstructorOptions, shell, ContextMenuParams, WebContents, MenuItem, ipcMain, app } from 'electron'; import { Menu, MenuItemConstructorOptions, shell, ContextMenuParams, WebContents, MenuItem, app } from 'electron';
import { debounce, take, drop, reverse, remove, compact } from 'lodash'; import { debounce, take, drop, reverse, remove, compact } from 'lodash';
import { injectable } from 'inversify'; import { injectable } from 'inversify';
import type { IMenuService, IOnContextMenuInfo } from './interface'; import type { IMenuService, IOnContextMenuInfo } from './interface';

View file

@ -334,7 +334,7 @@ const gitGUIApp: WindowsExternalEditor[] = [
function getKeyOrEmpty(keys: readonly RegistryValue[], key: string): string { function getKeyOrEmpty(keys: readonly RegistryValue[], key: string): string {
const entry = keys.find((k) => k.name === key); const entry = keys.find((k) => k.name === key);
return entry && entry.type === RegistryValueType.REG_SZ ? entry.data : ''; return entry !== undefined && entry.type === RegistryValueType.REG_SZ ? entry.data : '';
} }
function getAppInfo(editor: WindowsExternalEditor, keys: readonly RegistryValue[]): IWindowsAppInformation { function getAppInfo(editor: WindowsExternalEditor, keys: readonly RegistryValue[]): IWindowsAppInformation {

View file

@ -5,7 +5,7 @@ import { injectable } from 'inversify';
import serviceIdentifier from '@services/serviceIdentifier'; import serviceIdentifier from '@services/serviceIdentifier';
import type { IPreferenceService } from '@services/preferences/interface'; import type { IPreferenceService } from '@services/preferences/interface';
import type { IWorkspaceMetaData, IWorkspaceService } from '@services/workspaces/interface'; import type { IWorkspaceService } from '@services/workspaces/interface';
import type { IWorkspaceViewService } from '@services/workspacesView/interface'; import type { IWorkspaceViewService } from '@services/workspacesView/interface';
import type { IWindowService } from '@services/windows/interface'; import type { IWindowService } from '@services/windows/interface';
import type { IMenuService } from '@services/menu/interface'; import type { IMenuService } from '@services/menu/interface';

View file

@ -21,7 +21,6 @@ import { container } from '@services/container';
import { MetaDataChannel, ViewChannel, WindowChannel } from '@/constants/channels'; import { MetaDataChannel, ViewChannel, WindowChannel } from '@/constants/channels';
import { logger } from '@services/libs/log'; import { logger } from '@services/libs/log';
import { getLocalHostUrlWithActualIP } from '@services/libs/url'; import { getLocalHostUrlWithActualIP } from '@services/libs/url';
import { LOAD_VIEW_MAX_RETRIES } from '@/constants/parameters';
import { SETTINGS_FOLDER } from '@/constants/appPaths'; import { SETTINGS_FOLDER } from '@/constants/appPaths';
import { throttle } from 'lodash'; import { throttle } from 'lodash';

View file

@ -13,7 +13,7 @@ import { mkdtemp, writeFile } from 'fs-extra';
import { fixPath } from '@services/libs/fixPath'; import { fixPath } from '@services/libs/fixPath';
import { IWikiMessage, WikiControlActions, ZxWorkerControlActions, IZxWorkerMessage } from './interface'; import { IWikiMessage, WikiControlActions, ZxWorkerControlActions, IZxWorkerMessage } from './interface';
import { defaultServerIP } from '@/constants/urls'; import { defaultServerIP } from '@/constants/urls';
import { executeScriptInTWContext, extractTWContextScripts, getTWVmContext, TW_SCRIPT_SEPARATOR } from './plugin/zxPlugin'; import { executeScriptInTWContext, extractTWContextScripts, getTWVmContext } from './plugin/zxPlugin';
fixPath(); fixPath();
let wikiInstance: I$TW | undefined; let wikiInstance: I$TW | undefined;

View file

@ -21,7 +21,7 @@ import getViewBounds from '@services/libs/getViewBounds';
import getFromRenderer from '@services/libs/getFromRenderer'; import getFromRenderer from '@services/libs/getFromRenderer';
import { lazyInject } from '@services/container'; import { lazyInject } from '@services/container';
import { IWindowService } from './interface'; import { IWindowService } from './interface';
import { isDevelopmentOrTest, isTest } from '@/constants/environment'; import { isTest } from '@/constants/environment';
import { MENUBAR_ICON_PATH } from '@/constants/paths'; import { MENUBAR_ICON_PATH } from '@/constants/paths';
import { getLocalHostUrlWithActualIP } from '@services/libs/url'; import { getLocalHostUrlWithActualIP } from '@services/libs/url';
import { SETTINGS_FOLDER } from '@/constants/appPaths'; import { SETTINGS_FOLDER } from '@/constants/appPaths';

View file

@ -1,7 +1,7 @@
import { ProxyPropertyType } from 'electron-ipc-cat/common'; import { ProxyPropertyType } from 'electron-ipc-cat/common';
import { WorkspaceViewChannel } from '@/constants/channels'; import { WorkspaceViewChannel } from '@/constants/channels';
import { IWorkspace, INewWorkspaceConfig } from '@services/workspaces/interface'; import { IWorkspace } from '@services/workspaces/interface';
export interface IInitializeWorkspaceOptions { export interface IInitializeWorkspaceOptions {
/** /**