Skip to content

Commit

Permalink
Merge pull request #847 from remap-keys/change-eslint-no-unused-vars-…
Browse files Browse the repository at this point in the history
…error-checker

Fix no-unused-vars warnings.
  • Loading branch information
yoichiro authored Jun 15, 2024
2 parents 7d925ae + 6ce2fad commit 6190d4a
Show file tree
Hide file tree
Showing 28 changed files with 200 additions and 244 deletions.
14 changes: 12 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import react from "eslint-plugin-react";
import prettier from "eslint-plugin-prettier";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import tsEslint from "@typescript-eslint/eslint-plugin";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
Expand All @@ -29,6 +30,7 @@ export default [...fixupConfigRules(compat.extends(
plugins: {
react: fixupPluginRules(react),
prettier: fixupPluginRules(prettier),
"@typescript-eslint": tsEslint,
},

languageOptions: {
Expand All @@ -49,7 +51,6 @@ export default [...fixupConfigRules(compat.extends(

parserOptions: {
version: 2018,

ecmaFeatures: {
jsx: true,
},
Expand All @@ -61,7 +62,16 @@ export default [...fixupConfigRules(compat.extends(
usePrettierrc: true,
}],

"no-unused-vars": "warn",
"no-unused-vars": "off",
"react/prop-types": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_"
}
],
},
}];
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"@types/w3c-web-serial": "^1.0.2",
"@types/w3c-web-usb": "^1.0.5",
"@types/wicg-file-system-access": "^2020.9.7",
"@typescript-eslint/eslint-plugin": "^4.10.0",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@typescript-eslint/parser": "^7.11.0",
"@vitejs/plugin-react-swc": "^3.7.0",
"babel-eslint": "^10.1.0",
Expand Down
3 changes: 1 addition & 2 deletions src/actions/firmware.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ export const firmwareActionsThunk = {
(file: File): ThunkPromiseAction<void> =>
async (
dispatch: ThunkDispatch<RootState, undefined, ActionTypes>,
// eslint-disable-next-line no-unused-vars
getState: () => RootState
_getState: () => RootState
) => {
// eslint-disable-next-line no-undef
const loadBinaryFile = (file: File): Promise<ArrayBuffer> => {
Expand Down
6 changes: 2 additions & 4 deletions src/actions/hid.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,7 @@ export const hidActionsThunk = {
(keyboard: IKeyboard): ThunkPromiseAction<void> =>
async (
dispatch: ThunkDispatch<RootState, undefined, ActionTypes>,
// eslint-disable-next-line no-unused-vars
getState: () => RootState
_getState: () => RootState
) => {
await keyboard.close();
dispatch(AppActions.updateSetupPhase(SetupPhase.keyboardNotSelected));
Expand Down Expand Up @@ -625,8 +624,7 @@ export const hidActionsThunk = {
dispatch: ThunkDispatch<RootState, undefined, ActionTypes>,
getState: () => RootState
) => {
// eslint-disable-next-line no-unused-vars
const { app, entities } = getState();
const { entities } = getState();
const keyboard: IKeyboard = entities.keyboard!;

const rows = entities.keyboardDefinition!.matrix.rows;
Expand Down
3 changes: 1 addition & 2 deletions src/actions/storage.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ export const storageActionsThunk = {
(keyboardDefinition: KeyboardDefinitionSchema): ThunkPromiseAction<void> =>
async (
dispatch: ThunkDispatch<RootState, undefined, ActionTypes>,
// eslint-disable-next-line no-unused-vars
getState: () => RootState
_getState: () => RootState
) => {
dispatch(StorageActions.updateKeyboardDefinition(keyboardDefinition));
dispatch(
Expand Down
6 changes: 2 additions & 4 deletions src/components/catalog/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ class Header extends React.Component<HeaderProps, HeaderState> {
super(props);
}

// eslint-disable-next-line no-unused-vars
onClickBackButton(event: SyntheticEvent) {
onClickBackButton(_event: SyntheticEvent) {
sendEventToGoogleAnalytics('catalog/back_to_search');
this.props.goToSearch!();
}

// eslint-disable-next-line no-unused-vars
onClickFlashFirmware(event: SyntheticEvent) {
onClickFlashFirmware(_event: SyntheticEvent) {
this.props.openUploadFirmwareDialog!();
}

Expand Down
6 changes: 2 additions & 4 deletions src/components/catalog/keyboard/keymap/Catalogkeymap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export default function CatalogKeymap(props: CatalogKeymapProps) {

const navigate = useNavigate();

// eslint-disable-next-line no-unused-vars
const onClickBackButton = (event: React.MouseEvent<{}>) => {
const _onClickBackButton = (_event: React.MouseEvent<{}>) => {
// eslint-disable-next-line no-undef
navigate('/catalog');
props.goToSearch!();
Expand Down Expand Up @@ -296,8 +295,7 @@ type LayerProps = {

function Layer(props: LayerProps) {
const layers = [...Array(props.layerCount)].map((_, i) => i);
// eslint-disable-next-line no-unused-vars
const invisiblePages = layers.map((layer) => true);
const invisiblePages = layers.map((_layer) => true);
return (
<div className="catalog-keymap-layer-wrapper">
<LayerPagination
Expand Down
3 changes: 1 addition & 2 deletions src/components/common/auth/AuthProviderDialog.container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import AuthProviderDialog from './AuthProviderDialog';
import { RootState } from '../../../store/state';
import { AppActionsThunk } from '../../../actions/actions';

// eslint-disable-next-line no-unused-vars
const mapStateToProps = (state: RootState) => {
const mapStateToProps = (_state: RootState) => {
return {};
};
export type AuthProviderDialogStateType = ReturnType<typeof mapStateToProps>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export default {
],
};

// eslint-disable-next-line no-unused-vars
const keyboardDefinition: KeyboardDefinitionSchema = {
const _keyboardDefinition: KeyboardDefinitionSchema = {
name: 'Dummy',
vendorId: hexadecimal(777),
productId: hexadecimal(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { RootState } from '../../../../store/state';
import { AnyKeycodeKeyActions } from '../../../../actions/actions';
import { AnyKey } from '../KeycodeKey';

// eslint-disable-next-line no-unused-vars
const mapStateToProps = (state: RootState) => {
const mapStateToProps = (_state: RootState) => {
return {};
};
export type KeycodeAddKeyStateType = ReturnType<typeof mapStateToProps>;
Expand Down
3 changes: 1 addition & 2 deletions src/components/configure/keymap/Keymap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ export default class Keymap extends React.Component<

componentDidUpdate(
prevProps: KeymapPropsType,
// eslint-disable-next-line no-unused-vars
prevState: OwnKeymapStateType
_prevState: OwnKeymapStateType
) {
if (prevProps.testMatrix !== this.props.testMatrix) {
clearInterval(this.state.interval);
Expand Down
7 changes: 1 addition & 6 deletions src/components/configure/lighting/LightingDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@ export default class LightingDialog extends React.Component<
this.state = {};
}

shouldComponentUpdate(
// eslint-disable-next-line no-unused-vars
nextProps: OwnProps,
// eslint-disable-next-line no-unused-vars
nextState: OwnState
) {
shouldComponentUpdate(_nextProps: OwnProps, _nextState: OwnState) {
this.initLighting();
return true;
}
Expand Down
6 changes: 2 additions & 4 deletions src/components/configure/macroeditor/MacroEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/* eslint-disable no-unused-vars */
/* eslint-disable no-undef */
import React, { KeyboardEvent } from 'react';
import './MacroEditor.scss';
import {
MacroEditorActionsType,
MacroEditorStateType,
} from './MacroEditor.container';
import { Button } from '@mui/material';
import { genKey, Key } from '../keycodekey/KeyGen';
import { genKey } from '../keycodekey/KeyGen';
import {
Hold,
MacroHold,
Expand Down Expand Up @@ -467,7 +465,7 @@ export default class MacroEditor extends React.Component<
onDelete={(index) => {
this.onDelete(index);
}}
onChangeType={(index, type) => {
onChangeType={(index, _type) => {
this.onToggleKeyType(index);
}}
onChangeDelay={(index, subIndex) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ export default function CatalogForm(props: CatalogFormProps) {

const onChangeKeyboardType = (
event: SelectChangeEvent,
// eslint-disable-next-line no-unused-vars
child: React.ReactNode
_child: React.ReactNode
): void => {
props.updateFeature!(
event.target.value as IKeyboardFeatures,
Expand All @@ -90,8 +89,7 @@ export default function CatalogForm(props: CatalogFormProps) {

const onChangeKeyLayout = (
event: SelectChangeEvent,
// eslint-disable-next-line no-unused-vars
child: React.ReactNode
_child: React.ReactNode
): void => {
props.updateFeature!(
event.target.value as IKeyboardFeatures,
Expand Down Expand Up @@ -192,8 +190,7 @@ export default function CatalogForm(props: CatalogFormProps) {

const onChangeHotSwap = (
event: SelectChangeEvent,
// eslint-disable-next-line no-unused-vars
child: React.ReactNode
_child: React.ReactNode
): void => {
props.updateFeature!(
event.target.value as IKeyboardFeatures,
Expand All @@ -203,8 +200,7 @@ export default function CatalogForm(props: CatalogFormProps) {

const onChangeOled = (
event: SelectChangeEvent,
// eslint-disable-next-line no-unused-vars
child: React.ReactNode
_child: React.ReactNode
): void => {
props.updateFeature!(
event.target.value as IKeyboardFeatures,
Expand All @@ -214,8 +210,7 @@ export default function CatalogForm(props: CatalogFormProps) {

const onChangeSpeaker = (
event: SelectChangeEvent,
// eslint-disable-next-line no-unused-vars
child: React.ReactNode
_child: React.ReactNode
): void => {
props.updateFeature!(
event.target.value as IKeyboardFeatures,
Expand All @@ -225,8 +220,7 @@ export default function CatalogForm(props: CatalogFormProps) {

const onChangeWireless = (
event: SelectChangeEvent,
// eslint-disable-next-line no-unused-vars
child: React.ReactNode
_child: React.ReactNode
): void => {
props.updateFeature!(
event.target.value as IKeyboardFeatures,
Expand Down Expand Up @@ -285,8 +279,7 @@ export default function CatalogForm(props: CatalogFormProps) {
props.updateDescription!(description);
};

// eslint-disable-next-line no-unused-vars
const onClickAddStore = (event: React.MouseEvent<HTMLButtonElement>) => {
const onClickAddStore = (_event: React.MouseEvent<HTMLButtonElement>) => {
setOpenStoreAddDialog(true);
};

Expand Down Expand Up @@ -332,8 +325,7 @@ export default function CatalogForm(props: CatalogFormProps) {
setAdditionalDescriptionBody(additionalDescription.body);
};

// eslint-disable-next-line no-unused-vars
const onClickAdditionalDescriptionAdd = (event: React.SyntheticEvent) => {
const onClickAdditionalDescriptionAdd = (_event: React.SyntheticEvent) => {
props.addAdditionalDescription!(
additionalDescriptionTitle,
additionalDescriptionBody
Expand Down Expand Up @@ -801,8 +793,7 @@ export default function CatalogForm(props: CatalogFormProps) {
<ListItemSecondaryAction>
<IconButton
edge="end"
// eslint-disable-next-line no-unused-vars
onClick={(event: React.MouseEvent) => {
onClick={(_event: React.MouseEvent) => {
onClickDeleteStore(store);
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class StoreAddDialog extends React.Component<
}

// eslint-disable-next-line no-unused-vars
private onClickClose(event: React.MouseEvent) {
private onClickClose(_event: React.MouseEvent) {
this.props.onClose();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export default class EditOrganization extends React.Component<
<IconButton
edge="end"
// eslint-disable-next-line no-unused-vars
onClick={(event: React.MouseEvent) => {
onClick={(_event: React.MouseEvent) => {
this.handleDeleteMemberClick(member);
}}
disabled={member.me}
Expand Down
2 changes: 1 addition & 1 deletion src/components/top/Top.container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Top from './Top';
import { MetaActions } from '../../actions/meta.action';

// eslint-disable-next-line no-unused-vars
const mapStateToProps = (state: RootState) => {
const mapStateToProps = (_state: RootState) => {
return {};
};
export type TopStateType = ReturnType<typeof mapStateToProps>;
Expand Down
1 change: 0 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.scss';
import { createStore, applyMiddleware } from 'redux';
import { Provider } from 'react-redux';
Expand Down
2 changes: 1 addition & 1 deletion src/services/firmware/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export abstract class AbstractCommand<
}

// eslint-disable-next-line no-unused-vars
protected async verify(serial: ISerial): Promise<IResult> {
protected async verify(_serial: ISerial): Promise<IResult> {
return {
success: false,
error: 'Verification logic not implemented.',
Expand Down
Loading

0 comments on commit 6190d4a

Please sign in to comment.