-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#11233 Removing innerText & adding eslint rule
- Loading branch information
Marcin Komorski
authored and
Marcin Komorski
committed
May 21, 2024
1 parent
4af2afb
commit 84b91cc
Showing
7 changed files
with
62 additions
and
33 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const _ = require('lodash'); | ||
const { flagErrors } = require('./validateImports.js'); | ||
|
||
module.exports = { | ||
rules: { | ||
'no-innerText': { | ||
meta: { | ||
docs: { | ||
description: '.innerText property on DOM elements should not be used due to performance issues' | ||
}, | ||
messages: { | ||
noInnerText: 'Use of `.innerText` is not allowed. Use `.textContent` instead.', | ||
} | ||
}, | ||
create: function(context) { | ||
return { | ||
MemberExpression(node) { | ||
if (node.property && node.property.name === 'innerText') { | ||
context.report({ | ||
node: node.property, | ||
messageId: 'noInnerText', | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
'validate-imports': { | ||
meta: { | ||
docs: { | ||
description: 'validates module imports can be found without custom webpack resolvers, are in module whitelist, and not module entry points' | ||
} | ||
}, | ||
create: function(context) { | ||
return { | ||
"CallExpression[callee.name='require']"(node) { | ||
let importPath = _.get(node, ['arguments', 0, 'value']); | ||
if (importPath) { | ||
flagErrors(context, node, importPath); | ||
} | ||
}, | ||
ImportDeclaration(node) { | ||
let importPath = node.source.value.trim(); | ||
flagErrors(context, node, importPath); | ||
}, | ||
'ExportNamedDeclaration[source]'(node) { | ||
let importPath = node.source.value.trim(); | ||
flagErrors(context, node, importPath); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; |
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
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