feat(eslint+ci): R40 boundary rule for @sentry/* + R31 sendDefaultPii grep gate
Adds two flat-config blocks to core-eslint/base.js: (1) repo-wide
no-restricted-imports for @sentry/* with the R40 message, (2) an
allowlist override for the only paths permitted to import the Sentry
SDK directly — core-shared/instrumentation/sentry/**, the bind-sentry
DI files, the no-sentry test guards, and apps' instrumentation* /
next.config / vite.config / sentry.*.config files. Patterns use
**/-prefix so they match whether ESLint runs from the repo root or
from inside a sub-package.
Also adds the standard `argsIgnorePattern: "^_"` config (used
throughout the repo) and a Node-globals override for *.mjs/*.cjs/*.js
and *.config.{ts,tsx} so withSentryConfig in next.config.mjs lints
clean. Required adding `globals` as a core-eslint dep.
Adds .github/workflows/sentry-pii-guard.yml — a lightweight CI step
that fails any PR introducing `sendDefaultPii: true` (R31). Excludes
node_modules / dist / .next / .turbo from the grep so vendored SDK
JSDoc examples don't false-positive.
Pre-existing lint nits cleared as part of getting `pnpm lint` green:
- core-testing define-contract-suite.test.ts: void the unused
receivedTracer (mirrors the next test's pattern)
- marketing-pages bind-dev-seed.ts: drop unused MockSiteSettingsRepository
import
- marketing-pages get-site-settings.use-case.ts: drop the now-redundant
eslint-disable for `_input`
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,10 +3,17 @@ import eslintConfigPrettier from "eslint-config-prettier";
|
||||
import tseslint from "typescript-eslint";
|
||||
import turboPlugin from "eslint-plugin-turbo";
|
||||
import boundaries from "eslint-plugin-boundaries";
|
||||
import globals from "globals";
|
||||
|
||||
export default [
|
||||
{ ignores: ["dist/**", "node_modules/**", ".next/**", ".turbo/**", "storybook-static/**"] },
|
||||
js.configs.recommended,
|
||||
{
|
||||
files: ["**/*.{mjs,cjs,js}", "**/*.config.{ts,tsx}"],
|
||||
languageOptions: {
|
||||
globals: { ...globals.node },
|
||||
},
|
||||
},
|
||||
...tseslint.configs.recommended,
|
||||
eslintConfigPrettier,
|
||||
{
|
||||
@@ -15,6 +22,19 @@ export default [
|
||||
"turbo/no-undeclared-env-vars": "warn",
|
||||
},
|
||||
},
|
||||
{
|
||||
rules: {
|
||||
// Honour the leading-underscore convention for intentionally-unused params/vars.
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{
|
||||
argsIgnorePattern: "^_",
|
||||
varsIgnorePattern: "^_",
|
||||
caughtErrorsIgnorePattern: "^_",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
plugins: { boundaries },
|
||||
settings: {
|
||||
@@ -45,4 +65,42 @@ export default [
|
||||
],
|
||||
},
|
||||
},
|
||||
// R40 — block direct @sentry/* imports outside the allowlisted instrumentation paths
|
||||
{
|
||||
files: ["**/*.{ts,tsx,mjs,cjs,js}"],
|
||||
rules: {
|
||||
"no-restricted-imports": [
|
||||
"error",
|
||||
{
|
||||
patterns: [
|
||||
{
|
||||
group: ["@sentry/*"],
|
||||
message:
|
||||
"Import from @repo/core-shared/instrumentation instead — feature packages must not depend on Sentry directly (R40).",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
// R40 allowlist — the only paths permitted to import @sentry/*.
|
||||
// Patterns are double-star prefixed so they match whether eslint runs from
|
||||
// the repo root or from inside a sub-package.
|
||||
{
|
||||
files: [
|
||||
"**/instrumentation/sentry/**",
|
||||
"**/instrumentation/di/bind-sentry-instrumentation.{ts,js}",
|
||||
"**/instrumentation/di/bind-sentry-instrumentation.test.{ts,js}",
|
||||
"**/setup/no-sentry.{ts,js}",
|
||||
"**/setup/no-sentry.test.{ts,js}",
|
||||
"**/instrumentation.{ts,js,mjs}",
|
||||
"**/instrumentation-client.{ts,js,mjs}",
|
||||
"**/next.config.{mjs,ts,js}",
|
||||
"**/vite.config.{ts,mjs,js}",
|
||||
"**/sentry.*.config.{ts,mjs,js}",
|
||||
],
|
||||
rules: {
|
||||
"no-restricted-imports": "off",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -17,5 +17,8 @@
|
||||
"eslint-plugin-boundaries": "^4.2.2",
|
||||
"eslint-plugin-turbo": "^2.4.0",
|
||||
"typescript-eslint": "^8.25.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"globals": "^17.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ describe("defineContractSuite — getTracer plumbing (R50)", () => {
|
||||
// Vitest defers actual assertion to the `it`; we verify the wiring by re-reading after.
|
||||
// (This is a meta-test of plumbing only — the inner it() runs as a child describe.)
|
||||
expect(typeof tracer.startSpan).toBe("function");
|
||||
void receivedTracer;
|
||||
});
|
||||
|
||||
it("getTracer is undefined when opts.tracer not provided (backward compat)", () => {
|
||||
|
||||
@@ -16,7 +16,6 @@ export type IGetSiteSettingsUseCase = ReturnType<typeof getSiteSettingsUseCase>;
|
||||
|
||||
export const getSiteSettingsUseCase =
|
||||
(siteSettingsRepository: ISiteSettingsRepository) =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async (_input: GetSiteSettingsInput): Promise<GetSiteSettingsOutput> => {
|
||||
const result = await siteSettingsRepository.getSiteSettings();
|
||||
return getSiteSettingsOutputSchema.parse(result);
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
import { marketingPagesContainer } from "./container.js";
|
||||
import { MARKETING_PAGES_SYMBOLS } from "./symbols.js";
|
||||
import { MockPagesRepository } from "../infrastructure/repositories/pages.repository.mock.js";
|
||||
import { MockSiteSettingsRepository } from "../infrastructure/repositories/site-settings.repository.mock.js";
|
||||
import { buildDevPages, buildDevSiteSettings } from "../__seeds__/dev.js";
|
||||
import { getSiteSettingsUseCase } from "../application/use-cases/get-site-settings.use-case.js";
|
||||
import { getPageBySlugUseCase } from "../application/use-cases/get-page-by-slug.use-case.js";
|
||||
|
||||
Reference in New Issue
Block a user