Skip to content

Commit a18438e

Browse files
committed
Use Biome
1 parent 41a04b9 commit a18438e

32 files changed

+177
-2186
lines changed

.editorconfig

-5
This file was deleted.

.eslintignore

-1
This file was deleted.

.eslintrc.json

-42
This file was deleted.

.npmrc

-1
This file was deleted.

biome.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.7.1/schema.json",
3+
"organizeImports": {
4+
"enabled": true
5+
},
6+
"formatter": {
7+
"enabled": true,
8+
"formatWithErrors": false,
9+
"ignore": [],
10+
"attributePosition": "auto",
11+
"indentStyle": "space",
12+
"indentWidth": 2,
13+
"lineWidth": 80
14+
},
15+
"javascript": {
16+
"formatter": {
17+
"arrowParentheses": "always",
18+
"bracketSameLine": true,
19+
"bracketSpacing": true,
20+
"jsxQuoteStyle": "double",
21+
"quoteProperties": "asNeeded",
22+
"quoteStyle": "single",
23+
"semicolons": "asNeeded",
24+
"trailingComma": "all"
25+
}
26+
},
27+
"linter": {
28+
"enabled": true,
29+
"ignore": ["lib/**", "__tests__/**"],
30+
"rules": {
31+
"recommended": true
32+
}
33+
}
34+
}

package.json

