diff --git a/.cursorindexingignore b/.cursorindexingignore new file mode 100644 index 00000000000..953908e7300 --- /dev/null +++ b/.cursorindexingignore @@ -0,0 +1,3 @@ + +# Don't index SpecStory auto-save files, but allow explicit context inclusion via @ references +.specstory/** diff --git a/.specstory/.gitignore b/.specstory/.gitignore new file mode 100644 index 00000000000..53b537f48a2 --- /dev/null +++ b/.specstory/.gitignore @@ -0,0 +1,2 @@ +# SpecStory explanation file +/.what-is-this.md diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts index c5ca3434b1b..c6785c85e35 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts @@ -88,6 +88,7 @@ import { validateNoRefAccessInRender, validateNoSetStateInRender, validatePreservedManualMemoization, + validateSourceLocations, validateUseMemo, } from '../Validation'; import {validateLocalsNotReassignedAfterRender} from '../Validation/ValidateLocalsNotReassignedAfterRender'; @@ -574,6 +575,12 @@ function runWithEnvironment( log({kind: 'ast', name: 'Codegen (outlined)', value: outlined.fn}); } + console.debug(ast); + + if (env.config.validateSourceLocations) { + validateSourceLocations(ast).unwrap(); + } + /** * This flag should be only set for unit / fixture tests to check * that Forget correctly handles unexpected errors (e.g. exceptions diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts index 90a352620ce..b226cecfe81 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts @@ -369,6 +369,13 @@ export const EnvironmentConfigSchema = z.object({ */ validateNoFreezingKnownMutableFunctions: z.boolean().default(false), + /** + * Validates that all AST nodes generated during codegen have proper source locations. + * This is useful for debugging issues with source maps and Istanbul coverage. + * When enabled, the compiler will error if any AST node is missing a location. + */ + validateSourceLocations: z.boolean().default(false), + /* * When enabled, the compiler assumes that hooks follow the Rules of React: * - Hooks may memoize computation based on any of their parameters, thus diff --git a/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateSourceLocations.ts b/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateSourceLocations.ts new file mode 100644 index 00000000000..4eeb16c7a86 --- /dev/null +++ b/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateSourceLocations.ts @@ -0,0 +1,84 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import * as t from '@babel/types'; +import {CompilerError, ErrorSeverity} from '..'; +import {CodegenFunction} from '../ReactiveScopes'; +import {Result} from '../Utils/Result'; + +/** + * Validates that all AST nodes have proper source locations. + * This is useful for debugging issues with source maps and Istanbul coverage. + */ +export function validateSourceLocations( + ast: CodegenFunction, +): Result { + const errors = new CompilerError(); + const missingLocations: Array<{node: t.Node; path: string}> = []; + + function checkNode(node: t.Node, path: string): void { + if (node.loc == null) { + missingLocations.push({node, path}); + } + + // Recursively check all child nodes + for (const [key, value] of Object.entries(node)) { + if (value && typeof value === 'object') { + if (Array.isArray(value)) { + // Handle arrays of nodes + for (let i = 0; i < value.length; i++) { + const item = value[i]; + if (item && typeof item === 'object' && 'type' in item) { + checkNode(item as t.Node, `${path}.${key}[${i}]`); + } + } + } else if ('type' in value) { + // Handle single node + checkNode(value as t.Node, `${path}.${key}`); + } + } + } + } + + // Check the main function's AST components + if (ast.id) { + checkNode(ast.id, 'ast.id'); + } + + // Check parameters + for (let i = 0; i < ast.params.length; i++) { + checkNode(ast.params[i], `ast.params[${i}]`); + } + + // Check body + checkNode(ast.body, 'ast.body'); + + // Check outlined functions + for (let i = 0; i < ast.outlined.length; i++) { + const outlined = ast.outlined[i]; + if (outlined.fn.id) { + checkNode(outlined.fn.id, `ast.outlined[${i}].fn.id`); + } + for (let j = 0; j < outlined.fn.params.length; j++) { + checkNode(outlined.fn.params[j], `ast.outlined[${i}].fn.params[${j}]`); + } + checkNode(outlined.fn.body, `ast.outlined[${i}].fn.body`); + } + + // Report errors for missing locations + for (const {node, path} of missingLocations) { + errors.push({ + severity: ErrorSeverity.Todo, + reason: 'AST node is missing source location', + description: `Node at path "${path}" (type: ${node.type}) is missing a location. This can cause issues with source maps and coverage tools.`, + loc: null, + suggestions: null, + }); + } + + return errors.asResult(); +} diff --git a/compiler/packages/babel-plugin-react-compiler/src/Validation/index.ts b/compiler/packages/babel-plugin-react-compiler/src/Validation/index.ts index 3bf03f362fa..44abf3241d3 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/Validation/index.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/Validation/index.ts @@ -12,4 +12,5 @@ export {validateNoCapitalizedCalls} from './ValidateNoCapitalizedCalls'; export {validateNoRefAccessInRender} from './ValidateNoRefAccessInRender'; export {validateNoSetStateInRender} from './ValidateNoSetStateInRender'; export {validatePreservedManualMemoization} from './ValidatePreservedManualMemoization'; +export {validateSourceLocations} from './ValidateSourceLocations'; export {validateUseMemo} from './ValidateUseMemo'; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-missing-source-locations.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-missing-source-locations.expect.md new file mode 100644 index 00000000000..7795fe8a769 --- /dev/null +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-missing-source-locations.expect.md @@ -0,0 +1,294 @@ + +## Input + +```javascript +// @validateSourceLocations +import {useEffect} from 'react'; + +function Component({prop1, prop2}) { + const x = prop1 + prop2; + const y = x * 2; + const arr = [x, y]; + const [a, b] = arr; + + useEffect(() => { + if (a > 10) { + console.log(a); + } + }, [a]); + + return y; +} + +``` + + +## Error + +``` +Todo: AST node is missing source location. Node at path "ast.id" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.params[0]" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body" (type: BlockStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[0]" (type: VariableDeclaration) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[0].declarations[0]" (type: VariableDeclarator) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[0].declarations[0].id" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[0].declarations[0].init" (type: CallExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[0].declarations[0].init.callee" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[0].declarations[0].init.arguments[0]" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[1].declarations[0]" (type: VariableDeclarator) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[1].declarations[0].id" (type: ObjectPattern) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[1].declarations[0].id.properties[0]" (type: ObjectProperty) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[1].declarations[0].id.properties[0].key" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[1].declarations[0].id.properties[0].value" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[1].declarations[0].id.properties[1]" (type: ObjectProperty) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[1].declarations[0].id.properties[1].key" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[1].declarations[0].id.properties[1].value" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[2].declarations[0]" (type: VariableDeclarator) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[2].declarations[0].id" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[3].declarations[0]" (type: VariableDeclarator) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[3].declarations[0].id" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[3].declarations[0].init.right" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[4]" (type: VariableDeclaration) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[4].declarations[0]" (type: VariableDeclarator) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[4].declarations[0].id" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5]" (type: IfStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].test" (type: LogicalExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].test.left" (type: BinaryExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].test.left.left" (type: MemberExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].test.left.left.object" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].test.left.left.property" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].test.left.right" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].test.right" (type: BinaryExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].test.right.left" (type: MemberExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].test.right.left.object" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].test.right.left.property" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].test.right.right" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent" (type: BlockStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[0].expression" (type: AssignmentExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[0].expression.left" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[0].expression.right" (type: ArrayExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[1]" (type: ExpressionStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[1].expression" (type: AssignmentExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[1].expression.left" (type: MemberExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[1].expression.left.object" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[1].expression.left.property" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[1].expression.right" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[2]" (type: ExpressionStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[2].expression" (type: AssignmentExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[2].expression.left" (type: MemberExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[2].expression.left.object" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[2].expression.left.property" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[2].expression.right" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[3]" (type: ExpressionStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[3].expression" (type: AssignmentExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[3].expression.left" (type: MemberExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[3].expression.left.object" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[3].expression.left.property" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].consequent.body[3].expression.right" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].alternate" (type: BlockStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].alternate.body[0]" (type: ExpressionStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].alternate.body[0].expression" (type: AssignmentExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].alternate.body[0].expression.left" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].alternate.body[0].expression.right" (type: MemberExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].alternate.body[0].expression.right.object" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[5].alternate.body[0].expression.right.property" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[6].declarations[0]" (type: VariableDeclarator) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[6].declarations[0].id" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[7].declarations[0]" (type: VariableDeclarator) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[7].declarations[0].id" (type: ArrayPattern) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[7].declarations[0].id.elements[0]" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[8]" (type: VariableDeclaration) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[8].declarations[0]" (type: VariableDeclarator) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[8].declarations[0].id" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[9]" (type: VariableDeclaration) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[9].declarations[0]" (type: VariableDeclarator) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[9].declarations[0].id" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10]" (type: IfStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].test" (type: BinaryExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].test.left" (type: MemberExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].test.left.object" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].test.left.property" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].test.right" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent" (type: BlockStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[0].expression" (type: AssignmentExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[0].expression.left" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[0].expression.right" (type: ArrowFunctionExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[0].expression.right.body" (type: BlockStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[0].expression.right.body.body[0]" (type: IfStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[0].expression.right.body.body[0].test.right" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[0].expression.right.body.body[0].consequent" (type: BlockStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[0].expression.right.body.body[0].consequent.body[0]" (type: ExpressionStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[0].expression.right.body.body[0].consequent.body[0].expression.callee" (type: MemberExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[0].expression.right.body.body[0].consequent.body[0].expression.callee.object" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[0].expression.right.body.body[0].consequent.body[0].expression.callee.property" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[1].expression" (type: AssignmentExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[1].expression.left" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[1].expression.right" (type: ArrayExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[2]" (type: ExpressionStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[2].expression" (type: AssignmentExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[2].expression.left" (type: MemberExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[2].expression.left.object" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[2].expression.left.property" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[2].expression.right" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[3]" (type: ExpressionStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[3].expression" (type: AssignmentExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[3].expression.left" (type: MemberExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[3].expression.left.object" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[3].expression.left.property" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[3].expression.right" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[4]" (type: ExpressionStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[4].expression" (type: AssignmentExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[4].expression.left" (type: MemberExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[4].expression.left.object" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[4].expression.left.property" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].consequent.body[4].expression.right" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].alternate" (type: BlockStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].alternate.body[0]" (type: ExpressionStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].alternate.body[0].expression" (type: AssignmentExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].alternate.body[0].expression.left" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].alternate.body[0].expression.right" (type: MemberExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].alternate.body[0].expression.right.object" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].alternate.body[0].expression.right.property" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].alternate.body[1]" (type: ExpressionStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].alternate.body[1].expression" (type: AssignmentExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].alternate.body[1].expression.left" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].alternate.body[1].expression.right" (type: MemberExpression) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].alternate.body[1].expression.right.object" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[10].alternate.body[1].expression.right.property" (type: NumericLiteral) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[11]" (type: ExpressionStatement) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[11].expression.callee" (type: Identifier) is missing a location. This can cause issues with source maps and coverage tools. + +Todo: AST node is missing source location. Node at path "ast.body.body[12]" (type: ReturnStatement) is missing a location. This can cause issues with source maps and coverage tools. +``` + + \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-missing-source-locations.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-missing-source-locations.js new file mode 100644 index 00000000000..9d865ffc93b --- /dev/null +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-missing-source-locations.js @@ -0,0 +1,17 @@ +// @validateSourceLocations +import {useEffect} from 'react'; + +function Component({prop1, prop2}) { + const x = prop1 + prop2; + const y = x * 2; + const arr = [x, y]; + const [a, b] = arr; + + useEffect(() => { + if (a > 10) { + console.log(a); + } + }, [a]); + + return y; +} diff --git a/compiler/yarn.lock b/compiler/yarn.lock index 6e1bc7feeb3..399401119c0 100644 --- a/compiler/yarn.lock +++ b/compiler/yarn.lock @@ -542,11 +542,6 @@ resolved "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz" integrity sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA== -"@babel/helper-string-parser@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz#54da796097ab19ce67ed9f88b47bb2ec49367687" - integrity sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA== - "@babel/helper-validator-identifier@^7.19.1", "@babel/helper-validator-identifier@^7.25.9": version "7.25.9" resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz" @@ -1605,7 +1600,7 @@ debug "^4.3.1" globals "^11.1.0" -"@babel/types@^7.0.0", "@babel/types@^7.19.0", "@babel/types@^7.2.0", "@babel/types@^7.2.2", "@babel/types@^7.20.2", "@babel/types@^7.20.7", "@babel/types@^7.21.2", "@babel/types@^7.24.7", "@babel/types@^7.25.9", "@babel/types@^7.26.0", "@babel/types@^7.26.3", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4", "@babel/types@^7.7.4": +"@babel/types@7.26.3", "@babel/types@^7.0.0", "@babel/types@^7.19.0", "@babel/types@^7.2.0", "@babel/types@^7.2.2", "@babel/types@^7.20.2", "@babel/types@^7.20.7", "@babel/types@^7.21.2", "@babel/types@^7.24.7", "@babel/types@^7.25.9", "@babel/types@^7.26.0", "@babel/types@^7.26.10", "@babel/types@^7.26.3", "@babel/types@^7.27.0", "@babel/types@^7.27.1", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4", "@babel/types@^7.7.4": version "7.26.3" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.26.3.tgz#37e79830f04c2b5687acc77db97fbc75fb81f3c0" integrity sha512-vN5p+1kl59GVKMvTHt55NzzmYVxprfJD+ql7U9NFIfKCBkYE55LYtS+WtPlaYOyzydrKI8Nezd+aZextrd+FMA== @@ -1613,14 +1608,6 @@ "@babel/helper-string-parser" "^7.25.9" "@babel/helper-validator-identifier" "^7.25.9" -"@babel/types@^7.26.10", "@babel/types@^7.27.0", "@babel/types@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.27.1.tgz#9defc53c16fc899e46941fc6901a9eea1c9d8560" - integrity sha512-+EzkxvLNfiUeKMgy/3luqfsCWFRXLb7U6wNQTk60tovuckwB15B191tJWvpp4HjiQWdJkCxO3Wbvc6jlk3Xb2Q== - dependencies: - "@babel/helper-string-parser" "^7.27.1" - "@babel/helper-validator-identifier" "^7.27.1" - "@bcoe/v8-coverage@^0.2.3": version "0.2.3" resolved "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz"