Skip to content

Commit a9c02a3

Browse files
committed
🚨 fix lint errors in PR-title check and shared gitmoji module
- gate the script entry point with NODE_TEST_CONTEXT so the local disallow-non-scripts rule recognizes the top-level runMain() - switch ReadonlyArray<T> to readonly T[] (array-type rule) - single-quote two non-template strings
1 parent 004679b commit a9c02a3

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

scripts/check-pr-title.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function formatAllowedPrefixes(): string {
1010
return GITMOJI.map(({ emoji, label }) => ` ${emoji} ${label}`).join('\n')
1111
}
1212

13-
if (import.meta.main) {
13+
if (!process.env.NODE_TEST_CONTEXT) {
1414
runMain(() => {
1515
const title = process.env.PR_TITLE
1616
if (title === undefined) {
@@ -23,10 +23,10 @@ if (import.meta.main) {
2323
}
2424

2525
printError(
26-
`PR title must start with one of the allowed gitmoji prefixes.\n\n` +
26+
'PR title must start with one of the allowed gitmoji prefixes.\n\n' +
2727
`Current title: ${title}\n\n` +
2828
`Allowed prefixes:\n${formatAllowedPrefixes()}\n\n` +
29-
`See docs/DEVELOPMENT.md for the full convention.`
29+
'See docs/DEVELOPMENT.md for the full convention.'
3030
)
3131
process.exit(1)
3232
})

scripts/lib/gitmoji.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface Gitmoji {
99
category: GitmojiCategory
1010
}
1111

12-
export const GITMOJI: ReadonlyArray<Gitmoji> = [
12+
export const GITMOJI: readonly Gitmoji[] = [
1313
// User-facing changes
1414
{ emoji: '💥', label: 'Breaking change', category: 'public' },
1515
{ emoji: '✨', label: 'New feature', category: 'public' },
@@ -35,9 +35,9 @@ export const GITMOJI: ReadonlyArray<Gitmoji> = [
3535
const VARIATION_SELECTOR = //g
3636
export const normalizeGitmoji = (value: string): string => value.replace(VARIATION_SELECTOR, '')
3737

38-
export const PUBLIC_EMOJI_PRIORITY: ReadonlyArray<string> = GITMOJI.filter((g) => g.category === 'public').map(
38+
export const PUBLIC_EMOJI_PRIORITY: readonly string[] = GITMOJI.filter((g) => g.category === 'public').map(
3939
(g) => g.emoji
4040
)
41-
export const INTERNAL_EMOJI_PRIORITY: ReadonlyArray<string> = GITMOJI.filter((g) => g.category === 'internal').map(
41+
export const INTERNAL_EMOJI_PRIORITY: readonly string[] = GITMOJI.filter((g) => g.category === 'internal').map(
4242
(g) => g.emoji
4343
)

scripts/release/generate-changelog/lib/addNewChangesToChangelog.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ function getLastReleaseTagName(): string {
9898
return match[1]
9999
}
100100

101-
function sortByEmojiPriority(a: string, b: string, priorityList: ReadonlyArray<string>): number {
101+
function sortByEmojiPriority(a: string, b: string, priorityList: readonly string[]): number {
102102
const getFirstRelevantEmojiIndex = (text: string): number => {
103103
const emoji = findFirstEmoji(text)
104104
return emoji && priorityList.includes(emoji) ? priorityList.indexOf(emoji) : Number.MAX_VALUE
105105
}
106106
return getFirstRelevantEmojiIndex(a) - getFirstRelevantEmojiIndex(b)
107107
}
108108

109-
function formatChangeList(title: string, changes: string[], priority: ReadonlyArray<string>): string {
109+
function formatChangeList(title: string, changes: string[], priority: readonly string[]): string {
110110
if (!changes.length) {
111111
return ''
112112
}

0 commit comments

Comments
 (0)