initial commit of actions
This commit is contained in:
commit
949ece5785
44660 changed files with 12034344 additions and 0 deletions
37
github/codeql-action-v2/node_modules/eslint-plugin-github/lib/utils/get-element-type.js
generated
vendored
Normal file
37
github/codeql-action-v2/node_modules/eslint-plugin-github/lib/utils/get-element-type.js
generated
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
const {elementType, getProp, getLiteralPropValue} = require('jsx-ast-utils')
|
||||
|
||||
/*
|
||||
Allows custom component to be mapped to an element type.
|
||||
When a default is set, all instances of the component will be mapped to the default.
|
||||
If a prop determines the type, it can be specified with `props`.
|
||||
|
||||
For now, we only support the mapping of one prop type to an element type, rather than combinations of props.
|
||||
*/
|
||||
function getElementType(context, node, lazyElementCheck = false) {
|
||||
const {settings} = context
|
||||
|
||||
if (lazyElementCheck) {
|
||||
return elementType(node)
|
||||
}
|
||||
|
||||
// check if the node contains a polymorphic prop
|
||||
const polymorphicPropName = settings?.github?.polymorphicPropName ?? 'as'
|
||||
|
||||
const prop = getProp(node.attributes, polymorphicPropName)
|
||||
const literalPropValue = getLiteralPropValue(getProp(node.attributes, polymorphicPropName))
|
||||
let checkConditionalMap = true
|
||||
|
||||
// If the prop is not a literal and we cannot determine it, don't fall back to the conditional map value, if it exists
|
||||
if (prop && !literalPropValue) {
|
||||
checkConditionalMap = false
|
||||
}
|
||||
const rawElement = getLiteralPropValue(getProp(node.attributes, polymorphicPropName)) ?? elementType(node)
|
||||
|
||||
// if a component configuration does not exists, return the raw element
|
||||
if (!settings?.github?.components?.[rawElement]) return rawElement
|
||||
|
||||
// check if the default component is also defined in the configuration
|
||||
return checkConditionalMap ? settings.github.components[rawElement] : rawElement
|
||||
}
|
||||
|
||||
module.exports = {getElementType}
|
||||
37
github/codeql-action-v2/node_modules/eslint-plugin-github/lib/utils/get-exported-name.js
generated
vendored
Normal file
37
github/codeql-action-v2/node_modules/eslint-plugin-github/lib/utils/get-exported-name.js
generated
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
function getNodeName(node, options) {
|
||||
const op = options || []
|
||||
|
||||
if (node.type === 'Identifier') {
|
||||
return node.name
|
||||
}
|
||||
|
||||
if (node.id && node.id.type === 'Identifier') {
|
||||
return node.id.name
|
||||
}
|
||||
|
||||
if (op[2] && node.type === 'CallExpression' && node.callee.type === 'Identifier') {
|
||||
return node.callee.name
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function getExportedName(programNode, options) {
|
||||
for (let i = 0; i < programNode.body.length; i += 1) {
|
||||
const node = programNode.body[i]
|
||||
|
||||
if (node.type === 'ExportDefaultDeclaration') {
|
||||
return getNodeName(node.declaration, options)
|
||||
}
|
||||
|
||||
if (
|
||||
node.type === 'ExpressionStatement' &&
|
||||
node.expression.type === 'AssignmentExpression' &&
|
||||
node.expression.left.type === 'MemberExpression' &&
|
||||
node.expression.left.object.type === 'Identifier' &&
|
||||
node.expression.left.object.name === 'module' &&
|
||||
node.expression.left.property.type === 'Identifier' &&
|
||||
node.expression.left.property.name === 'exports'
|
||||
) {
|
||||
return getNodeName(node.expression.right, options)
|
||||
}
|
||||
}
|
||||
}
|
||||
111
github/codeql-action-v2/node_modules/eslint-plugin-github/lib/utils/get-role.js
generated
vendored
Normal file
111
github/codeql-action-v2/node_modules/eslint-plugin-github/lib/utils/get-role.js
generated
vendored
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
const {getProp, getLiteralPropValue} = require('jsx-ast-utils')
|
||||
const {elementRoles} = require('aria-query')
|
||||
const {getElementType} = require('./get-element-type')
|
||||
const ObjectMap = require('./object-map')
|
||||
|
||||
const elementRolesMap = cleanElementRolesMap()
|
||||
|
||||
/*
|
||||
Returns an element roles map which uses `aria-query`'s elementRoles as the foundation.
|
||||
We additionally clean the data so we're able to fetch a role using a key we construct based on the node we're looking at.
|
||||
In a few scenarios, we stray from the roles returned by `aria-query` and hard code the mapping.
|
||||
*/
|
||||
function cleanElementRolesMap() {
|
||||
const rolesMap = new ObjectMap()
|
||||
|
||||
for (const [key, value] of elementRoles.entries()) {
|
||||
// - Remove empty `attributes` key
|
||||
if (!key.attributes || key.attributes?.length === 0) {
|
||||
delete key.attributes
|
||||
}
|
||||
rolesMap.set(key, value)
|
||||
}
|
||||
// Remove insufficiently-disambiguated `menuitem` entry
|
||||
rolesMap.delete({name: 'menuitem'})
|
||||
// Disambiguate `menuitem` and `menu` roles by `type`
|
||||
rolesMap.set({name: 'menuitem', attributes: [{name: 'type', value: 'command'}]}, ['menuitem'])
|
||||
rolesMap.set({name: 'menuitem', attributes: [{name: 'type', value: 'radio'}]}, ['menuitemradio'])
|
||||
rolesMap.set({name: 'menuitem', attributes: [{name: 'type', value: 'toolbar'}]}, ['toolbar'])
|
||||
rolesMap.set({name: 'menu', attributes: [{name: 'type', value: 'toolbar'}]}, ['toolbar'])
|
||||
|
||||
/* These have constraints defined in aria-query's `elementRoles` which depend on knowledge of ancestor roles which we cant accurately determine in a linter context.
|
||||
However, we benefit more from assuming the role, than assuming it's generic or undefined so we opt to hard code the mapping */
|
||||
rolesMap.set({name: 'aside'}, ['complementary']) // `aside` still maps to `complementary` in https://www.w3.org/TR/html-aria/#docconformance.
|
||||
rolesMap.set({name: 'li'}, ['listitem']) // `li` can be generic if it's not within a list but we would never want to render `li` outside of a list.
|
||||
|
||||
return rolesMap
|
||||
}
|
||||
|
||||
/*
|
||||
Determine role of an element, based on its name and attributes.
|
||||
We construct a key and look up the element's role in `elementRolesMap`.
|
||||
If there is no match, we return undefined.
|
||||
*/
|
||||
function getRole(context, node) {
|
||||
// Early return if role is explicitly set
|
||||
const explicitRole = getLiteralPropValue(getProp(node.attributes, 'role'))
|
||||
if (explicitRole) {
|
||||
return explicitRole
|
||||
} else if (getProp(node.attributes, 'role')) {
|
||||
// If role is set to anything other than a literal prop
|
||||
return undefined
|
||||
}
|
||||
|
||||
// Assemble a key for looking-up the element’s role in the `elementRolesMap`
|
||||
// - Get the element’s name
|
||||
const key = {name: getElementType(context, node)}
|
||||
|
||||
for (const prop of [
|
||||
'aria-label',
|
||||
'aria-labelledby',
|
||||
'alt',
|
||||
'type',
|
||||
'size',
|
||||
'role',
|
||||
'href',
|
||||
'multiple',
|
||||
'scope',
|
||||
'name',
|
||||
]) {
|
||||
if ((prop === 'aria-labelledby' || prop === 'aria-label') && !['section', 'form'].includes(key.name)) continue
|
||||
if (prop === 'name' && key.name !== 'form') continue
|
||||
if (prop === 'href' && key.name !== 'a' && key.name !== 'area') continue
|
||||
if (prop === 'alt' && key.name !== 'img') continue
|
||||
|
||||
const propOnNode = getProp(node.attributes, prop)
|
||||
|
||||
if (!('attributes' in key)) {
|
||||
key.attributes = []
|
||||
}
|
||||
// Disambiguate "undefined" props
|
||||
if (propOnNode === undefined && prop === 'alt' && key.name === 'img') {
|
||||
key.attributes.push({name: prop, constraints: ['undefined']})
|
||||
continue
|
||||
}
|
||||
|
||||
const value = getLiteralPropValue(propOnNode)
|
||||
if (propOnNode) {
|
||||
if (
|
||||
prop === 'href' ||
|
||||
prop === 'aria-labelledby' ||
|
||||
prop === 'aria-label' ||
|
||||
prop === 'name' ||
|
||||
(prop === 'alt' && value !== '')
|
||||
) {
|
||||
key.attributes.push({name: prop, constraints: ['set']})
|
||||
} else if (value || (value === '' && prop === 'alt')) {
|
||||
key.attributes.push({name: prop, value})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// - Remove empty `attributes` key
|
||||
if (!key.attributes || key.attributes?.length === 0) {
|
||||
delete key.attributes
|
||||
}
|
||||
|
||||
// Get the element’s implicit role
|
||||
return elementRolesMap.get(key)?.[0]
|
||||
}
|
||||
|
||||
module.exports = {getRole}
|
||||
5
github/codeql-action-v2/node_modules/eslint-plugin-github/lib/utils/is-ignored-filename.js
generated
vendored
Normal file
5
github/codeql-action-v2/node_modules/eslint-plugin-github/lib/utils/is-ignored-filename.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
const ignoredFilenames = ['<text>', '<input>']
|
||||
|
||||
module.exports = function isIgnoredFilename(filename) {
|
||||
return ignoredFilenames.indexOf(filename) !== -1
|
||||
}
|
||||
58
github/codeql-action-v2/node_modules/eslint-plugin-github/lib/utils/object-map.js
generated
vendored
Normal file
58
github/codeql-action-v2/node_modules/eslint-plugin-github/lib/utils/object-map.js
generated
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
// @ts-check
|
||||
const {isDeepStrictEqual} = require('util')
|
||||
|
||||
/**
|
||||
* ObjectMap extends Map, but determines key equality using Node.js’ `util.isDeepStrictEqual` rather than using [SameValueZero](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#key_equality). This makes using objects as keys a bit simpler.
|
||||
*/
|
||||
module.exports = class ObjectMap extends Map {
|
||||
#data
|
||||
|
||||
constructor(iterable = []) {
|
||||
super()
|
||||
this.#data = iterable
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.#data = []
|
||||
}
|
||||
|
||||
delete(key) {
|
||||
if (!this.has(key)) {
|
||||
return false
|
||||
}
|
||||
this.#data = this.#data.filter(([existingKey]) => !isDeepStrictEqual(existingKey, key))
|
||||
return true
|
||||
}
|
||||
|
||||
entries() {
|
||||
return this.#data[Symbol.iterator]()
|
||||
}
|
||||
|
||||
forEach(cb) {
|
||||
for (const [key, value] of this.#data) {
|
||||
cb(value, key, this.#data)
|
||||
}
|
||||
}
|
||||
|
||||
get(key) {
|
||||
return this.#data.find(([existingKey]) => isDeepStrictEqual(existingKey, key))?.[1]
|
||||
}
|
||||
|
||||
has(key) {
|
||||
return this.#data.findIndex(([existingKey]) => isDeepStrictEqual(existingKey, key)) !== -1
|
||||
}
|
||||
|
||||
keys() {
|
||||
return this.#data.map(([key]) => key)[Symbol.iterator]()
|
||||
}
|
||||
|
||||
set(key, value) {
|
||||
this.delete(key)
|
||||
this.#data.push([key, value])
|
||||
return this
|
||||
}
|
||||
|
||||
values() {
|
||||
return this.#data.map(([, value]) => value)[Symbol.iterator]()
|
||||
}
|
||||
}
|
||||
12
github/codeql-action-v2/node_modules/eslint-plugin-github/lib/utils/parse-filename.js
generated
vendored
Normal file
12
github/codeql-action-v2/node_modules/eslint-plugin-github/lib/utils/parse-filename.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
const path = require('path')
|
||||
|
||||
module.exports = function parseFilename(filename) {
|
||||
const ext = path.extname(filename)
|
||||
|
||||
return {
|
||||
dir: path.dirname(filename),
|
||||
base: path.basename(filename),
|
||||
ext,
|
||||
name: path.basename(filename, ext),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue