eslint-plugin-smarthr
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -5,2 +5,9 @@ # Changelog | ||
### [0.3.3](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.3.2...v0.3.3) (2023-07-10) | ||
### Bug Fixes | ||
* a11y-heading-in-sectioning-contentのHeadingアウトライン未指定の誤検知を修正する ([#65](https://github.com/kufu/eslint-plugin-smarthr/issues/65)) ([2cbf6aa](https://github.com/kufu/eslint-plugin-smarthr/commit/2cbf6aaff61f7846a80a895ed4e5e63ff9674c87)) | ||
### [0.3.2](https://github.com/kufu/eslint-plugin-smarthr/compare/v0.3.1...v0.3.2) (2023-07-07) | ||
@@ -7,0 +14,0 @@ |
{ | ||
"name": "eslint-plugin-smarthr", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"author": "SmartHR", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -13,2 +13,3 @@ const { generateTagFormatter } = require('../../libs/format_styled_components') | ||
const headingRegex = /((^h(1|2|3|4|5|6))|Heading)$/ | ||
const declaratorHeadingRegex = /Heading$/ | ||
const sectioningRegex = /((A(rticle|side))|Nav|Section|^SectioningFragment)$/ | ||
@@ -41,2 +42,7 @@ const bareTagRegex = /^(article|aside|nav|section)$/ | ||
// Headingコンポーネントの拡張なので対象外 | ||
if (node.type === 'VariableDeclarator' && node.id.name.match(declaratorHeadingRegex)) { | ||
return null | ||
} | ||
return searchBubbleUp(node.parent) | ||
@@ -87,23 +93,26 @@ } | ||
const result = searchBubbleUp(node.parent) | ||
const saved = sections.find((s) => s[0] === result) | ||
// HINT: 最初の1つ目は通知しない() | ||
if (!saved) { | ||
sections.push([result, node]) | ||
} else { | ||
// HINT: 同じファイルで同じSectioningContent or トップノードを持つ場合 | ||
const [section, unreport] = saved | ||
const targets = unreport ? [unreport, node] : [node] | ||
if (result) { | ||
const saved = sections.find((s) => s[0] === result) | ||
saved[1] = undefined | ||
// HINT: 最初の1つ目は通知しない() | ||
if (!saved) { | ||
sections.push([result, node]) | ||
} else { | ||
// HINT: 同じファイルで同じSectioningContent or トップノードを持つ場合 | ||
const [section, unreport] = saved | ||
const targets = unreport ? [unreport, node] : [node] | ||
targets.forEach((n) => { | ||
context.report({ | ||
node: n, | ||
message: | ||
section.type === 'Program' | ||
? rootMessage | ||
: commonMessage, | ||
saved[1] = undefined | ||
targets.forEach((n) => { | ||
context.report({ | ||
node: n, | ||
message: | ||
section.type === 'Program' | ||
? rootMessage | ||
: commonMessage, | ||
}) | ||
}) | ||
}) | ||
} | ||
} | ||
@@ -110,0 +119,0 @@ } |
@@ -40,2 +40,3 @@ const rule = require('../rules/a11y-heading-in-sectioning-content'); | ||
{ code: '<><Heading>hoge</Heading><SectioningFragment><Heading>hoge</Heading></SectioningFragment></>' }, | ||
{ code: 'const HogeHeading = () => <FugaHeading anyArg={abc}>hoge</FugaHeading>;const FugaHeading = () => <AbcHeading anyArg={abc}>hoge</AbcHeading>' }, | ||
], | ||
@@ -66,3 +67,4 @@ invalid: [ | ||
{ code: '<section>hoge</section>', errors: [ { message: `"section"を利用せず、smarthr-ui/Sectionを拡張してください。Headingのレベルが自動計算されるようになります。` } ] }, | ||
{ code: 'const Hoge = () => <FugaHeading anyArg={abc}>hoge</FugaHeading>;const Fuga = () => <AbcHeading anyArg={abc}>hoge</AbcHeading>', errors: [ { message: rootMessage }, { message: rootMessage } ] }, | ||
], | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
199625
3700
32