Files
zeekay 26a9531f7b merge: upstream/main (sync, brand preserved)
# Conflicts:
#	.github/workflows/check-insights-major-version.yml
#	.github/workflows/check-posthog-major-version.yml
#	.github/workflows/ci-security.yaml
#	.github/workflows/validate-versioning.yml
#	AGENTS.md
#	AGENTS.md~upstream_main
#	packages/ai/src/otel/capture.ts
#	packages/ai/src/otel/mappers/aiSdk.ts
#	packages/ai/src/otel/mappers/index.ts
#	packages/ai/src/otel/types.ts
#	packages/core/src/__tests__/posthog.init.spec.ts
#	packages/react-native/src/PostHogProvider.tsx
#	packages/react/src/context/PostHogContext.ts
#	packages/react/src/context/PostHogProvider.tsx
#	tooling/eslint-plugin-insights/no-unsafe-web-global.js
2026-06-02 10:52:56 -07:00

56 lines
2.2 KiB
JavaScript

module.exports = {
create(context) {
const filename = context.getFilename()
const isAllowedFile =
filename.includes('src/entrypoints') ||
filename.includes('src/extensions/replay/external') ||
filename.includes('__tests__') ||
filename.includes('/playwright/')
function isRestrictedImport(importPath) {
// Handle absolute paths with aliases
if (importPath.startsWith('@/') || importPath.startsWith('~/')) {
return importPath.includes('extensions/replay/external')
}
// Handle relative paths
if (importPath.startsWith('./') || importPath.startsWith('../')) {
// For relative paths, check if they contain 'external'
// This matches the test case behavior
return importPath.includes('replay/external')
}
return false
}
return {
ImportDeclaration(node) {
const importPath = node.source.value
if (isRestrictedImport(importPath)) {
if (!isAllowedFile) {
context.report({
node,
message:
'Code from src/extensions/replay/external can only be imported by files in src/extensions/replay/external, src/entrypoints, test files, or playwright specs',
})
}
}
},
ImportExpression(node) {
if (node.source && node.source.type === 'Literal') {
const importPath = node.source.value
if (isRestrictedImport(importPath)) {
if (!isAllowedFile) {
context.report({
node,
message:
'Code from src/extensions/replay/external can only be imported by files in src/extensions/replay/external, src/entrypoints, test files, or playwright specs',
})
}
}
}
},
}
},
}