initial commit of actions
This commit is contained in:
commit
949ece5785
44660 changed files with 12034344 additions and 0 deletions
27
github/codeql-action-v1/node_modules/eslint-plugin-github/lib/rules/require-passive-events.js
generated
vendored
Normal file
27
github/codeql-action-v1/node_modules/eslint-plugin-github/lib/rules/require-passive-events.js
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
const passiveEventListenerNames = new Set(['touchstart', 'touchmove', 'wheel', 'mousewheel'])
|
||||
|
||||
const propIsPassiveTrue = prop => prop.key && prop.key.name === 'passive' && prop.value && prop.value.value === true
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'enforce marking high frequency event handlers as passive',
|
||||
url: require('../url')(module)
|
||||
},
|
||||
schema: []
|
||||
},
|
||||
|
||||
create(context) {
|
||||
return {
|
||||
['CallExpression[callee.property.name="addEventListener"]']: function (node) {
|
||||
const [name, listener, options] = node.arguments
|
||||
if (!listener) return
|
||||
if (name.type !== 'Literal') return
|
||||
if (!passiveEventListenerNames.has(name.value)) return
|
||||
if (options && options.type === 'ObjectExpression' && options.properties.some(propIsPassiveTrue)) return
|
||||
context.report({node, message: `High Frequency Events like "${name.value}" should be \`passive: true\``})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue