Skip to content

Commit 6f18d89

Browse files
authored
ref(✂️): include nsExports in knip analysis (#95235)
when something is imported as as namespace in `knip` (`import * as foo from './foo'`), and no additional direct property is accessed on that imported namespace, the whole namespace counts as being used. we often import a namespace completely in tests to mock a certain property, which hides some unused things. to enforce Knip to consider each export on a namespace individually, we can set `include: ['nsExports']`, which is what this PR does. see https://knip.dev/guides/namespace-imports
1 parent 8c46826 commit 6f18d89

File tree

7 files changed

+11
-36
lines changed

7 files changed

+11
-36
lines changed

knip.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ const config: KnipConfig = {
8181
enumMembers: 'off',
8282
unlisted: 'off',
8383
},
84+
include: ['nsExports', 'nsTypes'],
8485
};
8586

8687
export default config;

static/app/actionCreators/group.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ type FetchIssueTagValuesParameters = {
310310
sort?: string | string[];
311311
};
312312

313-
export const makeFetchIssueTagValuesQueryKey = ({
313+
const makeFetchIssueTagValuesQueryKey = ({
314314
orgSlug,
315315
groupId,
316316
tagKey,
@@ -339,7 +339,7 @@ type FetchIssueTagParameters = {
339339
tagKey: string;
340340
};
341341

342-
export const makeFetchIssueTagQueryKey = ({
342+
const makeFetchIssueTagQueryKey = ({
343343
orgSlug,
344344
groupId,
345345
tagKey,

static/app/components/events/contexts/contextIcon.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ const LOGO_MAPPING = {
111111
xbox: logoXbox,
112112
};
113113

114+
/** @internal used in stories **/
114115
export const NAMES = Object.keys(LOGO_MAPPING);
115116

116117
// The icons in this list will be inverted when the theme is set to dark mode

static/app/components/group/groupSummary.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export interface GroupSummaryData {
3232
whatsWrong?: string | null;
3333
}
3434

35-
export const makeGroupSummaryQueryKey = (
35+
const makeGroupSummaryQueryKey = (
3636
organizationSlug: string,
3737
groupId: string,
3838
eventId?: string
@@ -59,7 +59,7 @@ export function useGroupSummaryData(group: Group) {
5959
return {data, isPending};
6060
}
6161

62-
export function useGroupSummary(
62+
function useGroupSummary(
6363
group: Group,
6464
event: Event | null | undefined,
6565
project: Project,

static/app/constants/index.tsx

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const ORG_ROLES: OrgRole[] = [
114114
},
115115
];
116116

117-
export type PermissionChoice = {
117+
type PermissionChoice = {
118118
label: 'No Access' | 'Read' | 'Read & Write' | 'Admin';
119119
scopes: Scope[];
120120
};
@@ -215,17 +215,6 @@ export const DEFAULT_DEBOUNCE_DURATION = 300;
215215

216216
export const ALL_ENVIRONMENTS_KEY = '__all_environments__';
217217

218-
// Maps a `type: string` -> `url-prefix: string`
219-
export const AVATAR_URL_MAP = {
220-
team: 'team-avatar',
221-
organization: 'organization-avatar',
222-
project: 'project-avatar',
223-
user: 'avatar',
224-
sentryAppColor: 'sentry-app-avatar',
225-
sentryAppSimple: 'sentry-app-avatar',
226-
docIntegration: 'doc-integration-avatar',
227-
};
228-
229218
export const MENU_CLOSE_DELAY = 200;
230219

231220
export const SLOW_TOOLTIP_DELAY = 1000;
@@ -237,8 +226,6 @@ export const DEFAULT_STATS_PERIOD = '14d';
237226
export const DEFAULT_QUERY = 'is:unresolved issue.priority:[high, medium]';
238227
export const TAXONOMY_DEFAULT_QUERY = 'is:unresolved';
239228

240-
export const DEFAULT_USE_UTC = true;
241-
242229
export const DEFAULT_RELATIVE_PERIODS = {
243230
'1h': t('Last hour'),
244231
'24h': t('Last 24 hours'),
@@ -248,14 +235,6 @@ export const DEFAULT_RELATIVE_PERIODS = {
248235
'90d': t('Last 90 days'),
249236
};
250237

251-
export const DEFAULT_RELATIVE_PERIODS_PAGE_FILTER = {
252-
'1h': t('1H'),
253-
'24h': t('24H'),
254-
'7d': t('7D'),
255-
'14d': t('14D'),
256-
'30d': t('30D'),
257-
};
258-
259238
const DEFAULT_STATS_INFO = {
260239
showExternalStats: false,
261240
showInternalStats: true,
@@ -587,10 +566,6 @@ export const MAX_AUTOCOMPLETE_RELEASES = 5;
587566

588567
export const DEFAULT_PER_PAGE = 50;
589568

590-
// Limit query length so paginated response headers don't
591-
// go over HTTP header size limits (4Kb)
592-
export const MAX_QUERY_LENGTH = 400;
593-
594569
// Webpack configures DEPLOY_PREVIEW_CONFIG for deploy preview builds.
595570
export const DEPLOY_PREVIEW_CONFIG = process.env.DEPLOY_PREVIEW_CONFIG as unknown as
596571
| undefined
@@ -622,8 +597,6 @@ export const CONFIG_DOCS_URL = 'https://develop.sentry.dev/config/';
622597
export const DISCOVER2_DOCS_URL = 'https://docs.sentry.io/product/discover-queries/';
623598
export const SPAN_PROPS_DOCS_URL =
624599
'https://docs.sentry.io/concepts/search/searchable-properties/spans/';
625-
export const LOGS_PROPS_DOCS_URL =
626-
'https://docs.sentry.io/concepts/search/searchable-properties/logs/';
627600

628601
export const IS_ACCEPTANCE_TEST = !!process.env.IS_ACCEPTANCE_TEST;
629602
export const NODE_ENV = process.env.NODE_ENV;

static/app/utils/performanceForSentry/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export {Profiler};
2222
* It depends on where it is called but the way we fetch transactions can be empty despite an ongoing transaction existing.
2323
* This will return an interaction-type transaction held onto by a class static if one exists.
2424
*/
25-
export function getPerformanceTransaction(): Span | undefined {
25+
function getPerformanceTransaction(): Span | undefined {
2626
const span = PerformanceInteraction.getSpan();
2727
if (span) {
2828
return span;
@@ -523,7 +523,7 @@ export const setGroupedEntityTag = (
523523
Sentry.setTag(`${tagName}.grouped`, `<=${groups.find(g => n <= g)}`);
524524
};
525525

526-
export const addSlowAppInit = (transaction: TransactionEvent) => {
526+
const addSlowAppInit = (transaction: TransactionEvent) => {
527527
const appInitSpan = transaction.spans?.find(
528528
s => s.description === 'sentry-tracing-init'
529529
);

static/app/views/discover/savedQuery/utils.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export function handleResetHomepageQuery(api: Client, organization: Organization
224224
});
225225
}
226226

227-
export function getAnalyticsCreateEventKeyName(
227+
function getAnalyticsCreateEventKeyName(
228228
// True if this is a brand new query being saved
229229
// False if this is a modification from a saved query
230230
isNewQuery: boolean,
@@ -241,7 +241,7 @@ export function getAnalyticsCreateEventKeyName(
241241
* Takes in a DiscoverV2 NewQuery object and returns a Partial containing
242242
* the desired fields to populate into reload analytics
243243
*/
244-
export function extractAnalyticsQueryFields(payload: NewQuery): Partial<NewQuery> {
244+
function extractAnalyticsQueryFields(payload: NewQuery): Partial<NewQuery> {
245245
const {projects, fields, query} = payload;
246246
return {
247247
projects,

0 commit comments

Comments
 (0)