eslint-plugin-smarthr 0.5.9 → 0.5.11
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,21 @@
|
|
|
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
|
+
### [0.5.11](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.5.9...v0.5.11) (2024-06-06)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* <FormControl> 内に三項演算子がある場合に、入力要素が複数あると誤認されないようにする ([#139](https://github.com/kufu/eslint-plugin-smarthr/issues/139)) ([8a234c7](https://github.com/kufu/eslint-plugin-smarthr/commit/8a234c73e140725ff1926d4d23f64c263e46d5d6))
|
|
11
|
+
* 適切にonClick属性を利用しているケースを通したい! ([cc71417](https://github.com/kufu/eslint-plugin-smarthr/commit/cc7141768f222f45ffbff1aa1dadec1fcfb83dd2))
|
|
12
|
+
|
|
13
|
+
### [0.5.10](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.5.9...v0.5.10) (2024-04-26)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* <FormControl> 内に三項演算子がある場合に、入力要素が複数あると誤認されないようにする ([#139](https://github.com/kufu/eslint-plugin-smarthr/issues/139)) ([8a234c7](https://github.com/kufu/eslint-plugin-smarthr/commit/8a234c73e140725ff1926d4d23f64c263e46d5d6))
|
|
19
|
+
|
|
5
20
|
### [0.5.9](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.5.7...v0.5.9) (2024-04-22)
|
|
6
21
|
|
|
7
22
|
|
package/package.json
CHANGED
|
@@ -94,6 +94,7 @@ module.exports = {
|
|
|
94
94
|
const checkAdditionalMultiInputComponents = (name) => additionalMultiInputComponents && name.match(additionalMultiInputComponents)
|
|
95
95
|
|
|
96
96
|
let formControls = []
|
|
97
|
+
let conditionalformControls = []
|
|
97
98
|
let checkboxFormControls = []
|
|
98
99
|
|
|
99
100
|
return {
|
|
@@ -102,6 +103,7 @@ module.exports = {
|
|
|
102
103
|
const nodeName = node.name.name || '';
|
|
103
104
|
const isFormControlInput = nodeName.match(FORM_CONTROL_INPUTS_REGEX)
|
|
104
105
|
const isAdditionalMultiInput = checkAdditionalMultiInputComponents(nodeName)
|
|
106
|
+
let conditionalExpressions = []
|
|
105
107
|
|
|
106
108
|
if (isFormControlInput || isAdditionalMultiInput || checkAdditionalInputComponents(nodeName)) {
|
|
107
109
|
let isInMap = false
|
|
@@ -162,15 +164,25 @@ module.exports = {
|
|
|
162
164
|
if (name) {
|
|
163
165
|
if (name.match(FROM_CONTROLS_REGEX)) {
|
|
164
166
|
const hit = formControls.includes(n)
|
|
167
|
+
let conditionalHit = false
|
|
165
168
|
|
|
166
169
|
if (!hit) {
|
|
167
170
|
formControls.push(n)
|
|
168
171
|
|
|
172
|
+
|
|
169
173
|
if (isCheckbox) {
|
|
170
174
|
checkboxFormControls.push(n)
|
|
171
175
|
}
|
|
172
176
|
}
|
|
173
177
|
|
|
178
|
+
if (conditionalExpressions.length > 0) {
|
|
179
|
+
conditionalHit = conditionalformControls.includes(n)
|
|
180
|
+
|
|
181
|
+
if (!conditionalHit) {
|
|
182
|
+
conditionalformControls.push(n)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
174
186
|
const isMultiInput = isPreMultiple || hit || isInMap
|
|
175
187
|
const matcherFormControl = name.match(FORM_CONTROL_REGEX)
|
|
176
188
|
|
|
@@ -184,7 +196,7 @@ module.exports = {
|
|
|
184
196
|
- Fieldsetで同じname属性のラジオボタン全てを囲むことで正しくグループ化され、適切なタイトル・説明を追加出来ます` : ''}${isPureInput ? `
|
|
185
197
|
- 可能なら${nodeName}は${convertComp}への変更を検討してください。難しい場合は ${nodeName} と結びつくlabel要素が必ず存在するよう、マークアップする必要があることに注意してください。` : ''}`,
|
|
186
198
|
});
|
|
187
|
-
} else if (isMultiInput && !openingElement.attributes.find(findRoleGroup)) {
|
|
199
|
+
} else if (isMultiInput && !conditionalHit && !openingElement.attributes.find(findRoleGroup)) {
|
|
188
200
|
context.report({
|
|
189
201
|
node: n,
|
|
190
202
|
message: `${name} が複数の入力要素を含んでいます。ラベルと入力要素の紐づけが正しく行われない可能性があるため、以下の方法のいずれかで修正してください。
|
|
@@ -245,6 +257,10 @@ module.exports = {
|
|
|
245
257
|
|
|
246
258
|
break
|
|
247
259
|
}
|
|
260
|
+
case 'ConditionalExpression': {
|
|
261
|
+
conditionalExpressions.push(n)
|
|
262
|
+
break
|
|
263
|
+
}
|
|
248
264
|
case 'VariableDeclarator': {
|
|
249
265
|
if (n.parent.parent?.type && n.parent.parent.type.match(IGNORE_INPUT_CHECK_PARENT_TYPE)) {
|
|
250
266
|
const name = n.id.name
|
|
@@ -135,6 +135,7 @@ ruleTester.run('a11y-input-in-form-control', rule, {
|
|
|
135
135
|
{ code: '<Fieldset><HogeRadioButtonPanels /></Fieldset>' },
|
|
136
136
|
{ code: '<Fieldset><HogeCheckBoxs /></Fieldset>' },
|
|
137
137
|
{ code: '<Fieldset><HogeCheckBoxes /></Fieldset>' },
|
|
138
|
+
{ code: '<HogeFormControl>{ dateInput ? <DateInput /> : <Input /> }</HogeFormControl>'},
|
|
138
139
|
],
|
|
139
140
|
invalid: [
|
|
140
141
|
{ code: `import hoge from 'styled-components'`, errors: [ { message: `styled-components をimportする際は、名称が"styled" となるようにしてください。例: "import styled from 'styled-components'"` } ] },
|
|
@@ -179,5 +180,7 @@ ruleTester.run('a11y-input-in-form-control', rule, {
|
|
|
179
180
|
{ code: '<HogeFormControl><HogeRadioButtons /></HogeFormControl>', errors: [ { message: invalidRadioInFormControl('HogeRadioButtons') } ] },
|
|
180
181
|
{ code: '<HogeFormControl><HogeCheckBoxs /></HogeFormControl>', errors: [ { message: invalidMultiInputsInFormControl() } ] },
|
|
181
182
|
{ code: '<HogeFormControl><HogeCheckBoxes /></HogeFormControl>', errors: [ { message: invalidMultiInputsInFormControl() } ] },
|
|
183
|
+
{ code: "<HogeFormControl>{ dateInput ? <DateInput /> : <Input /> }<CheckBox /></HogeFormControl>", errors: [ { message: invalidMultiInputsInFormControl() } ]},
|
|
184
|
+
{ code: "<HogeFormControl><CheckBox />{ dateInput ? <DateInput /> : <Input /> }</HogeFormControl>", errors: [ { message: invalidMultiInputsInFormControl() } ]},
|
|
182
185
|
]
|
|
183
186
|
})
|