File tree 2 files changed +13
-0
lines changed
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,17 @@ const create = context => ({
91
91
return ;
92
92
}
93
93
94
+ const method = callExpression . callee . property . name ;
95
+ // Playwright's `Locator#getAttribute()` returns a promise.
96
+ // https://playwright.dev/docs/api/class-locator#locator-get-attribute
97
+ if (
98
+ callExpression . parent . type === 'AwaitExpression'
99
+ && callExpression . parent . argument === callExpression
100
+ && method === 'getAttribute'
101
+ ) {
102
+ return ;
103
+ }
104
+
94
105
const attributeName = callExpression . arguments [ 0 ] . value . toLowerCase ( ) ;
95
106
96
107
if ( ! attributeName . startsWith ( 'data-' ) ) {
Original file line number Diff line number Diff line change @@ -187,6 +187,8 @@ test.snapshot({
187
187
// First Argument is not startsWith `data-`
188
188
'element.getAttribute("foo-unicorn");' ,
189
189
'element.getAttribute("data");' ,
190
+ // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2307
191
+ 'await page.locator("text=Hello").getAttribute("data-foo")' ,
190
192
] ,
191
193
invalid : [
192
194
outdent `
You can’t perform that action at this time.
0 commit comments