Commit 9470521c authored by Oleksii Savran's avatar Oleksii Savran
Browse files

Updated eslint rules

parent c4f16d6f
......@@ -14,19 +14,41 @@
},
"plugins": [
"@typescript-eslint",
"@typescript-eslint/tslint",
"prefer-arrow"
"prefer-arrow",
"react"
],
"settings": {
"react": {
"version": "detect"
}
// "import/resolver": {
// "node": {
// "paths": ["src"]
// }
// }
},
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "off",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/ban-types": [
"error",
{
"types": {
"object": false
}
}
],
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": null
},
{
"selector": "function",
"format": ["camelCase", "PascalCase"]
}
],
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/explicit-member-accessibility": [
......@@ -35,6 +57,7 @@
"accessibility": "explicit"
}
],
// "@typescript-eslint/indent": ["error", 2],
"@typescript-eslint/member-delimiter-style": [
"error",
{
......@@ -72,13 +95,16 @@
"@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "error",
"react/jsx-curly-spacing": [2, "always"],
"arrow-body-style": "off",
"arrow-parens": [
"error",
"always"
],
"brace-style": ["error", "1tbs", {"allowSingleLine": true }],
"camelcase": "off",
"capitalized-comments": "off",
"comma-dangle": ["error", "always-multiline"],
"complexity": "off",
"constructor-super": "error",
"curly": "error",
......@@ -93,6 +119,8 @@
"import/no-extraneous-dependencies": "off",
"import/no-internal-modules": "off",
"import/order": "off",
"indent": [2, 2, {"SwitchCase": 1}],
// "no-restricted-imports": ["error", {"patterns": ["../*"]}],
"max-classes-per-file": [
"error",
10
......@@ -135,15 +163,15 @@
],
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
// "no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
// "no-underscore-dangle": "error",
"no-unneeded-ternary": "error",
"no-unsafe-finally": "error",
"no-unused-expressions": "off",
"no-unused-labels": "error",
"no-var": "error",
"object-shorthand": "error",
"object-curly-spacing": ["error", "always"],
"one-var": [
"error",
"never"
......@@ -158,11 +186,14 @@
],
"prefer-const": "error",
"prefer-object-spread": "error",
"quotes": ["error", "single"],
"quote-props": [
"error",
"consistent-as-needed"
],
"radix": "error",
"keyword-spacing": ["error"],
"space-before-blocks": ["error", "always"],
"space-before-function-paren": [
"error",
{
......@@ -173,47 +204,6 @@
],
"spaced-comment": "error",
"use-isnan": "error",
"valid-typeof": "off",
"@typescript-eslint/tslint/config": [
"error",
{
"rules": {
"import-spacing": true,
"jsdoc-format": [
true,
"check-multiline-start"
],
"no-reference-import": true,
"one-line": [
true,
"check-catch",
"check-else",
"check-finally",
"check-open-brace",
"check-whitespace"
],
"prefer-conditional-expression": true,
"trailing-comma": [
true,
{
"esSpecCompliant": true,
"multiline": "always",
"singleline": "never"
}
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type",
"check-typecast",
"check-type-operator",
"check-rest-spread"
]
}
}
]
"valid-typeof": "off"
}
}
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import initI18n from "./i18n";
import initI18n from './i18n';
import { log } from '@genesys/client/utilities/debug';
// import * as cookies from 'es-cookie';
import { reconfigureServiceAxios, LoginService } from '@genesys/client/service';
import App from './ui/App';
import ApiAccessError from './ui/ApiAccessError';
import { Config, DefaultConfig } from "../config/config";
import { Config, DefaultConfig } from '../config/config';
// declare const window: Window & { devToolsExtension: any, __REDUX_DEVTOOLS_EXTENSION_COMPOSE__: any, initialLanguage: any, initialI18nStore: any, localeMapping: any };
// const AUTH_COOKIE = 'GENESYS_AUTH';
......@@ -42,7 +42,7 @@ function checkAccessTokens(apiUrl: string, clientId: string, clientSecret: strin
return appLogin;
};
export function showGenesysUI(holdingNode: HTMLElement, config: Config = DefaultConfig, language: string = "en") {
export function showGenesysUI(holdingNode: HTMLElement, config: Config = DefaultConfig, language: string = 'en') {
const { apiUrl, clientId, clientKey, filter } = config;
reconfigureServiceAxios({ apiUrl });
......
import * as React from 'react';
import {withTranslation, WithTranslation} from 'react-i18next';
import { withTranslation, WithTranslation } from 'react-i18next';
// model
import AccessionOverview from '@genesys/client/model/accession/AccessionOverview';
import PropertiesCard from "ui/PropertiesCard";
import {VocabularyService} from "@genesys/client/service";
import PropertiesCard from 'ui/PropertiesCard';
import { VocabularyService } from '@genesys/client/service';
interface IAccessionOverviewPageState {
countryCodes: object;
......@@ -28,13 +28,13 @@ class AccessionOverviewSection extends React.Component<IAccessionOverviewPagePro
public async componentDidMount() {
const codes = await VocabularyService.decode3166Alpha3Terms(this.props.i18n.language);
this.setState({countryCodes: codes})
this.setState({ countryCodes: codes })
}
public render() {
const {overview, t} = this.props;
const { overview, t } = this.props;
const {countryCodes} = this.state;
const { countryCodes } = this.state;
if (!overview) {
......@@ -47,158 +47,158 @@ class AccessionOverviewSection extends React.Component<IAccessionOverviewPagePro
const overviewEl = overview[key];
const terms = overviewEl && overviewEl.terms ? [].concat(overviewEl.terms) : [];
if (overviewEl && overviewEl.other && overviewEl.other > 0) {
terms.push({term: 'accession.overview.Other', count: overviewEl.other});
terms.push({ term: 'accession.overview.Other', count: overviewEl.other });
}
if (overviewEl && overviewEl.missing && overviewEl.missing > 0) {
terms.push({term: 'accession.overview.Not specified', count: overviewEl.missing});
terms.push({ term: 'accession.overview.Not specified', count: overviewEl.missing });
}
overviewsTerms.set(key, terms);
});
return (
<div className="row">
{overviewsTerms && overviewsTerms.get('crop.shortName') &&
{ overviewsTerms && overviewsTerms.get('crop.shortName') &&
<PropertiesCard
propertiesList={overviewsTerms.get('crop.shortName')}
title={t(`accession.overview.crop shortName`)}
propertyItemProps={{numeric: true}}
propertiesList={ overviewsTerms.get('crop.shortName') }
title={ t('accession.overview.crop shortName') }
propertyItemProps={ { numeric: true } }
/>
}
{overviewsTerms && overviewsTerms.get('cropName') &&
{ overviewsTerms && overviewsTerms.get('cropName') &&
<PropertiesCard
propertiesList={overviewsTerms.get('cropName')}
title={t(`accession.overview.cropName`)}
propertyItemProps={{numeric: true}}
propertiesList={ overviewsTerms.get('cropName') }
title={ t('accession.overview.cropName') }
propertyItemProps={ { numeric: true } }
/>
}
{overviewsTerms && overviewsTerms.get('taxonomy.genus') &&
{ overviewsTerms && overviewsTerms.get('taxonomy.genus') &&
<PropertiesCard
propertiesList={overviewsTerms.get('taxonomy.genus')}
title={t(`accession.overview.taxonomy genus`)}
propertyItemProps={{numeric: true, titleStyle: {fontStyle: 'italic'}}}
propertiesList={ overviewsTerms.get('taxonomy.genus') }
title={ t('accession.overview.taxonomy genus') }
propertyItemProps={ { numeric: true, titleStyle: { fontStyle: 'italic' } } }
/>
}
{overviewsTerms && overviewsTerms.get('taxonomy.genusSpecies') &&
{ overviewsTerms && overviewsTerms.get('taxonomy.genusSpecies') &&
<PropertiesCard
propertiesList={overviewsTerms.get('taxonomy.genusSpecies')}
title={t(`accession.overview.taxonomy genusSpecies`)}
propertyItemProps={{numeric: true, titleStyle: {fontStyle: 'italic'}}}
propertiesList={ overviewsTerms.get('taxonomy.genusSpecies') }
title={ t('accession.overview.taxonomy genusSpecies') }
propertyItemProps={ { numeric: true, titleStyle: { fontStyle: 'italic' } } }
/>
}
{overviewsTerms && overviewsTerms.get('taxonomy.grinTaxonomySpecies.name') &&
{ overviewsTerms && overviewsTerms.get('taxonomy.grinTaxonomySpecies.name') &&
<PropertiesCard
propertiesList={overviewsTerms.get('taxonomy.grinTaxonomySpecies.name')}
title={t(`accession.overview.taxonomy grinTaxonomySpecies`)}
propertyItemProps={{numeric: true, titleStyle: {fontStyle: 'italic'}}}
propertiesList={ overviewsTerms.get('taxonomy.grinTaxonomySpecies.name') }
title={ t('accession.overview.taxonomy grinTaxonomySpecies') }
propertyItemProps={ { numeric: true, titleStyle: { fontStyle: 'italic' } } }
/>
}
{overviewsTerms && overviewsTerms.get('taxonomy.currentTaxonomySpecies.name') &&
{ overviewsTerms && overviewsTerms.get('taxonomy.currentTaxonomySpecies.name') &&
<PropertiesCard
propertiesList={overviewsTerms.get('taxonomy.currentTaxonomySpecies.name')}
title={t(`accession.overview.taxonomy currentTaxonomySpecies`)}
propertyItemProps={{numeric: true, titleStyle: {fontStyle: 'italic'}}}
propertiesList={ overviewsTerms.get('taxonomy.currentTaxonomySpecies.name') }
title={ t('accession.overview.taxonomy currentTaxonomySpecies') }
propertyItemProps={ { numeric: true, titleStyle: { fontStyle: 'italic' } } }
/>
}
{overviewsTerms && overviewsTerms.get('sampStat') &&
{ overviewsTerms && overviewsTerms.get('sampStat') &&
<PropertiesCard
propertiesList={overviewsTerms.get('sampStat')}
propertiesList={ overviewsTerms.get('sampStat') }
translationGroup="sampleStatus"
title={t(`accession.overview.sampStat`)}
propertyItemProps={{numeric: true}}
title={ t('accession.overview.sampStat') }
propertyItemProps={ { numeric: true } }
/>
}
{overviewsTerms && overviewsTerms.get('storage') &&
{ overviewsTerms && overviewsTerms.get('storage') &&
<PropertiesCard
propertiesList={overviewsTerms.get('storage')}
propertiesList={ overviewsTerms.get('storage') }
translationGroup="storage"
title={t(`accession.overview.storage`)}
propertyItemProps={{numeric: true}}
title={ t('accession.overview.storage') }
propertyItemProps={ { numeric: true } }
/>
}
{overviewsTerms && overviewsTerms.get('countryOfOrigin.code3') &&
{ overviewsTerms && overviewsTerms.get('countryOfOrigin.code3') &&
<PropertiesCard
propertiesList={overviewsTerms.get('countryOfOrigin.code3')}
countyCodes={countryCodes}
title={t(`accession.overview.countryOfOrigin code3`)}
propertyItemProps={{numeric: true}}
propertiesList={ overviewsTerms.get('countryOfOrigin.code3') }
countyCodes={ countryCodes }
title={ t('accession.overview.countryOfOrigin code3') }
propertyItemProps={ { numeric: true } }
/>
}
{overviewsTerms && overviewsTerms.get('donorCode') &&
{ overviewsTerms && overviewsTerms.get('donorCode') &&
<PropertiesCard
propertiesList={overviewsTerms.get('donorCode')}
title={t(`accession.overview.donorCode`)}
propertyItemProps={{numeric: true}}
propertiesList={ overviewsTerms.get('donorCode') }
title={ t('accession.overview.donorCode') }
propertyItemProps={ { numeric: true } }
/>
}
{overviewsTerms && overviewsTerms.get('duplSite') &&
{ overviewsTerms && overviewsTerms.get('duplSite') &&
<PropertiesCard
propertiesList={overviewsTerms.get('duplSite')}
title={t(`accession.overview.duplSite`)}
propertyItemProps={{numeric: true}}
propertiesList={ overviewsTerms.get('duplSite') }
title={ t('accession.overview.duplSite') }
propertyItemProps={ { numeric: true } }
/>
}
{overviewsTerms && overviewsTerms.get('breederCode') &&
{ overviewsTerms && overviewsTerms.get('breederCode') &&
<PropertiesCard
propertiesList={overviewsTerms.get('breederCode')}
title={t(`accession.overview.breederCode`)}
propertyItemProps={{numeric: true}}
propertiesList={ overviewsTerms.get('breederCode') }
title={ t('accession.overview.breederCode') }
propertyItemProps={ { numeric: true } }
/>
}
{overviewsTerms && overviewsTerms.get('mlsStatus') &&
{ overviewsTerms && overviewsTerms.get('mlsStatus') &&
<PropertiesCard
propertiesList={overviewsTerms.get('mlsStatus')}
propertiesList={ overviewsTerms.get('mlsStatus') }
translationGroup="mlsStatus"
title={t(`accession.overview.mlsStatus`)}
propertyItemProps={{numeric: true}}
title={ t('accession.overview.mlsStatus') }
propertyItemProps={ { numeric: true } }
/>
}
{overviewsTerms && overviewsTerms.get('aegis') &&
{ overviewsTerms && overviewsTerms.get('aegis') &&
<PropertiesCard
propertiesList={overviewsTerms.get('aegis')}
propertiesList={ overviewsTerms.get('aegis') }
translationGroup="aegisStatus"
title={t(`accession.overview.aegis`)}
propertyItemProps={{numeric: true}}
title={ t('accession.overview.aegis') }
propertyItemProps={ { numeric: true } }
/>
}
{overviewsTerms && overviewsTerms.get('available') &&
{ overviewsTerms && overviewsTerms.get('available') &&
<PropertiesCard
propertiesList={overviewsTerms.get('available')}
propertiesList={ overviewsTerms.get('available') }
translationGroup="available"
title={t(`accession.overview.available`)}
propertyItemProps={{numeric: true}}
title={ t('accession.overview.available') }
propertyItemProps={ { numeric: true } }
/>
}
{overviewsTerms && overviewsTerms.get('historic') &&
{ overviewsTerms && overviewsTerms.get('historic') &&
<PropertiesCard
propertiesList={overviewsTerms.get('historic')}
propertiesList={ overviewsTerms.get('historic') }
translationGroup="historic"
title={t(`accession.overview.historic`)}
propertyItemProps={{numeric: true}}
title={ t('accession.overview.historic') }
propertyItemProps={ { numeric: true } }
/>
}
{overviewsTerms && overviewsTerms.get('sgsv') &&
{ overviewsTerms && overviewsTerms.get('sgsv') &&
<PropertiesCard
propertiesList={overviewsTerms.get('sgsv')}
propertiesList={ overviewsTerms.get('sgsv') }
translationGroup="sgsv"
title={t(`accession.overview.sgsv`)}
propertyItemProps={{numeric: true}}
title={ t('accession.overview.sgsv') }
propertyItemProps={ { numeric: true } }
/>
}
{overviewsTerms && overviewsTerms.get('institute.code') &&
{ overviewsTerms && overviewsTerms.get('institute.code') &&
<PropertiesCard
propertiesList={overviewsTerms.get('institute.code')}
title={t(`accession.overview.institute code`)}
propertyItemProps={{numeric: true}}
propertiesList={ overviewsTerms.get('institute.code') }
title={ t('accession.overview.institute code') }
propertyItemProps={ { numeric: true } }
/>
}
{overviewsTerms && overviewsTerms.get('institute.country.code3') &&
{ overviewsTerms && overviewsTerms.get('institute.country.code3') &&
<PropertiesCard
propertiesList={overviewsTerms.get('institute.country.code3')}
countyCodes={countryCodes}
title={t(`accession.overview.institute country code3`)}
propertyItemProps={{numeric: true}}
propertiesList={ overviewsTerms.get('institute.country.code3') }
countyCodes={ countryCodes }
title={ t('accession.overview.institute country code3') }
propertyItemProps={ { numeric: true } }
/>
}
</div>
......
......@@ -6,7 +6,7 @@ import AccessionList from './AccessionListPage';
import AccessionDetails from './AccessionDetailsPage';
import { createHashHistory } from 'history';
import CartPage from './CartPage';
import OverviewPage from "ui/OverviewPage";
import OverviewPage from 'ui/OverviewPage';
const hashHistory = createHashHistory({});
......@@ -43,4 +43,4 @@ export default class App extends React.Component<IAppProps, any> {
};
}
export { hashHistory as history};
export { hashHistory as history };
import * as React from 'react';
import {withTranslation, WithTranslation} from "react-i18next";
import { withTranslation, WithTranslation } from 'react-i18next';
// interface INotFoundProps extends React.ClassAttributes<any> {}
class NotFound extends React.Component<WithTranslation> {
public render() {
const { t } = this.props
const { t } = this.props;
return (
<h3>
{t('error.notFound')}
......
import * as React from 'react';
import {WithTranslation, withTranslation} from "react-i18next";
import { WithTranslation, withTranslation } from 'react-i18next';
interface INumber extends React.ClassAttributes<any>, WithTranslation {
value: number;
......@@ -15,7 +15,7 @@ class Number extends React.Component<INumber, any> {
}
public render() {
const {value, config = {}, i18n} = this.props
const { value, config = {}, i18n } = this.props;
if (typeof value === 'number') {
return <span>{ value.toLocaleString(i18n.language, { maximumFractionDigits: 6, ...config }) }</span>;
......
import React from 'react';
import FilteredPage, { IPageRequest } from '@genesys/client/model/FilteredPage';
import { history } from './App';
import {withTranslation, WithTranslation} from "react-i18next";
import { withTranslation, WithTranslation } from 'react-i18next';
interface IPagination extends React.ClassAttributes<any>, WithTranslation {
loadData: (filter: Record<string, any>, pageR: IPageRequest) => Promise<any>;
......@@ -85,27 +85,27 @@ class Pagination extends React.Component<IPagination> {
return (
<nav aria-label="Page navigation">
<ul className="pagination">
<li className={`page-item ${paged.number === 0 ? "disabled" : ""}`}>
<li className={ `page-item ${paged.number === 0 ? 'disabled' : ''}` }>
<a className="page-link" onClick={ this.toPage } data-page={ 0 } href="#" aria-label={ t('pag.first') }>
<span aria-hidden="true">&laquo; {t('pag.first')}</span>
</a>
</li>
<li className={`page-item ${paged.number === 0 ? "disabled" : ""}`}>
<li className={ `page-item ${paged.number === 0 ? 'disabled' : ''}` }>
<a onClick={ this.toPage } data-page={ paged.number - 1 } href="#" className="page-link">&lsaquo; { t('pag.prev') }</a>
</li>
{ this.getPageNumbers().map((page, i) => (
<li key={ `page-${page}-${i}` } data-page={ page - 1 } onClick={ this.toPage } aria-current="page" className={`page-item ${paged.number === page - 1 ? "active" : ""}`}>
{paged.number === page - 1
? <span tabIndex={-1} className="page-link">{page} <span className="sr-only">(current)</span></span>
<li key={ `page-${page}-${i}` } data-page={ page - 1 } onClick={ this.toPage } aria-current="page" className={ `page-item ${paged.number === page - 1 ? 'active' : ''}` }>
{ paged.number === page - 1
? <span tabIndex={ -1 } className="page-link">{page} <span className="sr-only">(current)</span></span>
: <a className="page-link" href="#">{page}</a>
}
</li>
)) }
<li className={`page-item ${paged.last ? "disabled" : ""}`}>
<li className={ `page-item ${paged.last ? 'disabled' : ''}` }>
<a onClick={ this.toPage } data-page={ paged.number + 1 } href="#" className="page-link">{t('pag.next')} &rsaquo;</a>
</li>
<li className={`page-item ${paged.last ? "disabled" : ""}`}>
<li className={ `page-item ${paged.last ? 'disabled' : ''}` }>
<a className="page-link" onClick={ this.toPage } data-page={ paged.totalPages - 1 } href="#" aria-label={ t('pag.last') }>
<span aria-hidden="true">{t('pag.last')} &raquo;</span>
</a>
......
import React from 'react';
import { Property } from "ui/Property";
import { TreeMap } from "d3js";
import {WithTranslation, withTranslation} from "react-i18next";
import { Property } from 'ui/Property';
import { TreeMap } from 'd3js';
import { WithTranslation, withTranslation } from 'react-i18next';
interface IProperty extends React.ClassAttributes<any>, WithTranslation {
title: string;
......@@ -14,8 +14,8 @@ interface IProperty extends React.ClassAttributes<any>, WithTranslation {
class PropertiesCard extends React.Component<IProperty, any> {
private getTitle(property: {term: string, count: any}) {
const {translationGroup, countyCodes, t} = this.props;
private getTitle(property: { term: string, count: any }) {
const { translationGroup, countyCodes, t } = this.props;
if (countyCodes && countyCodes[property.term]) {
return countyCodes[property.term];
}
......@@ -30,7 +30,7 @@ class PropertiesCard extends React.Component<IProperty, any> {
}
public render() {
const {propertiesList, propertyItemProps, title, t} = this.props;
const { propertiesList, propertyItemProps, title, t } = this.props;
if ((propertiesList && propertiesList.length === 0) || !propertiesList) {
return null;
......@@ -39,23 +39,23 @@ class PropertiesCard extends React.Component<IProperty, any> {
return (
<div className="col-sm-12 col-md-12 col-xl-6 pb-5">
<div className="col-sm-12 col-md-12 col-xl-12 p-0 h-100">
<h4>{title}</h4>
<h4>{ title }</h4>
<div className="">
<div style={{height: "300px", width: "100%"}}>
<TreeMap style={{height: "100%"}} data={{
name: t("accession.overview.total"),
<div style={ { height: '300px', width: '100%' } }>
<TreeMap style={ { height: '100%' } } data={ {
name: t('accession.overview.total'),
children: propertiesList,
}}/>