eslint-plugin-smarthr 0.2.25 → 0.3.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 +11 -0
- package/package.json +1 -1
- package/rules/{best-practice-for-remote-trigger-action-dialog → best-practice-for-remote-trigger-dialog}/README.md +3 -3
- package/rules/{best-practice-for-remote-trigger-action-dialog → best-practice-for-remote-trigger-dialog}/index.js +2 -2
- package/test/{best-practice-for-remote-trigger-action-dialog.js → best-practice-for-remote-trigger-dialog.js} +2 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
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.3.0](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.2.25...v0.3.0) (2023-04-14)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* best-practice-for-remote-trigger-dialog にリネーム & 特定パターンでバグが起きる問題を修正する (#61)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* best-practice-for-remote-trigger-dialog にリネーム & 特定パターンでバグが起きる問題を修正する ([#61](https://github.com/kufu/eslint-plugin-smarthr/issues/61)) ([0ad3601](https://github.com/kufu/eslint-plugin-smarthr/commit/0ad3601caa941946a0f30aacc2f010cd478b6133))
|
|
15
|
+
|
|
5
16
|
### [0.2.25](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.2.24...v0.2.25) (2023-04-04)
|
|
6
17
|
|
|
7
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# smarthr/best-practice-for-remote-trigger-
|
|
1
|
+
# smarthr/best-practice-for-remote-trigger-dialog
|
|
2
2
|
|
|
3
|
-
- RemoteDialogTrigger,
|
|
3
|
+
- RemoteDialogTrigger, RemoteTriggerXxxxDialog のベストプラクティスをチェックするルールです
|
|
4
4
|
- `id` もしくは `targetId` にリテラルな文字列以外が設定できなくなります
|
|
5
5
|
- 変数なども使えません
|
|
6
6
|
- これは対応するTriggerとDialogをわかりやすくするためです(検索などが容易になります)
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
```js
|
|
11
11
|
{
|
|
12
12
|
rules: {
|
|
13
|
-
'smarthr/best-practice-for-remote-trigger-
|
|
13
|
+
'smarthr/best-practice-for-remote-trigger-dialog': 'error', // 'warn', 'off'
|
|
14
14
|
},
|
|
15
15
|
}
|
|
16
16
|
```
|
|
@@ -5,7 +5,7 @@ const EXPECTED_NAMES = {
|
|
|
5
5
|
'RemoteTrigger(.+)Dialog$': 'RemoteTrigger(.+)Dialog$',
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
const REGEX_REMOTE_TRIGGER_DIALOG = /RemoteTrigger(
|
|
8
|
+
const REGEX_REMOTE_TRIGGER_DIALOG = /RemoteTrigger(Action|Message|Modeless)Dialog$/
|
|
9
9
|
const REGEX_REMOTE_DIALOG_TRIGGER = /RemoteDialogTrigger$/
|
|
10
10
|
|
|
11
11
|
module.exports = {
|
|
@@ -25,7 +25,7 @@ module.exports = {
|
|
|
25
25
|
const attrName = regexRemoteTriggerDialog ? 'id' : 'targetId'
|
|
26
26
|
const id = node.attributes.find((a) => a.name?.name === attrName)
|
|
27
27
|
|
|
28
|
-
if (id.value.type !== 'Literal') {
|
|
28
|
+
if (id && id.value.type !== 'Literal') {
|
|
29
29
|
context.report({
|
|
30
30
|
node: id,
|
|
31
31
|
message: `${nodeName}の${attrName}属性には直接文字列を指定してください。
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const rule = require('../rules/best-practice-for-remote-trigger-
|
|
1
|
+
const rule = require('../rules/best-practice-for-remote-trigger-dialog')
|
|
2
2
|
const RuleTester = require('eslint').RuleTester
|
|
3
3
|
|
|
4
4
|
const ruleTester = new RuleTester({
|
|
@@ -12,7 +12,7 @@ const ruleTester = new RuleTester({
|
|
|
12
12
|
},
|
|
13
13
|
})
|
|
14
14
|
|
|
15
|
-
ruleTester.run('best-practice-for-remote-trigger-
|
|
15
|
+
ruleTester.run('best-practice-for-remote-trigger-dialog', rule, {
|
|
16
16
|
valid: [
|
|
17
17
|
{ code: `import styled from 'styled-components'` },
|
|
18
18
|
{ code: 'const HogeRemoteDialogTrigger = styled(RemoteDialogTrigger)``' },
|
|
@@ -33,10 +33,6 @@ ruleTester.run('best-practice-for-remote-trigger-action-dialog', rule, {
|
|
|
33
33
|
{ code: '<StyledRemoteDialogTrigger targetId={"fuga"}>open.</StyledRemoteDialogTrigger>', errors: [ { message: `StyledRemoteDialogTriggerのtargetId属性には直接文字列を指定してください。
|
|
34
34
|
- 変数などは利用できません(これは関連するTriggerとDialogを検索しやすくするためです)
|
|
35
35
|
- RemoteTriggerActionDialogはループやDropdown内にTriggerが存在する場合に利用してください
|
|
36
|
-
- ループやDropdown以外にTriggerが設定されている場合、TriggerAndActionDialogを利用してください` } ] },
|
|
37
|
-
{ code: '<RemoteTriggerHogeDialog {...args} id={hoge}>content.</RemoteTriggerHogeDialog>', errors: [ { message: `RemoteTriggerHogeDialogのid属性には直接文字列を指定してください。
|
|
38
|
-
- 変数などは利用できません(これは関連するTriggerとDialogを検索しやすくするためです)
|
|
39
|
-
- RemoteTriggerActionDialogはループやDropdown内にTriggerが存在する場合に利用してください
|
|
40
36
|
- ループやDropdown以外にTriggerが設定されている場合、TriggerAndActionDialogを利用してください` } ] },
|
|
41
37
|
{ code: '<StyldRemoteTriggerActionDialog {...args} id={"fuga"}>content.</StyldRemoteTriggerActionDialog>', errors: [ { message: `StyldRemoteTriggerActionDialogのid属性には直接文字列を指定してください。
|
|
42
38
|
- 変数などは利用できません(これは関連するTriggerとDialogを検索しやすくするためです)
|