eslint-plugin-smarthr 0.3.12 → 0.3.14

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,20 @@
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.14](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.3.13...v0.3.14) (2023-11-05)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * styled-components/attrsメソッドを利用している場合、継承時の名称チェック対象外になっていたため修正 ([#89](https://github.com/kufu/eslint-plugin-smarthr/issues/89)) ([93b72f2](https://github.com/kufu/eslint-plugin-smarthr/commit/93b72f23f0bcc507976793c63955cff13313e79f))
11
+
12
+ ### [0.3.13](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.3.12...v0.3.13) (2023-10-16)
13
+
14
+
15
+ ### Features
16
+
17
+ * a11-heading-in-sectioning-contentのtag属性不要チェックのエラー位置を、タグの開始行ではなく属性の記述されている行に変更する ([#86](https://github.com/kufu/eslint-plugin-smarthr/issues/86)) ([e25080a](https://github.com/kufu/eslint-plugin-smarthr/commit/e25080a461ddce87eaaf20cd0c7ef290fd321836))
18
+
5
19
  ### [0.3.12](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.3.11...v0.3.12) (2023-10-12)
6
20
 
7
21
 
@@ -54,6 +54,10 @@ const generateTagFormatter = ({ context, EXPECTED_NAMES, UNEXPECTED_NAMES }) =>
54
54
  case callee.object?.name:
55
55
  base = callee.property.name
56
56
  break
57
+ case callee.object?.callee?.name:
58
+ const arg = callee.object.arguments[0]
59
+ base = arg.name || arg.value
60
+ break
57
61
  }
58
62
  }
59
63
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-smarthr",
3
- "version": "0.3.12",
3
+ "version": "0.3.14",
4
4
  "author": "SmartHR",
5
5
  "license": "MIT",
6
6
  "description": "A sharable ESLint plugin for SmartHR",
@@ -39,8 +39,9 @@ const checkFalsyJSXText = (c) => (
39
39
  !(c.type === 'JSXText' && c.value.match(REGEX_NLSP))
40
40
  )
41
41
 
42
- const message = `a, buttonなどのクリッカブルな要素内にはテキストを設定してください。
42
+ const message = `a, buttonなどのクリッカブルな要素内にはテキストを設定してください
43
43
  - 要素内にアイコン、画像のみを設置する場合はaltなどの代替テキスト用属性を指定してください
44
+ - SVG component の場合、altを属性として受け取れるようにした上で '<svg role="img" aria-label={alt}>' のように指定してください
44
45
  - クリッカブルな要素内に設置しているコンポーネントがテキストを含んでいる場合、"XxxxText" のように末尾に "Text" もしくは "Message" という名称を設定してください`
45
46
 
46
47
  module.exports = {
@@ -178,7 +178,7 @@ module.exports = {
178
178
 
179
179
  if (!hit && tagAttr) {
180
180
  context.report({
181
- node,
181
+ node: tagAttr,
182
182
  message: noTagAttrMessage,
183
183
  })
184
184
  }
@@ -12,8 +12,9 @@ const ruleTester = new RuleTester({
12
12
  },
13
13
  })
14
14
 
15
- const defaultErrorMessage = `a, buttonなどのクリッカブルな要素内にはテキストを設定してください。
15
+ const defaultErrorMessage = `a, buttonなどのクリッカブルな要素内にはテキストを設定してください
16
16
  - 要素内にアイコン、画像のみを設置する場合はaltなどの代替テキスト用属性を指定してください
17
+ - SVG component の場合、altを属性として受け取れるようにした上で '<svg role="img" aria-label={alt}>' のように指定してください
17
18
  - クリッカブルな要素内に設置しているコンポーネントがテキストを含んでいる場合、"XxxxText" のように末尾に "Text" もしくは "Message" という名称を設定してください`
18
19
 
19
20
  ruleTester.run('a11y-clickable-element-has-text', rule, {
@@ -38,6 +38,7 @@ ruleTester.run('a11y-heading-in-sectioning-content', rule, {
38
38
  { code: 'const FugaAside = styled(HogeAside)``' },
39
39
  { code: 'const FugaNav = styled(HogeNav)``' },
40
40
  { code: 'const FugaSection = styled(HogeSection)``' },
41
+ { code: "const FugaHeading = styled(Heading).attrs(() => ({ type: 'blockTitle' }))``" },
41
42
  { code: '<PageHeading>hoge</PageHeading>' },
42
43
  { code: '<Section><Heading>hoge</Heading></Section>' },
43
44
  { code: '<><Section><Heading>hoge</Heading></Section><Section><Heading>fuga</Heading></Section></>' },
@@ -54,6 +55,7 @@ ruleTester.run('a11y-heading-in-sectioning-content', rule, {
54
55
  { code: 'const Hoge = styled.h6``', errors: [ { message: `Hogeを正規表現 "/Heading$/" がmatchする名称に変更してください` } ] },
55
56
  { code: 'const Fuga = styled(Heading)``', errors: [ { message: `Fugaを正規表現 "/Heading$/" がmatchする名称に変更してください` } ] },
56
57
  { code: 'const Fuga = styled(HogeHeading)``', errors: [ { message: `Fugaを正規表現 "/Heading$/" がmatchする名称に変更してください` } ] },
58
+ { code: 'const Fuga = styled(HogeHeading).attrs(() => ({ type: "blockTitle" }))``', errors: [ { message: `Fugaを正規表現 "/Heading$/" がmatchする名称に変更してください` } ] },
57
59
  { code: 'const Fuga = styled(HogeArticle)``', errors: [ { message: `Fugaを正規表現 "/Article$/" がmatchする名称に変更してください` } ] },
58
60
  { code: 'const Fuga = styled(HogeAside)``', errors: [ { message: `Fugaを正規表現 "/Aside$/" がmatchする名称に変更してください` } ] },
59
61
  { code: 'const Fuga = styled(HogeNav)``', errors: [ { message: `Fugaを正規表現 "/Nav$/" がmatchする名称に変更してください` } ] },