Skip to content

Commit

Permalink
(#147) Update Node, Webpack, Misc security updates
Browse files Browse the repository at this point in the history
Updates node to 20, webpack to v8 and addresses security updates

```

nvm install 20
nvm use 20
```
* Updates LTS in `.nvmrc`

`npm install webpack@latest --save-dev`
- Updates webpack config to address CRA CommonJS bug  affecting axios/nock/jest combo
   facebook/create-react-app#11889 (comment)

- Updater syntax change for IgnorePlugin in webpack config

- Misc webpack config changes following migration guide: https://webpack.js.org/migrate/5/

- Moves jest config out of package.json into own config

- Adds axios to transformIgnoreModules

`npm audit fix --force`
  • Loading branch information
adriancofie committed Aug 20, 2024
1 parent a982cb2 commit 39c2ccb
Show file tree
Hide file tree
Showing 78 changed files with 19,286 additions and 49,887 deletions.
63 changes: 51 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,77 @@
const jestRules = require('eslint-plugin-jest').rules;
const jestDomRules = require('eslint-plugin-jest-dom').rules;
const testLibRules = require('eslint-plugin-testing-library').rules;

const disableAllRules = (pluginName, rules) => {
return Object.keys(rules).reduce((ac, ruleName) => {
return {
...ac,
[`${pluginName}/${ruleName}`]: 'off',
};
}, {});
};

// We need to turn off jest rules for cypress because
// Cypress uses expect.
const cypressRuleDisables = {
...disableAllRules('jest', jestRules),
...disableAllRules('jest-dom', jestDomRules),
...disableAllRules('testing-library', testLibRules),
};

// Default to development if we've somehow hit the linter without it being set
// react-scritps technically sets this to development also
if (process.env.NODE_ENV == null) {
process.env.NODE_ENV = 'development';
}

module.exports = {
extends: ['@nciocpl/eslint-config-react', 'plugin:jest/recommended', 'plugin:jest-dom/recommended'],
plugins: ['testing-library', 'jest', 'jest-dom'],
env: {
browser: true,
es6: true,
node: true,
jest: true,
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
'plugin:prettier/recommended',
],
settings: {
react: {
version: 'detect',
},
},
parser: 'babel-eslint',
parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 2016,
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
babelOptions: {
presets: ['@babel/preset-react'],
},
},
// Plugins are configured by the recommended extensions above
rules: {
'react/display-name': 'off',
'react-hooks/exhaustive-deps': 'off',
'testing-library/no-render-in-setup': 'off', // This is now no-render-in-lifecycle. Remove when NCIOCPL standards are updated.
'testing-library/no-render-in-lifecycle': 'error',

'testing-library/prefer-wait-for': 'off', // This is now prefer-find-by. Remove when NCIOCPL standards are updated.
'testing-library/prefer-find-by': 'error',

'jest/no-if': 'off', // Removed in eslint-plugin-jest 28. This is now no-conditional-in-test. Note: v28 and above only supports for node 20+. Remove when NCIOCPL standards are updated.
'jest/no-conditional-in-test': 'error',

'react/jsx-filename-extension': [1, { allow: 'always' }],
},
globals: {
cy: true,
Cypress: true,
getFixture: true,
},
ignorePatterns: ['**/node_modules/***', 'build/', 'dist/', '*/node_modules/'],
overrides: [
{
files: ['cypress/**'],
rules: cypressRuleDisables,
},
],
};
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/gallium
lts/iron
12 changes: 11 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const plugins = [];

module.exports = {
presets: ['react-app'],
presets: [
[
'react-app',
{
absoluteRuntime: false,
},
],
'@babel/preset-react',
'@babel/preset-env',
],

plugins,
};
1 change: 1 addition & 0 deletions config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const publicUrlOrPath = getPublicUrlOrPath(
const moduleFileExtensions = [
'web.mjs',
'mjs',
'cjs',
'web.js',
'js',
'web.ts',
Expand Down
Loading

0 comments on commit 39c2ccb

Please sign in to comment.