Regenerating node_modules

This commit is contained in:
Chris Raynor
2020-09-14 10:42:37 +01:00
parent 09b4a82c83
commit c96f84308a
5488 changed files with 487362 additions and 60779 deletions

View File

@@ -0,0 +1,18 @@
module.exports = {
env: {
browser: true
},
plugins: ['github'],
rules: {
'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/unescaped-html-literal': 'error',
'github/no-useless-passive': 'error',
'github/require-passive-events': 'error',
'github/prefer-observers': 'error'
}
}

View File

@@ -0,0 +1,8 @@
module.exports = {
plugins: ['github'],
rules: {
'github/authenticity-token': 'error',
'github/js-class-name': 'error',
'github/no-d-none': 'error'
}
}

View File

@@ -0,0 +1,116 @@
module.exports = {
parserOptions: {
ecmaFeatures: {
ecmaVersion: 6
},
sourceType: 'module'
},
env: {
es6: true
},
plugins: ['github', 'prettier', 'eslint-comments', 'import'],
rules: {
'constructor-super': 'error',
'eslint-comments/disable-enable-pair': 'off',
'eslint-comments/no-aggregating-enable': 'off',
'eslint-comments/no-duplicate-disable': 'error',
'eslint-comments/no-unlimited-disable': 'error',
'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']}],
'func-style': ['error', 'declaration', {allowArrowFunctions: true}],
'github/array-foreach': 'error',
'github/no-implicit-buggy-globals': 'error',
'github/no-then': 'error',
'import/default': 'error',
'import/export': 'error',
'import/first': 'error',
'import/named': 'error',
'import/namespace': 'error',
'import/no-absolute-path': 'error',
'import/no-anonymous-default-export': [
'error',
{
allowAnonymousClass: false,
allowAnonymousFunction: false,
allowArray: true,
allowArrowFunction: false,
allowLiteral: true,
allowObject: true
}
],
'import/no-deprecated': 'error',
'import/no-duplicates': 'error',
'import/no-mutable-exports': 'error',
'import/no-named-as-default': 'error',
'import/no-named-as-default-member': 'error',
'import/no-namespace': 'error',
'no-case-declarations': 'error',
'no-class-assign': 'error',
'no-compare-neg-zero': 'error',
'no-cond-assign': 'error',
'no-console': 'error',
'no-const-assign': 'error',
'no-constant-condition': 'error',
'no-control-regex': 'error',
'no-debugger': 'error',
'no-delete-var': 'error',
'no-dupe-args': 'error',
'no-dupe-class-members': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-empty': 'error',
'no-empty-character-class': 'error',
'no-empty-pattern': 'error',
'no-ex-assign': 'error',
'no-extra-boolean-cast': 'error',
'no-fallthrough': 'error',
'no-func-assign': 'error',
'no-global-assign': 'error',
'no-implicit-globals': 'error',
'no-implied-eval': 'error',
'no-inner-declarations': 'error',
'no-invalid-regexp': 'error',
'no-invalid-this': 'error',
'no-irregular-whitespace': 'error',
'no-new-symbol': 'error',
'no-obj-calls': 'error',
'no-octal': 'error',
'no-redeclare': 'error',
'no-regex-spaces': 'error',
'no-return-assign': 'error',
'no-self-assign': 'error',
'no-shadow': 'error',
'no-sparse-arrays': 'error',
'no-this-before-super': 'error',
'no-throw-literal': 'error',
'no-undef': 'error',
'no-unreachable': 'error',
'no-unsafe-finally': 'error',
'no-unsafe-negation': 'error',
'no-unused-labels': 'error',
'no-unused-vars': 'error',
'no-useless-concat': 'error',
'no-useless-escape': 'error',
'no-var': 'error',
'object-shorthand': ['error', 'always', {avoidQuotes: true}],
'prefer-const': 'error',
'prefer-promise-reject-errors': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
'prettier/prettier': 'error',
'require-yield': 'error',
'use-isnan': 'error',
'valid-typeof': 'error',
camelcase: ['error', {properties: 'always'}],
eqeqeq: ['error', 'smart']
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.ts']
}
}
}
}

View File

@@ -0,0 +1,15 @@
module.exports = {
extends: ['plugin:@typescript-eslint/recommended', 'prettier', 'prettier/@typescript-eslint'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'github'],
rules: {
camelcase: 'off',
'no-unused-vars': 'off',
'@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'
}
}

View File

