Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit af415a6

Browse files
committed
Ignore calls to a method named innerText
1 parent 8d691db commit af415a6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/rules/no-innerText.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ module.exports = {
1212
create(context) {
1313
return {
1414
MemberExpression(node) {
15+
// If the member expression is part of a call expression like `.innerText()` then it is not the same
16+
// as the `Element.innerText` property, and should not trigger a warning
17+
if (node.parent.type === 'CallExpression') return
18+
1519
if (node.property && node.property.name === 'innerText') {
1620
context.report({
1721
meta: {

tests/no-innerText.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ ruleTester.run('no-innerText', rule, {
1111
{
1212
code: 'document.querySelector("js-flash-text").textContent = "bar"',
1313
},
14+
{
15+
// This is unrelated to the `HTMLElement.innerText` property, and should not trigger a warning
16+
code: 'var text = element.textContent()',
17+
},
1418
],
1519
invalid: [
1620
{

0 commit comments

Comments
 (0)