Exclude files from builds by build type (#12521)
This PR enables the exclusion of JavaScript and JSON source by `buildType`, and enables the running of `eslint` under LavaMoat. 80-90% of the changes in this PR are `.patch` files and LavaMoat policy additions.
The file exclusion is designed to work in conjunction with our code fencing. If you forget to fence an import statement of an excluded file, the application will now error on boot. **This PR commits us to a particular naming convention for files intended only for certain builds.** Continue reading for details.
### Code Fencing and ESLint
When a file is modified by the code fencing transform, we run ESLint on it to ensure that we fail early for syntax-related issues. This PR adds the first code fences that will be actually be removed in production builds. As a consequence, this was also the first time we attempted to run ESLint under LavaMoat. Making that work required a lot of manual labor because of ESLint's use of dynamic imports, but the manual changes necessary were ultimately quite minor.
### File Exclusion
For all builds, any file in `app/`, `shared/` or `ui/` in a sub-directory matching `**/${otherBuildType}/**` (where `otherBuildType` is any build type except `main`) will be added to the list of excluded files, regardless of its file extension. For example, if we want to add one or more pages to the UI settings in Flask, we'd create the folder `ui/pages/settings/flask`, add any necessary files or sub-folders there, and fence the import statements for anything in that folder. If we wanted the same thing for Beta, we would name the directory `ui/pages/settings/beta`.
As it happens, we already organize some of our source files in this way, namely the logo JSON for Beta and Flask builds. See `ui/helpers/utils/build-types.js` to see how this works in practice.
Because the list of ignored filed is only passed to `browserify.exclude()`, any files not bundled by `browserify` will be ignored. For our purposes, this is mostly relevant for `.scss`. Since we don't have anything like code fencing for SCSS, we'll have to consider how to handle our styles separately.
2021-11-02 04:20:31 +01:00
|
|
|
const { version: reactVersion } = require('react/package.json');
|
|
|
|
|
2020-01-22 15:37:19 +01:00
|
|
|
module.exports = {
|
2020-02-11 17:51:13 +01:00
|
|
|
root: true,
|
2020-10-21 18:31:03 +02:00
|
|
|
parser: '@babel/eslint-parser',
|
2020-01-22 15:37:19 +01:00
|
|
|
parserOptions: {
|
2020-11-03 00:41:28 +01:00
|
|
|
sourceType: 'module',
|
|
|
|
ecmaVersion: 2017,
|
|
|
|
ecmaFeatures: {
|
|
|
|
experimentalObjectRestSpread: true,
|
|
|
|
impliedStrict: true,
|
|
|
|
modules: true,
|
|
|
|
blockBindings: true,
|
|
|
|
arrowFunctions: true,
|
|
|
|
objectLiteralShorthandMethods: true,
|
|
|
|
objectLiteralShorthandProperties: true,
|
|
|
|
templateStrings: true,
|
|
|
|
classes: true,
|
|
|
|
jsx: true,
|
2020-01-22 15:37:19 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-09-10 19:05:29 +02:00
|
|
|
ignorePatterns: [
|
|
|
|
'!.eslintrc.js',
|
|
|
|
'node_modules/**',
|
|
|
|
'dist/**',
|
|
|
|
'builds/**',
|
|
|
|
'test-*/**',
|
|
|
|
'docs/**',
|
|
|
|
'coverage/',
|
2021-04-09 19:20:32 +02:00
|
|
|
'jest-coverage/',
|
2021-03-31 05:12:28 +02:00
|
|
|
'development/chromereload.js',
|
2020-09-10 19:05:29 +02:00
|
|
|
'app/vendor/**',
|
2020-11-03 00:41:28 +01:00
|
|
|
'test/e2e/send-eth-with-private-key-test/**',
|
|
|
|
'nyc_output/**',
|
|
|
|
'.vscode/**',
|
2021-02-22 15:43:29 +01:00
|
|
|
'lavamoat/*/policy.json',
|
2021-10-20 14:34:54 +02:00
|
|
|
'storybook-build/**',
|
2020-09-10 19:05:29 +02:00
|
|
|
],
|
|
|
|
|
2020-01-22 15:37:19 +01:00
|
|
|
extends: [
|
|
|
|
'@metamask/eslint-config',
|
2021-04-08 23:34:55 +02:00
|
|
|
'@metamask/eslint-config-nodejs',
|
2021-03-31 17:19:20 +02:00
|
|
|
'prettier',
|
2020-01-22 15:37:19 +01:00
|
|
|
],
|
|
|
|
|
2021-04-01 20:44:31 +02:00
|
|
|
plugins: ['@babel', 'import', 'prettier'],
|
2020-01-22 15:37:19 +01:00
|
|
|
|
|
|
|
globals: {
|
2020-04-15 19:23:27 +02:00
|
|
|
document: 'readonly',
|
|
|
|
window: 'readonly',
|
2020-01-22 15:37:19 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
rules: {
|
2021-03-31 17:19:20 +02:00
|
|
|
'default-param-last': 'off',
|
2021-04-08 23:34:55 +02:00
|
|
|
'prefer-object-spread': 'error',
|
2021-03-31 17:19:20 +02:00
|
|
|
'require-atomic-updates': 'off',
|
2020-08-13 01:49:33 +02:00
|
|
|
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
// This is the same as our default config, but for the noted exceptions
|
|
|
|
'spaced-comment': [
|
|
|
|
'error',
|
|
|
|
'always',
|
|
|
|
{
|
|
|
|
markers: [
|
|
|
|
'global',
|
|
|
|
'globals',
|
|
|
|
'eslint',
|
|
|
|
'eslint-disable',
|
|
|
|
'*package',
|
|
|
|
'!',
|
|
|
|
',',
|
|
|
|
// Local additions
|
|
|
|
'/:', // This is for our code fences
|
|
|
|
],
|
|
|
|
exceptions: ['=', '-'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
2021-04-08 23:34:55 +02:00
|
|
|
'import/no-unassigned-import': 'off',
|
|
|
|
|
2020-08-13 01:49:33 +02:00
|
|
|
'no-invalid-this': 'off',
|
2020-10-21 18:31:03 +02:00
|
|
|
'@babel/no-invalid-this': 'error',
|
2020-08-13 01:49:33 +02:00
|
|
|
|
2021-04-08 23:34:55 +02:00
|
|
|
// Prettier handles this
|
2021-02-04 19:15:23 +01:00
|
|
|
'@babel/semi': 'off',
|
|
|
|
|
2020-10-21 18:31:03 +02:00
|
|
|
'node/no-process-env': 'off',
|
|
|
|
|
|
|
|
// TODO: re-enable these rules
|
|
|
|
'node/no-sync': 'off',
|
|
|
|
'node/no-unpublished-import': 'off',
|
|
|
|
'node/no-unpublished-require': 'off',
|
2020-01-22 15:37:19 +01:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
overrides: [
|
|
|
|
{
|
Increase Jest unit test coverage for the Swaps feature to ~25% (#10900)
* Swaps: Show a network name dynamically in a tooltip
* Replace “Ethereum” with “$1”, change “Test” to “Testnet”
* Replace 이더리움 with $1
* Translate network names, use ‘Ethereum’ by default if a translation is not available yet
* Reorder messages to resolve ESLint issues
* Add a snapshot test for the FeeCard component, increase Jest threshold
* Enable snapshot testing into external .snap files in ESLint
* Add the “networkNameEthereum” key in ko/messages.json, remove default “Ethereum” value
* Throw an error if chain ID is not supported by the Swaps feature
* Use string literals when calling the `t` fn,
* Watch Jest tests silently (no React warnings in terminal, only errors)
* Add @testing-library/jest-dom, import it before running Jest tests
* Add snapshot testing of Swaps’ React components for happy paths, increase minimum threshold for Jest
* Add the test/jest folder for Jest setup and shared functions, use it in Swaps Jest tests
* Fix ESLint issues, update linting config
* Enable ESLint for .snap files (Jest snapshots), throw an error if a snapshot is bigger than 50 lines
* Don’t run lint:fix for .snap files
* Move `createProps` outside of `describe` blocks, move store creation inside tests
* Use translations instead of keys, update a rendering function to load translations
* Make sure all Jest snapshots are shorter than 50 lines (default limit)
* Add / update props for Swaps tests
* Fix React warnings when running tests for Swaps
2021-04-21 21:34:35 +02:00
|
|
|
files: ['ui/**/*.js', 'test/lib/render-helpers.js', 'test/jest/*.js'],
|
2021-04-01 20:44:31 +02:00
|
|
|
plugins: ['react'],
|
|
|
|
extends: ['plugin:react/recommended', 'plugin:react-hooks/recommended'],
|
|
|
|
rules: {
|
|
|
|
'react/no-unused-prop-types': 'error',
|
|
|
|
'react/no-unused-state': 'error',
|
|
|
|
'react/jsx-boolean-value': 'error',
|
|
|
|
'react/jsx-curly-brace-presence': [
|
|
|
|
'error',
|
|
|
|
{ props: 'never', children: 'never' },
|
|
|
|
],
|
|
|
|
'react/no-deprecated': 'error',
|
|
|
|
'react/default-props-match-prop-types': 'error',
|
|
|
|
'react/jsx-no-duplicate-props': 'error',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['test/e2e/**/*.spec.js'],
|
2021-04-08 23:34:55 +02:00
|
|
|
extends: ['@metamask/eslint-config-mocha'],
|
2020-11-03 00:41:28 +01:00
|
|
|
rules: {
|
|
|
|
'mocha/no-hooks-for-single-case': 'off',
|
2021-04-01 20:44:31 +02:00
|
|
|
'mocha/no-setup-in-describe': 'off',
|
2020-11-03 00:41:28 +01:00
|
|
|
},
|
2020-08-14 18:11:25 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
{
|
|
|
|
files: ['app/scripts/migrations/*.js', '*.stories.js'],
|
|
|
|
rules: {
|
|
|
|
'import/no-anonymous-default-export': ['error', { allowObject: true }],
|
|
|
|
},
|
2020-05-19 01:48:11 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
{
|
|
|
|
files: ['app/scripts/migrations/*.js'],
|
|
|
|
rules: {
|
|
|
|
'node/global-require': 'off',
|
|
|
|
},
|
2020-07-18 01:36:29 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
{
|
2021-04-01 20:44:31 +02:00
|
|
|
files: ['**/*.test.js'],
|
2021-06-24 21:52:29 +02:00
|
|
|
excludedFiles: [
|
|
|
|
'ui/**/*.test.js',
|
|
|
|
'ui/__mocks__/*.js',
|
|
|
|
'shared/**/*.test.js',
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
'development/**/*.test.js',
|
2021-09-21 18:28:13 +02:00
|
|
|
'app/scripts/migrations/*.test.js',
|
2021-10-14 23:20:14 +02:00
|
|
|
'app/scripts/platforms/*.test.js',
|
2021-06-24 21:52:29 +02:00
|
|
|
],
|
2021-04-08 23:34:55 +02:00
|
|
|
extends: ['@metamask/eslint-config-mocha'],
|
2020-11-03 00:41:28 +01:00
|
|
|
rules: {
|
2021-04-01 20:44:31 +02:00
|
|
|
'mocha/no-setup-in-describe': 'off',
|
2021-03-31 17:19:20 +02:00
|
|
|
},
|
|
|
|
},
|
2021-04-09 19:20:32 +02:00
|
|
|
{
|
Increase Jest unit test coverage for the Swaps feature to ~25% (#10900)
* Swaps: Show a network name dynamically in a tooltip
* Replace “Ethereum” with “$1”, change “Test” to “Testnet”
* Replace 이더리움 with $1
* Translate network names, use ‘Ethereum’ by default if a translation is not available yet
* Reorder messages to resolve ESLint issues
* Add a snapshot test for the FeeCard component, increase Jest threshold
* Enable snapshot testing into external .snap files in ESLint
* Add the “networkNameEthereum” key in ko/messages.json, remove default “Ethereum” value
* Throw an error if chain ID is not supported by the Swaps feature
* Use string literals when calling the `t` fn,
* Watch Jest tests silently (no React warnings in terminal, only errors)
* Add @testing-library/jest-dom, import it before running Jest tests
* Add snapshot testing of Swaps’ React components for happy paths, increase minimum threshold for Jest
* Add the test/jest folder for Jest setup and shared functions, use it in Swaps Jest tests
* Fix ESLint issues, update linting config
* Enable ESLint for .snap files (Jest snapshots), throw an error if a snapshot is bigger than 50 lines
* Don’t run lint:fix for .snap files
* Move `createProps` outside of `describe` blocks, move store creation inside tests
* Use translations instead of keys, update a rendering function to load translations
* Make sure all Jest snapshots are shorter than 50 lines (default limit)
* Add / update props for Swaps tests
* Fix React warnings when running tests for Swaps
2021-04-21 21:34:35 +02:00
|
|
|
files: ['**/__snapshots__/*.snap'],
|
|
|
|
plugins: ['jest'],
|
|
|
|
rules: {
|
|
|
|
'jest/no-large-snapshots': [
|
|
|
|
'error',
|
|
|
|
{ maxSize: 50, inlineMaxSize: 50 },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
files: [
|
|
|
|
'ui/**/*.test.js',
|
|
|
|
'ui/__mocks__/*.js',
|
|
|
|
'shared/**/*.test.js',
|
|
|
|
'development/**/*.test.js',
|
2021-09-21 18:28:13 +02:00
|
|
|
'app/scripts/migrations/*.test.js',
|
2021-10-14 23:20:14 +02:00
|
|
|
'app/scripts/platforms/*.test.js',
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
],
|
2021-04-09 19:20:32 +02:00
|
|
|
extends: ['@metamask/eslint-config-jest'],
|
2021-04-16 23:52:32 +02:00
|
|
|
rules: {
|
|
|
|
'jest/no-restricted-matchers': 'off',
|
Increase Jest unit test coverage for the Swaps feature to ~25% (#10900)
* Swaps: Show a network name dynamically in a tooltip
* Replace “Ethereum” with “$1”, change “Test” to “Testnet”
* Replace 이더리움 with $1
* Translate network names, use ‘Ethereum’ by default if a translation is not available yet
* Reorder messages to resolve ESLint issues
* Add a snapshot test for the FeeCard component, increase Jest threshold
* Enable snapshot testing into external .snap files in ESLint
* Add the “networkNameEthereum” key in ko/messages.json, remove default “Ethereum” value
* Throw an error if chain ID is not supported by the Swaps feature
* Use string literals when calling the `t` fn,
* Watch Jest tests silently (no React warnings in terminal, only errors)
* Add @testing-library/jest-dom, import it before running Jest tests
* Add snapshot testing of Swaps’ React components for happy paths, increase minimum threshold for Jest
* Add the test/jest folder for Jest setup and shared functions, use it in Swaps Jest tests
* Fix ESLint issues, update linting config
* Enable ESLint for .snap files (Jest snapshots), throw an error if a snapshot is bigger than 50 lines
* Don’t run lint:fix for .snap files
* Move `createProps` outside of `describe` blocks, move store creation inside tests
* Use translations instead of keys, update a rendering function to load translations
* Make sure all Jest snapshots are shorter than 50 lines (default limit)
* Add / update props for Swaps tests
* Fix React warnings when running tests for Swaps
2021-04-21 21:34:35 +02:00
|
|
|
'import/unambiguous': 'off',
|
2021-04-27 22:16:17 +02:00
|
|
|
'import/named': 'off',
|
2021-04-16 23:52:32 +02:00
|
|
|
},
|
2021-04-09 19:20:32 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
{
|
2021-03-16 22:00:08 +01:00
|
|
|
files: [
|
|
|
|
'development/**/*.js',
|
|
|
|
'test/e2e/benchmark.js',
|
|
|
|
'test/helpers/setup-helper.js',
|
|
|
|
],
|
2020-11-03 00:41:28 +01:00
|
|
|
rules: {
|
|
|
|
'node/no-process-exit': 'off',
|
|
|
|
'node/shebang': 'off',
|
|
|
|
},
|
2020-08-13 23:31:40 +02:00
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
{
|
|
|
|
files: [
|
|
|
|
'.eslintrc.js',
|
|
|
|
'babel.config.js',
|
|
|
|
'nyc.config.js',
|
|
|
|
'stylelint.config.js',
|
2021-07-15 19:59:34 +02:00
|
|
|
'app/scripts/lockdown-run.js',
|
2021-10-01 20:53:12 +02:00
|
|
|
'app/scripts/lockdown-more.js',
|
2020-11-03 00:41:28 +01:00
|
|
|
'development/**/*.js',
|
|
|
|
'test/e2e/**/*.js',
|
2020-12-03 19:00:50 +01:00
|
|
|
'test/lib/wait-until-called.js',
|
2020-11-03 00:41:28 +01:00
|
|
|
'test/env.js',
|
|
|
|
'test/setup.js',
|
2021-04-09 19:20:32 +02:00
|
|
|
'jest.config.js',
|
2020-11-03 00:41:28 +01:00
|
|
|
],
|
|
|
|
parserOptions: {
|
|
|
|
sourceType: 'script',
|
|
|
|
},
|
2020-08-17 18:21:01 +02:00
|
|
|
},
|
2021-08-30 23:30:48 +02:00
|
|
|
{
|
|
|
|
files: [
|
|
|
|
'app/scripts/lockdown-run.js',
|
2021-10-01 20:53:12 +02:00
|
|
|
'app/scripts/lockdown-more.js',
|
2021-08-30 23:30:48 +02:00
|
|
|
'test/unit-global/protect-intrinsics.test.js',
|
|
|
|
],
|
|
|
|
globals: {
|
|
|
|
harden: 'readonly',
|
|
|
|
Compartment: 'readonly',
|
|
|
|
},
|
|
|
|
},
|
2020-11-03 00:41:28 +01:00
|
|
|
],
|
2020-05-19 01:48:11 +02:00
|
|
|
|
2020-02-24 19:54:35 +01:00
|
|
|
settings: {
|
2020-11-03 00:41:28 +01:00
|
|
|
react: {
|
Exclude files from builds by build type (#12521)
This PR enables the exclusion of JavaScript and JSON source by `buildType`, and enables the running of `eslint` under LavaMoat. 80-90% of the changes in this PR are `.patch` files and LavaMoat policy additions.
The file exclusion is designed to work in conjunction with our code fencing. If you forget to fence an import statement of an excluded file, the application will now error on boot. **This PR commits us to a particular naming convention for files intended only for certain builds.** Continue reading for details.
### Code Fencing and ESLint
When a file is modified by the code fencing transform, we run ESLint on it to ensure that we fail early for syntax-related issues. This PR adds the first code fences that will be actually be removed in production builds. As a consequence, this was also the first time we attempted to run ESLint under LavaMoat. Making that work required a lot of manual labor because of ESLint's use of dynamic imports, but the manual changes necessary were ultimately quite minor.
### File Exclusion
For all builds, any file in `app/`, `shared/` or `ui/` in a sub-directory matching `**/${otherBuildType}/**` (where `otherBuildType` is any build type except `main`) will be added to the list of excluded files, regardless of its file extension. For example, if we want to add one or more pages to the UI settings in Flask, we'd create the folder `ui/pages/settings/flask`, add any necessary files or sub-folders there, and fence the import statements for anything in that folder. If we wanted the same thing for Beta, we would name the directory `ui/pages/settings/beta`.
As it happens, we already organize some of our source files in this way, namely the logo JSON for Beta and Flask builds. See `ui/helpers/utils/build-types.js` to see how this works in practice.
Because the list of ignored filed is only passed to `browserify.exclude()`, any files not bundled by `browserify` will be ignored. For our purposes, this is mostly relevant for `.scss`. Since we don't have anything like code fencing for SCSS, we'll have to consider how to handle our styles separately.
2021-11-02 04:20:31 +01:00
|
|
|
// If this is set to 'detect', ESLint will import React in order to find
|
|
|
|
// its version. Because we run ESLint in the build system under LavaMoat,
|
|
|
|
// this means that detecting the React version requires a LavaMoat policy
|
|
|
|
// for all of React, in the build system. That's a no-go, so we grab it
|
|
|
|
// from React's package.json.
|
|
|
|
version: reactVersion,
|
2020-02-24 19:54:35 +01:00
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|