Skip to content

Commit

Permalink
Merge pull request #617 from maryia-deriv/maryia/DTRA-970/security-audit
Browse files Browse the repository at this point in the history
[DTRA] Maryia/DTRA-970/build: packages audit, upgrading to node 18 & webpack 5
  • Loading branch information
balakrishna-deriv authored Mar 29, 2024
2 parents ffa1005 + 89b1984 commit dcfe6ca
Show file tree
Hide file tree
Showing 77 changed files with 15,444 additions and 15,898 deletions.
3 changes: 1 addition & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"presets": ["env", "stage-1", "react"],
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
"transform-decorators-legacy",
"transform-object-rest-spread",
"transform-class-properties",
"babel-plugin-syntax-dynamic-import",
[
Expand Down
67 changes: 37 additions & 30 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
parser: 'babel-eslint',
env: {
parser: '@babel/eslint-parser',
env : {
es6 : true,
browser: true,
amd : true,
Expand All @@ -12,35 +12,38 @@ module.exports = {
texts_json: false,
},
rules: {
camelcase : 0,
semi : ['error', 'always'],
'array-callback-return' : 0,
'brace-style' : ['error', '1tbs', { allowSingleLine: true }],
'eol-last' : ['error', 'always'],
'func-names' : ['error', 'never'],
'keyword-spacing' : ['error', { after: true }],
'lines-between-class-members' : ['error', 'always', { exceptAfterSingleLine: true }],
'no-extra-semi' : 'error',
'no-console' : 'error',
'no-else-return' : ['error', { allowElseIf: true }],
'no-multi-assign' : 0,
'no-param-reassign' : ['error', { props: false }],
'no-restricted-globals' : 0,
'no-script-url' : 0,
'no-trailing-spaces' : ['error', { skipBlankLines: true }],
'object-curly-spacing' : ['error', 'always', { arraysInObjects: true, objectsInObjects: true }],
'one-var' : ['error', { initialized: 'never', uninitialized: 'always' }],
'prefer-destructuring' : 0,
'space-in-parens' : ['error', 'never'],
'space-infix-ops' : 'error',
'space-unary-ops' : 'error',
'no-multiple-empty-lines' : ['error', { 'max': 1, 'maxEOF': 1 }],
camelcase : 0,
semi : ['error', 'always'],
'array-callback-return' : 0,
'brace-style' : ['error', '1tbs', { allowSingleLine: true }],
'eol-last' : ['error', 'always'],
'func-names' : ['error', 'never'],
'keyword-spacing' : ['error', { after: true }],
'lines-between-class-members' : ['error', 'always', { exceptAfterSingleLine: true }],
'no-extra-semi' : 'error',
'no-console' : 'error',
'no-else-return' : ['error', { allowElseIf: true }],
'no-multi-assign' : 0,
'no-param-reassign' : ['error', { props: false }],
'no-restricted-globals' : 0,
'no-script-url' : 0,
'no-trailing-spaces' : ['error', { skipBlankLines: true }],
'object-curly-spacing' : ['error', 'always', { arraysInObjects: true, objectsInObjects: true }],
'one-var' : ['error', { initialized: 'never', uninitialized: 'always' }],
'prefer-destructuring' : 0,
'space-in-parens' : ['error', 'never'],
'space-infix-ops' : 'error',
'space-unary-ops' : 'error',
'no-multiple-empty-lines' : ['error', { 'max': 1, 'maxEOF': 1 }],
'prefer-exponentiation-operator': 0,
'prefer-object-spread' : 0,

// import rules
'import/no-extraneous-dependencies' : [0, { extensions: ['.jsx'] }],
'import/no-useless-path-segments' : 'error',
'import/order' : ['error', { groups: [['builtin', 'external'], 'internal', 'sibling', 'parent'], 'newlines-between': 'ignore' }],
'import/prefer-default-export' : 0,
'import/no-extraneous-dependencies': [0, { extensions: ['.jsx'] }],
'import/no-useless-path-segments' : 'error',
'import/order' : ['error', { groups: [['builtin', 'external'], 'internal', 'sibling', 'parent'], 'newlines-between': 'ignore' }],
'import/prefer-default-export' : 0,
'import/extensions' : [0, { 'js': 'always' }],

// react rules
'jsx-quotes' : ['error', 'prefer-single'],
Expand All @@ -65,10 +68,14 @@ module.exports = {
ecmaFeatures: {
jsx: true,
},
requireConfigFile: false,
babelOptions : {
configFile: './.babelrc',
},
},
settings: {
react: {
version: '16',
version: 'detect',
},
},
};
2 changes: 1 addition & 1 deletion .github/workflows/release_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@f1f314fca9dfce2769ece7d933488f076716723e
with:
node-version: 12
node-version: 18.x
- name: Install dependencies
uses: "./.github/actions/npm_install"
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@f1f314fca9dfce2769ece7d933488f076716723e
with:
node-version: 12
node-version: 18.x
- name: Install dependencies
uses: "./.github/actions/npm_install"
- name: Build Staging
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@f1f314fca9dfce2769ece7d933488f076716723e
with:
node-version: 12.22
node-version: 18.x
- name: Install dependencies
uses: "./.github/actions/npm_install"
- name: Build
Expand Down
59 changes: 3 additions & 56 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,32 @@ module.exports = {
plugins: [
'stylelint-selector-bem-pattern',
],
customSyntax: 'postcss-scss',
rules: {
'at-rule-name-case' : 'lower',
'at-rule-name-space-after' : 'always',
'at-rule-semicolon-newline-after' : 'always',
'block-closing-brace-newline-after' : 'always',
'block-closing-brace-newline-before' : 'always',
'at-rule-no-unknown' : null,
'block-no-empty' : true,
'block-opening-brace-newline-after' : 'always',
'block-opening-brace-space-before' : 'always',
'color-hex-case' : 'lower',
'color-named' : 'never',
'color-no-hex' : true,
'color-no-invalid-hex' : true,
'declaration-bang-space-after' : 'never',
'declaration-bang-space-before' : 'always',
'declaration-block-no-duplicate-properties' : [true, { ignore: ['consecutive-duplicates'] }],
'declaration-block-no-shorthand-property-overrides': true,
'declaration-block-semicolon-newline-after' : 'always',
'declaration-block-semicolon-newline-before' : 'never-multi-line',
'declaration-block-semicolon-space-after' : 'always-single-line',
'declaration-block-semicolon-space-before' : 'never',
'declaration-block-trailing-semicolon' : 'always',
'declaration-colon-space-after' : 'always',
'declaration-colon-space-before' : 'never',
'font-family-name-quotes' : 'always-unless-keyword',
'function-calc-no-unspaced-operator' : true,
'function-comma-space-after' : 'always',
'function-comma-space-before' : 'never',
'function-name-case' : 'lower',
'function-parentheses-space-inside' : 'never',
'function-url-quotes' : 'always',
'indentation' : 4,
'max-empty-lines' : 1,
'media-feature-colon-space-after' : 'always',
'media-feature-colon-space-before' : 'never',
'media-feature-range-operator-space-after' : 'always',
'media-feature-range-operator-space-before' : 'always',
'media-query-list-comma-newline-after' : 'never-multi-line',
'media-query-list-comma-newline-before' : 'never-multi-line',
'media-query-list-comma-space-after' : 'always',
'media-query-list-comma-space-before' : 'never',
'no-duplicate-selectors' : true,
'no-eol-whitespace' : true,
'no-extra-semicolons' : true,
'no-invalid-double-slash-comments' : true,
'number-leading-zero' : 'always',
'number-max-precision' : 3,
'number-no-trailing-zeros' : true,
'property-case' : 'lower',
'rule-empty-line-before' : ['always', { ignore: ['after-comment'], except: ['inside-block-and-after-rule', 'first-nested'] }],
'selector-attribute-brackets-space-inside' : 'never',
'selector-attribute-operator-space-after' : 'never',
'selector-attribute-operator-space-before' : 'never',
'selector-class-pattern' : null,
'selector-combinator-space-after' : 'always',
'selector-combinator-space-before' : 'always',
'selector-list-comma-newline-after' : 'never-multi-line',
'selector-list-comma-newline-before' : 'never-multi-line',
'selector-list-comma-space-after' : 'always',
'selector-list-comma-space-before' : 'never',
'selector-max-empty-lines' : 0,
'selector-pseudo-class-case' : 'lower',
'selector-pseudo-class-no-unknown' : true,
'selector-pseudo-class-parentheses-space-inside' : 'never',
'selector-pseudo-element-case' : 'lower',
'selector-pseudo-element-colon-notation' : 'single',
'selector-pseudo-element-no-unknown' : true,
'selector-type-case' : 'lower',
'selector-type-no-unknown' : [true, { ignoreTypes: ['from', 'to', '0%', '50%', '100%', '_'] }],
'shorthand-property-no-redundant-values' : true,
'string-no-newline' : true,
'string-quotes' : 'single',
'time-min-milliseconds' : 100,
'unit-case' : 'lower',
'unit-whitelist' : ['px', 'em', 'rem', '%', 'vw', 'vh', 'deg', 'ms', 's', 'fr'],
'value-keyword-case' : 'lower',
'value-list-comma-newline-after' : 'never-multi-line',
'value-list-comma-newline-before' : 'never-multi-line',
'value-list-comma-space-after' : 'always',
'value-list-comma-space-before' : 'never',
'unit-allowed-list' : ['px', 'em', 'rem', '%', 'vw', 'vh', 'deg', 'ms', 's', 'fr'],
}
};
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Before running or contribute to this project, you need to have the setup of the

- Ruby, RubyGems
- Sass (`sudo gem install sass`)
- Node.js (14.19.3 is recommended)
- Node.js (18.16.0 is recommended)
- NPM (see <https://nodejs.org/en/download/package-manager/>)
- NVM (see <https://www.linode.com/docs/guides/how-to-install-use-node-version-manager-nvm/> and follow install NVM section)
- Grunt (`sudo npm install -g grunt-cli`)
Expand Down Expand Up @@ -59,7 +59,7 @@ Before running or contribute to this project, you need to have the setup of the

- Check node version `node -v`
- Check list of available node versions `nvm ls`
- To install node 14 `nvm install 14`
- To install node 18 `nvm install 18`
- To switch to a different node version in the current terminal `nvm use {version number}`

6. **Install your dependencies:**
Expand Down
2 changes: 1 addition & 1 deletion build/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
options: {
minified : true,
plugins : ['transform-remove-strict-mode'],
presets : ['env'],
presets : ['@babel/preset-env'],
sourceMap : true,
sourceType: 'script',
},
Expand Down
3 changes: 2 additions & 1 deletion build/checkDependencies.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
all: {
options: {
install : false,
install : true,
continueAfterInstall: true,
verbose : true,
scopeList: ['dependencies', 'devDependencies'],
},
Expand Down
1 change: 0 additions & 1 deletion build/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const release_config = {

const node_modules_paths = {
binary_style: 'node_modules/@binary-com/binary-style',
deriv_p2p : 'node_modules/@deriv/p2p',
};

const config = {
Expand Down
2 changes: 1 addition & 1 deletion build/config/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const isRelease = (grunt) => ['release', 'releaseci'].indexOf(grunt.cli.tasks[0]) != -1;
const isRelease = (grunt) => ['release', 'releaseci'].indexOf(grunt.cli.tasks[0]) !== -1;

const getReleaseTarget = (grunt) => {
const release_target = Object.keys(global.release_config).find(grunt.option);
Expand Down
12 changes: 6 additions & 6 deletions build/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ module.exports = function (grunt) {
return {
livereload: {
options: {
hostname : '0.0.0.0',
port : 8090,
protocol : 'https',
base : 'dist',
open : {
hostname : '0.0.0.0',
port : 8090,
protocol : 'https',
base : 'dist',
open : {
appName: {
app: 'Google\ Chrome'
name: 'Google\ Chrome'
},
target : 'https://localhost:8090',
},
Expand Down
1 change: 0 additions & 1 deletion build/cssmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module.exports = {
dest: `${global.dist}/css/common.min.css`,
},
{ src: `${global.dist}/css/app.css`, dest: `${global.dist}/css/app.min.css` },
{ src: `${global.node_modules_paths.deriv_p2p}/lib/main.css`, dest: `${global.dist}/css/p2p.min.css` },
{ src: `${global.dist}/css/static.css`, dest: `${global.dist}/css/static.min.css` },
],
},
Expand Down
4 changes: 2 additions & 2 deletions build/mochaTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module.exports = {
quiet : false, // Optionally suppress output to standard out (defaults to false)
clearRequireCache: false, // Optionally clear the require cache before running tests (defaults to false)
require: [
'babel-register',
'babel-polyfill',
'@babel/register',
'@babel/polyfill',
'jsdom-global/register',
'mock-local-storage',
],
Expand Down
2 changes: 1 addition & 1 deletion build/postcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = function (grunt) {
return {
options: {
processors: [
require('autoprefixer')({ browsers: ['last 2 version', 'last 5 iOS versions', 'last 3 Safari versions'] })
require('autoprefixer')()
],
},
dist: {
Expand Down
2 changes: 1 addition & 1 deletion build/sass.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const sass = require('node-sass');
const sass = require('sass');

module.exports = {
app: {
Expand Down
1 change: 0 additions & 1 deletion build/webpack.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const appConfig = require('./webpack/config_app');
Expand Down
32 changes: 16 additions & 16 deletions build/webpack/config_common.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const publicPathFactory = require('./helpers').publicPathFactory;

const commonConfig = (grunt) => ({
devtool: false, // handled by SourceMapDevToolPlugin
mode : global.is_release ? 'production' : 'development',
stats : {
chunks : false,
maxModules: 0,
warnings : false,
chunks : false,
warnings: false,
},
output: {
filename : '[name].js',
chunkFilename: '[name].min.js',
publicPath : publicPathFactory(grunt),
},
optimization: {
namedChunks: true,
minimize : true,
minimizer : [
new UglifyJsPlugin({
test : /\.min\.js/,
exclude : /vendors~/,
parallel : true,
sourceMap: true,
chunkIds : 'named',
minimize : true,
minimizer: [
new TerserPlugin({
test : /\.min\.js$/,
exclude : /vendors~/,
parallel : true,
terserOptions: {
sourceMap: true,
},
}),
],
},
Expand All @@ -36,10 +37,9 @@ const commonConfig = (grunt) => ({
exclude: /node_modules/,
loader : 'babel-loader',
options: {
presets: ['env', 'stage-1', 'react'],
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: [
'transform-decorators-legacy',
'transform-object-rest-spread',
'transform-class-properties',
'babel-plugin-syntax-dynamic-import',
],
Expand All @@ -50,9 +50,9 @@ const commonConfig = (grunt) => ({
use : [
'babel-loader',
{
loader : 'react-svg-loader',
loader : '@svgr/webpack',
options: {
svgo: {
svgoConfig: {
plugins: [
{ removeTitle: false },
],
Expand Down
Loading

0 comments on commit dcfe6ca

Please sign in to comment.