Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tslint-airbnb-config #40

Merged
merged 12 commits into from
Dec 11, 2018
138 changes: 138 additions & 0 deletions optaweb-tsp-ui/package-lock.json

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

3 changes: 2 additions & 1 deletion optaweb-tsp-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"start": "react-scripts-ts start",
"build": "react-scripts-ts build",
"test": "react-scripts-ts test --env=jsdom",
"lint": "./node_modules/tslint/bin/tslint -c tslint.json 'src/**/*.{ts,tsx}' -e 'src/@types/**'",
"lint": "./node_modules/tslint/bin/tslint -p tsconfig.json --force",
"lint:fix": "npm run lint -- --fix",
"eject": "react-scripts-ts eject"
},
Expand All @@ -39,6 +39,7 @@
"enzyme-adapter-react-16": "^1.7.0",
"react-test-renderer": "^16.6.3",
"redux-devtools-extension": "^2.13.7",
"tslint-config-airbnb": "^5.11.1",
"typescript": "^3.1.6"
},
"browserslist": [
Expand Down
27 changes: 23 additions & 4 deletions optaweb-tsp-ui/src/@types/react-styles.d.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// tslint:disable:interface-name
// tslint:disable:variable-name
declare module '@patternfly/react-styles' {
export interface StyleDeclarationStatic {
__className: string;

__inject(): void;
}

export function isValidStyleDeclaration(
obj: any
obj: any,
): obj is StyleDeclarationStatic;

export function createStyleDeclaration(
className: string,
rawCss: string
rawCss: string,
): StyleDeclarationStatic;

export function isModifier(className: string): boolean;

export function getModifier(
styleObject: any,
modifier: string,
defaultModifer?: StyleDeclarationStatic | string
defaultModifer?: StyleDeclarationStatic | string,
): StyleDeclarationStatic | string;

export function formatClassName(className: string): string;
Expand All @@ -32,8 +50,9 @@ declare module '@patternfly/react-styles' {

export interface StyleSheetStatic {
parse(cssString: string): StyleSheetValueStatic;

create<T extends Record<keyof T, any>>(
styles: T
styles: T,
): Record<keyof T, string>;
}

Expand Down
4 changes: 2 additions & 2 deletions optaweb-tsp-ui/src/components/ConnectionError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

import { Modal, Text, TextContent, TextVariants } from '@patternfly/react-core';
import * as React from 'react';
import { ReactNode } from 'react';

export interface IConnectionErrorProps {
title: string;
message: string;
icon?: ReactNode;
icon?: React.ReactNode;
help?: string;
}

Expand Down
1 change: 0 additions & 1 deletion optaweb-tsp-ui/src/components/Location.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ describe('Location Component', () => {
expect(location).toMatchSnapshot();
location.find('Grid').simulate('mouseEnter');
location.find('Button').simulate('click');


expect(props.removeHandler).toHaveBeenCalledTimes(1);
});
Expand Down
6 changes: 3 additions & 3 deletions optaweb-tsp-ui/src/components/LocationList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { shallow } from 'enzyme';
import * as React from 'react';
import * as types from '../store/tsp/types';
import LocationList from './LocationList';

describe('Location List Component', () => {
it('should render correctly with no routes', () => {
const props = {
Expand All @@ -28,8 +29,7 @@ describe('Location List Component', () => {
removeHandler: jest.fn(),
route: [],
selectHandler: jest.fn(),
ws: types.WS_CONNECTION_STATE.OPEN

ws: types.WS_CONNECTION_STATE.OPEN,
};
expect.assertions(2);
const locationList = shallow(<LocationList {...props} />);
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('Location List Component', () => {
},
],
selectHandler: jest.fn(),
ws: types.WS_CONNECTION_STATE.OPEN
ws: types.WS_CONNECTION_STATE.OPEN,
};
expect.assertions(2);
const locationList = shallow(<LocationList {...props} />);
Expand Down
2 changes: 1 addition & 1 deletion optaweb-tsp-ui/src/components/LocationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const renderLocationList = ({
};

const LocationList: React.SFC<ILocationListProps> = (
props: ILocationListProps
props: ILocationListProps,
) => {
return (
<div
Expand Down
2 changes: 2 additions & 0 deletions optaweb-tsp-ui/src/components/TravelingSalesmanProblem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default class TravelingSalesmanProblem extends React.Component<
segments: [],
},
};

constructor(props: ITravelingSalesmanProblemProps) {
super(props);

Expand Down Expand Up @@ -71,6 +72,7 @@ export default class TravelingSalesmanProblem extends React.Component<
this.setState({ maxDistance: intDistance });
}
}

render() {
const { center, zoom, selectedId, maxDistance } = this.state;
const {
Expand Down
16 changes: 7 additions & 9 deletions optaweb-tsp-ui/src/components/TspMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
Polyline,
TileLayer,
Tooltip,
ZoomControl
ZoomControl,
} from 'react-leaflet';
import { ILatLng, ITSPRouteWithSegments } from '../store/tsp';

Expand All @@ -42,7 +42,7 @@ const TspMap: React.SFC<ITspMapProps> = ({
segments,
domicileId,
clickHandler,
removeHandler
removeHandler,
}) => {
const homeIcon = L.icon({
iconAnchor: [12, 12],
Expand All @@ -51,7 +51,7 @@ const TspMap: React.SFC<ITspMapProps> = ({
popupAnchor: [0, -10],
shadowAnchor: [16, 2],
shadowSize: [50, 16],
shadowUrl: 'if_big_house-home_2222740_shadow.png'
shadowUrl: 'if_big_house-home_2222740_shadow.png',
});
const defaultIcon = new L.Icon.Default();
return (
Expand All @@ -63,7 +63,9 @@ const TspMap: React.SFC<ITspMapProps> = ({
zoomControl={false} // hide the default zoom control which is on top left
>
<TileLayer
attribution={'&amp;copy <a href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors'}
attribution={
'&amp;copy <a href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors'
}
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<ZoomControl position="topright" />
Expand All @@ -80,9 +82,7 @@ const TspMap: React.SFC<ITspMapProps> = ({
key={location.id + (location.id === selectedId ? 'T' : 't')}
permanent={location.id === selectedId}
>
{`Location ${location.id} [Lat=${location.lat}, Lng=${
location.lng
}]`}
{`Location ${location.id} [Lat=${location.lat}, Lng=${location.lng}]`}
</Tooltip>
</Marker>
))}
Expand All @@ -91,6 +91,4 @@ const TspMap: React.SFC<ITspMapProps> = ({
);
};



export default TspMap;
Loading