{"record":{"id":"50b53ca91f9ff00d","repo":"avajs/ava","slug":"factory-method-exported-by-fileforerrormessage","errorCode":null,"errorMessage":"Factory method exported by ${fileForErrorMessage} must return a plain object","messagePattern":"Factory method exported by (.+?) must return a plain object","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/load-config.js","lineNumber":146,"sourceCode":"\t\tthrow new Error(`Conflicting configuration in ${fileForErrorMessage} and ${conflicting.map(({fileForErrorMessage}) => fileForErrorMessage).join(' & ')}`);\n\t}\n\n\tif (fileConf !== NO_SUCH_FILE) {\n\t\tif (allowConflictWithPackageJson) {\n\t\t\tpackageConf = {};\n\t\t} else if (Object.keys(packageConf).length > 0) {\n\t\t\tthrow new Error(`Conflicting configuration in ${fileForErrorMessage} and package.json`);\n\t\t}\n\n\t\tif (!isPlainObject(fileConf) && typeof fileConf !== 'function') {\n\t\t\tthrow new TypeError(`${fileForErrorMessage} must export a plain object or factory function`);\n\t\t}\n\n\t\tif (typeof fileConf === 'function') {\n\t\t\tfileConf = await fileConf({projectDir});\n\n\t\t\tif (!isPlainObject(fileConf)) {\n\t\t\t\tthrow new TypeError(`Factory method exported by ${fileForErrorMessage} must return a plain object`);\n\t\t\t}\n\t\t}\n\n\t\tif ('ava' in fileConf) {\n\t\t\tthrow new Error(`Encountered ’ava’ property in ${fileForErrorMessage}; avoid wrapping the configuration`);\n\t\t}\n\t}\n\n\tconst config = {\n\t\t...defaults, nonSemVerExperiments: {}, ...fileConf, ...packageConf, projectDir, configFile,\n\t};\n\n\tif (\n\t\t'filterNodeArgumentsForWorkerThreads' in config\n\t\t&& typeof config.filterNodeArgumentsForWorkerThreads !== 'function'\n\t) {\n\t\tthrow new Error(`filterNodeArgumentsForWorkerThreads from ${fileForErrorMessage} must be a function`);\n\t}","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/load-config.js#L128-L164","documentation":"Guard in loadConfig: the configuration file exports a factory function, but its return value is not a plain object. The input at fault is the value returned by the exported factory — class instances, arrays, Maps, or primitives are rejected.","triggerScenarios":"Thrown at lib/load-config.js:146 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Have the factory return a plain object literal (module.exports = () => ({files: [...]}))","Remove class instances, Maps, or Sets from the returned config","If no factory is needed, export a plain object directly"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bbfd946322fdeca2b547a691d947fb4e18c0c67f","analyzedAt":"2026-09-02T01:24:43.834Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}