Skip to content

Commit

Permalink
Swap to biome for formatting and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
GRA0007 committed Jan 4, 2024
1 parent 93c719b commit 1fff88e
Show file tree
Hide file tree
Showing 21 changed files with 4,917 additions and 3,491 deletions.
36 changes: 0 additions & 36 deletions .eslintrc.json

This file was deleted.

48 changes: 21 additions & 27 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@
name: Check

on:
pull_request:
paths:
- 'src/**'
- 'tests/**'
- '.eslintrc.json'
- 'tsconfig.json'
- '.github/workflows/check.yml'
push:
paths-ignore:
- .vscode/**
- README.md

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'
- run: yarn install --immutable
- run: yarn lint --max-warnings 0
cache: yarn
- run: yarn install
- run: yarn lint

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'
- run: yarn install --immutable
- run: yarn typecheck
cache: yarn
- run: yarn install
- run: yarn tsc

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'
- run: yarn install --immutable
cache: yarn
- run: yarn install
- run: yarn test
21 changes: 11 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@ name: Release

on:
push:
branches: ['main']
branches:
- main
paths:
- '**/package.json'
- '.changeset/**'
- '.github/workflows/release.yml'
- .changeset/**
- .github/workflows/release.yml

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v3
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'
- run: yarn install --immutable
cache: yarn
- run: yarn install
- run: yarn build
- uses: changesets/action@v1
with:
publish: yarn ci:release
publish: yarn changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
dist
.vscode
yarn-error.log
.yarn
*.tsbuildinfo
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["biomejs.biome"]
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"editor.formatOnSave": true,
"editor.defaultFormatter": "biomejs.biome",
"editor.codeActionsOnSave": {
"source.organizeImports.biome": "explicit"
}
}
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nodeLinker: node-modules
compressionLevel: mixed
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Ewan Breakey
Copyright (c) 2022 Stevent Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
25 changes: 25 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"files": {
"ignore": [".yarn", "dist"]
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"formatter": {
"indentStyle": "space",
"lineWidth": 120
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"semicolons": "asNeeded"
}
}
}
35 changes: 0 additions & 35 deletions index.html

This file was deleted.

41 changes: 15 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
"name": "ayecal",
"version": "0.1.7",
"description": "Create and manipulate iCal files",
"keywords": [
"ical",
"ics",
"calendar",
"webcal"
],
"keywords": ["ical", "ics", "calendar", "webcal"],
"repository": "https://github.com/stevent-team/ayecal",
"author": "Stevent team (https://stevent.club)",
"license": "MIT",
"packageManager": "[email protected]",
"type": "module",
"main": "dist/ayecal.umd.cjs",
"module": "dist/ayecal.js",
Expand All @@ -21,28 +17,21 @@
"require": "./dist/ayecal.umd.cjs"
}
},
"files": ["dist"],
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build:demo": "tsc && vite build -m demo",
"lint": "eslint --ext .ts ./src",
"test": "vitest",
"typecheck": "tsc",
"ci:release": "yarn build && yarn changeset publish"
"lint": "biome check .",
"format": "biome check --apply .",
"test": "vitest"
},
"devDependencies": {
"@changesets/cli": "^2.26.1",
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"eslint": "^8.10.0",
"type-fest": "^3.7.2",
"typescript": "^5.0.3",
"vite": "^4.2.1",
"vite-plugin-dts": "^2.1.0",
"vitest": "^0.29.8"
},
"files": [
"dist"
]
"@biomejs/biome": "^1.4.1",
"@changesets/cli": "^2.27.1",
"@types/node": "^20.10.6",
"type-fest": "^4.9.0",
"typescript": "^5.3.3",
"vite": "^5.0.10",
"vite-plugin-dts": "^3.7.0",
"vitest": "^1.1.1"
}
}
35 changes: 21 additions & 14 deletions src/Calendar.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import { Event } from './Event'
import { CalendarMethod, CalendarName, CalendarProductId, CalendarScale, CalendarScope, CalendarTimeZone, CustomProperty } from './properties'
import {
CalendarMethod,
CalendarName,
CalendarProductId,
CalendarScale,
CalendarScope,
CalendarTimeZone,
CustomProperty,
} from './properties'
import { takeOr } from './utils'

export type CalendarProperties = Partial<Pick<Calendar, 'name' | 'scope' | 'timeZone' | 'scale' | 'method' | 'productId' | 'custom'>>
export type CalendarProperties = Partial<
Pick<Calendar, 'name' | 'scope' | 'timeZone' | 'scale' | 'method' | 'productId' | 'custom'>
>

/**
* An AyeCal Calendar.
Expand Down Expand Up @@ -37,11 +47,11 @@ export class Calendar {

constructor(props: CalendarProperties = {}) {
this.name = takeOr(props.name, null)
this.scope = takeOr(props.scope, null),
this.scale = takeOr(props.scale, 'GREGORIAN'),
this.method = takeOr(props.method, 'PUBLISH'),
this.productId = takeOr(props.productId, '-//AyeCal//AyeCal//EN'),
this.timeZone = takeOr(props.timeZone, Intl.DateTimeFormat().resolvedOptions().timeZone),
this.scope = takeOr(props.scope, null)
this.scale = takeOr(props.scale, 'GREGORIAN')
this.method = takeOr(props.method, 'PUBLISH')
this.productId = takeOr(props.productId, '-//AyeCal//AyeCal//EN')
this.timeZone = takeOr(props.timeZone, Intl.DateTimeFormat().resolvedOptions().timeZone)
this.custom = takeOr(props.custom, {})
this.#events = []
}
Expand All @@ -58,9 +68,8 @@ export class Calendar {
*/
addEvent(newEvent: Event) {
// Look for uid collision
const collidingEvent = this.#events.find(event => event.id === newEvent.id)
if (collidingEvent)
throw new Error(`Failed to add event with id ${newEvent.id}, id already present in calendar`)
const collidingEvent = this.#events.find((event) => event.id === newEvent.id)
if (collidingEvent) throw new Error(`Failed to add event with id ${newEvent.id}, id already present in calendar`)

this.#events = [...this.#events, newEvent]

Expand All @@ -71,7 +80,7 @@ export class Calendar {
* Removes an event by ID from the Calendar. Does nothing if there are no matching events.
*/
removeEvent(eventId: string) {
this.#events = this.#events.filter(event => event.id !== eventId)
this.#events = this.#events.filter((event) => event.id !== eventId)
}

/**
Expand All @@ -95,9 +104,7 @@ export class Calendar {
.join('\n')

// Convert calendar events to a string
const eventText = this.#events
.map(event => event.toString(this.scope))
.join('\n')
const eventText = this.#events.map((event) => event.toString(this.scope)).join('\n')

return `BEGIN:VCALENDAR\n${text}\n${eventText}\nEND:VCALENDAR`
}
Expand Down
Loading

0 comments on commit 1fff88e

Please sign in to comment.