- Source files should be placed in a directory named
src. - Build files should be placed in a directory named
dist. - It is important to ensure that the source files are organized in a logical and modular way, with each file containing a single module or class.
- The build files should be generated automatically using a build tool such as Webpack or Rollup, and should not be committed to the repository.
- Tests should be placed in a directory named
test. - Test helpers should be placed in a directory named
test-helpers. - It is important to write comprehensive tests for all modules and classes, and to ensure that the tests are run automatically as part of the build process.
- Test helpers should be used to provide common functionality that is needed by multiple tests, such as setting up test data or mocking external dependencies.
- Types should be included in the package by adding a
typesfield to thepackage.jsonfile. - Types should be written using TypeScript or Flow, and should be kept up-to-date with the latest version of the package.
- It is important to ensure that the types are accurate and comprehensive, and that they cover all public APIs of the package.
- Bash scripts used for development tools or CI should be placed in a directory named
scripts. - It is important to ensure that the scripts are well-documented and easy to use, and that they are kept up-to-date with the latest version of the package.
- Bash scripts should be used sparingly, and only for tasks that cannot be easily accomplished using existing build tools or package scripts.
- Contributor documentation should be placed in a directory named
contributing. - Contributor documentation should include information on how to contribute to the package, including guidelines for submitting pull requests and reporting issues.
- It is important to ensure that the contributor documentation is up-to-date and accurate, and that it is easy to understand for first-time contributors.
- The README should include a brief description of the package, installation instructions, usage instructions, and a list of contributors.
- It is important to ensure that the README is well-written and easy to understand, and that it provides all the information that a user would need to get started with the package.
- The README should be kept up-to-date with the latest version of the package, and should be reviewed periodically to ensure that it is still accurate and relevant.
- The
package.jsonfile should include the following fields:name: The name of the package.version: The version of the package.description: A brief description of the package.main: The entry point for the package.scripts: A list of scripts that can be run withnpm run.repository: The URL of the repository.keywords: A list of keywords that describe the package.author: The name and email address of the package author.license: The license under which the package is released.bugs: The URL where issues can be reported.homepage: The URL of the package's homepage.
- It is important to ensure that all fields are accurate and up-to-date, and that they provide all the information that a user would need to understand and use the package.
- The
namefield should be unique and descriptive, and should follow the naming conventions for npm packages. - The
versionfield should follow the semantic versioning conventions. - The
descriptionfield should provide a brief overview of the package's functionality. - The
mainfield should point to the entry point for the package. - The
scriptsfield should include all the scripts that are needed to build, test, and run the package. - The
repositoryfield should point to the URL of the repository. - The
keywordsfield should include a list of keywords that describe the package. - The
authorfield should include the name and email address of the package author. - The
licensefield should specify the license under which the package is released. - The
bugsfield should point to the URL where issues can be reported. - The
homepagefield should point to the URL of the package's homepage.
- The license should be placed in a file named
LICENSE. - It is recommended to use a standard open-source license, such as the MIT License or Apache License.
- Before releasing a package, it is important to get approval from the legal team to ensure that the license is appropriate for the project.
- It is important to ensure that the license is included in all distributions of the package, and that it is clearly visible and easy to understand.
- Generated API documentation should be placed in a directory named
docs. - The documentation should be hosted on
metamask.github.io/<package-name>/<latest|staging|version>. - It is important to ensure that the API documentation is accurate and up-to-date, and that it covers all public APIs of the package.
- The documentation should be generated automatically using a tool such as JSDoc or TypeDoc, and should be reviewed periodically to ensure that it is still accurate and relevant.
- Configuration files should be placed in a directory named
config. - Configuration files should be used to store configuration data that is needed by the package, such as API keys or database credentials.
- It is important to ensure that the configuration files are well-documented and easy to use, and that they are kept up-to-date with the latest version of the package.
- To keep packages in sync with the module template, use the
@metamask/template-synctool. - It is important to ensure that the package is kept up-to-date with the latest version of the module template, and that any changes to the template are incorporated into the package as soon as possible.
- It is also important to ensure that any customizations to the package are not overwritten by updates to the module template, and that any conflicts are resolved in a timely manner.