Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add restricted import rule for Sentry pkg #1700

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilly-geckos-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-config-saleor": patch
---

Add restricted import rule for importing Sentry package.
5 changes: 5 additions & 0 deletions apps/segment/src/pages/api/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createManifestHandler } from "@saleor/app-sdk/handlers/next";
import { AppManifest } from "@saleor/app-sdk/types";
import { wrapWithLoggerContext } from "@saleor/apps-logger/node";
import { captureException } from "@sentry/nextjs";

import { env } from "@/env";
import { loggerContext } from "@/logger-context";
Expand All @@ -14,6 +15,10 @@ export default wrapWithLoggerContext(
const iframeBaseUrl = env.APP_IFRAME_BASE_URL ?? appBaseUrl;
const apiBaseURL = env.APP_API_BASE_URL ?? appBaseUrl;

const error = new Error("Test error - checking if importing sentry works");

captureException(error);

const manifest: AppManifest = {
about: "Seamlessly feed Twillo Segment with Saleor events",
appUrl: iframeBaseUrl,
Expand Down
7 changes: 7 additions & 0 deletions packages/eslint-config-saleor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ module.exports = {
"error",
{ name: "@saleor/apps-logger", message: "Use your app logger directly" },
],
"no-restricted-syntax": [
"error",
{
selector: "ImportDeclaration[source.value='@sentry/nextjs'] > ImportDefaultSpecifier",
message: "Use `import * as Sentry from '@sentry/nextjs';`",
Comment on lines +41 to +42
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add comment with docs why this rule should be used?

},
],
},
parserOptions: {
babelOptions: {
Expand Down
Loading