Commit d5faae2e authored by Matija Obreza's avatar Matija Obreza

Merge branch '552-upgrade-dependencies-unstable' into 'master'

Resolve "Upgrade dependencies"

Closes #552

See merge request genesys-pgr/genesys-ui!541
parents ac9a9ced 7d53c53b
{
"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?$/,
......@@ -168,7 +171,9 @@ module.exports = {
loader: 'sass-loader',
options: {
sourceMap: true,
includePaths: ['node_modules']
sassOptions: {
includePaths: ['node_modules']
}
}
}
]
......@@ -285,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(),
......
......@@ -2,18 +2,18 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';
import Loadable from 'react-loadable';
import {routerMiddleware, ConnectedRouter} from 'react-router-redux';
import createHistory from 'history/createBrowserHistory';
import {routerMiddleware, ConnectedRouter} from 'connected-react-router';
import { createBrowserHistory as createHistory } from 'history';
import {Provider} from 'react-redux';
import {applyMiddleware, compose, createStore} from 'redux';
import { checkAccessTokens, refreshAuthTokenAuto } from 'actions/login';
import rootReducer from 'reducers/index';
import thunk from 'redux-thunk';
import {log} from 'utilities/debug';
import { I18nextProvider } from 'react-i18next';
import { I18nextProvider, withSSR } from 'react-i18next';
import routes from 'ui/routes';
import renderRoutes from 'ui/renderRoutes';
import i18nClient from '../i18n/i18n-client';
import { i18nClient } from '../i18n/i18n-client';
import detectLocaleFromPath from '../server/middleware/detectLocaleFromPath';
import getDir from '../server/middleware/detectDirection';
import { receiveLang } from 'actions/applicationConfig';
......@@ -39,11 +39,14 @@ const history = createHistory(historyOptions);
const direction = getDir(detectedLang);
const initialState = __PRELOADED_STATE__ === undefined ? {} : __PRELOADED_STATE__;
const store = composeEnhancers(applyMiddleware(thunk, routerMiddleware(history)))(createStore)(rootReducer, initialState);
const store = composeEnhancers(applyMiddleware(thunk, routerMiddleware(history)))(createStore)(rootReducer(history), initialState);
const SsrI18nProvider = withSSR()(I18nextProvider) as any;
// Configure axios for client
configureBackendApi({ apiUrl: store.getState().applicationConfig.apiUrl || process.env.API_URL || 'http://localhost:8080' });
if (__PRELOADED_STATE__ === undefined) {
document.getElementsByTagName('html')[0].setAttribute('lang', detectedLang);
document.getElementsByTagName('html')[0].setAttribute('dir', direction);
......@@ -55,7 +58,7 @@ if (__PRELOADED_STATE__ === undefined) {
ReactDOM.render(
<Provider store={ store }>
<ConnectedRouter history={ history }>
<I18nextProvider i18n={ i18nClient } initialLanguage={ initialLanguage } initialI18nStore={ initialI18nStore }>
<I18nextProvider i18n={ i18nClient }>
<MuiThemeProvider theme={ theme(direction) }>
{ renderRoutes(routes) }
</MuiThemeProvider>
......@@ -74,11 +77,11 @@ if (__PRELOADED_STATE__ === undefined) {
ReactDOM.hydrate(
<Provider store={ store }>
<ConnectedRouter history={ history }>
<I18nextProvider i18n={ i18nClient } initialLanguage={ initialLanguage } initialI18nStore={ initialI18nStore }>
<SsrI18nProvider i18n={ i18nClient } initialLanguage={ initialLanguage } initialI18nStore={ initialI18nStore }>
<MuiThemeProvider theme={ theme(direction) }>
{ renderRoutes(routes) }
</MuiThemeProvider>
</I18nextProvider>
</SsrI18nProvider>
</ConnectedRouter>
</Provider>,
document.getElementById('the-app'),
......
import * as i18n from 'i18next';
// @ts-ignore
import i18n from 'i18next';
import axios from 'axios';
import optionsBase from './options-base';
import langDetector from './langDetector';
const XHR = require('i18next-xhr-backend');
const LanguageDetector = require('i18next-browser-languagedetector');
import XHR from 'i18next-xhr-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';
const lngDetector = new LanguageDetector();
lngDetector.addDetector(langDetector);
......@@ -28,15 +29,21 @@ const backendKey = 'backend';
optionsBase[backendKey] = backend;
const i18nClient = i18n
i18n
.use(XHR)
.use(lngDetector)
.use(initReactI18next)
.init({
detection: {
order: ['catalogLangDetector'],
lookupFromPathIndex: 0,
},
react: {
useSuspense: false,
},
...optionsBase,
});
export default i18nClient;
export { i18n as i18nClient };
import * as i18n from 'i18next';
// @ts-ignore
import i18n from 'i18next';
import * as path from 'path';
import optionsBase from './options-base';
const Backend = require('i18next-sync-fs-backend'); // has no proper import yet
import Backend from 'i18next-sync-fs-backend';
import { initReactI18next } from 'react-i18next';