Thinking about contributing to RES? Awesome! We just ask that you follow a few simple guidelines:
-
RES has grown quite large, so we have carefully chosen what features we should add to avoid maintenance burden and code bloat. If you're unsure if your feature would appeal to a wide audience, please post about it on /r/Enhancement.
-
There are a few features we have made a conscious choice not to add to RES, so make sure whatever you'd like to contribute isn't on that list.
-
To build the extension, see Building development versions of the extension.
-
To add new modules or hosts, see Adding new files.
-
To check code style and autofix some formatting errors, see Lint and test commands.
-
Come chat with us on Discord if you would like to implement a new feature. It is the quickest way to get a response from the development team.
- Install git.
- Install node.js (version >= 22).
- Install yarn
- Clone this repository.
- Run
yarn
in that folder.
Once done, you can build the extension by running yarn start
(see Build commands).
To load the extension into your browser, see Loading RES into your browser.
yarn start [--browsers <browsers>]
will clean dist/
, then build RES (dev mode), and start a watch task that will rebuild RES when you make changes. Only changed files will be rebuilt.
yarn once [--browsers <browsers>]
will clean dist/
, then build RES (dev mode) a single time.
yarn build [--browsers <browsers>]
will clean dist/
, then build RES (release mode). Each build output will be compressed to a .zip file in dist/zip/
.
<browsers>
is a comma-separated list of browsers to target, e.g. chrome,firefox
. all
will build all targets. By default, chrome
will be targeted.
yarn lint
will verify the code style (and point out any errors) of all .js
files in lib/
(except lib/vendor/
) using ESLint, as well as all .scss
files with stylelint.
yarn lint-fix
will autofix any fixable lint issues.
yarn flow
will run Flow type checking, and start the Flow server so future runs will complete faster. Use yarn flow -- stop
to stop the server, or yarn flow check
to run Flow once without starting the server.
yarn test
will run unit tests (in __tests__
directories) using Ava.
yarn integration <browsers> [-f <testFileGlob>]
will run integration tests (in tests/
) using Nightwatch.js.
Currently just chrome
and firefox
can be targeted.
To run integration tests locally, you need to run an instance of Selenium Standalone Server and have either ChromeDriver or GeckoDriver on your PATH
.
The selenium-standalone
package may help with this.
The default host and port (localhost
and 4444
) should work for most local installations, but if necessary they can be overridden with the SELENIUM_HOST
and SELENIUM_PORT
environment variables.
- Go to
Menu->More tools->Extensions
and tick theDeveloper Mode
checkbox. - Click
Load unpacked extension
and select the/dist/chrome
folder (not the/chrome
folder). - Any time you make changes, you must go back to the
Menu->More tools->Extensions
page andReload
the extension.
- Go to
about:debugging
and tick theEnable add-on debugging
checkbox. - Click
Load Temporary Add-on
and select/dist/firefox/manifest.json
(not the/firefox
folder). - Any time you make changes, you must go back to the
about:debugging
page andReload
the extension.
.github/
: Github templatesbrowser/
: extension API files common to all browsersbuild/
: files handling automated browser deploymentschangelog/
: release changelogschrome/
: Chrome-specific RES filesdist/
: build outputexamples/
: example code for new hosts/modulesfirefox/
: Firefox-specific RES filesimages/
: images for RES logo and CSS iconslib/
: all RES codelib/core/
: core RES codelib/css/
: RES csslib/environment/
: RES environment codelib/images/
: RES imageslib/modules/
: RES moduleslib/templates/
: RES templateslib/utils/
: RES utilitieslib/vendor/
: RES vendor libraries (old libs not on npm)lib/**/__tests__
: unit testslocales
: RES i18n translationstests/
: integration testspackage.json
: package info, dependenciesbuild.js
: build script
First, check to see if there is an existing module with the same focus.
See examples/module.js
for an example.
Create a new .js
file in lib/modules
. Export it in lib/modules/index.js
It will automatically be loaded when the build script is restarted.
All user-visible text must be translated. See the locales README for details.
See examples/host.js
for an example.
Create a new .js
file in lib/modules/hosts
. Export it in lib/modules/hosts/index.js
It will automatically be loaded when the build script is restarted.
If the host uses an API that does not support CORS, you must add it to the browsers' manifests and the host's permissions
property. For example, search for usages of api.twitter.com
.
Create a new .scss
file in lib/css/modules/
(with a leading underscore, e.g. _myModule.scss
).
Import the file in lib/css/res.scss
(e.g. @import 'modules/myPartial';
).
For toggleable CSS, add bodyClass: true
to an option or module, then wrap your CSS with .res-moduleId-optionKey
(boolean options), .res-moduleId-optionKey-optionValue
(enum options), or .res-moduleId
(modules).
For example:
.res-showImages-hideImages {
img {
display: none;
}
}