Files
payload/packages/eslint-plugin/index.mjs
Elliot DeNolf 7aed0d7c2e chore(eslint): payload logger usage (#8578)
Payload uses `pino` for a logger. When using the error logger
`payload.logger.error` it is possible to pass any number of arguments
like this: `payload.logger.error('Some error ocurred', err)`. However,
in this scenario, the full error will not be serialized by `pino`. It
must be passed as the `err` property inside of an object in order to be
properly serialized.

This rule ensures that a user is using this function call to properly serialize the error.
2024-10-06 13:23:30 -07:00

43 lines
1.5 KiB
JavaScript

import noJsxImportStatements from './customRules/no-jsx-import-statements.js'
import noNonRetryableAssertions from './customRules/no-non-retryable-assertions.js'
import noRelativeMonorepoImports from './customRules/no-relative-monorepo-imports.js'
import noImportsFromExportsDir from './customRules/no-imports-from-exports-dir.js'
import noFlakyAssertions from './customRules/no-flaky-assertions.js'
import noImportsFromSelf from './customRules/no-imports-from-self.js'
import properPinoLoggerErrorUsage from './customRules/proper-payload-logger-usage.js'
/**
* @type {import('eslint').ESLint.Plugin}
*/
const index = {
rules: {
'no-jsx-import-statements': noJsxImportStatements,
'no-relative-monorepo-imports': noRelativeMonorepoImports,
'no-imports-from-exports-dir': noImportsFromExportsDir,
'no-imports-from-self': noImportsFromSelf,
'proper-payload-logger-usage': properPinoLoggerErrorUsage,
// Testing-related
'no-non-retryable-assertions': noNonRetryableAssertions,
'no-flaky-assertions': noFlakyAssertions,
'no-wait-function': {
create: function (context) {
return {
CallExpression(node) {
// Check if the function being called is named "wait"
if (node.callee.name === 'wait') {
context.report({
node,
message:
'Usage of "wait" function is discouraged as it\'s flaky. Proper assertions should be used instead.',
})
}
},
}
},
},
},
}
export default index