Skip to content

Commit eb2d4aa

Browse files
committed
Migrate deprecated syntax
1 parent 159abef commit eb2d4aa

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/rules/a11y-explicit-heading.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ module.exports = {
4646
},
4747
},
4848
create(context) {
49+
const sourceCode = context.sourceCode ?? context.getSourceCode()
4950
return {
5051
JSXOpeningElement(jsxNode) {
5152
const skipImportCheck = context.options[0] ? context.options[0].skipImportCheck : false
5253

5354
if (
54-
(skipImportCheck || isPrimerComponent(jsxNode.name, context.getScope(jsxNode))) &&
55+
(skipImportCheck || isPrimerComponent(jsxNode.name, sourceCode.getScope(jsxNode))) &&
5556
isHeadingComponent(jsxNode)
5657
) {
5758
const error = isInvalid(jsxNode)

src/rules/a11y-tooltip-interactive-trigger.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,14 @@ module.exports = {
152152
},
153153
},
154154
create(context) {
155+
const sourceCode = context.sourceCode ?? context.getSourceCode()
155156
return {
156157
JSXElement(jsxNode) {
157158
// If `skipImportCheck` is true, this rule will check for non-interactive element in any components (not just ones that are imported from `@primer/react`).
158159
const skipImportCheck = context.options[0] ? context.options[0].skipImportCheck : false
159160
const name = getJSXOpeningElementName(jsxNode.openingElement)
160161
if (
161-
(skipImportCheck || isPrimerComponent(jsxNode.openingElement.name, context.getScope(jsxNode))) &&
162+
(skipImportCheck || isPrimerComponent(jsxNode.openingElement.name, sourceCode.getScope(jsxNode))) &&
162163
name === 'Tooltip' &&
163164
jsxNode.children
164165
) {

src/rules/direct-slot-children.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports = {
4545
},
4646
create(context) {
4747
const stack = []
48+
const sourceCode = context.sourceCode ?? context.getSourceCode()
4849
return {
4950
JSXOpeningElement(jsxNode) {
5051
const name = getJSXOpeningElementName(jsxNode)
@@ -56,7 +57,7 @@ module.exports = {
5657
// If component is a Primer component and a slot child,
5758
// check if it's a direct child of the slot parent
5859
if (
59-
(skipImportCheck || isPrimerComponent(jsxNode.name, context.getScope(jsxNode))) &&
60+
(skipImportCheck || isPrimerComponent(jsxNode.name, sourceCode.getScope(jsxNode))) &&
6061
slotChildToParentMap[name]
6162
) {
6263
const expectedParentNames = slotChildToParentMap[name]

src/rules/no-system-props.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ module.exports = {
7878
...(includeUtilityComponents ? [] : utilityComponents),
7979
])
8080

81+
const sourceCode = context.sourceCode ?? context.getSourceCode()
82+
8183
return {
8284
JSXOpeningElement(jsxNode) {
8385
if (skipImportCheck) {
@@ -86,7 +88,7 @@ module.exports = {
8688
if (isHTMLElement(jsxNode)) return
8789
} else {
8890
// skip if component is not imported from primer/react
89-
if (!isPrimerComponent(jsxNode.name, context.getScope(jsxNode))) return
91+
if (!isPrimerComponent(jsxNode.name, sourceCode.getScope(jsxNode))) return
9092
}
9193

9294
const componentName = getJSXOpeningElementName(jsxNode)

0 commit comments

Comments
 (0)