Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/rules/no-innerText.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ module.exports = {
create(context) {
return {
MemberExpression(node) {
// If the member expression is part of a call expression like `.innerText()` then it is not the same
// as the `Element.innerText` property, and should not trigger a warning
if (node.parent.type === 'CallExpression') return

if (node.property && node.property.name === 'innerText') {
context.report({
meta: {
Expand Down
4 changes: 4 additions & 0 deletions tests/no-innerText.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ ruleTester.run('no-innerText', rule, {
{
code: 'document.querySelector("js-flash-text").textContent = "bar"',
},
{
// This is unrelated to the `HTMLElement.innerText` property, and should not trigger a warning
code: 'var text = element.textContent()',
},
],
invalid: [
{
Expand Down