Thinking about contributing to RES? Awesome! We just ask that you follow a few simple guidelines:
-
RES has grown quite large, so we do have to pick and choose what features we should add. Code bloat is always a concern, and RES is already rather hefty. If you're unsure if your feature would appeal to a wide audience, please post about it on /r/Enhancement or contact @honestbleeps directly to ask.
-
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.
-
If you're adding new modules or hosts, see Adding new files.
-
Code style is enforced with ESLint and sass-lint. To check code style and autofix common errors, see Lint and test commands.
.github/
: Github templatesbuild/
: Files handling automated browser deploymentschangelog/
: Release changelogschrome/
: Chrome-specific RES filesdist/
: build outputedge/
: Microsoft Edge-specific RES filesexamples/
: 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 testsutils/
: Misc RES utilitiespackage.json
: package info, dependencieswebpack.config.babel.js
: build script
background.entry.js
: the "background page" for RES, necessary for Chrome extensionsenvironment.js
: specific environment settings for Chromemanifest.json
: the project manifestoptions.html
: options page for chrome extensions
edge.entry.js
: shim to allow chrome extension code usageenvironment.js
: Edge-specific overrides of the Chrome environmentmanifest.json
: the project manifest
background.entry.js
: the "background page" for RES, necessary for Firefox extensionsenvironment.js
: specific environment settings for Firefoxpackage.json
: the project manifest for the Firefox add-on
- Install git.
- Install node.js (version >= 6).
- Install Python 2 (not version 3). On Windows, please install the "Add python.exe to path" feature on the customize screen.
- Navigate to your RES folder.
- Run
npm install
.
Once done, you can build the extension by running npm start
(see Build commands).
To load the extension into your browser, see Loading RES into your browser.
npm start [-- <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.
npm run once [-- <browsers>]
will clean dist/
, then build RES (dev mode) a single time.
npm run build [-- <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,edge
. all
will build all targets. By default, chrome
will be targeted.
npm run 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 sass-lint.
npm run lint-fix
will autofix any fixable lint issues.
npm run flow
will run Flow type checking, and start the Flow server so future runs will complete faster. Use npm run flow -- stop
to stop the server, or npm run flow -- check
to run Flow once without starting the server.
npm test
will run unit tests (in __tests__
directories) using Ava.
npm run test-integration -- <browsers>
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->Tools->Extensions
and tick theDeveloper Mode
checkbox - Choose
Load unpacked extension
and point it to the/dist/chrome
folder (not the/chrome
folder). Make sure you only have one RES version running at a time. - Any time you make changes to the script, you must go back to the
Menu->Tools->Extensions
page andReload
the extension.
- Go to
about:flags
and tick theEnable extension developer features
checkbox. - Choose
Load extension
on the extensions menu and select the/dist/edgeextension/manifest/Extension
folder. - Any time you make changes to the extension, you must go back to the
Menu->Extensions
page, go to the extensions settings andReload
the extension.
- Install jpm using
npm
:npm install -g jpm
- Navigate to the
/dist/firefox
folder (not the/firefox
folder) and run the commandjpm run
, which should launch a new Firefox browser using a temporary profile with only RES installed.
See examples/module.js
for an example.
Create a new .js
file in lib/modules
.
It will automatically be loaded when the build script is restarted.
All modules must now have i18n implementations. Please see here for details.
Please be sure that they support CORS so the sites do not need to be added as additional permissions, which has caused headaches in the past.
See examples/host.js
for an example.
Create a new .js
file in lib/modules/hosts
.
It will automatically be loaded when the build script is restarted.
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';
).
Body classes will be automatically added for boolean and enum options with the property bodyClass: true
, in the form .res-moduleId-optionKey
for boolean options (only when they're enabled), and .res-moduleId-optionKey-optionValue
for enums.
This is the preferred way to create optional CSS; do not use addCSS()
unless absolutely necessary (i.e. variable color, size, etc.).