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
8 changes: 6 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
test/*.conf.js
build/
node_modules
coverage
storybook-static
build
package-lock.json
i18n
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"plugins": ["testing-library", "jest"],
"extends": [
"eslint-config-synacor",
// "eslint-config-synacor",
"plugin:react-hooks/recommended",
"plugin:testing-library/react",
"plugin:jest/recommended",
Expand Down
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Massive linting commits:
5c335c0846c88fbf39c0f34b1ae5c5bbf03b637c
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
4 changes: 2 additions & 2 deletions devTools/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const myStory = () => <${componentName} />

const styleContent = () => "// Here you define the css for this plugin";

const argv = yargs(hideBin(process.argv))
yargs(hideBin(process.argv))
.command('$0 create <name>', 'create an skeleton for a new plugin',
yargs => yargs
.positional('name', {
Expand All @@ -156,7 +156,7 @@ const argv = yargs(hideBin(process.argv))
function create(argv) {
const name = argv.name;
const pluginName = `lime-plugin-${name}`;
baseDir = path.join(__dirname, '..', 'plugins', pluginName);
const baseDir = path.join(__dirname, '..', 'plugins', pluginName);
fs.mkdirSync(baseDir);
fs.mkdirSync(path.join(baseDir, 'src'))
fs.writeFileSync(path.join(baseDir, 'src', `${name}Page.js`), pageContent(name));
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
'<rootDir>/plugins/**/__tests__/**/*.{mjs,js,jsx,ts,tsx}',
'<rootDir>/{plugins, src,test,tests}/**/*.{spec,test}.{mjs,js,jsx,ts,tsx}'
],
setupFiles: ['core-js'],
setupFilesAfterEnv: ['jest-extended'],
moduleNameMapper: {
...preactPreset.moduleNameMapper,
Expand Down
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,9 @@
"storybook:build": "build-storybook -c .storybook",
"storybook:deploy": "gh-pages -d storybook-static",
"test": "jest",
"create-plugin": "node ./devTools/plugins create"
"create-plugin": "node ./devTools/plugins create",
"prepare": "husky install"
},
"eslintConfig": {
"extends": "eslint-config-synacor"
},
"eslintIgnore": [
"build/*"
],
"devDependencies": {
"@commitlint/cli": "^8.0.0",
"@commitlint/config-conventional": "^8.0.0",
Expand Down Expand Up @@ -58,7 +53,7 @@
"eslint-plugin-testing-library": "^3.1.4",
"fetch-mock": "^8.3.2",
"gh-pages": "^2.0.1",
"husky": "^3.0.0",
"husky": "^7.0.0",
"identity-obj-proxy": "^3.0.0",
"if-env": "^1.0.0",
"jest": "^24.9.0",
Expand All @@ -68,6 +63,7 @@
"jest-when": "^2.7.2",
"less": "^3.12.2",
"less-loader": "^6.2.0",
"lint-staged": "^12.3.4",
"per-env": "^1.0.2",
"serve": "^11.1.0",
"standard-version": "^8.0.1",
Expand Down Expand Up @@ -103,5 +99,8 @@
"hooks": {
"commit-msg": "commitlint -e $HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"*.js": "eslint --fix"
}
}
5 changes: 2 additions & 3 deletions plugins/lime-plugin-firmware/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {h} from 'preact';
import { Trans } from '@lingui/macro';
import FirmwarePage from './src/firmwarePage';
import { Menu } from './src/firmwareMenu';
import { UpgradeAvailabeInfo } from './src/upgradeAvailable';

export default {
name: 'Firmware',
page: FirmwarePage,
menu: () => <a href={'#/firmware'}><Trans>Firmware</Trans></a>,
menu: Menu,
isCommunityProtected: true,
additionalRoutes: [
['releaseInfo', UpgradeAvailabeInfo]
Expand Down
3 changes: 3 additions & 0 deletions plugins/lime-plugin-firmware/src/firmwareMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {h} from 'preact';
import { Trans } from '@lingui/macro';
export const Menu = () => <a href={'#/firmware'}><Trans>Firmware</Trans></a>;
3 changes: 1 addition & 2 deletions plugins/lime-plugin-firmware/src/upgradeAvailable.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { h } from "preact";
import { h, Fragment } from "preact";
import { route } from 'preact-router';
import Match from 'preact-router/match';
import { Trans } from '@lingui/macro';
import { Fragment } from 'preact';
import { useNewVersion } from './firmwareQueries';
import Loading from 'components/loading';
import { useBoardData } from 'utils/queries';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Page = ({ getGroundRouting, loading, configuration }) => {

useEffect(() => {
getGroundRouting();
}, []);
}, [getGroundRouting]);

const preStyle = {
backgroundColor: '#f5f5f5',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const initialState = {
error: false
};

export const reducer = (state = initialState, { type, payload, meta }) => {
export const reducer = (state = initialState, { type, payload }) => {
switch (type) {

case GROUNDROUTING_GET:
Expand Down
4 changes: 1 addition & 3 deletions plugins/lime-plugin-locate/locate.stories.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions plugins/lime-plugin-locate/src/assetsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function loadLeafletScript() {
document.body.appendChild(script);
}
})
};
}

function loadLeafletStylesheet() {
return new Promise((res, rej) => {
Expand All @@ -27,7 +27,7 @@ function loadLeafletStylesheet() {
document.head.appendChild(style);
}
})
};
}


