Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ updates:
update-types:
- 'version-update:semver-minor'
- 'version-update:semver-patch'
ignore:
- dependency-name: '@types/estree' # Skip the error updating this specific package
commit-message:
prefix: 'chore(deps)'

Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/pr-updated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on:
pull_request:

jobs:
code-check:
if: ${{ !github.event.pull_request.draft }}
concurrency:
group: code-check--${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- uses: pnpm/action-setup@v6

- run: pnpm run lint

- run: pnpm run test
18 changes: 0 additions & 18 deletions .oxfmtrc.json

This file was deleted.

45 changes: 0 additions & 45 deletions .oxlintrc.json

This file was deleted.

7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"editor.indentSize": 2,
"editor.defaultFormatter": "oxc.oxc-vscode",
"oxc.typeAware": true
"search.exclude": {
"**/node_modules": true,
"coverage": true,
"*.js": true,
"*.map": true
}
}
9 changes: 4 additions & 5 deletions index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { calculateChildPosition, type Dimension, type Offset } from './index.ts'
import { calculateChildPosition, type Dimension, type Offset, type Strategy } from './index.ts'

const viewportRect: Dimension = { width: 80, height: 20 }
const buttonRect: Offset & Dimension = {
Expand All @@ -8,18 +8,17 @@ const buttonRect: Offset & Dimension = {
width: 4,
height: 2,
}
const moveTo = (left: number, top: number) => (rect) => ({ ...rect, top, left })
const moveBy = (dx: number, dy: number) => (rect) => ({
const moveBy = (dx: number, dy: number) => (rect: Offset & Dimension) => ({
...rect,
top: rect.top + dy,
left: rect.left + dx,
})

describe('strategies', () => {
const testStrategy = (strategyName, expectedResult) => {
const testStrategy = (strategyName: Strategy, expectedResult: string) => {
const menuRect = { width: 12, height: 6 }

it(`${strategyName}`, () => {
it(strategyName, () => {
const args: Parameters<typeof calculateChildPosition> = [
strategyName,
buttonRect,
Expand Down
2 changes: 0 additions & 2 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ pre-commit:
format:
run: pnpm exec oxfmt --no-error-on-unmatched-pattern {staged_files}
stage_fixed: true
test:
run: pnpm run test --silent --reporter dot
19 changes: 19 additions & 0 deletions oxfmt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from 'oxfmt'

export default defineConfig({
arrowParens: 'always',
bracketSameLine: false,
bracketSpacing: true,
endOfLine: 'lf',
ignorePatterns: ['**/*.js', '**/*.map', '**/*.d.ts', 'coverage'],
insertFinalNewline: true,
jsxSingleQuote: false,
objectWrap: 'preserve',
printWidth: 100,
quoteProps: 'as-needed',
semi: false,
singleAttributePerLine: false,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
})
47 changes: 47 additions & 0 deletions oxlint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { defineConfig } from 'oxlint'

export default defineConfig({
plugins: ['import', 'typescript', 'unicorn', 'vitest'],
options: {
typeAware: true,
typeCheck: true,
},
env: {
browser: true,
},
ignorePatterns: ['**/*.js', '**/*.map', '**/*.d.ts', 'coverage'],
categories: {
correctness: 'error',
suspicious: 'error',
},
rules: {
'eslint/eqeqeq': 'error',
'eslint/no-shadow': 'off', // Too picky
'eslint/no-unused-vars': 'off', // Rely on TypeScript compiler instead

'import/no-named-as-default': 'off', // Too picky
'import/no-unassigned-import': 'off', // Does not recognize CSS imports

'typescript/no-base-to-string': 'off', // Too picky
'typescript/no-floating-promises': 'warn', // Too many errors
'typescript/no-explicit-any': 'warn', // Too many errors
'typescript/no-unnecessary-type-assertion': 'warn', // Too many errors
'typescript/no-unsafe-type-assertion': 'warn', // Too many errors
'typescript/unbound-method': 'off', // Too picky

'unicorn/explicit-length-check': 'warn',
'unicorn/no-array-sort': 'off', // Risk of backward-compatibility break

'vitest/consistent-test-it': ['error', { fn: 'it' }],
'vitest/expect-expect': 'off', // Does not work with our `assertVisual` utility function
'vitest/no-alias-methods': 'error',
'vitest/no-conditional-in-test': 'warn',
'vitest/no-identical-title': 'error',
'vitest/prefer-describe-function-title': 'warn',
'vitest/prefer-equality-matcher': 'error',
'vitest/prefer-hooks-in-order': 'error',
'vitest/prefer-to-contain': 'error',
'vitest/prefer-to-have-length': 'error',
'vitest/valid-title': 'off', // Rely on https://oxc.rs/docs/guide/usage/linter/rules/vitest/prefer-describe-function-title
},
})
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "positioning-strategy",
"version": "5.0.0",
"version": "5.0.1",
"homepage": "https://github.com/taskworld/positioning-strategy#readme",
"bugs": {
"url": "https://github.com/taskworld/positioning-strategy/issues"
Expand All @@ -19,8 +19,8 @@
"main": "index.js",
"scripts": {
"build": "tsc",
"lint": "oxlint --quiet --type-aware",
"test": "pnpm run build --noEmit && vitest --no-watch --coverage",
"lint": "oxlint",
"test": "pnpm run build --noEmit && vitest --coverage",
"version": "pnpm run build",
"postversion": "pnpm publish"
},
Expand Down