Skip to content

Commit b253e51

Browse files
author
Michael Johansen
authored
TFP-449 FPSAK-FRONTEND: Oppdatere dependencies og fjerne sikkerhetsproblemer (navikt#720)
Merger denne selv om quality gate fra SonarCloud feiler. Den feiler pga gammel kode. :-(
1 parent 8434107 commit b253e51

File tree

54 files changed

+5130
-3280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+5130
-3280
lines changed

.circleci/config.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
docker:
3434
- image: circleci/node:latest
3535
working_directory: ~/repo
36+
resource_class: large
3637
steps:
3738
- attach_workspace:
3839
at: /tmp/workspace
@@ -46,7 +47,12 @@ jobs:
4647
- yarn-packages-{{ checksum "yarn.lock" }}
4748
- run:
4849
name: Run yarn install
49-
command: yarn install --ignore-scripts --no-progress --frozen-lockfile
50+
command: yarn install --ignore-optional --ignore-scripts --no-progress --frozen-lockfile
51+
# - run:
52+
# name: Node prune feiler på "assets" i NAV-folderen.
53+
# command: |
54+
# curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | bash
55+
# ./bin/node-prune
5056
- run:
5157
name: Run linting and tests
5258
command: yarn less:lint && yarn test

.sonarcloud.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Path to sources
22
sonar.sources=packages
3-
sonar.exclusions=**/assets/**,**/*.spec.*
3+
sonar.exclusions=**/assets/**,packages/**/*.spec.*
44
#sonar.inclusions=**/assets/**,**/*.spec.jsx
55

66
# Path to tests
77
sonar.tests=packages
88
#sonar.test.exclusions=
9-
sonar.test.inclusions=**/*.spec.*
9+
sonar.test.inclusions=packages/**/*.spec.*
1010

1111
# Source encoding
1212
sonar.sourceEncoding=UTF-8

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ yarn build
2121
* gjøre form pakken tilgjengelig med final-form og redux-form
2222
* Legge inn readme for pakkene!
2323

24+
25+
## Workspaces
26+
* Common dev dependencies skal kun ligge på roten. ref
27+
https://medium.com/@jsilvax/a-workflow-guide-for-lerna-with-yarn-workspaces-60f97481149d
28+
>If you have common dev dependencies, it’s better to specify them in the workspace root package.json.
29+
>For instance, this can be dependencies like Jest, Husky, Storybook, Eslint, Prettier, etc.
30+
31+
2432
### Licenses and attribution
2533
*For updated information, always see LICENSE first!*
2634

babel.config.js

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,35 @@
1+
/* eslint-disable no-console */
2+
const { NODE_ENV, BABEL_ENV } = process.env;
3+
14
module.exports = function (api) {
2-
api.cache(true);
3-
const presets = ['@babel/react', ['@babel/env', { modules: false }], '@babel/typescript'];
5+
// eslint-disable-next-line no-unused-expressions
6+
api ? api.cache(true) : null;
7+
const presets = [
8+
'@babel/preset-react',
9+
[
10+
'@babel/preset-env',
11+
{
12+
modules: false,
13+
},
14+
],
15+
'@babel/preset-typescript',
16+
];
417
const plugins = ['@babel/plugin-proposal-class-properties'];
518

19+
20+
if (NODE_ENV && BABEL_ENV && NODE_ENV !== BABEL_ENV) {
21+
console.warn('WARNING: Both BABEL_ENV and NODE_ENV are set in');
22+
console.warn('WARNING: the environment, but with different values.');
23+
console.warn(`WARNING: BABEL_ENV = ${BABEL_ENV}`);
24+
console.warn(`WARNING: NODE_ENV = ${NODE_ENV}`);
25+
}
26+
27+
if (NODE_ENV === 'coverage' || BABEL_ENV === 'coverage') {
28+
plugins.push('istanbul');
29+
process.env.NODE_ENV = 'coverage';
30+
process.env.BABEL_ENV = 'coverage';
31+
}
32+
633
return {
734
presets,
835
plugins,

eslint/eslintrc.common.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@ const OFF = 0;
22
const ON = 1;
33
const ERROR = 2;
44

5-
65
const config = {
7-
86
env: {
97
es6: true,
108
browser: true,
119
mocha: true,
1210
},
1311

1412
globals: {
15-
VERSION: ON,
13+
VERSION: 'off',
1614
},
1715

1816
parser: '@typescript-eslint/parser',
@@ -43,7 +41,7 @@ const config = {
4341

4442
// TODO (TOR) Ignorert inntil videre grunnet kost/nytte
4543
'jsx-a11y/anchor-is-valid': OFF,
46-
44+
4745
'@typescript-eslint/no-unused-vars': ERROR,
4846
'@typescript-eslint/indent': OFF,
4947

@@ -52,6 +50,14 @@ const config = {
5250
'@typescript-eslint/explicit-function-return-type': OFF,
5351
'@typescript-eslint/no-explicit-any': OFF,
5452
},
55-
};
5653

54+
overrides: [
55+
{
56+
files: ['*.spec.jsx'],
57+
rules: {
58+
'no-unused-expressions': 'off',
59+
},
60+
},
61+
],
62+
};
5763
module.exports = config;

package.json

+34-33
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "fpsak-frontend",
3-
"version": "0.3.363",
43
"description": "Klient for Foreldrepenger",
54
"main": "./dist/index.js",
65
"author": "NAV",
@@ -11,23 +10,21 @@
1110
"url": "git+https://github.com/navikt/fpsak-frontend.git"
1211
},
1312
"scripts": {
14-
"test": "mochapack --webpack-config webpack/webpack.test.js \"packages/**/*.spec.*\"",
13+
"test": "mochapack --colors --webpack-config webpack/webpack.test.js \"packages/**/*.spec.*\"",
1514
"test:watch": "mochapack --watch --webpack-config webpack/webpack.test.watch.js \"packages/**/*.spec.*\"",
1615
"test:coverage": "nyc mochapack --webpack-config webpack/webpack.test.coverage.js \"packages/**/*.spec.*\"",
1716
"dev": "cross-env NODE_ENV=development node webpack/webpack.dev.server.js --config webpack/webpack.dev.js",
1817
"build": "cross-env NODE_ENV=production webpack --no-progress --colors --config webpack/webpack.prod.js",
19-
"postinstall": "yarn run build && yarn test && yarn run less:lint",
18+
"postinstall": "yarn test && yarn less:lint",
2019
"lerna": "lerna",
2120
"lerna:publish": "(lerna updated && lerna publish --cd-version patch --yes -m \"publish [ci skip]\") || echo \"Ingen endringer avslutter OK\"",
2221
"less:lint": "stylelint \"packages/**/*.less\"",
2322
"ts-check": "tsc --pretty",
2423
"doc": "react-asciidoc-generator ./packages/ -o ../../docs/generated/react.adoc --handlebar-template src/docs/asciidoc-template.handlebars",
25-
"docker:build": "docker build . -t fpfront -f ./docker/Dockerfile --build-arg HTTP_PROXY=$HTTP_PROXY --build-arg HTTPS_PROXY=$HTTP_PROXY",
26-
"docker:start": "yarn docker:stop; yarn docker:build; docker run -d --env-file=./docker/.env --name fpfront -p 443:9000 fpfront",
27-
"docker:stop": "docker stop fpfront; docker rm fpfront",
28-
"redis:start": "docker stop redis; docker rm redis; docker run --name redis -p 6379:6379 -d redis",
2924
"up": "docker-compose up -d --remove-orphans --build",
30-
"down": "docker-compose down"
25+
"down": "docker-compose down",
26+
"lint": "./node_modules/.bin/eslint packages/**/*.jsx",
27+
"remove-node-modules": "find . -name \"node_modules\" -exec rm -rf '{}' +"
3128
},
3229
"workspaces": [
3330
"packages/*"
@@ -36,24 +33,23 @@
3633
"@babel/polyfill": "^7.4.4",
3734
"@babel/runtime": "^7.4.4",
3835
"axios": "^0.19.0",
39-
"circular-dependency-plugin": "^5.0.2",
40-
"copy-webpack-plugin": "^5.0.3",
4136
"core-js": "^3.1.4",
4237
"dotenv": "^8.0.0",
4338
"history": "^4.9.0",
4439
"react": "^16.8.6",
4540
"react-dom": "^16.8.6",
46-
"stylelint-order": "^3.0.0"
41+
"react-modal": "3.9.1"
4742
},
4843
"devDependencies": {
49-
"@babel/core": "^7.4.5",
44+
"@babel/core": "^7.5.5",
5045
"@babel/plugin-proposal-class-properties": "^7.4.4",
5146
"@babel/plugin-transform-runtime": "^7.4.4",
5247
"@babel/preset-env": "^7.4.5",
5348
"@babel/preset-react": "^7.0.0",
5449
"@babel/preset-typescript": "^7.3.3",
55-
"@babel/register": "^7.4.4",
50+
"@babel/register": "^7.5.5",
5651
"@commercetools/enzyme-extensions": "^5.0.0",
52+
"@istanbuljs/nyc-config-babel": "^2.1.1",
5753
"@types/chai": "^4.1.7",
5854
"@types/classnames": "^2.2.8",
5955
"@types/enzyme": "^3.9.3",
@@ -68,26 +64,28 @@
6864
"@types/react-redux": "^7.1.0",
6965
"@types/react-router-dom": "^4.3.4",
7066
"@types/sinon": "^7.0.13",
71-
"@typescript-eslint/eslint-plugin": "^1.10.2",
67+
"@typescript-eslint/eslint-plugin": "^1.13.0",
7268
"@typescript-eslint/parser": "^1.10.2",
7369
"axios-mock-adapter": "^1.16.0",
7470
"babel-eslint": "^10.0.2",
7571
"babel-loader": "^8.0.6",
72+
"babel-plugin-istanbul": "^5.2.0",
73+
"cache-loader": "^4.1.0",
7674
"chai": "^4.2.0",
75+
"circular-dependency-plugin": "^5.0.2",
76+
"copy-webpack-plugin": "^5.0.3",
7777
"cross-env": "^5.2.0",
7878
"css-loader": "^1.0.1",
7979
"enzyme": "^3.10.0",
8080
"enzyme-adapter-react-16": "^1.14.0",
81-
"eslint": "^5.16.0",
82-
"eslint-config-airbnb": "^17.1.0",
83-
"eslint-config-import": "^0.13.0",
81+
"eslint": "^5.3.0",
82+
"eslint-config-airbnb": "^17.1.1",
8483
"eslint-import-resolver-webpack": "^0.11.1",
8584
"eslint-loader": "^2.1.2",
86-
"eslint-plugin-import": "^2.17.2",
87-
"eslint-plugin-jsx-a11y": "^6.2.1",
88-
"eslint-plugin-react": "^7.13.0",
85+
"eslint-plugin-import": "^2.18.0",
86+
"eslint-plugin-jsx-a11y": "^6.2.3",
87+
"eslint-plugin-react": "^7.14.2",
8988
"file-loader": "^4.0.0",
90-
"happypack": "^5.0.1",
9189
"html-webpack-plugin": "^3.2.0",
9290
"ignore-styles": "^5.0.1",
9391
"istanbul-instrumenter-loader": "^3.0.1",
@@ -97,29 +95,32 @@
9795
"less": "^3.8.1",
9896
"less-loader": "^5.0.0",
9997
"mini-css-extract-plugin": "^0.7.0",
100-
"mocha": "^6.1.4",
101-
"mochapack": "^1.1.1",
98+
"mocha": "^6.2.0",
99+
"mochapack": "^1.1.2",
102100
"null-loader": "^3.0.0",
103101
"nyc": "^14.1.1",
104-
"optimize-css-assets-webpack-plugin": "^4.0.3",
102+
"optimize-css-assets-webpack-plugin": "^5.0.3",
105103
"react-test-renderer": "^16.8.6",
106104
"redux-mock-store": "^1.5.3",
107-
"sinon": "^5.0.10",
108-
"sinon-chai": "^3.2.0",
105+
"sinon": "^7.3.2",
106+
"sinon-chai": "^3.3.0",
109107
"style-loader": "^0.23.1",
110108
"stylelint": "^10.1.0",
109+
"stylelint-order": "^3.0.0",
110+
"thread-loader": "^2.1.2",
111111
"typescript": "^3.4.5",
112112
"uglifyjs-webpack-plugin": "^2.1.0",
113-
"wait-on": "^3.2.0",
114-
"webpack": "^4.35.0",
115-
"webpack-cli": "^3.3.5",
113+
"webpack": "^4.38.0",
114+
"webpack-cli": "^3.3.6",
116115
"webpack-dev-server": "^3.3.1",
117116
"webpack-merge": "^4.2.1"
118117
},
119118
"resolutions": {
120119
"react-test-renderer": "^16.8.6"
121120
},
122121
"nyc": {
122+
"cache": false,
123+
"check-coverage": true,
123124
"require": [
124125
"@babel/register",
125126
"./setup/setup.jsx"
@@ -129,7 +130,7 @@
129130
"reporter": [
130131
"text",
131132
"lcov",
132-
"html"
133+
"text-summary"
133134
],
134135
"extension": [
135136
".jsx",
@@ -138,9 +139,9 @@
138139
".es6"
139140
],
140141
"exclude": [
141-
"**/*.spec.jsx",
142-
"**/*.spec.tsx",
143-
"**/*.spec.ts"
142+
"packages/**/*.spec.jsx",
143+
"packages/**/*.spec.tsx",
144+
"packages/**/*.spec.ts"
144145
]
145146
}
146147
}

packages/dekorator/package.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,30 @@
1111
"@fpsak-frontend/shared-components": "1.0.0",
1212
"@fpsak-frontend/utils": "1.0.0",
1313
"classnames": "^2.2.6",
14+
"lodash.throttle": "^4.1.1",
15+
"nav-frontend-core": "4.0.9",
1416
"nav-frontend-grid": "1.0.21",
1517
"nav-frontend-grid-style": "0.2.18",
18+
"nav-frontend-js-utils": "^1.0.7",
1619
"nav-frontend-knapper": "1.0.30",
1720
"nav-frontend-knapper-style": "0.3.26",
1821
"nav-frontend-lukknapp": "1.0.21",
1922
"nav-frontend-lukknapp-style": "0.2.19",
2023
"nav-frontend-modal": "1.0.28",
2124
"nav-frontend-modal-style": "0.3.29",
25+
"nav-frontend-paneler-style": "0.3.15",
2226
"nav-frontend-typografi": "2.0.12",
2327
"nav-frontend-typografi-style": "1.0.13",
2428
"prop-types": "^15.7.2",
2529
"react": "^16.8.6",
2630
"react-intl": "^2.8.0",
31+
"react-modal": "3.9.1",
2732
"react-redux": "^5.1.1",
2833
"react-router-dom": "^4.3.1",
34+
"redux": "^4.0.4",
2935
"reselect": "^4.0.0"
3036
},
3137
"devDependencies": {
32-
"@fpsak-frontend/utils-test": "1.0.0",
33-
"chai": "^4.2.0",
34-
"enzyme": "^3.10.0",
35-
"sinon": "^5.0.10",
36-
"sinon-chai": "^3.2.0"
38+
"@fpsak-frontend/utils-test": "1.0.0"
3739
}
3840
}

packages/error-api-redux/package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,5 @@
88
"reselect": "^4.0.0",
99
"@fpsak-frontend/utils": "1.0.0"
1010
},
11-
"devDependencies": {
12-
"chai": "^4.2.0",
13-
"sinon": "^5.0.10"
14-
}
11+
"devDependencies": {}
1512
}