@@ -0,0 +1,89 @@
'use strict'
const childProcess = require('child_process')
const fs = require('fs')
const os = require('os')
const path = require('path')
let SourceCodeFixer = null
try {
SourceCodeFixer = require('eslint/lib/linter/source-code-fixer')
} catch (e) {
SourceCodeFixer = require('eslint/lib/util/source-code-fixer')
}
const getRuleURI = require('eslint-rule-documentation')
module.exports = function(results) {
let output = '\n'
let errors = 0
let warnings = 0
const rootPath = process.cwd()
for (const result of results) {
const messages = result.messages
if (messages.length === 0) {
continue
}
errors += result.errorCount
warnings += result.warningCount
const relativePath = path.relative(rootPath, result.filePath)
output += `${relativePath}\n`
for (const message of messages) {
output += `${message.line}:${message.column} ${message.ruleId || ''}`
if (message.ruleId) {
const ruleURI = getRuleURI(message.ruleId)
if (ruleURI.found) {
output += ` (${ruleURI.url})`
}
}
output += `\n\t${message.message}\n`
}
if (messages.some(msg => msg.fix)) {
const fixResult = SourceCodeFixer.applyFixes(result.source, messages)
output += `\n\n$ eslint --fix ${relativePath}\n`
output += diff(result.source, fixResult.output)
}
output += '\n\n'
}
const total = errors + warnings
if (total > 0) {
output += [
'\u2716 ',
total,
pluralize(' problem', total),
' (',
errors,
pluralize(' error', errors),
', ',
warnings,
pluralize(' warning', warnings),
')\n'
].join('')
}
return total > 0 ? output : ''
}
function pluralize(word, count) {
return count === 1 ? word : `${word}s`
}
function diff(a, b) {
const aPath = path.join(os.tmpdir(), 'a.js')
const bPath = path.join(os.tmpdir(), 'p.js')
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')
}

26
node_modules/eslint-plugin-github/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
module.exports = {
rules: {
'array-foreach': require('./rules/array-foreach'),
'async-currenttarget': require('./rules/async-currenttarget'),
'async-preventdefault': require('./rules/async-preventdefault'),
'authenticity-token': require('./rules/authenticity-token'),
'get-attribute': require('./rules/get-attribute'),
'js-class-name': require('./rules/js-class-name'),
'no-blur': require('./rules/no-blur'),
'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-innerText': require('./rules/no-innerText'),
'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')
},
configs: {
internal: require('./configs/internal'),
browser: require('./configs/browser'),
recommended: require('./configs/recommended'),
typescript: require('./configs/typescript')
}
}

View File

@@ -0,0 +1,16 @@
module.exports = {
meta: {
docs: {},
schema: []
},
create(context) {
return {
CallExpression(node) {
if (node.callee.property && node.callee.property.name === 'forEach') {
context.report(node, 'Prefer for...of instead of Array.forEach')
}
}
}
}
}

View File

@@ -0,0 +1,24 @@
module.exports = {
meta: {
docs: {},
schema: []
},
create(context) {
const scopeDidWait = new WeakSet()
return {
AwaitExpression() {
scopeDidWait.add(context.getScope(), true)
},
MemberExpression(node) {
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')
}
}
}
}
}
}

View File

@@ -0,0 +1,24 @@
module.exports = {
meta: {
docs: {},
schema: []
},
create(context) {
const scopeDidWait = new WeakSet()
return {
AwaitExpression() {
scopeDidWait.add(context.getScope(), true)
},
CallExpression(node) {
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')
}
}
}
}
}
}

View File

@@ -0,0 +1,25 @@
module.exports = {
meta: {
docs: {},
schema: []
},
create(context) {
function checkAuthenticityTokenUsage(node, str) {
if (str.includes('authenticity_token')) {
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.'
)
}
}
return {
Literal(node) {
if (typeof node.value === 'string') {
checkAuthenticityTokenUsage(node, node.value)
}
}
}
}
}

View File

@@ -0,0 +1,45 @@
const svgElementAttributes = require('svg-element-attributes')
const attributeCalls = /^(get|has|set|remove)Attribute$/
const validAttributeName = /^[a-z][a-z0-9-]*$/
// these are common SVG attributes that *must* have the correct case to work
const camelCaseAttributes = Object.values(svgElementAttributes)
.reduce((all, elementAttrs) => all.concat(elementAttrs), [])
.filter(name => !validAttributeName.test(name))
const validSVGAttributeSet = new Set(camelCaseAttributes)
// lowercase variants of camelCase SVG attributes are probably an error
const invalidSVGAttributeSet = new Set(camelCaseAttributes.map(name => name.toLowerCase()))
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
const calleeName = node.callee.property.name
if (!attributeCalls.test(calleeName)) 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()}'`)
}
})
}
}
}
}

View File

@@ -0,0 +1,53 @@
module.exports = {
meta: {
docs: {},
schema: []
},
create(context) {
const allJsClassNameRegexp = /\bjs-[_a-zA-Z0-9-]*/g
const validJsClassNameRegexp = /^js(-[a-z0-9]+)+$/g
const endWithJsClassNameRegexp = /\bjs-[_a-zA-Z0-9-]*$/g
function checkStringFormat(node, str) {
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.')
}
}
}
function checkStringEndsWithJSClassName(node, str) {
if (str.match(endWithJsClassNameRegexp)) {
context.report(node, 'js- class names should be statically defined.')
}
}
return {
Literal(node) {
if (typeof node.value === 'string') {
checkStringFormat(node, node.value)
if (
node.parent &&
node.parent.type === 'BinaryExpression' &&
node.parent.operator === '+' &&
node.parent.left.value
) {
checkStringEndsWithJSClassName(node.parent.left, node.parent.left.value)
}
}
},
TemplateLiteral(node) {
for (const quasi of node.quasis) {
checkStringFormat(quasi, quasi.value.raw)
if (quasi.tail === false) {
checkStringEndsWithJSClassName(quasi, quasi.value.raw)
}
}
}
}
}
}

