Skip to content

Commit

Permalink
refactor: upgrade to react-leaflet@3.0.0 (#101)
Browse files Browse the repository at this point in the history
* feat: upgrade to react-leaflet@3.0.0-beta

* chore: release version 2.0.0-alpha.0

* style: prettier config

* build: use @babel/runtime

* chore: release 2.0.0-alpha.1

* chore: configure eslint with jest

* feat: drop support for IE11

* chore: release v2.0.0-beta.0

* fix: fix commonjs build

* chore: release v2.0.0-beta.1

* chore: release v2.0.0-beta.2

* chore: make @babel/runtime dependency instead of peerdependency

* chore: drop support for edge 18

* build: typescript tooling

* chore: upgrade dependencies

* chore: use @typescript-eslint/parser

* chore: upgrade to react@^17.0.0-rc

* chore: upgrade dependencies

* chore: upgrade dependencies

* refactor: switch to named export

* build: add react-leaflet-v3 tag to npm keywords

* chore: upgrade dependencies

* chore: release v2.0.0-beta.4

* docs: update readme

* chore: upgrade dependencies

* chore: upgrade dependencies
  • Loading branch information
anajavi authored Oct 31, 2020
1 parent 9890e5e commit 28c4a3f
Show file tree
Hide file tree
Showing 15 changed files with 781 additions and 511 deletions.
27 changes: 0 additions & 27 deletions .babelrc

This file was deleted.

38 changes: 38 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const ENV = process.env.BABEL_ENV || process.env.NODE_ENV || 'development';

const config = {
presets: [
[
'@babel/env',
{
targets: {
browsers: [
'chrome > 74',
'edge >= 81',
'firefox >= 68',
'ios >= 12',
'opera >= 58',
'safari >= 12',
'samsung >= 10'
]
},
modules: false,
loose: true,
bugfixes: true,
debug: false
}
],
'@babel/react',
'@babel/typescript'
],
env: {
cjs: {
plugins: ['@babel/transform-modules-commonjs']
},
test: {
plugins: ['@babel/transform-modules-commonjs']
}
}
};

module.exports = config;
14 changes: 9 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"parser": "babel-eslint",
"plugins": [
"react", "flowtype"
],
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["react", "@typescript-eslint"],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
Expand All @@ -13,5 +13,9 @@
"browser": true,
"es6": true
},
"extends": ["eslint:recommended","plugin:react/recommended", "plugin:flowtype/recommended"]
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
]
}
13 changes: 0 additions & 13 deletions .flowconfig

This file was deleted.

4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"singleQuote": true
"singleQuote": true,
"arrowParens": "always",
"trailingComma": "none"
}
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# React-Leaflet-NmScale

[![npm (scoped)](https://img.shields.io/npm/v/@marfle/react-leaflet-nmscale.svg)](https://www.npmjs.com/package/@marfle/react-leaflet-nmscale)

React nautical mile scale component for [`React-Leaflet`](https://github.com/PaulLeCam/react-leaflet)
Expand All @@ -14,18 +15,18 @@ npm install @marfle/react-leaflet-nmscale
## Usage

Import:

```javascript
import { Map, TileLayer } from "react-leaflet";
import NmScale from "@marfle/react-leaflet-nmscale";
import { Map, TileLayer } from 'react-leaflet';
import { NmScale } from '@marfle/react-leaflet-nmscale';
```

Use:

```jsx
<Map center={[0, 0]} zoom={10}>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
<TileLayer
url="https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png" />
<TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
<TileLayer url="https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png" />
<NmScale />
</Map>
```
Expand Down
5 changes: 5 additions & 0 deletions __tests__/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"env": {
"jest": true
}
}
29 changes: 0 additions & 29 deletions __tests__/nmscale.js

This file was deleted.

30 changes: 30 additions & 0 deletions __tests__/nmscale.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as React from 'react';
import { renderIntoDocument } from 'react-dom/test-utils';

import { MapContainer, TileLayer } from 'react-leaflet';

import { NmScale } from '../src/nmscale';
import LeafletNmScale from '../src/leafletnmscale';

describe('NmScale', () => {
it('adds the scale to the map', (done) => {
const spy_updateNautical = jest.spyOn(
LeafletNmScale.prototype,
'_updateNautical'
);

renderIntoDocument(
<MapContainer
center={[0, 0]}
zoom={10}
whenCreated={() => {
expect(spy_updateNautical).toHaveBeenCalledTimes(1);
done();
}}
>
<TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
<NmScale />
</MapContainer>
);
});
});
Loading

0 comments on commit 28c4a3f

Please sign in to comment.