eslint-plugin-smarthr 2.1.0 → 2.2.1
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 +16 -0
- package/package.json +4 -4
- package/rules/a11y-anchor-has-href-attribute/index.js +1 -1
- package/rules/a11y-help-link-with-support-href/index.js +1 -1
- package/rules/a11y-input-has-name-attribute/index.js +1 -1
- package/rules/trim-props/index.js +13 -16
- package/test/a11y-help-link-with-support-href.js +2 -1
- package/test/a11y-input-has-name-attribute.js +1 -0
- package/test/trim-props.js +15 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
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
|
+
## [2.2.1](https://github.com/kufu/tamatebako/compare/eslint-plugin-smarthr-v2.2.0...eslint-plugin-smarthr-v2.2.1) (2025-11-18)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* a11y-anchor-has-href-attributeがhrefにメソッドが指定されている場合に誤検知することがある問題を修正 ([#905](https://github.com/kufu/tamatebako/issues/905)) ([6ebd6ec](https://github.com/kufu/tamatebako/commit/6ebd6ecc074a7088652697dcb6bfb60b63a13fc4))
|
|
11
|
+
* a11y-input-has-name-attributeでtemplate literalの場合、誤検知してしまう問題を修正 ([#904](https://github.com/kufu/tamatebako/issues/904)) ([d440e86](https://github.com/kufu/tamatebako/commit/d440e8675bf600dbe8a51e496d7076bcf617336f))
|
|
12
|
+
|
|
13
|
+
## [2.2.0](https://github.com/kufu/tamatebako/compare/eslint-plugin-smarthr-v2.1.0...eslint-plugin-smarthr-v2.2.0) (2025-11-07)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* a11y-help-link-with-support-hrefで対象となる変数名のバグを修正 ([#890](https://github.com/kufu/tamatebako/issues/890)) ([c9c4984](https://github.com/kufu/tamatebako/commit/c9c49848293fd88640e886c6586ae8d92a99f40c))
|
|
19
|
+
* trim-propsでtemplate literalもautofixの対象にする ([#884](https://github.com/kufu/tamatebako/issues/884)) ([4072950](https://github.com/kufu/tamatebako/commit/40729507f5084308128ca39d5887ee81f2f67dd5))
|
|
20
|
+
|
|
5
21
|
## [2.1.0](https://github.com/kufu/tamatebako/compare/eslint-plugin-smarthr-v2.0.0...eslint-plugin-smarthr-v2.1.0) (2025-10-29)
|
|
6
22
|
|
|
7
23
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-smarthr",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"author": "SmartHR",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A sharable ESLint plugin for SmartHR",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"engines": {
|
|
9
|
-
"node": ">=22.21.
|
|
9
|
+
"node": ">=22.21.1"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"test": "jest"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"json5": "^2.2.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"typescript-eslint": "^8.46.
|
|
29
|
+
"typescript-eslint": "^8.46.3"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"eslint": "^9"
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"eslintplugin",
|
|
38
38
|
"smarthr"
|
|
39
39
|
],
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "a730418d8a507045795ce6140a58b5aea18c818b"
|
|
41
41
|
}
|
|
@@ -91,7 +91,7 @@ module.exports = {
|
|
|
91
91
|
reporter(node)
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
|
-
[`${ANCHOR_ELEMENT}:has(${HREF_ATTRIBUTE}:matches([value=null],:has(Literal[value=/^(|#)$/])))`]: reporter,
|
|
94
|
+
[`${ANCHOR_ELEMENT}:has(${HREF_ATTRIBUTE}:matches([value=null],:has(>Literal[value=/^(|#)$/]),:has(>JSXExpressionContainer[expression.value=/^(|#)$/])))`]: reporter,
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
97
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const SCHEMA = []
|
|
2
2
|
|
|
3
3
|
const SUPPORT_URL_PREFIX_REGEX = /(\/|\.)support\./
|
|
4
|
-
const SUPPORT_IDENTIFIER_REGEX = /(S|(^|_)s)upport(.*)(H(ref|REF)|U(rl|
|
|
4
|
+
const SUPPORT_IDENTIFIER_REGEX = /(S|(^|_)s)upport(.*)(H(ref|REF)|U(rl|RL))$/
|
|
5
5
|
const PATH_OBJ_REGEX = /^((p|P)ath|PATH)\./
|
|
6
6
|
const SUPPORT_PATH_MEMBER_REGEX = /\.support\./
|
|
7
7
|
|
|
@@ -67,7 +67,7 @@ module.exports = {
|
|
|
67
67
|
- 適切に指定することで同じname属性を指定したinput[radio]とグループが確立され、適切なキーボード操作を行えるようになります${MESSAGE_UNDEFINED_NAME_PART}`,
|
|
68
68
|
})
|
|
69
69
|
},
|
|
70
|
-
[`${INPUT_ELEMENT}${notHasSpreadAttribute} ${NAME_ATTRIBUTE}:not([value.value=${INPUT_NAME_REGEX}])`]: (node) => {
|
|
70
|
+
[`${INPUT_ELEMENT}${notHasSpreadAttribute} ${NAME_ATTRIBUTE}[value.value]:not([value.value=${INPUT_NAME_REGEX}])`]: (node) => {
|
|
71
71
|
context.report({
|
|
72
72
|
node,
|
|
73
73
|
message: `${node.parent.name.name} のname属性の値(${node.value.value})はブラウザの自動補完が適切に行えない可能性があるため${MESSAGE_PART_FORMAT}`,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const SCHEMA = []
|
|
2
|
-
const EXTRA_SPACE_REGES = /(^\s+|\s+$)/
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* @type {import('@typescript-eslint/utils').TSESLint.RuleModule<''>}
|
|
@@ -12,22 +11,20 @@ module.exports = {
|
|
|
12
11
|
},
|
|
13
12
|
create(context) {
|
|
14
13
|
return {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
})
|
|
29
|
-
}
|
|
14
|
+
'JSXAttribute Literal[value=/(^ | $)/]': (node) => {
|
|
15
|
+
return context.report({
|
|
16
|
+
node,
|
|
17
|
+
message: '属性に設定している文字列から先頭、末尾の空白文字を削除してください',
|
|
18
|
+
fix: (fixer) => fixer.replaceText(node, context.sourceCode.getText(node).replace(/^('|")\s+/, '$1').replace(/\s+('|")$/, '$1')),
|
|
19
|
+
})
|
|
20
|
+
},
|
|
21
|
+
'JSXAttribute TemplateLiteral:has(TemplateElement:matches(:first-child[value.raw=/^ /],:last-child[value.raw=/ $/]))': (node) => {
|
|
22
|
+
return context.report({
|
|
23
|
+
node,
|
|
24
|
+
message: '属性に設定している文字列から先頭、末尾の空白文字を削除してください',
|
|
25
|
+
fix: (fixer) => fixer.replaceText(node, context.sourceCode.getText(node).replace(/(^`\s+|\s+`$)/g, '`')),
|
|
30
26
|
})
|
|
27
|
+
},
|
|
31
28
|
}
|
|
32
29
|
},
|
|
33
30
|
}
|
|
@@ -19,7 +19,8 @@ ruleTester.run('a11y-help-link-with-support-href', rule, {
|
|
|
19
19
|
{ code: `<HelpLink href="//support.hoge" />` },
|
|
20
20
|
{ code: `<HelpLink href={"//support.hoge"} />` },
|
|
21
21
|
{ code: `<HelpLink href={path.support.hoge} />` },
|
|
22
|
-
{ code: `<HelpLink href={
|
|
22
|
+
{ code: `<HelpLink href={supportURL} />` },
|
|
23
|
+
{ code: `<HelpLink href={supportHref} />` },
|
|
23
24
|
],
|
|
24
25
|
invalid: [
|
|
25
26
|
{ code: `<Anchor href="//support.hoge">any</Anchor>`, errors: [{ message: errorText }] },
|
|
@@ -26,6 +26,7 @@ ruleTester.run('a11y-input-has-name-attribute', rule, {
|
|
|
26
26
|
{ code: '<HogeTextarea name="hoge" />' },
|
|
27
27
|
{ code: '<select name="hoge" />' },
|
|
28
28
|
{ code: '<Select name="hoge[0][Fuga]" />' },
|
|
29
|
+
{ code: '<Select name={`ABC`} />' },
|
|
29
30
|
{ code: '<Input {...hoge} />', options: [{ checkType: 'allow-spread-attributes' }] },
|
|
30
31
|
{ code: '<Input {...args1} {...args2} />', options: [{ checkType: 'allow-spread-attributes' }] },
|
|
31
32
|
{ code: '<Input {...args} hoge="fuga" />', options: [{ checkType: 'allow-spread-attributes' }] },
|
package/test/trim-props.js
CHANGED
|
@@ -16,8 +16,9 @@ ruleTester.run('trim-props', rule, {
|
|
|
16
16
|
{ code: '<a href="https://www.google.com">google</a>' },
|
|
17
17
|
{ code: '<a href={"https://www.google.com"}>google</a>' },
|
|
18
18
|
{ code: '<img src="/sample.jpg" alt="sample" />' },
|
|
19
|
-
{ code:
|
|
19
|
+
{ code: `<img src={'/sample.jpg'} alt={'sample'} />` },
|
|
20
20
|
{ code: '<div data-spec="info-area">....</div>' },
|
|
21
|
+
{ code: '<div data-spec={`a${b} c`}>....</div>' },
|
|
21
22
|
],
|
|
22
23
|
invalid: [
|
|
23
24
|
{
|
|
@@ -59,8 +60,8 @@ ruleTester.run('trim-props', rule, {
|
|
|
59
60
|
],
|
|
60
61
|
},
|
|
61
62
|
{
|
|
62
|
-
code:
|
|
63
|
-
output:
|
|
63
|
+
code: `<img src={' /sample.jpg'} alt={'sample '} />`,
|
|
64
|
+
output: `<img src={'/sample.jpg'} alt={'sample'} />`,
|
|
64
65
|
errors: [
|
|
65
66
|
{ message: '属性に設定している文字列から先頭、末尾の空白文字を削除してください' },
|
|
66
67
|
{ message: '属性に設定している文字列から先頭、末尾の空白文字を削除してください' },
|
|
@@ -76,5 +77,15 @@ ruleTester.run('trim-props', rule, {
|
|
|
76
77
|
output: '<div data-spec={"info-area"}>....</div>',
|
|
77
78
|
errors: [{ message: '属性に設定している文字列から先頭、末尾の空白文字を削除してください' }],
|
|
78
79
|
},
|
|
80
|
+
{
|
|
81
|
+
code: '<div data-spec={` ab c `}>....</div>',
|
|
82
|
+
output: '<div data-spec={`ab c`}>....</div>',
|
|
83
|
+
errors: [{ message: '属性に設定している文字列から先頭、末尾の空白文字を削除してください' }],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
code: '<div data-spec={` a${b} c `}>....</div>',
|
|
87
|
+
output: '<div data-spec={`a${b} c`}>....</div>',
|
|
88
|
+
errors: [{ message: '属性に設定している文字列から先頭、末尾の空白文字を削除してください' }],
|
|
89
|
+
},
|
|
79
90
|
],
|
|
80
|
-
})
|
|
91
|
+
})
|