export function loadLeafLet() {
Expand All @@ -44,7 +44,7 @@ export function loadGoogleMapsApi() {
const script = document.createElement('script');
script.onload = res;
script.onerror = rej;
script.src = 'https://maps.googleapis.com/maps/api/js?key='+key;
script.src = `https://maps.googleapis.com/maps/api/js?key=${key}`;
script.id = 'googlemaps-script';
document.body.appendChild(script);
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/lime-plugin-locate/src/communityGeoJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function getCommunityGeoJSON(nodesData, keepClean = null) {
.filter(mac => node.macs.some(node_mac => macLinks[mac].indexOf(node_mac) != -1))
.map(mac => [geomac[node.macs[0]], geomac[mac]].sort())
).flat()
geolinks = removeDuplicates(geolinks, l => l[0] + ',' + l[1]);
geolinks = removeDuplicates(geolinks, l => `${l[0]},${l[1]}`);

// nodefeatures: [..., GeoJSONFeature:Point] All nodes to be shown
let nodefeatures = nodes.map(node => coordsToPoint(
Expand Down
108 changes: 54 additions & 54 deletions plugins/lime-plugin-locate/src/communityGeoJSON.spec.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
/* eslint jest/expect-expect: ["error", { "assertFunctionNames": ["expect", "compareGeoJsons"] }] */
import { getCommunityGeoJSON } from './communityGeoJSON'

const getMockedNodesData = jest.fn(() => (
{
"host1": {
"bleachTTL": 29,
"data": {
"hostname": "host1",
"coordinates": {
"lon": "-64.42818",
"lat": "-31.81317"
host1: {
bleachTTL: 29,
data: {
hostname: "host1",
coordinates: {
lon: "-64.42818",
lat: "-31.81317"
},
"macs": [
macs: [
"a0:f3:c1:86:31:d2",
"a0:f3:c1:86:31:d3",
"a2:f3:c1:86:31:d2"
],
"links": [
links: [
"a0:f3:c1:46:28:37",
"a8:40:41:1c:85:44"
]
},
"author": "host1"
author: "host1"
},
"host2": {
"bleachTTL": 30,
"data": {
"links": [
host2: {
bleachTTL: 30,
data: {
links: [
"a0:f3:c1:86:31:d2",
// Link to host3, but host3 doenst link host2
"a8:40:41:1c:84:20"
],
"coordinates": {
"lon": "-64.42450",
"lat": "-31.81799"
coordinates: {
lon: "-64.42450",
lat: "-31.81799"
},
"macs": [
macs: [
"a0:f3:c1:46:28:36",
"a0:f3:c1:46:28:37",
"a2:f3:c1:46:28:36"
],
"hostname": "host2"
hostname: "host2"
},
"author": "host2"
author: "host2"
},
"host3": {
"bleachTTL": 30,
"data": {
"hostname": "host3",
"coordinates": {
"lon": "-64.39950",
"lat": "-31.79970"
host3: {
bleachTTL: 30,
data: {
hostname: "host3",
coordinates: {
lon: "-64.39950",
lat: "-31.79970"
},
"macs": [
macs: [
"a8:40:41:1c:84:20",
"a8:40:41:1c:84:28",
"a8:40:41:1c:85:44"
],
"links": [
links: [
"a0:f3:c1:86:31:d3",
]
},
"author": "host3"
author: "host3"
}
}
));
Expand All @@ -78,14 +78,14 @@ test('getCommunityGeoJSON returns a well formed geo JSON', () => {
const nodesData = getMockedNodesData();
const geoJSON = getCommunityGeoJSON(nodesData);
const expected = {
"type": "FeatureCollection",
"features": [
{"type":"Feature","geometry":{"type":"Point","coordinates":[-64.42818,-31.81317]},"properties":{"name":"host1"}},
{"type":"Feature","geometry":{"type":"Point","coordinates":[-64.42450,-31.81799]},"properties":{"name":"host2"}},
{"type":"Feature","geometry":{"type":"Point","coordinates":[-64.39950,-31.79970]},"properties":{"name":"host3"}},
type: "FeatureCollection",
features: [
{ type: "Feature", geometry: { type: "Point", coordinates: [-64.42818, -31.81317] }, properties: { name: "host1" } },
{ type: "Feature", geometry: { type: "Point", coordinates: [-64.42450, -31.81799] }, properties: { name: "host2" } },
{ type: "Feature", geometry: { type: "Point", coordinates: [-64.39950, -31.79970] }, properties: { name: "host3" } },
// Note: coordinates list is expected to be sorted to simplify testing
{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-64.42818,-31.81317],[-64.42450,-31.81799]].sort()}},
{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-64.42818,-31.81317],[-64.39950,-31.79970]].sort()}}
{ type: "Feature", geometry: { type: "LineString", coordinates: [[-64.42818, -31.81317], [-64.42450, -31.81799]].sort() } },
{ type: "Feature", geometry: { type: "LineString", coordinates: [[-64.42818, -31.81317], [-64.39950, -31.79970]].sort() } }
]

};
Expand All @@ -94,15 +94,15 @@ test('getCommunityGeoJSON returns a well formed geo JSON', () => {

test('getCommunityGeoJSON ignore nodes without coordinates and their links', () => {
let nodesData = getMockedNodesData();
nodesData.host2.data.coordinates = {lat: 'FIXME', lon: 'FIXME'};
nodesData.host2.data.coordinates = { lat: 'FIXME', lon: 'FIXME' };
const geoJSON = getCommunityGeoJSON(nodesData);
const expected = {
"type": "FeatureCollection",
"features": [
{"type":"Feature","geometry":{"type":"Point","coordinates":[-64.42818,-31.81317]},"properties":{"name":"host1"}},
{"type":"Feature","geometry":{"type":"Point","coordinates":[-64.39950,-31.79970]},"properties":{"name":"host3"}},
type: "FeatureCollection",
features: [
{ type: "Feature", geometry: { type: "Point", coordinates: [-64.42818, -31.81317] }, properties: { name: "host1" } },
{ type: "Feature", geometry: { type: "Point", coordinates: [-64.39950, -31.79970] }, properties: { name: "host3" } },
// Note: coordinates list is expected to be sorted to simplify testing
{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-64.42818,-31.81317],[-64.39950,-31.79970]].sort()}}
{ type: "Feature", geometry: { type: "LineString", coordinates: [[-64.42818, -31.81317], [-64.39950, -31.79970]].sort() } }
]
};
compareGeoJsons(geoJSON, expected);
Expand All @@ -113,12 +113,12 @@ test('getCommunityGeoJSON ignore nodes without mac addresses', () => {
nodesData.host2.data.macs = [];
const geoJSON = getCommunityGeoJSON(nodesData);
const expected = {
"type": "FeatureCollection",
"features": [
{"type":"Feature","geometry":{"type":"Point","coordinates":[-64.42818,-31.81317]},"properties":{"name":"host1"}},
{"type":"Feature","geometry":{"type":"Point","coordinates":[-64.39950,-31.79970]},"properties":{"name":"host3"}},
type: "FeatureCollection",
features: [
{ type: "Feature", geometry: { type: "Point", coordinates: [-64.42818, -31.81317] }, properties: { name: "host1" } },
{ type: "Feature", geometry: { type: "Point", coordinates: [-64.39950, -31.79970] }, properties: { name: "host3" } },
// Note: coordinates list is expected to be sorted to simplify testing
{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-64.42818,-31.81317],[-64.39950,-31.79970]].sort()}}
{ type: "Feature", geometry: { type: "LineString", coordinates: [[-64.42818, -31.81317], [-64.39950, -31.79970]].sort() } }
]
};
compareGeoJsons(geoJSON, expected);
Expand All @@ -127,13 +127,13 @@ test('getCommunityGeoJSON ignore nodes without mac addresses', () => {
test('getCommunityGeoJSON doesnt return geo points in keepClean coordinates', () => {
let nodesData = getMockedNodesData();
nodesData.host2.data.macs = [];
const geoJSON = getCommunityGeoJSON(nodesData, [-64.42818,-31.81317]);
const geoJSON = getCommunityGeoJSON(nodesData, [-64.42818, -31.81317]);
const expected = {
"type": "FeatureCollection",
"features": [
{"type":"Feature","geometry":{"type":"Point","coordinates":[-64.39950,-31.79970]},"properties":{"name":"host3"}},
type: "FeatureCollection",
features: [
{ type: "Feature", geometry: { type: "Point", coordinates: [-64.39950, -31.79970] }, properties: { name: "host3" } },
// Note: coordinates list is expected to be sorted to simplify testing
{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-64.42818,-31.81317],[-64.39950,-31.79970]].sort()}}
{ type: "Feature", geometry: { type: "LineString", coordinates: [[-64.42818, -31.81317], [-64.39950, -31.79970]].sort() } }
]
};
compareGeoJsons(geoJSON, expected);
Expand Down
2 changes: 1 addition & 1 deletion plugins/lime-plugin-locate/src/locateEpics.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const locateChange = ( action$, _state$, { wsAPI } ) =>
action$.pipe(
ofType(LOCATION_CHANGE),
mergeMap((action) => changeLocation(wsAPI, action.payload)),
map((payload) => ({ type: LOCATION_CHANGE_SUCCESS }))
map(() => ({ type: LOCATION_CHANGE_SUCCESS }))
);

const locateLoadlinks = ( action$, _state$, { wsAPI } ) =>
Expand Down
Loading