eslint-plugin-smarthr 6.1.0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [6.2.0](https://github.com/kufu/tamatebako/compare/eslint-plugin-smarthr-v6.1.0...eslint-plugin-smarthr-v6.2.0) (2026-01-29)
6
+
7
+
8
+ ### Features
9
+
10
+ * **best-practice-for-interactive-element:** 特定の要素・コンポーネントに対してrole属性の設定を共用する条件を追加 ([#1031](https://github.com/kufu/tamatebako/issues/1031)) ([1bf4c67](https://github.com/kufu/tamatebako/commit/1bf4c679e767edf169de53c89d7ac69c4873b1e1))
11
+
5
12
  ## [6.1.0](https://github.com/kufu/tamatebako/compare/eslint-plugin-smarthr-v6.0.2...eslint-plugin-smarthr-v6.1.0) (2026-01-29)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-smarthr",
3
- "version": "6.1.0",
3
+ "version": "6.2.0",
4
4
  "author": "SmartHR",
5
5
  "license": "MIT",
6
6
  "description": "A sharable ESLint plugin for SmartHR",
@@ -37,5 +37,5 @@
37
37
  "eslintplugin",
38
38
  "smarthr"
39
39
  ],
40
- "gitHead": "1b4d368c3cdf3b637b8f4866638b2b8bc261f3ca"
40
+ "gitHead": "aed30ef2313795136134408db0ab4fb88dd49d02"
41
41
  }
@@ -32,6 +32,13 @@ const INTERACTIVE_COMPONENT_NAMES = `(${[
32
32
  const INTERACTIVE_ON_REGEX = /^on(Change|Input|Focus|Blur|(Double)?Click|Key(Down|Up|Press)|Mouse(Enter|Over|Down|Up|Leave)|Select|Submit)$/
33
33
  const DELEGATE_REGEX = /(d|D)elegate/
34
34
 
35
+ const ARROW_ROLES = {
36
+ '((^i|I)nput|(^c|C)heck(b|B)ox)$': 'switch',
37
+ '(^i|I)nput$': 'combobox',
38
+ '(^b|B)utton$': 'option',
39
+ }
40
+ const NOT_ARROW_ROLE_ATTRIBUTES = Object.entries(ARROW_ROLES).reduce((prev, [key, value]) => `${prev}:not([parent.name.name=/${key}/][value.value="${value}"])`, '')
41
+
35
42
  const ELEMENT_HAS_ROLE_ATTRIBUTE = 'JSXOpeningElement:has(JSXAttribute[name.name="role"])'
36
43
  const AS_FORM_PART_ATTRIBUTE = 'JSXAttribute[name.name=/^(as|forwardedAs)$/][value.value=/^f(orm|ieldset)$/]'
37
44
 
@@ -59,7 +66,7 @@ module.exports = {
59
66
  const targetNameProp = `[name.name=${interactiveComponentRegex}]`
60
67
 
61
68
  return {
62
- [`JSXOpeningElement${targetNameProp}>JSXAttribute[name.name="role"]:not([parent.name.name=/(^c|C)heck(b|B)ox$/][value.value="switch"])`]: (node) => {
69
+ [`JSXOpeningElement${targetNameProp}>JSXAttribute[name.name="role"]${NOT_ARROW_ROLE_ATTRIBUTES}`]: (node) => {
63
70
  context.report({
64
71
  node: node.parent,
65
72
  message: `${node.parent.name.name}にrole属性は指定しないでください。
@@ -69,6 +69,9 @@ ruleTester.run('best-practice-for-interactive-element', rule, {
69
69
  { code: `<Stack onSubmit={hoge.fuga.delegateAny.piyo} />` },
70
70
  { code: `<Stack onSubmit={(a, delegateEvent, b) => {}} />` },
71
71
  { code: `<HogeCheckbox role="switch" />` },
72
+ { code: `<HogeInput role="switch" />` },
73
+ { code: `<input role="combobox" />` },
74
+ { code: `<FugaButton role="option" />` },
72
75
  ],
73
76
  invalid: [
74
77
  { code: `<button role="presentation">...</button>`, errors: [{ message: interactiveError('button') }] },
@@ -79,6 +82,9 @@ ruleTester.run('best-practice-for-interactive-element', rule, {
79
82
  { code: `<CrewDetail onChange={onChange} />`, errors: [{ message: uninteractiveError('CrewDetail') }] },
80
83
  { code: `<Stack onSubmit={onSubmit} />`, errors: [{ message: uninteractiveError('Stack') }] },
81
84
  { code: `<HogeCheckbox role="any" />`, errors: [{ message: interactiveError('HogeCheckbox') }] },
85
+ { code: `<HogeInput role="any" />`, errors: [{ message: interactiveError('HogeInput') }] },
86
+ { code: `<input role="any" />`, errors: [{ message: interactiveError('input') }] },
87
+ { code: `<FugaButton role="any" />`, errors: [{ message: interactiveError('FugaButton') }] },
82
88
  ]
83
89
  })
84
90