1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/helpers/utils
Erik Marks a2d3d942ec
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-01 20:20:31 -07:00
..
build-types.js Exclude files from builds by build type (#12521) 2021-11-01 20:20:31 -07:00
common.util.js remove the ui/app and ui/lib folders (#10911) 2021-04-28 14:53:59 -05:00
common.util.test.js remove the ui/app and ui/lib folders (#10911) 2021-04-28 14:53:59 -05:00
confirm-tx.util.js Only show dapp suggested gas fee warning if user has not edited the fee (#11621) 2021-07-27 20:01:53 -02:30
confirm-tx.util.test.js Add gas constants (#11248) 2021-06-08 10:25:48 -05:00
conversions.util.js Fixes updates on the confirm screen. (#11788) 2021-08-06 14:31:30 -05:00
conversions.util.test.js remove the ui/app and ui/lib folders (#10911) 2021-04-28 14:53:59 -05:00
fetch-with-cache.js Using values from shared/constants/time to represent timing values (#11241) 2021-06-10 12:27:03 -07:00
fetch-with-cache.test.js bump @metamask/controllers to v15.0.2 and remove AbortController workaround in e2e tests (#11988) 2021-09-03 09:34:21 -05:00
formatters.js remove the ui/app and ui/lib folders (#10911) 2021-04-28 14:53:59 -05:00
hardware.js Create function for hardware keyring checking (#12457) 2021-10-27 18:54:18 -05:00
i18n-helper.js Using values from shared/constants/time to represent timing values (#11241) 2021-06-10 12:27:03 -07:00
i18n-helper.test.js remove the ui/app and ui/lib folders (#10911) 2021-04-28 14:53:59 -05:00
icon-factory.js adding checksum conversion (#12209) 2021-09-27 09:58:12 -04:00
is-mobile-view.js Using design system breakpoint values across ui/ 2021-09-11 11:00:46 -07:00
storage-helpers.js remove the ui/app and ui/lib folders (#10911) 2021-04-28 14:53:59 -05:00
switch-direction.js remove the ui/app and ui/lib folders (#10911) 2021-04-28 14:53:59 -05:00
token-util.js Integrating the TokenListController to Extension (#11398) 2021-09-09 16:56:27 -04:00
transactions.util.js Refactor checking if address is contract into a new module. (#12354) 2021-10-20 16:12:07 +01:00
transactions.util.test.js Support for type 0 transaction (#12252) 2021-10-06 23:59:57 +05:30
tx-helper.js remove the ui/app and ui/lib folders (#10911) 2021-04-28 14:53:59 -05:00
tx-helper.test.js remove the ui/app and ui/lib folders (#10911) 2021-04-28 14:53:59 -05:00
util.js Fixing address truncation papercuts (#12330) 2021-10-13 12:54:48 -05:00
util.test.js create safer isValidAddress method (#11089) 2021-05-17 14:00:59 -05:00
webcam-utils.js remove the ui/app and ui/lib folders (#10911) 2021-04-28 14:53:59 -05:00