packages/form/package.json

+2-6
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,10 @@
2828
"react": "^16.8.6",
2929
"react-intl": "^2.8.0",
3030
"react-redux": "^5.1.1",
31-
"redux": "^4.0.1",
31+
"redux": "^4.0.4",
3232
"redux-form": "^7.4.2"
3333
},
3434
"devDependencies": {
35-
"@fpsak-frontend/utils-test": "1.0.0",
36-
"chai": "^4.2.0",
37-
"enzyme": "^3.10.0",
38-
"sinon": "^5.0.10",
39-
"sinon-chai": "^3.2.0"
35+
"@fpsak-frontend/utils-test": "1.0.0"
4036
}
4137
}

packages/form/src/SelectField.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import renderNavField from './renderNavField';
77
import { labelPropType } from './Label';
88
import ReadOnlyField from './ReadOnlyField';
99

10-
// eslint-disable-next-line react/prop-types
10+
/* eslint-disable-next-line react/prop-types */
1111
const renderReadOnly = () => ({ input, selectValues, ...otherProps }) => {
12+
/* eslint-disable-next-line react/prop-types */
1213
const option = selectValues.map(sv => sv.props).find(o => o.value === input.value);
1314
const value = option ? option.children : undefined;
1415
return <ReadOnlyField input={{ value }} {...otherProps} />;

packages/form/src/renderNavField.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const renderNavField = (WrappedNavFieldComponent) => {
4545
input: PropTypes.shape(fieldInputPropTypes).isRequired,
4646
meta: PropTypes.shape({
4747
...fieldMetaPropTypes,
48+
submitFailed: PropTypes.bool,
4849
error: PropTypes.any,
4950
}).isRequired,
5051
intl: intlShape.isRequired,

0 commit comments

Comments
 (0)