11
node_modules/eslint-plugin-github/lib/rules/no-blur.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
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.schema = []

View File

@@ -0,0 +1,23 @@
module.exports = {
create(context) {
return {
CallExpression(node) {
if (
node.callee.type === 'MemberExpression' &&
node.callee.object.property &&
node.callee.object.property.name === 'classList'
) {
const invalidArgument = node.arguments.some(arg => {
return arg.type === 'Literal' && arg.value === 'd-none'
})
if (invalidArgument) {
context.report({
node,
message: 'Prefer hidden property to d-none class'
})
}
}
}
}
}
}

View File

@@ -0,0 +1,16 @@
module.exports = {
meta: {
docs: {},
schema: []
},
create(context) {
return {
MemberExpression(node) {
if (node.property && node.property.name === 'dataset') {
context.report(node, "Use getAttribute('data-your-attribute') instead of dataset.")
}
}
}
}
}

View File

@@ -0,0 +1,31 @@
module.exports = {
meta: {
docs: {},
schema: []
},
create(context) {
return {
Program() {
const scope = context.getScope()
for (const variable of scope.variables) {
if (variable.writeable) {
return
}
for (const def of variable.defs) {
if (
def.type === 'FunctionName' ||
def.type === 'ClassName' ||
(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.')
}
}
}
}
}
}
}

View File

@@ -0,0 +1,25 @@
module.exports = {
meta: {
docs: {},
fixable: 'code'
},
create(context) {
return {
MemberExpression(node) {
if (node.property && node.property.name === 'innerText') {
context.report({
meta: {
fixable: 'code'
},
node: node.property,
message: 'Prefer textContent to innerText',
fix(fixer) {
return fixer.replaceText(node.property, 'textContent')
}
})
}
}
}
}
}

17
node_modules/eslint-plugin-github/lib/rules/no-then.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
module.exports = {
meta: {
docs: {}
},
create(context) {
return {
MemberExpression(node) {
if (node.property && node.property.name === 'then') {
context.report(node.property, 'Prefer async/await to Promise.then()')
} else if (node.property && node.property.name === 'catch') {
context.report(node.property, 'Prefer async/await to Promise.catch()')
}
}
}
}
}

View File

@@ -0,0 +1,46 @@
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: {
docs: {},
fixable: 'code'
},
create(context) {
return {
['CallExpression[callee.property.name="addEventListener"]']: function(node) {
const [name, listener, options] = node.arguments
if (name.type !== 'Literal') return
if (passiveEventListenerNames.has(name.value)) return
if (options && options.type === 'ObjectExpression') {
const i = options.properties.findIndex(propIsPassiveTrue)
if (i === -1) return
const passiveProp = options.properties[i]
const l = options.properties.length
const source = context.getSourceCode()
context.report({
node: passiveProp,
message: `"${name.value}" event listener is not cancellable and so \`passive: true\` does nothing.`,
fix(fixer) {
const removals = []
if (l === 1) {
removals.push(options)
removals.push(...source.getTokensBetween(listener, options))
} else {
removals.push(passiveProp)
if (i > 0) {
removals.push(...source.getTokensBetween(options.properties[i - 1], passiveProp))
} else {
removals.push(...source.getTokensBetween(passiveProp, options.properties[i + 1]))
}
}
return removals.map(t => fixer.remove(t))
}
})
}
}
}
}
}

View File

@@ -0,0 +1,24 @@
const observerMap = {
scroll: 'IntersectionObserver',
resize: 'ResizeObserver'
}
module.exports = {
meta: {
docs: {},
fixable: 'code'
},
create(context) {
return {
['CallExpression[callee.property.name="addEventListener"]']: function(node) {
const [name] = node.arguments
if (name.type !== 'Literal') return
if (!(name.value in observerMap)) return
context.report({
node,
message: `Avoid using "${name.value}" event listener. Consider using ${observerMap[name.value]} instead`
})
}
}
}
}

View File

@@ -0,0 +1,22 @@
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: {
docs: {}
},
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, `High Frequency Events like "${name.value}" should be \`passive: true\``)
}
}
}
}

View File

@@ -0,0 +1,25 @@
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
})
},
TemplateLiteral(node) {
if (!htmlOpenTag.test(node.quasis[0].value.raw)) return
if (!node.parent.tag || node.parent.tag.name !== 'html') {
context.report({
node,
message
})
}
}
}
}