Commit e7cf13da authored by Viacheslav Pavlov's avatar Viacheslav Pavlov

WIP: migration from tslint to eslint

hotfix of props
parent 3e2668b8
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": [
"@typescript-eslint",
"@typescript-eslint/tslint",
"prefer-arrow"
],
"settings": {
"react": {
"version": "detect"
}
},
"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/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/member-delimiter-style": [
"error",
{
"multiline": {
"delimiter": "comma",
"requireLast": true
},
"singleline": {
"delimiter": "comma",
"requireLast": false
},
"overrides": {
"interface": {
"multiline": {
"delimiter": "semi",
"requireLast": true
}
}
}
}
],
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-use-before-declare": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "error",
"arrow-body-style": "off",
"arrow-parens": [
"error",
"always"
],
"camelcase": "off",
"capitalized-comments": "off",
"complexity": "off",
"constructor-super": "error",
"curly": "error",
"dot-notation": "error",
"eol-last": "error",
"eqeqeq": [
"error",
"smart"
],
"guard-for-in": "error",
"id-match": "error",
"import/no-extraneous-dependencies": "off",
"import/no-internal-modules": "off",
"import/order": "off",
"max-classes-per-file": [
"error",
10
],
"max-len": [
"error",
{
"code": 250
}
],
"new-parens": "error",
"no-bitwise": "error",
"no-caller": "error",
"no-cond-assign": "error",
"no-console": "off",
"no-debugger": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "error",
"no-empty": "error",
"no-eval": "error",
"no-extra-bind": "error",
"no-fallthrough": "off",
"no-invalid-this": "off",
"no-multiple-empty-lines": [
"error",
{
"max": 3
}
],
"no-new-func": "error",
"no-new-wrappers": "error",
"no-redeclare": "error",
"no-return-await": "error",
"no-sequences": "error",
"no-shadow": [
"off",
{
"hoist": "all"
}
],
"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-unsafe-finally": "error",
"no-unused-expressions": "off",
"no-unused-labels": "error",
"no-var": "error",
"object-shorthand": "error",
"one-var": [
"error",
"never"
],
"prefer-arrow/prefer-arrow-functions": [
"off",
{
"disallowPrototype": true,
"singleReturnOnly": false,
"classPropertiesAllowed": false
}
],
"prefer-const": "error",
"prefer-object-spread": "error",
"quote-props": [
"error",
"consistent-as-needed"
],
"radix": "error",
"space-before-function-paren": [
"error",
{
"anonymous": "never",
"asyncArrow": "always",
"named": "never"
}
],
"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"
]
}
}
]
}
}
......@@ -38,15 +38,17 @@ module.exports = {
module: {
rules: [
{
enforce: 'pre',
test: /\.tsx?$/,
loader: 'tslint-loader'
enforce: 'pre',
loader: 'eslint-loader',
exclude: /node_modules/,
},
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{
test: /\.tsx?$/,
use: ["awesome-typescript-loader"]
}
use: {
loader: 'awesome-typescript-loader',
},
},
]
},
......
......@@ -3,12 +3,12 @@ const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const HtmlWebpackExcludeAssetsPlugin = require('html-webpack-exclude-assets-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const WebpackChunkHash = require("webpack-chunk-hash");
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WebpackChunkHash = require('webpack-chunk-hash');
const ManifestPlugin = require('webpack-manifest-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const GitRevisionPlugin = require('git-revision-webpack-plugin');
var gitRevisionPlugin = new GitRevisionPlugin();
const gitRevisionPlugin = new GitRevisionPlugin();
const ReactLoadable = require('react-loadable/webpack');
const fs = require('fs');
......@@ -25,12 +25,12 @@ const CLIENT_SECRET = process.env.CLIENT_SECRET || 'changeme';
const sortedChunks = function(list) {
return function(chunk1, chunk2) {
var index1 = list.indexOf(chunk1.names[0]);
var index2 = list.indexOf(chunk2.names[0]);
if (index2 == -1 || index1 < index2) {
const index1 = list.indexOf(chunk1.names[0]);
const index2 = list.indexOf(chunk2.names[0]);
if (index2 === -1 || index1 < index2) {
return -1;
}
if (index1 == -1 || index1 > index2) {
if (index1 === -1 || index1 > index2) {
return 1;
}
return 0;
......@@ -54,7 +54,7 @@ module.exports = {
warnings: true,
errors: true
},
clientLogLevel: "warning",
clientLogLevel: 'warning',
historyApiFallback: {
disableDotRule: true
},
......@@ -68,12 +68,13 @@ module.exports = {
pathRewrite(path, req) {
let p = path.replace('/proxy', '');
if (p.startsWith('/oauth/token')) {
const grantType = req.query['grant_type'];
const grantType = req.query.grant_type;
if (grantType === 'refresh_token') {
const refreshToken = req.query['refresh_token'];
const refreshToken = req.query.refresh_token;
if (!refreshToken) {
req.query['grant_type'] = 'client_credentials';
// eslint-disable-next-line camelcase
req.query.grant_type = 'client_credentials';
p = p.replace('refresh_token', 'client_credentials');
}
}
......@@ -132,14 +133,16 @@ module.exports = {
module: {
rules: [
{
enforce: 'pre',
test: /\.tsx?$/,
loader: 'tslint-loader'
enforce: 'pre',
loader: 'eslint-loader',
exclude: /node_modules/,
},
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
{
test: /\.tsx?$/,
use: [ "awesome-typescript-loader" ]
use: {
loader: 'awesome-typescript-loader',
},
},
// {
// test: /\.js?$/,
......@@ -287,8 +290,8 @@ module.exports = {
// Keep CSS separate
new MiniCssExtractPlugin({
filename: "[name].[hash].css",
chunkFilename: "[name].[hash].css"
filename: '[name].[hash].css',
chunkFilename: '[name].[hash].css'
}),
new HtmlWebpackExcludeAssetsPlugin(),
......
This diff is collapsed.
......@@ -43,9 +43,9 @@
},
"dependencies": {
"@material-ui/core": "^4.5.1",
"@material-ui/styles": "^4.5.0",
"@material-ui/icons": "^4.5.1",
"@material-ui/lab": "^4.0.0-alpha.28",
"@material-ui/styles": "^4.5.0",
"autosuggest-highlight": "^3.1.0",
"axios": "^0.19.0",
"chart.js": "^2.8.0",
......@@ -114,11 +114,15 @@
"url-template": "^2.0.8"
},
"devDependencies": {
"@types/node": "12.12.6",
"@types/react": "16.8.6",
"@types/node": "12.11.2",
"@types/webpack-env": "^1.14.0",
"@typescript-eslint/eslint-plugin": "^2.6.1",
"@typescript-eslint/eslint-plugin-tslint": "^2.6.1",
"@typescript-eslint/parser": "^2.6.1",
"awesome-typescript-loader": "^5.2.1",
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"babel-plugin-react-transform": "^3.0.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
......@@ -132,6 +136,14 @@
"css-loader": "^3.2.0",
"del": "^5.1.0",
"es6-promise": "^4.2.8",
"eslint": "^6.6.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-prettier": "^6.5.0",
"eslint-loader": "^3.0.2",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prefer-arrow": "^1.1.6",
"eslint-plugin-react": "^7.16.0",
"file-loader": "^4.2.0",
"git-revision-webpack-plugin": "^3.0.4",
"html-webpack-exclude-assets-plugin": "0.0.7",
......@@ -163,8 +175,6 @@
"terser-webpack-plugin": "^2.1.2",
"ts-node": "^8.4.1",
"tslint": "^5.20.0",
"tslint-loader": "^3.6.0",
"tslint-react": "^4.1.0",
"typescript": "^3.6.3",
"url-loader": "^1.1.2",
"webpack": "^4.41.0",
......
......@@ -14,7 +14,7 @@ console.dir(argv);
const config = {
// Timeout (ms) for proxied calls to the API
frontendPath: argv['frontend-path'] || '',
origin: argv['origin'] || 'http://localhost:3000',
origin: argv.origin || 'http://localhost:3000',
// Backend
apiTimeout: +(argv['api-timeout'] || 10000),
apiUrl: argv['api-url'] || 'http://localhost:8080',
......
......@@ -8,14 +8,14 @@ import Accession from 'model/accession/Accession';
import ApiCall from 'model/ApiCall';
const INITIAL_STATE: {
accession: ApiCall<Accession>;
paged: ApiCall<FilteredPage<Accession>>;
accession: ApiCall<Accession>,
paged: ApiCall<FilteredPage<Accession>>,
} = {
accession: null,
paged: null,
};
function dashboardAccessions(state = INITIAL_STATE, action: IReducerAction) {
const dashboardAccessions = (state = INITIAL_STATE, action: IReducerAction) => {
switch (action.type) {
......
......@@ -22,22 +22,22 @@ import AccessionDetails from 'model/accession/AccessionDetails';
const INITIAL_STATE: {
accession: ApiCall<Accession>;
accession: ApiCall<Accession>,
auditLog: ApiCall<AccessionAuditLog>,
paged: ApiCall<FilteredPage<Accession>>;
suggestions: any;
overview: ApiCall<AccessionOverview>;
images: ApiCall<FilteredPage<AccessionDetails>>;
mapInfo: ApiCall<AccessionMapInfo>;
mapLayers: MapLayer[];
paged: ApiCall<FilteredPage<Accession>>,
suggestions: any,
overview: ApiCall<AccessionOverview>,
images: ApiCall<FilteredPage<AccessionDetails>>,
mapInfo: ApiCall<AccessionMapInfo>,
mapLayers: MapLayer[],
defaultLayer: {
name: string,
default: boolean,
enabled: boolean,
opacity: number,
color: string,
};
myMaps: any;
},
myMaps: any,
} = {
accession: null,
auditLog: null,
......@@ -57,7 +57,7 @@ const INITIAL_STATE: {
myMaps: [],
};
function publicAccessions(state = INITIAL_STATE, action: IReducerAction) {
const publicAccessions = (state = INITIAL_STATE, action: IReducerAction) => {
switch (action.type) {
......
......@@ -27,7 +27,7 @@ import { ScrollToTopOnMount } from 'ui/common/page/scrollers';
class BrowsePage extends BrowsePageTemplate<Accession> {
constructor(props: IBrowsePageProps<Accession>, context: any) {
public constructor(props: IBrowsePageProps<Accession>, context: any) {
super(props, context);
}
......
......@@ -88,7 +88,7 @@ class BrowsePage extends React.Component<IBrowsePageProps, any> {
},
];
constructor(props: IBrowsePageProps, context: any) {
public constructor(props: IBrowsePageProps, context: any) {
super(props, context);
}
......
......@@ -122,7 +122,7 @@ class ImageBrowsePage extends React.Component<IImageBrowsePageProps> {
const { repositoryThumbnailUrl, classes } = this.props;
const srcSet = (image) => {
const thumbSizes: number[] = [ 200, 300, 600 /*, 1024 */ ];
const thumbSizes: number[] = [ 200, 300, 600 /* , 1024 */ ];
let x: string = '';
for (const size of thumbSizes) {
x += repositoryThumbnailUrl(image, size, size, true) + ` ${size}w, `;
......@@ -157,7 +157,7 @@ class ImageBrowsePage extends React.Component<IImageBrowsePageProps> {
);
}
/// Wrap loadAccessionsMapInfo dispatch and fills the current sort selection
// Wrap loadAccessionsMapInfo dispatch and fills the current sort selection
protected myApplyFilters = (filters: AccessionFilter) => {
const { applyImagesFilters } = this.props;
......
......@@ -82,7 +82,7 @@ interface IMapPageProps extends WithStyles, WithTranslation {
}
const styles = (theme) => ({
/*tslint:disable*/
/* eslint-disable*/
leafletContainer: {
width: '100%',
minHeight: '500px',
......@@ -191,7 +191,7 @@ const styles = (theme) => ({
climateDialogTitle: {
lineHeight: '48px'
}
/*tslint:enable*/
/* eslint-enable */
});
class BrowsePage extends React.Component<IMapPageProps, any> {
......@@ -223,7 +223,7 @@ class BrowsePage extends React.Component<IMapPageProps, any> {
authenticated: false,
};
constructor(props, context) {
public constructor(props, context) {
super(props, context);
if (typeof window !== 'undefined') {
MapComponent = require('react-leaflet').Map;
......@@ -539,7 +539,7 @@ class BrowsePage extends React.Component<IMapPageProps, any> {
}
}
/// Wrap loadAccessionsMapInfo dispatch and fills the current sort selection
// Wrap loadAccessionsMapInfo dispatch and fills the current sort selection
protected myApplyFilters = (filters: AccessionFilter) => {
const { loadAccessionsMapInfo } = this.props;
......
......@@ -37,10 +37,10 @@ interface IOverviewPageProps extends React.ClassAttributes<any>, WithTranslation
updateRouteWithFilterCode: (filterCode: string, path: string) => void;
currentTab: string;
}
/* tslint:disable */
/* eslint-disable */
class BrowsePage extends React.Component<IOverviewPageProps, any> {
constructor(props: IOverviewPageProps, context: any) {
public constructor(props: IOverviewPageProps, context: any) {
super(props, context);
}
......