eslint-plugin-smarthr 0.2.4 → 0.2.5
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 +8 -0
- package/package.json +1 -1
- package/rules/a11y-clickable-element-has-text/index.js +28 -11
- package/rules/a11y-image-has-alt-attribute/index.js +1 -1
- package/rules/format-import-path/README.md +1 -1
- package/rules/no-import-other-domain/README.md +1 -1
- package/rules/prohibit-import/index.js +1 -1
- package/rules/redundant-name/README.md +1 -1
- package/rules/redundant-name/index.js +1 -1
- package/rules/require-barrel-import/README.md +1 -1
- package/rules/require-import/index.js +1 -1
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
|
+
### [0.2.5](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.2.4...v0.2.5) (2022-09-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* require-import, prohibit-import: report message の一部でテンプレート文字列がそのまま出力されてしまう事があるバグを修正 ([#29](https://github.com/kufu/eslint-plugin-smarthr/issues/29)) ([b805f90](https://github.com/kufu/eslint-plugin-smarthr/commit/b805f90cd39b1aa4b95cbfbd983c5ff1c61f8afe))
|
|
11
|
+
* 画像系コンポーネントが代替テキスト属性を持つかチェックする際にエラーになるパターンを修正 ([#30](https://github.com/kufu/eslint-plugin-smarthr/issues/30)) ([bcd1044](https://github.com/kufu/eslint-plugin-smarthr/commit/bcd1044d7532531015a279520ed8eda582227492))
|
|
12
|
+
|
|
5
13
|
### [0.2.4](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.2.3...v0.2.4) (2022-08-30)
|
|
6
14
|
|
|
7
15
|
|
package/package.json
CHANGED
|
@@ -36,17 +36,34 @@ module.exports = {
|
|
|
36
36
|
return
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
const recursiveSearch = (c) =>
|
|
40
|
-
['JSXText', 'JSXExpressionContainer'].includes(c.type)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
const recursiveSearch = (c) => {
|
|
40
|
+
if (['JSXText', 'JSXExpressionContainer'].includes(c.type)) {
|
|
41
|
+
return true
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (c.type === 'JSXElement') {
|
|
45
|
+
// // HINT: SmartHRLogo コンポーネントは内部でaltを持っているため対象外にする
|
|
46
|
+
if (c.openingElement.name.name.match(/SmartHRLogo$/)) {
|
|
47
|
+
return true
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (c.openingElement.attributes.some((a) => {
|
|
51
|
+
if (!['visuallyHiddenText', 'alt'].includes(a.name.name)) {
|
|
52
|
+
return false
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (!!a.value.value || a.value.type === 'JSXExpressionContainer')
|
|
56
|
+
})) {
|
|
57
|
+
return true
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (c.children && filterFalsyJSXText(c.children).some(recursiveSearch)) {
|
|
61
|
+
return true
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return false
|
|
66
|
+
}
|
|
50
67
|
|
|
51
68
|
const child = filterFalsyJSXText(parentNode.children).find(recursiveSearch)
|
|
52
69
|
|
|
@@ -21,7 +21,7 @@ module.exports = {
|
|
|
21
21
|
...generateTagFormatter({ context, EXPECTED_NAMES }),
|
|
22
22
|
JSXOpeningElement: (node) => {
|
|
23
23
|
if ((node.name.name || '').match(/(img|image)$/i)) { // HINT: Iconは別途テキストが存在する場合が多いためチェックの対象外とする
|
|
24
|
-
const alt = node.attributes.find((a) => a.name
|
|
24
|
+
const alt = node.attributes.find((a) => a.name?.name === 'alt')
|
|
25
25
|
|
|
26
26
|
let message = ''
|
|
27
27
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
## config
|
|
9
9
|
|
|
10
|
-
- tsconfig.json の compilerOptions.pathsに '@/*' としてroot path を指定する必要があります
|
|
10
|
+
- tsconfig.json の compilerOptions.pathsに '@/*', もしくは '~/*' としてroot path を指定する必要があります
|
|
11
11
|
- ドメインを識別するために以下の設定を記述する必要があります
|
|
12
12
|
- globalModuleDir
|
|
13
13
|
- 全体で利用するファイルを収めているディレクトリを相対パスで指定します
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## config
|
|
8
8
|
|
|
9
|
-
- tsconfig.json の compilerOptions.pathsに '@/*' としてroot path を指定する必要があります
|
|
9
|
+
- tsconfig.json の compilerOptions.pathsに '@/*', もしくは '~/*' としてroot path を指定する必要があります
|
|
10
10
|
- ドメインを識別するために以下の設定を記述する必要があります
|
|
11
11
|
- globalModuleDir
|
|
12
12
|
- 全体で利用するファイルを収めているディレクトリを相対パスで指定します
|
|
@@ -90,7 +90,7 @@ module.exports = {
|
|
|
90
90
|
node,
|
|
91
91
|
messageId: 'prohibit_import',
|
|
92
92
|
data: {
|
|
93
|
-
message: reportMessage ? reportMessage.
|
|
93
|
+
message: reportMessage ? reportMessage.replaceAll('{{module}}', node.source.value).replaceAll('{{export}}', useImported) : defaultReportMessage(node.source.value, useImported)
|
|
94
94
|
},
|
|
95
95
|
});
|
|
96
96
|
}
|
|
@@ -406,7 +406,7 @@ module.exports = {
|
|
|
406
406
|
},
|
|
407
407
|
create(context) {
|
|
408
408
|
if (!rootPath) {
|
|
409
|
-
throw new Error('tsconfig.json の compilerOptions.paths に `"@/*": ["any_path/*"]`
|
|
409
|
+
throw new Error('tsconfig.json の compilerOptions.paths に `@/*`、もしくは `~/*` 形式でフロントエンドのroot dir を指定してください(例: `"@/*": ["./any_path/*"]`)')
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
let rules = {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# smarthr/require-barrel-import
|
|
2
2
|
|
|
3
|
-
- tsconfig.json の compilerOptions.pathsに '@/*' としてroot path を指定する必要があります
|
|
3
|
+
- tsconfig.json の compilerOptions.pathsに '@/*', もしくは '~/*' としてroot path を指定する必要があります
|
|
4
4
|
- importした対象が本来exportされているべきであるbarrel(index.tsなど)が有る場合、import pathの変更を促します
|
|
5
5
|
- 例: Page/parts/Menu/Item の import は Page/parts/Menu から行わせたい
|
|
6
6
|
- ディレクトリ内のindexファイルを捜査し、対象を決定します
|
|
@@ -83,7 +83,7 @@ module.exports = {
|
|
|
83
83
|
node,
|
|
84
84
|
messageId: 'require_import',
|
|
85
85
|
data: {
|
|
86
|
-
message: reportMessage ? reportMessage.
|
|
86
|
+
message: reportMessage ? reportMessage.replaceAll('{{module}}', actualTarget).replaceAll('{{export}}', item) : defaultReportMessage(actualTarget, item)
|
|
87
87
|
},
|
|
88
88
|
})
|
|
89
89
|
}
|