refactor start

This commit is contained in:
Spectre 2025-02-18 11:19:45 +01:00
parent bd49791e06
commit e46d25f0b7
16699 changed files with 2 additions and 1484887 deletions

View file

@ -1,70 +0,0 @@
'use strict'
const getDocsUrl = require('./lib/get-docs-url')
const {
isPromiseConstructorWithInlineExecutor,
} = require('./lib/is-promise-constructor')
module.exports = {
meta: {
type: 'suggestion',
docs: {
description:
'Enforce consistent param names and ordering when creating new promises.',
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,
},
})
}
}
},
}
},
}