Currently ResourceModules in extension.json is the source of truth of the JS dependency graph and which assets will be served.
At the same time, the JS sources explicitly define dependencies on other modules by using them in the source or requireing them, giving form to a parallel dependency graph specified by the source code.
Such source-defined dependencies may get out of sync or be mis-configured with the separate ResourceModules configuration, giving place to ResourceLoader serving assets with order/dependencies that are not really the constraints defined by the source files.
This results in non-deterministic JS exceptions in the runtime, missing messages at runtime, bad dependency order in ResourceModules configuration, etc.
We want a linter that parses the frontend sources of extensions and builds a dependency graph from the source, and then checks that those constraints specified by the sources are reflected in extension.json ResourceModules.
That way, extension.json ResourceModules will for sure reflect the needs of the source code. We want that linter to run on CI so that no sources on master are out of sync with extension.json config.
Things to be linted (current = current js file, current-RLmodules = ResourceModules that include current in scripts):
- Messages in current are in current-RLmodules
- Required modules/function/variables in current are somewhere in the dependencies of current-RLmodules
- For legacy M.require/M.define
- For RL new require/module.exports
- For global JS variables in mw (mw.blah.blah)
- Templates used in current are in current-RLmodules
- Create an npm cli tool to perform the linting: https://www.npmjs.com/package/resource-modules
- Create experimental CI job for running the linting: T146748#2670140
- Lint MobileFrontend as first test
- Create placeholder patch to run the linting on previous patches: T146748#2670146
- Fix linter errors & iterate on linter's features
- T160056: Add disabling comment syntax to resource-modules linter resource-modules/issues/2
- T163882: Migrate experimental CI job mwext-MobileFrontend-npm-run-lint-modules to stable
- Lint Popups
- Lint RelatedArticles
- Lint QuickSurveys
Please, help review
- Nothing right now