Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2021-07-27 16:54:26 +00:00
parent 6b0d45a5c6
commit cc1adb825a
4247 changed files with 144820 additions and 149530 deletions

View file

@ -1,5 +1,7 @@
# eslint-plugin-github
[![Node CI](https://github.com/github/eslint-plugin-github/actions/workflows/nodejs.yml/badge.svg)](https://github.com/github/eslint-plugin-github/actions/workflows/nodejs.yml)
## Installation
```sh
@ -28,7 +30,7 @@ JSON ESLint config example:
The available configs are:
- `app`
- `internal`
- Rules useful for github applications.
- `browser`
- Useful rules when shipping your app to the browser.

View file

@ -1,10 +1,12 @@
module.exports = {
extends: ['plugin:@typescript-eslint/recommended', 'prettier', 'prettier/@typescript-eslint'],
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'github'],
rules: {
camelcase: 'off',
'no-unused-vars': 'off',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/array-type': ['error', {default: 'array-simple'}],
'@typescript-eslint/no-use-before-define': 'off',

View file

@ -12,7 +12,8 @@ try {
}
const getRuleURI = require('eslint-rule-documentation')
module.exports = function(results) {
// eslint-disable-next-line eslint-plugin/prefer-object-rule
module.exports = function (results) {
let output = '\n'
let errors = 0
let warnings = 0
@ -82,8 +83,5 @@ function diff(a, b) {
fs.writeFileSync(aPath, a, {encoding: 'utf8'})
fs.writeFileSync(bPath, b, {encoding: 'utf8'})
const result = childProcess.spawnSync('diff', ['-U5', aPath, bPath], {encoding: 'utf8'})
return result.stdout
.split('\n')
.slice(2)
.join('\n')
return result.stdout.split('\n').slice(2).join('\n')
}

View file

@ -1,6 +1,10 @@
module.exports = {
meta: {
docs: {},
type: 'suggestion',
docs: {
description: 'enforce `for..of` loops over `Array.forEach`',
url: require('../url')(module)
},
schema: []
},
@ -8,7 +12,7 @@ module.exports = {
return {
CallExpression(node) {
if (node.callee.property && node.callee.property.name === 'forEach') {
context.report(node, 'Prefer for...of instead of Array.forEach')
context.report({node, message: 'Prefer for...of instead of Array.forEach'})
}
}
}

View file

@ -1,6 +1,10 @@
module.exports = {
meta: {
docs: {},
type: 'problem',
docs: {
description: 'disallow `event.currentTarget` calls inside of async functions',
url: require('../url')(module)
},
schema: []
},
@ -15,7 +19,7 @@ module.exports = {
if (node.property && node.property.name === 'currentTarget') {
const scope = context.getScope()
if (scope.block.async && scopeDidWait.has(scope)) {
context.report(node, 'event.currentTarget inside an async function is error prone')
context.report({node, message: 'event.currentTarget inside an async function is error prone'})
}
}
}

View file

@ -1,6 +1,10 @@
module.exports = {
meta: {
docs: {},
type: 'problem',
docs: {
description: 'disallow `event.preventDefault` calls inside of async functions',
url: require('../url')(module)
},
schema: []
},
@ -15,7 +19,7 @@ module.exports = {
if (node.callee.property && node.callee.property.name === 'preventDefault') {
const scope = context.getScope()
if (scope.block.async && scopeDidWait.has(scope)) {
context.report(node, 'event.preventDefault() inside an async function is error prone')
context.report({node, message: 'event.preventDefault() inside an async function is error prone'})
}
}
}

View file

@ -1,16 +1,21 @@
module.exports = {
meta: {
docs: {},
type: 'problem',
docs: {
description: 'disallow usage of CSRF tokens in JavaScript',
url: require('../url')(module)
},
schema: []
},
create(context) {
function checkAuthenticityTokenUsage(node, str) {
if (str.includes('authenticity_token')) {
context.report(
context.report({
node,
'Form CSRF tokens (authenticity tokens) should not be created in JavaScript and their values should not be used directly for XHR requests.'
)
message:
'Form CSRF tokens (authenticity tokens) should not be created in JavaScript and their values should not be used directly for XHR requests.'
})
}
}

View file

@ -17,28 +17,36 @@ function isValidAttribute(name) {
return validSVGAttributeSet.has(name) || (validAttributeName.test(name) && !invalidSVGAttributeSet.has(name))
}
module.exports = function(context) {
return {
CallExpression(node) {
if (!node.callee.property) return
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'disallow wrong usage of attribute names',
url: require('../url')(module)
},
fixable: 'code',
schema: []
},
create(context) {
return {
CallExpression(node) {
if (!node.callee.property) return
const calleeName = node.callee.property.name
if (!attributeCalls.test(calleeName)) return
const calleeName = node.callee.property.name
if (!attributeCalls.test(calleeName)) return
const attributeNameNode = node.arguments[0]
if (!attributeNameNode) return
const attributeNameNode = node.arguments[0]
if (!attributeNameNode) return
if (!isValidAttribute(attributeNameNode.value)) {
context.report({
meta: {
fixable: 'code'
},
node: attributeNameNode,
message: 'Attributes should be lowercase and hyphen separated, or part of the SVG whitelist.',
fix(fixer) {
return fixer.replaceText(attributeNameNode, `'${attributeNameNode.value.toLowerCase()}'`)
}
})
if (!isValidAttribute(attributeNameNode.value)) {
context.report({
node: attributeNameNode,
message: 'Attributes should be lowercase and hyphen separated, or part of the SVG whitelist.',
fix(fixer) {
return fixer.replaceText(attributeNameNode, `'${attributeNameNode.value.toLowerCase()}'`)
}
})
}
}
}
}

View file

@ -1,6 +1,10 @@
module.exports = {
meta: {
docs: {},
type: 'suggestion',
docs: {
description: 'enforce a naming convention for js- prefixed classes',
url: require('../url')(module)
},
schema: []
},
@ -13,14 +17,14 @@ module.exports = {
const matches = str.match(allJsClassNameRegexp) || []
for (const match of matches) {
if (!match.match(validJsClassNameRegexp)) {
context.report(node, 'js- class names should be lowercase and only contain dashes.')
context.report({node, message: 'js- class names should be lowercase and only contain dashes.'})
}
}
}
function checkStringEndsWithJSClassName(node, str) {
if (str.match(endWithJsClassNameRegexp)) {
context.report(node, 'js- class names should be statically defined.')
context.report({node, message: 'js- class names should be statically defined.'})
}
}

View file

@ -1,11 +1,19 @@
module.exports = function(context) {
return {
CallExpression(node) {
if (node.callee.property && node.callee.property.name === 'blur') {
context.report(node, 'Do not use element.blur(), instead restore the focus of a previous element.')
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'disallow usage of `Element.prototype.blur()`',
url: require('../url')(module)
},
schema: []
},
create(context) {
return {
CallExpression(node) {
if (node.callee.property && node.callee.property.name === 'blur') {
context.report({node, message: 'Do not use element.blur(), instead restore the focus of a previous element.'})
}
}
}
}
}
module.exports.schema = []

View file

@ -1,4 +1,12 @@
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'disallow usage the `d-none` CSS class',
url: require('../url')(module)
},
schema: []
},
create(context) {
return {
CallExpression(node) {

View file

@ -1,6 +1,10 @@
module.exports = {
meta: {
docs: {},
type: 'problem',
docs: {
description: 'enforce usage of `Element.prototype.getAttribute` instead of `Element.prototype.datalist`',
url: require('../url')(module)
},
schema: []
},
@ -8,7 +12,7 @@ module.exports = {
return {
MemberExpression(node) {
if (node.property && node.property.name === 'dataset') {
context.report(node, "Use getAttribute('data-your-attribute') instead of dataset.")
context.report({node, message: "Use getAttribute('data-your-attribute') instead of dataset."})
}
}
}

View file

@ -1,6 +1,10 @@
module.exports = {
meta: {
docs: {},
type: 'problem',
docs: {
description: 'disallow implicit global variables',
url: require('../url')(module)
},
schema: []
},
@ -21,7 +25,7 @@ module.exports = {
(def.type === 'Variable' && def.parent.kind === 'const') ||
(def.type === 'Variable' && def.parent.kind === 'let')
) {
context.report(def.node, 'Implicit global variable, assign as global property instead.')
context.report({node: def.node, message: 'Implicit global variable, assign as global property instead.'})
}
}
}

View file

@ -1,7 +1,12 @@
module.exports = {
meta: {
docs: {},
fixable: 'code'
type: 'problem',
docs: {
description: 'disallow `Element.prototype.innerText` in favor of `Element.prototype.textContent`',
url: require('../url')(module)
},
fixable: 'code',
schema: []
},
create(context) {

View file

@ -1,15 +1,20 @@
module.exports = {
meta: {
docs: {}
type: 'suggestion',
docs: {
description: 'enforce using `async/await` syntax over Promises',
url: require('../url')(module)
},
schema: []
},
create(context) {
return {
MemberExpression(node) {
if (node.property && node.property.name === 'then') {
context.report(node.property, 'Prefer async/await to Promise.then()')
context.report({node: node.property, message: 'Prefer async/await to Promise.then()'})
} else if (node.property && node.property.name === 'catch') {
context.report(node.property, 'Prefer async/await to Promise.catch()')
context.report({node: node.property, message: 'Prefer async/await to Promise.catch()'})
}
}
}

View file

@ -4,13 +4,18 @@ const propIsPassiveTrue = prop => prop.key && prop.key.name === 'passive' && pro
module.exports = {
meta: {
docs: {},
fixable: 'code'
type: 'suggestion',
docs: {
description: 'disallow marking a event handler as passive when it has no effect',
url: require('../url')(module)
},
fixable: 'code',
schema: []
},
create(context) {
return {
['CallExpression[callee.property.name="addEventListener"]']: function(node) {
['CallExpression[callee.property.name="addEventListener"]']: function (node) {
const [name, listener, options] = node.arguments
if (name.type !== 'Literal') return
if (passiveEventListenerNames.has(name.value)) return

View file

@ -4,13 +4,17 @@ const observerMap = {
}
module.exports = {
meta: {
docs: {},
fixable: 'code'
type: 'suggestion',
docs: {
description: 'disallow poorly performing event listeners',
url: require('../url')(module)
},
schema: []
},
create(context) {
return {
['CallExpression[callee.property.name="addEventListener"]']: function(node) {
['CallExpression[callee.property.name="addEventListener"]']: function (node) {
const [name] = node.arguments
if (name.type !== 'Literal') return
if (!(name.value in observerMap)) return

View file

@ -4,18 +4,23 @@ const propIsPassiveTrue = prop => prop.key && prop.key.name === 'passive' && pro
module.exports = {
meta: {
docs: {}
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) {
['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, `High Frequency Events like "${name.value}" should be \`passive: true\``)
context.report({node, message: `High Frequency Events like "${name.value}" should be \`passive: true\``})
}
}
}

