Skip to content

Commit

Permalink
Update: React Native version, eslint, babel, Android SDK, bugfixes fo…
Browse files Browse the repository at this point in the history
…r text styles.
  • Loading branch information
kristfal committed Mar 1, 2019
1 parent ca2eb2d commit 88f9f7f
Show file tree
Hide file tree
Showing 98 changed files with 838 additions and 685 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

58 changes: 0 additions & 58 deletions .eslintrc

This file was deleted.

94 changes: 94 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,94 @@
module.exports = {
"parser": "babel-eslint",
"plugins": [
"react",
"react-native",
"prettier",
"fp",
"flowtype",
],
"env": {
"jest": true
},
"settings": {
"react": {
"version": require('./package.json').dependencies.react,
},
"import/resolver": {
"node": {
"extensions": [
".js",
".jsx"
]
}
},
"react": {
"pragma": "React",
"version": "16.6.1",
"flowVersion": "0.87"
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true
}
}
},
"globals": {
"fetch": true,
"FormData": true,
"requestAnimationFrame": true,
"cancelAnimationFrame": true,
"WebSocket": true,
"__DEV__": true,
"window": true,
"document": true,
"navigator": true,
"XMLSerializer": true,
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"airbnb-base",
"prettier",
"plugin:flowtype/recommended"
],
"rules": {
"react/no-deprecated": "error",
"import/named": [2],
"import/no-named-default": [0],
"import/order": ["error", { "groups": ["builtin", "external", "parent", "sibling", "index"], "newlines-between": "always" }],
"import/exports-last": [0],
"import/no-useless-path-segments": [2],
"camelcase": [0],
"no-console": [0],
"import/prefer-default-export": "off",
"jsx-a11y/href-no-hash": "off",
"react/prop-types": [2],
"quotes": [2, "single"],
"eol-last": [0],
"no-continue": [1],
"class-methods-use-this": [1],
"no-bitwise": [1],
"prefer-destructuring": [1],
"consistent-return": [1],
"no-warning-comments": [2],
"no-mixed-requires": [0],
"no-return-assign": 0,
"no-underscore-dangle": [0],
"no-await-in-loop": 0,
"no-restricted-syntax": 0,
"no-use-before-define": ["error", { "functions": false }],
"no-unused-expressions": ["error", { "allowTaggedTemplates": true }],
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
"prettier/prettier": [
"error",
{
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": false
}
],
"fp/no-mutating-methods": "warn"
}
};
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -47,3 +47,5 @@ android/local.properties
reactnativemapboxgl.iml
.idea
coverage
.project
*.core.prefs
10 changes: 5 additions & 5 deletions __tests__/__mocks__/react-native-mapbox-gl.mock.js
@@ -1,8 +1,8 @@
import { NativeModules } from 'react-native';
import {NativeModules} from 'react-native';

function keyMirror(keys) {
let obj = {};
keys.forEach((key) => (obj[key] = key));
const obj = {};
keys.forEach(key => (obj[key] = key));
return obj;
}

Expand Down Expand Up @@ -87,10 +87,10 @@ NativeModules.MGLModule = {
};

NativeModules.MGLOfflineModule = {
createPack: (packOptions) => {
createPack: packOptions => {
return Promise.resolve({
bounds: packOptions.bounds,
metadata: JSON.stringify({ name: packOptions.name }),
metadata: JSON.stringify({name: packOptions.name}),
});
},
getPacks: () => Promise.resolve([]),
Expand Down
2 changes: 1 addition & 1 deletion __tests__/__mocks__/react-native.mock.js
@@ -1,5 +1,5 @@
jest.mock('react-native/Libraries/Image/resolveAssetSource', () => {
return () => ({ uri: `asset://test.png` });
return () => ({uri: 'asset://test.png'});
});

jest.mock('NativeEventEmitter', () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/interface.test.js
Expand Up @@ -74,6 +74,6 @@ describe('Public Interface', () => {
// animated
'Animated',
];
actualKeys.forEach((key) => expect(expectedKeys).toContain(key));
actualKeys.forEach(key => expect(expectedKeys).toContain(key));
});
});
3 changes: 2 additions & 1 deletion __tests__/modules/offline/OfflinePack.test.js
@@ -1,4 +1,5 @@
import { NativeModules } from 'react-native';
import {NativeModules} from 'react-native';

