mirror of
https://github.com/github/codeql-action.git
synced 2025-12-22 07:10:23 +08:00
32 lines
773 B
JavaScript
32 lines
773 B
JavaScript
const {getProp} = require('jsx-ast-utils')
|
|
|
|
module.exports = {
|
|
meta: {
|
|
docs: {
|
|
description: '[aria-label] text should be formatted as you would visual text.',
|
|
url: require('../url')(module),
|
|
},
|
|
schema: [],
|
|
},
|
|
|
|
create(context) {
|
|
return {
|
|
JSXOpeningElement: node => {
|
|
const prop = getProp(node.attributes, 'aria-label')
|
|
if (!prop) return
|
|
|
|
const propValue = prop.value
|
|
if (propValue.type !== 'Literal') return
|
|
|
|
const ariaLabel = propValue.value
|
|
if (ariaLabel.match(/^[a-z]+.*$/)) {
|
|
context.report({
|
|
node,
|
|
message: '[aria-label] text should be formatted the same as you would visual text. Use sentence case.',
|
|
})
|
|
}
|
|
},
|
|
}
|
|
},
|
|
}
|