Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

already-has-placeholder-data-property.cjs

26 lines844 Bytes

1class AlreadyHasPlaceholderDataProperty extends Error {
2 /**
3 * @param {import('jscodeshift').CallExpression} callExpression
4 * @param {string} filePath
5 */
6 constructor(callExpression, filePath) {
7 super('')
8 this.message = this.buildMessage(callExpression, filePath)
9 this.name = 'AlreadyHasPlaceholderDataProperty'
10 }
11​
12 /**
13 * @param {import('jscodeshift').CallExpression} callExpression
14 * @param {string} filePath
15 * @returns {string}
16 */
17 buildMessage(callExpression, filePath) {
18 const location = callExpression.callee.loc
19 const start = location.start.line
20 const end = location.end.line
21​
22 return `The usage in file "${filePath}" at line ${start}:${end} already contains a "placeholderData" property. Please migrate this usage manually.`
23 }
25​
26module.exports = AlreadyHasPlaceholderDataProperty