View file

@ -1,24 +1,35 @@
module.exports = function(context) {
const htmlOpenTag = /^<[a-zA-Z]/
const message = 'Unescaped HTML literal. Use html`` tag template literal for secure escaping.'
return {
Literal(node) {
if (!htmlOpenTag.test(node.value)) return
context.report({
node,
message
})
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'disallow unesaped HTML literals',
url: require('../url')(module)
},
TemplateLiteral(node) {
if (!htmlOpenTag.test(node.quasis[0].value.raw)) return
schema: []
},
create(context) {
const htmlOpenTag = /^<[a-zA-Z]/
const message = 'Unescaped HTML literal. Use html`` tag template literal for secure escaping.'
return {
Literal(node) {
if (!htmlOpenTag.test(node.value)) return
if (!node.parent.tag || node.parent.tag.name !== 'html') {
context.report({
node,
message
})
},
TemplateLiteral(node) {
if (!htmlOpenTag.test(node.quasis[0].value.raw)) return
if (!node.parent.tag || node.parent.tag.name !== 'html') {
context.report({
node,
message
})
}
}
}
}

10
node_modules/eslint-plugin-github/lib/url.js generated vendored Normal file
View file

@ -0,0 +1,10 @@
const {homepage, version} = require('../package.json')
const path = require('path')
// eslint-disable-next-line eslint-plugin/prefer-object-rule
module.exports = ({id}) => {
const url = new URL(homepage)
const rule = path.basename(id, '.js')
url.hash = ''
url.pathname += `/blob/v${version}/docs/rules/${rule}.md`
return url.toString()
}

View file

@ -1,6 +1,6 @@
{
"name": "eslint-plugin-github",
"version": "4.1.1",
"version": "4.1.5",
"description": "An opinionated collection of ESLint shared configs and rules used by GitHub.",
"main": "lib/index.js",
"entries": [
@ -11,7 +11,7 @@
},
"scripts": {
"pretest": "mkdir -p node_modules/ && ln -fs $(pwd) node_modules/",
"eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check",
"eslint-check": "eslint-config-prettier .eslintrc.js",
"test": "npm run eslint-check && eslint . && mocha tests/"
},
"repository": {
@ -25,19 +25,19 @@
},
"homepage": "https://github.com/github/eslint-plugin-github#readme",
"dependencies": {
"@typescript-eslint/eslint-plugin": ">=2.25.0",
"@typescript-eslint/parser": ">=2.25.0",
"eslint-config-prettier": ">=6.10.1",
"eslint-plugin-eslint-comments": ">=3.0.1",
"eslint-plugin-import": ">=2.20.1",
"eslint-plugin-prettier": ">=3.1.2",
"@typescript-eslint/eslint-plugin": "^4.20.0",
"@typescript-eslint/parser": "^4.20.0",
"eslint-config-prettier": ">=8.0.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-rule-documentation": ">=1.0.0",
"prettier": ">=1.12.0",
"svg-element-attributes": ">=1.3.1"
"prettier": "^2.2.1",
"svg-element-attributes": "^1.3.1"
},
"prettier": "@github/prettier-config",
"peerDependencies": {
"eslint": ">=4.19.0"
"eslint": "^7.23.0"
},
"files": [
"bin/*",
@ -45,7 +45,10 @@
],
"devDependencies": {
"@github/prettier-config": "0.0.4",
"eslint": ">=7.0.0",
"mocha": ">=7.1.1"
"eslint": "7.23.0",
"eslint-plugin-eslint-plugin": "^2.3.0",
"eslint-visitor-keys": "^2.0.0",
"globals": "^13.7.0",
"mocha": "^8.3.2"
}
}