-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prebid 9: Removing innerText & adding eslint rule (#11531)
* 11233 Removing innerText & adding eslint rule * tests fix --------- Co-authored-by: Marcin Komorski <[email protected]>
- Loading branch information
Showing
7 changed files
with
75 additions
and
46 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
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
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