Bump packages to fix linter

This commit is contained in:
Henry Mercer 2023-01-18 20:50:03 +00:00
parent ed9506bbaf
commit 0a11e3fdd9
6063 changed files with 378752 additions and 306784 deletions

View file

@ -2,14 +2,17 @@ module.exports = {
env: {
browser: true
},
plugins: ['github'],
plugins: ['github', 'escompat'],
extends: ['plugin:escompat/recommended'],
rules: {
'escompat/no-dynamic-imports': 'off',
'github/async-currenttarget': 'error',
'github/async-preventdefault': 'error',
'github/get-attribute': 'error',
'github/no-blur': 'error',
'github/no-dataset': 'error',
'github/no-innerText': 'error',
'github/no-inner-html': 'error',
'github/unescaped-html-literal': 'error',
'github/no-useless-passive': 'error',
'github/require-passive-events': 'error',

13
node_modules/eslint-plugin-github/lib/configs/react.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
module.exports = {
parserOptions: {
sourceType: 'module',
ecmaFeatures: {
jsx: true
}
},
plugins: ['github', 'jsx-a11y'],
extends: ['plugin:jsx-a11y/recommended'],
rules: {
'github/a11y-no-generic-link-text': 'error'
}
}

View file

@ -18,11 +18,12 @@ module.exports = {
'eslint-comments/no-unused-disable': 'error',
'eslint-comments/no-unused-enable': 'error',
'eslint-comments/no-use': ['error', {allow: ['eslint', 'eslint-disable-next-line', 'eslint-env', 'globals']}],
'filenames/match-regex': ['error', '^[a-z0-9-]+(.d)?$'],
'filenames/match-regex': ['error', '^[a-z0-9-]+(.[a-z0-9-]+)?$'],
'func-style': ['error', 'declaration', {allowArrowFunctions: true}],
'github/array-foreach': 'error',
'github/no-implicit-buggy-globals': 'error',
'github/no-then': 'error',
'github/no-dynamic-script-tag': 'error',
'i18n-text/no-en': ['error'],
'import/default': 'error',
'import/export': 'error',
@ -118,7 +119,6 @@ module.exports = {
'prefer-template': 'error',
'prettier/prettier': 'error',
'require-yield': 'error',
'sort-imports': 'error',
'use-isnan': 'error',
'valid-typeof': 'error',
camelcase: ['error', {properties: 'always'}],

View file

@ -1,17 +1,21 @@
module.exports = {
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
extends: ['plugin:@typescript-eslint/recommended', 'prettier', 'plugin:escompat/typescript-2020'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'github'],
plugins: ['@typescript-eslint', 'escompat', 'github'],
rules: {
camelcase: 'off',
'no-unused-vars': 'off',
'no-shadow': 'off',
'no-invalid-this': 'off',
'@typescript-eslint/no-invalid-this': ['error'],
'@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',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-non-null-assertion': 'off'
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off'
}
}

View file

@ -12,7 +12,6 @@ try {
}
const getRuleURI = require('eslint-rule-documentation')
// eslint-disable-next-line eslint-plugin/prefer-object-rule
module.exports = function (results) {
let output = '\n'
let errors = 0

View file

@ -1,5 +1,6 @@
module.exports = {
rules: {
'a11y-no-generic-link-text': require('./rules/a11y-no-generic-link-text'),
'array-foreach': require('./rules/array-foreach'),
'async-currenttarget': require('./rules/async-currenttarget'),
'async-preventdefault': require('./rules/async-preventdefault'),
@ -10,17 +11,20 @@ module.exports = {
'no-d-none': require('./rules/no-d-none'),
'no-dataset': require('./rules/no-dataset'),
'no-implicit-buggy-globals': require('./rules/no-implicit-buggy-globals'),
'no-inner-html': require('./rules/no-inner-html'),
'no-innerText': require('./rules/no-innerText'),
'no-dynamic-script-tag': require('./rules/no-dynamic-script-tag'),
'no-then': require('./rules/no-then'),
'unescaped-html-literal': require('./rules/unescaped-html-literal'),
'no-useless-passive': require('./rules/no-useless-passive'),
'prefer-observers': require('./rules/prefer-observers'),
'require-passive-events': require('./rules/require-passive-events')
'require-passive-events': require('./rules/require-passive-events'),
'unescaped-html-literal': require('./rules/unescaped-html-literal')
},
configs: {
internal: require('./configs/internal'),
browser: require('./configs/browser'),
internal: require('./configs/internal'),
recommended: require('./configs/recommended'),
typescript: require('./configs/typescript')
typescript: require('./configs/typescript'),
react: require('./configs/react')
}
}

View file

@ -0,0 +1,71 @@
const {getProp, getPropValue} = require('jsx-ast-utils')
const {getElementType} = require('../utils/get-element-type')
const bannedLinkText = ['read more', 'here', 'click here', 'learn more', 'more']
/* Downcase and strip extra whitespaces and punctuation */
const stripAndDowncaseText = text => {
return text
.toLowerCase()
.replace(/[.,/#!$%^&*;:{}=\-_`~()]/g, '')
.replace(/\s{2,}/g, ' ')
.trim()
}
module.exports = {
meta: {
docs: {
description: 'disallow generic link text',
url: require('../url')(module)
},
schema: []
},
create(context) {
return {
JSXOpeningElement: node => {
const elementType = getElementType(context, node)
if (elementType !== 'a') return
if (getProp(node.attributes, 'aria-labelledby')) return
let cleanTextContent // text content we can reliably fetch
const parent = node.parent
let jsxTextNode
if (parent.children && parent.children.length > 0 && parent.children[0].type === 'JSXText') {
jsxTextNode = parent.children[0]
cleanTextContent = stripAndDowncaseText(parent.children[0].value)
}
const ariaLabel = getPropValue(getProp(node.attributes, 'aria-label'))
const cleanAriaLabelValue = ariaLabel && stripAndDowncaseText(ariaLabel)
if (ariaLabel) {
if (bannedLinkText.includes(cleanAriaLabelValue)) {
context.report({
node,
message:
'Avoid setting generic link text like `Here`, `Click here`, `Read more`. Make sure that your link text is both descriptive and concise.'
})
}
if (cleanTextContent && !cleanAriaLabelValue.includes(cleanTextContent)) {
context.report({
node,
message: 'When using ARIA to set a more descriptive text, it must fully contain the visible label.'
})
}
} else {
if (cleanTextContent) {
if (!bannedLinkText.includes(cleanTextContent)) return
context.report({
node: jsxTextNode,
message:
'Avoid setting generic link text like `Here`, `Click here`, `Read more`. Make sure that your link text is both descriptive and concise.'
})
}
}
}
}
}
}

View file

@ -0,0 +1,29 @@
module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'disallow creating dynamic script tags',
url: require('../url')(module)
},
schema: []
},
create(context) {
return {
'CallExpression[callee.property.name="createElement"][arguments.length > 0]': function (node) {
if (node.arguments[0].value !== 'script') return
context.report({
node: node.arguments[0],
message: "Don't create dynamic script tags, add them in the server template instead."
})
},
'AssignmentExpression[left.property.name="type"][right.value="text/javascript"]': function (node) {
context.report({
node: node.right,
message: "Don't create dynamic script tags, add them in the server template instead."
})
}
}
}
}

View file

@ -0,0 +1,21 @@
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'disallow `Element.prototype.innerHTML` in favor of `Element.prototype.textContent`',
url: require('../url')(module)
},
schema: []
},
create(context) {
return {
'MemberExpression[property.name=innerHTML]': function (node) {
context.report({
node: node.property,
message: 'Using innerHTML poses a potential security risk and should not be used. Prefer using textContent.'
})
}
}
}
}

View file

@ -2,7 +2,7 @@ module.exports = {
meta: {
type: 'problem',
docs: {
description: 'disallow unesaped HTML literals',
description: 'disallow unescaped HTML literals',
url: require('../url')(module)
},
schema: []

View file

@ -1,6 +1,6 @@
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')

View file

@ -0,0 +1,36 @@
const {elementType, getProp, getPropValue} = 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) {
const {settings} = context
const rawElement = elementType(node)
if (!settings) return rawElement
const componentMap = settings.github && settings.github.components
if (!componentMap) return rawElement
const component = componentMap[rawElement]
if (!component) return rawElement
let element = component.default ? component.default : rawElement
if (component.props) {
const props = Object.entries(component.props)
for (const [key, value] of props) {
const propMap = value
const propValue = getPropValue(getProp(node.attributes, key))
const mapValue = propMap[propValue]
if (mapValue) {
element = mapValue
}
}
}
return element
}
module.exports = {getElementType}