Skip to content

Commit

Permalink
chore: update Biome config and add package.json fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mikerourke committed Jan 7, 2025
1 parent 6192549 commit cea6da5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
22 changes: 18 additions & 4 deletions biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
"enabled": true,
"indentStyle": "space",
"lineWidth": 80,
// We use Prettier to format test files because we can't override the line
// width based on directory/extension:
"ignore": ["**/*.test.ts"]
"ignore": ["./package.json"]
},
"organizeImports": {
"enabled": true
Expand All @@ -41,5 +39,21 @@
"formatter": {
"quoteStyle": "double"
}
}
},
"overrides": [
{
"include": ["src/**/*.test.ts"],
"formatter": {
"lineWidth": 100
},
"linter": {
"rules": {
"recommended": true,
"style": {
"noNonNullAssertion": "off"
}
}
}
}
]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"name": "@laserware/keytar",
"version": "3.0.2",
"description": "Handle keyboard and mouse events in the browser.",
"author": "Mike Rourke <mike.w.rourke@gmail.com>",
"author": "Mike Rourke <mike.w.rourke@gmail.com> (https://mikerourke.dev/)",
"license": "MIT",
"repository": {
"url": "git+https://github.com/laserware/keytar.git",
"type": "git"
},
"homepage": "https://laserware.github.io/keytar/",
"type": "module",
"browser": "dist/index.mjs",
"main": "dist/index.mjs",
Expand Down Expand Up @@ -39,7 +40,6 @@
"docs:generate": "typedoc --options typedoc.json",
"docs:serve": "mkdir -p ./site && cd ./site && bunx vite",
"format": "biome check --formatter-enabled=true --linter-enabled=false --organize-imports-enabled=true --write src",
"format:tests": "bunx prettier \"src/**/*.test.ts\" --write --print-width 100",
"lint": "biome lint src",
"test": "bun test",
"typecheck": "tsc --noEmit"
Expand Down
18 changes: 9 additions & 9 deletions src/__tests__/isChordPressed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Key, Modifier, MouseButton, MouseEventButton } from "../types.ts";

describe("the isChordPressed function", () => {
describe("returns true if requirements are met for keyboard events", () => {
// prettier-ignore
// biome-ignore format:
it.each([
{
event: new KeyboardEvent("keydown", { key: "B", altKey: false, ctrlKey: false, metaKey: false, shiftKey: false }),
Expand Down Expand Up @@ -46,7 +46,7 @@ describe("the isChordPressed function", () => {
});

describe("returns false if requirements are not met for keyboard events", () => {
// prettier-ignore
// biome-ignore format:
it.each([
{
event: new KeyboardEvent("keydown", { key: "B", altKey: true, ctrlKey: false, metaKey: false, shiftKey: false }),
Expand Down Expand Up @@ -81,7 +81,7 @@ describe("the isChordPressed function", () => {
});

describe("when the Command key is specified", () => {
// prettier-ignore
// biome-ignore format:
it.each([
// Command modifier:
{
Expand Down Expand Up @@ -173,7 +173,7 @@ describe("the isChordPressed function", () => {
});

it("returns true if only modifiers are specified with no key", () => {
// prettier-ignore
// biome-ignore format:
const event = new KeyboardEvent("keydown", { altKey: true, ctrlKey: true, metaKey: false, shiftKey: true });

const result = isChordPressed(event, Modifier.Ctrl | Modifier.Alt | Modifier.Shift);
Expand All @@ -182,7 +182,7 @@ describe("the isChordPressed function", () => {
});

it("returns true if mouse buttons are specified and are clicked", () => {
// prettier-ignore
// biome-ignore format:
const event = new MouseEvent("mousedown", { altKey: true, ctrlKey: false, metaKey: false, shiftKey: false, buttons: MouseEventButton.Left });

const result = isChordPressed(event, Modifier.Alt | MouseButton.Left);
Expand All @@ -192,7 +192,7 @@ describe("the isChordPressed function", () => {

describe("when checking for CmdOrCtrl", () => {
it("clears the Cmd key on macOS", () => {
// prettier-ignore
// biome-ignore format:
const event = new KeyboardEvent("keydown", { altKey: false, ctrlKey: true, metaKey: true, shiftKey: false });

const result = isChordPressed(event, Modifier.CmdOrCtrl | Modifier.Ctrl);
Expand All @@ -205,7 +205,7 @@ describe("the isChordPressed function", () => {
isPlatform: (platform: string) => platform !== "mac",
}));

// prettier-ignore
// biome-ignore format:
const event = new KeyboardEvent("keydown", { altKey: false, ctrlKey: true, metaKey: false, shiftKey: false });

const result = isChordPressed(event, Modifier.CmdOrCtrl);
Expand All @@ -215,7 +215,7 @@ describe("the isChordPressed function", () => {
});

it("handles Shift and Shift + Tab", () => {
// prettier-ignore
// biome-ignore format:
const event = new KeyboardEvent("keydown", { key: "Tab", altKey: false, ctrlKey: false, metaKey: false, shiftKey: true });

const result = isChordPressed(event, Key.Tab, Modifier.Shift | Key.Tab);
Expand All @@ -224,7 +224,7 @@ describe("the isChordPressed function", () => {
});

describe("returns true if requirements are met for mouse events", () => {
// prettier-ignore
// biome-ignore format:
it.each([
{
event: new MouseEvent("keydown", { buttons: MouseEventButton.Left, altKey: false, ctrlKey: false, metaKey: false, shiftKey: false }),
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
"sourceMap": false,
"strict": true,
"strictNullChecks": true,
"stripInternal": true,
"target": "ESNext",
"verbatimModuleSyntax": true
},
"include": ["src"],
"include": ["src", "./test.setup.ts", "./tsup.config.ts"],
"exclude": ["dist", "node_modules"]
}
1 change: 1 addition & 0 deletions typedoc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://typedoc.org/schema.json",
"cleanOutputDir": true,
"entryPoints": ["./src/index.ts"],
"exclude": ["**/**test.ts"],
Expand Down

0 comments on commit cea6da5

Please sign in to comment.