From b32b5b3727dc0f2f5bc803d7168fba0933eba98d Mon Sep 17 00:00:00 2001 From: s-sasaki-0529 Date: Mon, 16 Dec 2024 19:20:23 +0900 Subject: [PATCH 01/12] chore: ESLint v9 --- .eslintrc.js | 31 - package.json | 4 +- packages/smarthr-ui/.eslintignore | 4 - packages/smarthr-ui/eslint.config.mjs | 41 ++ packages/smarthr-ui/package.json | 2 +- .../src/components/Button/ButtonWrapper.tsx | 2 +- .../components/ComboBox/ListBoxItemButton.tsx | 1 - .../stories/SingleComboBox.stories.tsx | 2 - .../MessageDialogContentInner.tsx | 2 +- .../stories/FormControl.stories.tsx | 2 +- .../stories/SearchInput.stories.tsx | 3 +- .../src/components/Layout/Cluster/Cluster.tsx | 4 +- .../components/Layout/Reel/Reel.stories.tsx | 8 +- .../src/components/Picker/TimePicker.tsx | 2 +- packages/smarthr-ui/src/hooks/usePortal.tsx | 1 - pnpm-lock.yaml | 553 ++++++++++++------ 16 files changed, 430 insertions(+), 232 deletions(-) delete mode 100644 .eslintrc.js delete mode 100644 packages/smarthr-ui/.eslintignore create mode 100644 packages/smarthr-ui/eslint.config.mjs diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 34976f12e5..0000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,31 +0,0 @@ -module.exports = { - extends: ['smarthr', 'plugin:storybook/recommended'], - rules: { - 'jsx-a11y/anchor-is-valid': 'warn', - 'jsx-a11y/click-events-have-key-events': 'warn', - 'jsx-a11y/no-static-element-interactions': 'warn', - 'jsx-a11y/label-has-associated-control': [ - 'error', - { - controlComponents: ['Input', 'InputWithTooltip'], - }, - ], - '@typescript-eslint/consistent-type-definitions': [ - 'error', - 'type', - ], - 'smarthr/require-barrel-import': 'off', - 'smarthr/a11y-anchor-has-href-attribute': [ - 'error', - { - checkType: 'allow-spread-attributes', - } - ], - 'smarthr/a11y-input-has-name-attribute': [ - 'error', - { - checkType: 'allow-spread-attributes', - } - ], - }, -} diff --git a/package.json b/package.json index 90d62bfffd..1b8c9bc82b 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "devDependencies": { "@commitlint/cli": "^19.6.1", "@commitlint/config-conventional": "^19.6.0", - "eslint": "^8.57.0", - "eslint-config-smarthr": "^7.3.0", + "eslint": "^9.17.0", + "eslint-config-smarthr": "^8.0.0", "eslint-plugin-storybook": "^0.11.1", "husky": "^9.1.7", "lint-staged": "^15.2.11", diff --git a/packages/smarthr-ui/.eslintignore b/packages/smarthr-ui/.eslintignore deleted file mode 100644 index 6fa228092f..0000000000 --- a/packages/smarthr-ui/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules -esm -lib -*.stories.tsx diff --git a/packages/smarthr-ui/eslint.config.mjs b/packages/smarthr-ui/eslint.config.mjs new file mode 100644 index 0000000000..0c4d5f931c --- /dev/null +++ b/packages/smarthr-ui/eslint.config.mjs @@ -0,0 +1,41 @@ +import smarthr from 'eslint-config-smarthr' +import storybook from 'eslint-plugin-storybook' + +/** + * @type {import('eslint').Linter.Config[]} + */ +export default [ + ...smarthr, + ...storybook.configs['flat/recommended'], + { + rules: { + 'jsx-a11y/anchor-is-valid': 'warn', + 'jsx-a11y/click-events-have-key-events': 'warn', + 'jsx-a11y/no-static-element-interactions': 'warn', + 'jsx-a11y/label-has-associated-control': [ + 'error', + { + controlComponents: ['Input', 'InputWithTooltip'], + }, + ], + '@typescript-eslint/consistent-type-definitions': [ + 'error', + 'type', + ], + 'smarthr/require-barrel-import': 'off', + 'smarthr/a11y-anchor-has-href-attribute': [ + 'error', + { + checkType: 'allow-spread-attributes', + } + ], + 'smarthr/a11y-input-has-name-attribute': [ + 'error', + { + checkType: 'allow-spread-attributes', + } + ], + }, + }, + { ignores: ['esm/**/*', 'lib/**/*', '.storybook/**/*'] }, +] \ No newline at end of file diff --git a/packages/smarthr-ui/package.json b/packages/smarthr-ui/package.json index 176f087e51..eb6531fecc 100644 --- a/packages/smarthr-ui/package.json +++ b/packages/smarthr-ui/package.json @@ -111,7 +111,7 @@ "license": "MIT", "lint-staged": { "*.{ts,tsx}": [ - "eslint --fix", + "pnpm ui eslint --fix", "prettier --write", "stylelint --fix" ] diff --git a/packages/smarthr-ui/src/components/Button/ButtonWrapper.tsx b/packages/smarthr-ui/src/components/Button/ButtonWrapper.tsx index 98d3efc0de..7b60b3f91d 100644 --- a/packages/smarthr-ui/src/components/Button/ButtonWrapper.tsx +++ b/packages/smarthr-ui/src/components/Button/ButtonWrapper.tsx @@ -60,7 +60,7 @@ export function ButtonWrapper({ if (props.isAnchor) { const { anchorRef, elementAs, isAnchor: _, ...others } = props const Component = elementAs || 'a' - // eslint-disable-next-line jsx-a11y/anchor-has-content + return } else { const { buttonRef, disabled, onClick, ...others } = props diff --git a/packages/smarthr-ui/src/components/ComboBox/ListBoxItemButton.tsx b/packages/smarthr-ui/src/components/ComboBox/ListBoxItemButton.tsx index 7262791620..f134cf85d8 100644 --- a/packages/smarthr-ui/src/components/ComboBox/ListBoxItemButton.tsx +++ b/packages/smarthr-ui/src/components/ComboBox/ListBoxItemButton.tsx @@ -66,7 +66,6 @@ const ListBoxItemButton = ({ ) return isNew ? ( - // eslint-disable-next-line smarthr/a11y-clickable-element-has-text