+2-13
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
"type": "module",
66
"packageManager": "pnpm@9.0.6",
77
"scripts": {
8-
"lint": "eslint './packages/**/*.ts' './packages/**/*.tsx'",
8+
"lint": "biome check --apply ./packages",
99
"test": "jest",
1010
"build": "turbo run build:clean && pnpm run -r build:types && turbo run build:js"
1111
},
1212
"devDependencies": {
13+
"@biomejs/biome": "^1.7.2",
1314
"@skypack/package-check": "^0.2.2",
1415
"@swc/cli": "^0.3.12",
1516
"@swc/core": "^1.3.37",
@@ -19,23 +20,11 @@
1920
"@types/jest": "^29.4.0",
2021
"@types/leaflet": "^1.9.1",
2122
"@types/warning": "^3.0.0",
22-
"@typescript-eslint/eslint-plugin": "^7.8.0",
23-
"@typescript-eslint/parser": "^7.8.0",
2423
"cross-env": "^7.0.3",
2524
"del-cli": "^5.0.0",
26-
"eslint": "^8.57.0",
27-
"eslint-config-prettier": "^9.1.0",
28-
"eslint-plugin-import": "^2.27.5",
29-
"eslint-plugin-node": "^11.1.0",
30-
"eslint-plugin-prettier": "^5.1.3",
31-
"eslint-plugin-promise": "^6.1.1",
32-
"eslint-plugin-react": "^7.32.2",
33-
"eslint-plugin-react-hooks": "^4.6.0",
3425
"jest": "^29.4.3",
3526
"jest-environment-jsdom": "^29.4.3",
3627
"leaflet": "^1.9.3",
37-
"prettier": "^3.2.5",
38-
"prettier-eslint": "^16.3.0",
3928
"react": "^18.2.0",
4029
"react-dom": "^18.2.0",
4130
"react-test-renderer": "^18.2.0",

packages/core/__tests__/components.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { act, render, screen } from '@testing-library/react'
22
import React, { StrictMode, useEffect, useRef } from 'react'
33

44
import {
5-
createElementHook,
65
createContainerComponent,
76
createDivOverlayComponent,
87
createDivOverlayHook,
8+
createElementHook,
99
createLeafComponent,
1010
useLeafletContext,
1111
} from '../src'

packages/core/package.json

+3-13
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66
"type": "git",
77
"url": "https://github.com/PaulLeCam/react-leaflet.git"
88
},
9-
"keywords": [
10-
"react-component",
11-
"react",
12-
"leaflet",
13-
"map"
14-
],
9+
"keywords": ["react-component", "react", "leaflet", "map"],
1510
"author": "Paul Le Cam <paul@ulem.net>",
1611
"license": "Hippocratic-2.1",
1712
"bugs": {
@@ -24,9 +19,7 @@
2419
"exports": {
2520
".": "./lib/index.js"
2621
},
27-
"files": [
28-
"lib/*"
29-
],
22+
"files": ["lib/*"],
3023
"sideEffects": false,
3124
"scripts": {
3225
"build:clean": "del lib",
@@ -50,10 +43,7 @@
5043
"@types/react-dom": "^18.0.11"
5144
},
5245
"jest": {
53-
"extensionsToTreatAsEsm": [
54-
".ts",
55-
".tsx"
56-
],
46+
"extensionsToTreatAsEsm": [".ts", ".tsx"],
5747
"resolver": "ts-jest-resolver",
5848
"testEnvironment": "jsdom",
5949
"transform": {

packages/core/src/attribution.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { Map } from 'leaflet'
1+
import type { Map as LeafletMap } from 'leaflet'
22
import { useEffect, useRef } from 'react'
33

44
export function useAttribution(
5-
map: Map,
5+
map: LeafletMap,
66
attribution: string | null | undefined,
77
) {
88
const attributionRef = useRef(attribution)

packages/core/src/circle.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type {
2-
Circle as LeafletCircle,
3-
CircleMarker as LeafletCircleMarker,
42
CircleMarkerOptions,
53
CircleOptions,
64
LatLngExpression,
5+
Circle as LeafletCircle,
6+
CircleMarker as LeafletCircleMarker,
77
} from 'leaflet'
88
import type { ReactNode } from 'react'
99

packages/core/src/component.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export function createDivOverlayComponent<
4343
const { instance } = useElement(props, setOpen).current
4444

4545
useImperativeHandle(forwardedRef, () => instance)
46+
// biome-ignore lint/correctness/useExhaustiveDependencies: update overlay when children change
4647
useEffect(
4748
function updateOverlay() {
4849
if (isOpen) {

packages/core/src/context.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Control, Layer, LayerGroup, Map } from 'leaflet'
1+
import type { Control, Layer, LayerGroup, Map as LeafletMap } from 'leaflet'
22
import { createContext, useContext } from 'react'
33

44
export const CONTEXT_VERSION = 1
@@ -10,14 +10,14 @@ export type ControlledLayer = {
1010

1111
export type LeafletContextInterface = Readonly<{
1212
__version: number
13-
map: Map
13+
map: LeafletMap
1414
layerContainer?: ControlledLayer | LayerGroup
1515
layersControl?: Control.Layers
1616
overlayContainer?: Layer
1717
pane?: string
1818
}>
1919

20-
export function createLeafletContext(map: Map): LeafletContextInterface {
20+
export function createLeafletContext(map: LeafletMap): LeafletContextInterface {
2121
return Object.freeze({ __version: CONTEXT_VERSION, map })
2222
}
2323

packages/core/src/control.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Control, type ControlOptions } from 'leaflet'
1+
import type { Control, ControlOptions } from 'leaflet'
22
import { useEffect, useRef } from 'react'
33

44
import { useLeafletContext } from './context.js'

packages/core/src/div-overlay.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { Popup, Tooltip } from 'leaflet'
22

33
import { useAttribution } from './attribution.js'
4-
import { useLeafletContext, type LeafletContextInterface } from './context.js'
5-
import type { LeafletElement, ElementHook } from './element.js'
4+
import { type LeafletContextInterface, useLeafletContext } from './context.js'
5+
import type { ElementHook, LeafletElement } from './element.js'
66
import { useEventHandlers } from './events.js'
77
import type { LayerProps } from './layer.js'
88
import { withPane } from './pane.js'

packages/core/src/dom.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ function splitClassName(className: string): string[] {
55
}
66

77
export function addClassName(element: HTMLElement, className: string) {
8-
splitClassName(className).forEach((cls) => {
8+
for (const cls of splitClassName(className)) {
99
DomUtil.addClass(element, cls)
10-
})
10+
}
1111
}
1212

1313
export function removeClassName(element: HTMLElement, className: string) {
14-
splitClassName(className).forEach((cls) => {
14+
for (const cls of splitClassName(className)) {
1515
DomUtil.removeClass(element, cls)
16-
})
16+
}
1717
}
1818

1919
export function updateClassName(

packages/core/src/element.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function createElementHook<E, P, C = unknown>(
6060
propsRef.current = props
6161
}
6262
},
63-
[instance, props, context],
63+
[instance, props, updateElement],
6464
)
6565

6666
return elementRef

packages/core/src/generic.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ import {
1414
} from './component.js'
1515
import type { LeafletContextInterface } from './context.js'
1616
import { createControlHook } from './control.js'
17+
import {
18+
type DivOverlay,
19+
type DivOverlayLifecycleHook,
20+
createDivOverlayHook,
21+
} from './div-overlay.js'
1722
import {
1823
type LeafletElement,
1924
createElementHook,
2025
createElementObject,
2126
} from './element.js'
2227
import { type LayerProps, createLayerHook } from './layer.js'
23-
import {
24-
type DivOverlay,
25-
type DivOverlayLifecycleHook,
26-
createDivOverlayHook,
27-
} from './div-overlay.js'
2828
import { type PathProps, createPathHook } from './path.js'
2929

3030
interface LayerWithChildrenProps extends LayerProps, PropsWithChildren {}

packages/core/src/layer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useEffect } from 'react'
33

44
import { useAttribution } from './attribution.js'
55
import { type LeafletContextInterface, useLeafletContext } from './context.js'
6-
import type { LeafletElement, ElementHook } from './element.js'
6+
import type { ElementHook, LeafletElement } from './element.js'
77
import { type EventedProps, useEventHandlers } from './events.js'
88
import { withPane } from './pane.js'
99

packages/core/src/media-overlay.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
2+
type ImageOverlayOptions,
23
LatLngBounds,
34
type LatLngBoundsExpression,
45
type ImageOverlay as LeafletImageOverlay,
5-
type ImageOverlayOptions,
66
type SVGOverlay as LeafletSVGOverlay,
77
type VideoOverlay as LeafletVideoOverlay,
88
} from 'leaflet'

packages/core/src/path.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { FeatureGroup, Path, PathOptions } from 'leaflet'
22
import { useEffect, useRef } from 'react'
33

44
import { useLeafletContext } from './context.js'
5-
import type { LeafletElement, ElementHook } from './element.js'
5+
import type { ElementHook, LeafletElement } from './element.js'
66
import { useEventHandlers } from './events.js'
77
import { type InteractiveLayerProps, useLayerLifecycle } from './layer.js'
88
import { withPane } from './pane.js'
@@ -15,7 +15,7 @@ export function usePathOptions(
1515
element: LeafletElement<FeatureGroup | Path>,
1616
props: PathProps,
1717
) {
18-
const optionsRef = useRef<PathOptions | void>()
18+
const optionsRef = useRef<PathOptions | undefined>()
1919

2020
useEffect(
2121
function updatePathOptions() {

packages/react-leaflet/__tests__/ScaleControl.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { render } from '@testing-library/react'
22
import React from 'react'
33

4-
import { ScaleControl, MapContainer } from '../src'
4+
import { MapContainer, ScaleControl } from '../src'
55

66
describe('ScaleControl', () => {
77
test('renders and unmounts', () => {

packages/react-leaflet/__tests__/ZoomControl.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { render } from '@testing-library/react'
22
import React from 'react'
33

4-
import { ZoomControl, MapContainer } from '../src'
4+
import { MapContainer, ZoomControl } from '../src'
55

66
describe('ZoomControl', () => {
77
test('renders and unmounts', () => {

packages/react-leaflet/package.json

+3-13
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66
"type": "git",
77
"url": "https://github.com/PaulLeCam/react-leaflet.git"
88
},
9-
"keywords": [
10-
"react-component",
11-
"react",
12-
"leaflet",
13-
"map"
14-
],
9+
"keywords": ["react-component", "react", "leaflet", "map"],
1510
"author": "Paul Le Cam <paul@ulem.net>",
1611
"license": "Hippocratic-2.1",
1712
"bugs": {
@@ -25,9 +20,7 @@
2520
".": "./lib/index.js",
2621
"./*": "./lib/*.js"
2722
},
28-
"files": [
29-
"lib/*"
30-
],
23+
"files": ["lib/*"],
3124
"sideEffects": false,
3225
"scripts": {
3326
"build:clean": "del lib",
@@ -56,10 +49,7 @@
5649
"@types/react-dom": "^18.0.11"
5750
},
5851
"jest": {
59-
"extensionsToTreatAsEsm": [
60-
".ts",
61-
".tsx"
62-
],
52+
"extensionsToTreatAsEsm": [".ts", ".tsx"],
6353
"resolver": "ts-jest-resolver",
6454
"testEnvironment": "jsdom",
6555
"transform": {

0 commit comments

Comments
 (0)