Skip to content
Source
Sign inSign up
TanStack/showcase
A read-only demo of every feature
Every page of this repository is open, and nothing can change. Take a guided tour of what TanStack Source does.

fix: refuse a negative priority in addTask #5

MergedAlemTuzlakmerged 3 commits intomain fromfix/negative-prioritymerged by AlemTuzlak

Showing 3 changed files with 11 additions and 6 deletions.

x
0 of 3 viewed, 3 left
6 additions and 6 deletions.source/workflows/ci.tsModified
View file
@@ -1,9 +1,9 @@
import { defineWorkflow, pullRequest, push, setup } from '@tanstack-source/ci'
​
+// A job reaches only the hosts that it lists. pnpm and the packages come from the npm registry.
+const egress = ['registry.npmjs.org']
+const install = [setup.node(), setup.pnpm(), { name: 'Install dependencies', run: 'pnpm install --frozen-lockfile' }]
+​
export default defineWorkflow('ci', { on: [pullRequest({ branches: ['main'] }), push({ branches: ['main'] })] })
- .job('types', {
- steps: [setup.node(), setup.pnpm(), { name: 'Install dependencies', run: 'pnpm install --frozen-lockfile' }, { name: 'Check the types', run: 'pnpm typecheck' }],
- })
- .job('test', {
- steps: [setup.node(), setup.pnpm(), { name: 'Install dependencies', run: 'pnpm install --frozen-lockfile' }, { name: 'Run the tests', run: 'pnpm test' }],
- })
+ .job('types', { egress, steps: [...install, { name: 'Check the types', run: 'pnpm typecheck' }] })
+ .job('test', { egress, steps: [...install, { name: 'Run the tests', run: 'pnpm test' }] })
1 addition and 0 deletionssrc/tasks.tsModified
View file
@@ -18,6 +18,7 @@
export function addTask(list: TaskList, title: string, priority = 3): TaskList {
const name = title.trim()
if (name === '') throw new Error('A task needs a title.')
+ if (priority < 0) throw new Error('A priority is 0 or more.')
const id = list.reduce((max, task) => Math.max(max, task.id), 0) + 1
return [...list, { id, title: name, done: false, priority }]
4 additions and 0 deletionstest/tasks.test.tsModified
View file