import OfflinePack from '../../../javascript/modules/offline/OfflinePack';

describe('OfflinePack', () => {
Expand Down
13 changes: 7 additions & 6 deletions __tests__/modules/offline/offlineManager.test.js
@@ -1,6 +1,7 @@
import { NativeModules, Platform } from 'react-native';
import {NativeModules, Platform} from 'react-native';

import MapboxGL from '../../../javascript';
import { OfflineModuleEventEmitter } from '../../../javascript/modules/offline/offlineManager';
import {OfflineModuleEventEmitter} from '../../../javascript/modules/offline/offlineManager';

describe('offlineManager', () => {
const packOptions = {
Expand Down Expand Up @@ -39,7 +40,7 @@ describe('offlineManager', () => {

afterEach(async () => {
const packs = await MapboxGL.offlineManager.getPacks();
for (let pack of packs) {
for (const pack of packs) {
await MapboxGL.offlineManager.deletePack(pack.name);
}
});
Expand Down Expand Up @@ -179,7 +180,7 @@ describe('offlineManager', () => {

const name = `test-${Date.now()}`;
const noop = () => {};
const options = { ...packOptions, name: name };
const options = {...packOptions, name};
await MapboxGL.offlineManager.createPack(options);
await MapboxGL.offlineManager.subscribe(name, noop, noop);

Expand All @@ -192,7 +193,7 @@ describe('offlineManager', () => {

const name = `test-${Date.now()}`;
const noop = () => {};
const options = { ...packOptions, name: name };
const options = {...packOptions, name};
await MapboxGL.offlineManager.createPack(options, noop, noop);

expect(spy).not.toHaveBeenCalled();
Expand All @@ -208,7 +209,7 @@ describe('offlineManager', () => {

const name = `test-${Date.now()}`;
const noop = () => {};
const options = { ...packOptions, name: name };
const options = {...packOptions, name};
await MapboxGL.offlineManager.createPack(options);
await MapboxGL.offlineManager.subscribe(name, noop, noop);

Expand Down
9 changes: 5 additions & 4 deletions __tests__/modules/snapshot/SnapshotOptions.test.js
@@ -1,4 +1,5 @@
import { NativeModules } from 'react-native';
import {NativeModules} from 'react-native';

import SnapshotOptions from '../../../javascript/modules/snapshot/SnapshotOptions';
import {
makePoint,
Expand All @@ -8,12 +9,12 @@ import {
describe('SnapshotOptions', () => {
it('should throw error if no centerCoordinate or bounds are provided', () => {
expect(() => new SnapshotOptions()).toThrow();
expect(() => new SnapshotOptions({ styleURL: 'test' })).toThrow();
expect(() => new SnapshotOptions({styleURL: 'test'})).toThrow();
});

it('should create options with valid defaults', () => {
const centerCoordinate = [1, 2];
const options = new SnapshotOptions({ centerCoordinate: centerCoordinate });
const options = new SnapshotOptions({centerCoordinate});

expect(options.toJSON()).toEqual({
styleURL: NativeModules.MGLModule.StyleURL.Street,
Expand Down Expand Up @@ -58,7 +59,7 @@ describe('SnapshotOptions', () => {
};

const geoJSONBounds = JSON.stringify(
makeFeatureCollection(expectedOptions.bounds.map((c) => makePoint(c))),
makeFeatureCollection(expectedOptions.bounds.map(c => makePoint(c))),
);

const options = new SnapshotOptions(expectedOptions);
Expand Down
2 changes: 1 addition & 1 deletion __tests__/modules/snapshot/snapshotManager.test.js
Expand Up @@ -2,7 +2,7 @@ import MapboxGL from '../../../javascript';

describe('snapshotManager', () => {
it('should resolve uri', async () => {
const options = { centerCoordinate: [1, 2] };
const options = {centerCoordinate: [1, 2]};
const uri = await MapboxGL.snapshotManager.takeSnap(options);
expect(uri).toEqual('file://test.png');
});
Expand Down

0 comments on commit 88f9f7f

Please sign in to comment.