Permalink
Cannot retrieve contributors at this time
34 lines (32 sloc)
971 Bytes
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/eslint-plugin-github/lib/rules/no-innerText.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
meta: { | |
type: 'problem', | |
docs: { | |
description: 'disallow `Element.prototype.innerText` in favor of `Element.prototype.textContent`', | |
url: require('../url')(module), | |
}, | |
fixable: 'code', | |
schema: [], | |
}, | |
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: { | |
fixable: 'code', | |
}, | |
node: node.property, | |
message: 'Prefer textContent to innerText', | |
fix(fixer) { | |
return fixer.replaceText(node.property, 'textContent') | |
}, | |
}) | |
} | |
}, | |
} | |
}, | |
} |