File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,17 @@ const create = context => ({
9191 return ;
9292 }
9393
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+
94105 const attributeName = callExpression . arguments [ 0 ] . value . toLowerCase ( ) ;
95106
96107 if ( ! attributeName . startsWith ( 'data-' ) ) {
Original file line number Diff line number Diff line change @@ -187,6 +187,8 @@ test.snapshot({
187187 // First Argument is not startsWith `data-`
188188 'element.getAttribute("foo-unicorn");' ,
189189 'element.getAttribute("data");' ,
190+ // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2307
191+ 'await page.locator("text=Hello").getAttribute("data-foo")' ,
190192 ] ,
191193 invalid : [
192194 outdent `
You can’t perform that action at this time.
0 commit comments