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

Updated eslint rules

parent c4f16d6f
...@@ -14,19 +14,41 @@ ...@@ -14,19 +14,41 @@
}, },
"plugins": [ "plugins": [
"@typescript-eslint", "@typescript-eslint",
"@typescript-eslint/tslint", "prefer-arrow",
"prefer-arrow" "react"
], ],
"settings": { "settings": {
"react": { "react": {
"version": "detect" "version": "detect"
} }
// "import/resolver": {
// "node": {
// "paths": ["src"]
// }
// }
}, },
"rules": { "rules": {
"@typescript-eslint/adjacent-overload-signatures": "error", "@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "off", "@typescript-eslint/array-type": "off",
"@typescript-eslint/ban-types": "error", "@typescript-eslint/ban-types": [
"@typescript-eslint/class-name-casing": "error", "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-assertions": "error",
"@typescript-eslint/consistent-type-definitions": "error", "@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/explicit-member-accessibility": [ "@typescript-eslint/explicit-member-accessibility": [
...@@ -35,6 +57,7 @@ ...@@ -35,6 +57,7 @@
"accessibility": "explicit" "accessibility": "explicit"
} }
], ],
// "@typescript-eslint/indent": ["error", 2],
"@typescript-eslint/member-delimiter-style": [ "@typescript-eslint/member-delimiter-style": [
"error", "error",
{ {
...@@ -72,13 +95,16 @@ ...@@ -72,13 +95,16 @@
"@typescript-eslint/triple-slash-reference": "error", "@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/type-annotation-spacing": "error", "@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "error", "@typescript-eslint/unified-signatures": "error",
"react/jsx-curly-spacing": [2, "always"],
"arrow-body-style": "off", "arrow-body-style": "off",
"arrow-parens": [ "arrow-parens": [
"error", "error",
"always" "always"
], ],
"brace-style": ["error", "1tbs", {"allowSingleLine": true }],
"camelcase": "off", "camelcase": "off",
"capitalized-comments": "off", "capitalized-comments": "off",
"comma-dangle": ["error", "always-multiline"],
"complexity": "off", "complexity": "off",
"constructor-super": "error", "constructor-super": "error",
"curly": "error", "curly": "error",
...@@ -93,6 +119,8 @@ ...@@ -93,6 +119,8 @@
"import/no-extraneous-dependencies": "off", "import/no-extraneous-dependencies": "off",
"import/no-internal-modules": "off", "import/no-internal-modules": "off",
"import/order": "off", "import/order": "off",
"indent": [2, 2, {"SwitchCase": 1}],
// "no-restricted-imports": ["error", {"patterns": ["../*"]}],
"max-classes-per-file": [ "max-classes-per-file": [
"error", "error",
10 10
...@@ -135,15 +163,15 @@ ...@@ -135,15 +163,15 @@
], ],
"no-sparse-arrays": "error", "no-sparse-arrays": "error",
"no-template-curly-in-string": "error", "no-template-curly-in-string": "error",
// "no-throw-literal": "error",
"no-trailing-spaces": "error", "no-trailing-spaces": "error",
"no-undef-init": "error", "no-undef-init": "error",
// "no-underscore-dangle": "error", "no-unneeded-ternary": "error",
"no-unsafe-finally": "error", "no-unsafe-finally": "error",
"no-unused-expressions": "off", "no-unused-expressions": "off",
"no-unused-labels": "error", "no-unused-labels": "error",
"no-var": "error", "no-var": "error",
"object-shorthand": "error", "object-shorthand": "error",
"object-curly-spacing": ["error", "always"],
"one-var": [ "one-var": [
"error", "error",
"never" "never"
...@@ -158,11 +186,14 @@ ...@@ -158,11 +186,14 @@
], ],
"prefer-const": "error", "prefer-const": "error",
"prefer-object-spread": "error", "prefer-object-spread": "error",
"quotes": ["error", "single"],
"quote-props": [ "quote-props": [
"error", "error",
"consistent-as-needed" "consistent-as-needed"
], ],
"radix": "error", "radix": "error",
"keyword-spacing": ["error"],
"space-before-blocks": ["error", "always"],
"space-before-function-paren": [ "space-before-function-paren": [
"error", "error",
{ {
...@@ -173,47 +204,6 @@ ...@@ -173,47 +204,6 @@
], ],
"spaced-comment": "error", "spaced-comment": "error",
"use-isnan": "error", "use-isnan": "error",
"valid-typeof": "off", "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"
]
}
}
]
} }
} }
import * as React from 'react'; import * as React from 'react';
import * as ReactDOM from 'react-dom'; import * as ReactDOM from 'react-dom';
import initI18n from "./i18n"; import initI18n from './i18n';
import { log } from '@genesys/client/utilities/debug'; import { log } from '@genesys/client/utilities/debug';
// import * as cookies from 'es-cookie'; // import * as cookies from 'es-cookie';
import { reconfigureServiceAxios, LoginService } from '@genesys/client/service'; import { reconfigureServiceAxios, LoginService } from '@genesys/client/service';
import App from './ui/App'; import App from './ui/App';
import ApiAccessError from './ui/ApiAccessError'; 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 }; // declare const window: Window & { devToolsExtension: any, __REDUX_DEVTOOLS_EXTENSION_COMPOSE__: any, initialLanguage: any, initialI18nStore: any, localeMapping: any };
// const AUTH_COOKIE = 'GENESYS_AUTH'; // const AUTH_COOKIE = 'GENESYS_AUTH';
...@@ -42,7 +42,7 @@ function checkAccessTokens(apiUrl: string, clientId: string, clientSecret: strin ...@@ -42,7 +42,7 @@ function checkAccessTokens(apiUrl: string, clientId: string, clientSecret: strin
return appLogin; 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; const { apiUrl, clientId, clientKey, filter } = config;
reconfigureServiceAxios({ apiUrl }); reconfigureServiceAxios({ apiUrl });
......
import * as React from 'react'; import * as React from 'react';
import {withTranslation, WithTranslation} from 'react-i18next'; import { withTranslation, WithTranslation } from 'react-i18next';
// model // model
import AccessionOverview from '@genesys/client/model/accession/AccessionOverview'; import AccessionOverview from '@genesys/client/model/accession/AccessionOverview';
import PropertiesCard from "ui/PropertiesCard"; import PropertiesCard from 'ui/PropertiesCard';
import {VocabularyService} from "@genesys/client/service"; import { VocabularyService } from '@genesys/client/service';
interface IAccessionOverviewPageState { interface IAccessionOverviewPageState {
countryCodes: object; countryCodes: object;
...@@ -28,13 +28,13 @@ class AccessionOverviewSection extends React.Component<IAccessionOverviewPagePro ...@@ -28,13 +28,13 @@ class AccessionOverviewSection extends React.Component<IAccessionOverviewPagePro
public async componentDidMount() { public async componentDidMount() {
const codes = await VocabularyService.decode3166Alpha3Terms(this.props.i18n.language); const codes = await VocabularyService.decode3166Alpha3Terms(this.props.i18n.language);
this.setState({countryCodes: codes}) this.setState({ countryCodes: codes })
} }
public render() { public render() {
const {overview, t} = this.props; const { overview, t } = this.props;
const {countryCodes} = this.state; const { countryCodes } = this.state;
if (!overview) { if (!overview) {
...@@ -47,158 +47,158 @@ class AccessionOverviewSection extends React.Component<IAccessionOverviewPagePro ...@@ -47,158 +47,158 @@ class AccessionOverviewSection extends React.Component<IAccessionOverviewPagePro
const overviewEl = overview[key]; const overviewEl = overview[key];
const terms = overviewEl && overviewEl.terms ? [].concat(overviewEl.terms) : []; const terms = overviewEl && overviewEl.terms ? [].concat(overviewEl.terms) : [];
if (overviewEl && overviewEl.other && overviewEl.other > 0) { 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) { 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); overviewsTerms.set(key, terms);
}); });
return ( return (
<div className="row"> <div className="row">
{overviewsTerms && overviewsTerms.get('crop.shortName') && { overviewsTerms && overviewsTerms.get('crop.shortName') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('crop.shortName')} propertiesList={ overviewsTerms.get('crop.shortName') }
title={t(`accession.overview.crop shortName`)} title={ t('accession.overview.crop shortName') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
{overviewsTerms && overviewsTerms.get('cropName') && { overviewsTerms && overviewsTerms.get('cropName') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('cropName')} propertiesList={ overviewsTerms.get('cropName') }
title={t(`accession.overview.cropName`)} title={ t('accession.overview.cropName') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
{overviewsTerms && overviewsTerms.get('taxonomy.genus') && { overviewsTerms && overviewsTerms.get('taxonomy.genus') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('taxonomy.genus')} propertiesList={ overviewsTerms.get('taxonomy.genus') }
title={t(`accession.overview.taxonomy genus`)} title={ t('accession.overview.taxonomy genus') }
propertyItemProps={{numeric: true, titleStyle: {fontStyle: 'italic'}}} propertyItemProps={ { numeric: true, titleStyle: { fontStyle: 'italic' } } }
/> />
} }
{overviewsTerms && overviewsTerms.get('taxonomy.genusSpecies') && { overviewsTerms && overviewsTerms.get('taxonomy.genusSpecies') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('taxonomy.genusSpecies')} propertiesList={ overviewsTerms.get('taxonomy.genusSpecies') }
title={t(`accession.overview.taxonomy genusSpecies`)} title={ t('accession.overview.taxonomy genusSpecies') }
propertyItemProps={{numeric: true, titleStyle: {fontStyle: 'italic'}}} propertyItemProps={ { numeric: true, titleStyle: { fontStyle: 'italic' } } }
/> />
} }
{overviewsTerms && overviewsTerms.get('taxonomy.grinTaxonomySpecies.name') && { overviewsTerms && overviewsTerms.get('taxonomy.grinTaxonomySpecies.name') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('taxonomy.grinTaxonomySpecies.name')} propertiesList={ overviewsTerms.get('taxonomy.grinTaxonomySpecies.name') }
title={t(`accession.overview.taxonomy grinTaxonomySpecies`)} title={ t('accession.overview.taxonomy grinTaxonomySpecies') }
propertyItemProps={{numeric: true, titleStyle: {fontStyle: 'italic'}}} propertyItemProps={ { numeric: true, titleStyle: { fontStyle: 'italic' } } }
/> />
} }
{overviewsTerms && overviewsTerms.get('taxonomy.currentTaxonomySpecies.name') && { overviewsTerms && overviewsTerms.get('taxonomy.currentTaxonomySpecies.name') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('taxonomy.currentTaxonomySpecies.name')} propertiesList={ overviewsTerms.get('taxonomy.currentTaxonomySpecies.name') }
title={t(`accession.overview.taxonomy currentTaxonomySpecies`)} title={ t('accession.overview.taxonomy currentTaxonomySpecies') }
propertyItemProps={{numeric: true, titleStyle: {fontStyle: 'italic'}}} propertyItemProps={ { numeric: true, titleStyle: { fontStyle: 'italic' } } }
/> />
} }
{overviewsTerms && overviewsTerms.get('sampStat') && { overviewsTerms && overviewsTerms.get('sampStat') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('sampStat')} propertiesList={ overviewsTerms.get('sampStat') }
translationGroup="sampleStatus" translationGroup="sampleStatus"
title={t(`accession.overview.sampStat`)} title={ t('accession.overview.sampStat') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
{overviewsTerms && overviewsTerms.get('storage') && { overviewsTerms && overviewsTerms.get('storage') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('storage')} propertiesList={ overviewsTerms.get('storage') }
translationGroup="storage" translationGroup="storage"
title={t(`accession.overview.storage`)} title={ t('accession.overview.storage') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
{overviewsTerms && overviewsTerms.get('countryOfOrigin.code3') && { overviewsTerms && overviewsTerms.get('countryOfOrigin.code3') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('countryOfOrigin.code3')} propertiesList={ overviewsTerms.get('countryOfOrigin.code3') }
countyCodes={countryCodes} countyCodes={ countryCodes }
title={t(`accession.overview.countryOfOrigin code3`)} title={ t('accession.overview.countryOfOrigin code3') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
{overviewsTerms && overviewsTerms.get('donorCode') && { overviewsTerms && overviewsTerms.get('donorCode') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('donorCode')} propertiesList={ overviewsTerms.get('donorCode') }
title={t(`accession.overview.donorCode`)} title={ t('accession.overview.donorCode') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
{overviewsTerms && overviewsTerms.get('duplSite') && { overviewsTerms && overviewsTerms.get('duplSite') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('duplSite')} propertiesList={ overviewsTerms.get('duplSite') }
title={t(`accession.overview.duplSite`)} title={ t('accession.overview.duplSite') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
{overviewsTerms && overviewsTerms.get('breederCode') && { overviewsTerms && overviewsTerms.get('breederCode') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('breederCode')} propertiesList={ overviewsTerms.get('breederCode') }
title={t(`accession.overview.breederCode`)} title={ t('accession.overview.breederCode') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
{overviewsTerms && overviewsTerms.get('mlsStatus') && { overviewsTerms && overviewsTerms.get('mlsStatus') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('mlsStatus')} propertiesList={ overviewsTerms.get('mlsStatus') }
translationGroup="mlsStatus" translationGroup="mlsStatus"
title={t(`accession.overview.mlsStatus`)} title={ t('accession.overview.mlsStatus') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
{overviewsTerms && overviewsTerms.get('aegis') && { overviewsTerms && overviewsTerms.get('aegis') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('aegis')} propertiesList={ overviewsTerms.get('aegis') }
translationGroup="aegisStatus" translationGroup="aegisStatus"
title={t(`accession.overview.aegis`)} title={ t('accession.overview.aegis') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
{overviewsTerms && overviewsTerms.get('available') && { overviewsTerms && overviewsTerms.get('available') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('available')} propertiesList={ overviewsTerms.get('available') }
translationGroup="available" translationGroup="available"
title={t(`accession.overview.available`)} title={ t('accession.overview.available') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
{overviewsTerms && overviewsTerms.get('historic') && { overviewsTerms && overviewsTerms.get('historic') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('historic')} propertiesList={ overviewsTerms.get('historic') }
translationGroup="historic" translationGroup="historic"
title={t(`accession.overview.historic`)} title={ t('accession.overview.historic') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
{overviewsTerms && overviewsTerms.get('sgsv') && { overviewsTerms && overviewsTerms.get('sgsv') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('sgsv')} propertiesList={ overviewsTerms.get('sgsv') }
translationGroup="sgsv" translationGroup="sgsv"
title={t(`accession.overview.sgsv`)} title={ t('accession.overview.sgsv') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
{overviewsTerms && overviewsTerms.get('institute.code') && { overviewsTerms && overviewsTerms.get('institute.code') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('institute.code')} propertiesList={ overviewsTerms.get('institute.code') }
title={t(`accession.overview.institute code`)} title={ t('accession.overview.institute code') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
{overviewsTerms && overviewsTerms.get('institute.country.code3') && { overviewsTerms && overviewsTerms.get('institute.country.code3') &&
<PropertiesCard <PropertiesCard
propertiesList={overviewsTerms.get('institute.country.code3')} propertiesList={ overviewsTerms.get('institute.country.code3') }
countyCodes={countryCodes} countyCodes={ countryCodes }
title={t(`accession.overview.institute country code3`)} title={ t('accession.overview.institute country code3') }
propertyItemProps={{numeric: true}} propertyItemProps={ { numeric: true } }
/> />
} }
</div> </div>
......
...@@ -6,7 +6,7 @@ import AccessionList from './AccessionListPage'; ...@@ -6,7 +6,7 @@ import AccessionList from './AccessionListPage';
import AccessionDetails from './AccessionDetailsPage'; import AccessionDetails from './AccessionDetailsPage';
import { createHashHistory } from 'history'; import { createHashHistory } from 'history';
import CartPage from './CartPage'; import CartPage from './CartPage';
import OverviewPage from "ui/OverviewPage"; import OverviewPage from 'ui/OverviewPage';
const hashHistory = createHashHistory({}); const hashHistory = createHashHistory({});
...@@ -43,4 +43,4 @@ export default class App extends React.Component<IAppProps, any> { ...@@ -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 * as React from 'react';