eslint-plugin-smarthr 2.1.0 → 2.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,14 @@
|
|
|
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.0](https://github.com/kufu/tamatebako/compare/eslint-plugin-smarthr-v2.1.0...eslint-plugin-smarthr-v2.2.0) (2025-11-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* a11y-help-link-with-support-hrefで対象となる変数名のバグを修正 ([#890](https://github.com/kufu/tamatebako/issues/890)) ([c9c4984](https://github.com/kufu/tamatebako/commit/c9c49848293fd88640e886c6586ae8d92a99f40c))
|
|
11
|
+
* trim-propsでtemplate literalもautofixの対象にする ([#884](https://github.com/kufu/tamatebako/issues/884)) ([4072950](https://github.com/kufu/tamatebako/commit/40729507f5084308128ca39d5887ee81f2f67dd5))
|
|
12
|
+
|
|
5
13
|
## [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
14
|
|
|
7
15
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-smarthr",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
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": "56a52ee0be0573e3c6117ff2b368543fbbac5c4f"
|
|
41
41
|
}
|
|
@@ -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
|
|
|
@@ -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 }] },
|
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
|
+
})
|