mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-25 11:28:51 +01:00
a2d3d942ec
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.
54 lines
1.3 KiB
JSON
54 lines
1.3 KiB
JSON
{
|
|
"resources": {
|
|
"@babel/core": {
|
|
"packages": {
|
|
"<root>": true,
|
|
"@babel/preset-env": true,
|
|
"@babel/preset-react": true,
|
|
"@babel/plugin-transform-runtime": true,
|
|
"@babel/plugin-proposal-class-properties": true,
|
|
"@babel/plugin-proposal-object-rest-spread": true,
|
|
"@babel/plugin-proposal-optional-chaining": true,
|
|
"@babel/plugin-proposal-nullish-coalescing-operator": true
|
|
}
|
|
},
|
|
"@eslint/eslintrc": {
|
|
"packages": {
|
|
"@babel/eslint-parser": true,
|
|
"@babel/eslint-plugin": true,
|
|
"@metamask/eslint-config": true,
|
|
"@metamask/eslint-config-nodejs": true,
|
|
"eslint": true,
|
|
"eslint-config-prettier": true,
|
|
"eslint-plugin-import": true,
|
|
"eslint-plugin-node": true,
|
|
"eslint-plugin-prettier": true,
|
|
"eslint-plugin-react": true,
|
|
"eslint-plugin-react-hooks": true
|
|
}
|
|
},
|
|
"eslint-module-utils": {
|
|
"packages": {
|
|
"eslint-import-resolver-node": true
|
|
}
|
|
},
|
|
"node-sass": {
|
|
"native": true
|
|
},
|
|
"module-deps": {
|
|
"packages": {
|
|
"loose-envify": true
|
|
}
|
|
},
|
|
"sass": {
|
|
"env": "unfrozen",
|
|
"builtin": {
|
|
"url": true
|
|
},
|
|
"globals": {
|
|
"Buffer": true
|
|
}
|
|
}
|
|
}
|
|
}
|