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 choose 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.
- 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.
- Clone this repository.
- Run
npm installin that folder.
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 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->Extensionsand tick theDeveloper Modecheckbox. - Click
Load unpacked extensionand select the/dist/chromefolder (not the/chromefolder). - Any time you make changes, you must go back to the
Menu->Tools->Extensionspage andReloadthe extension.
- Go to
about:flagsand tick theEnable extension developer featurescheckbox. - Click
Load extensionon the extensions menu and select the/dist/edgeextension/manifest/Extensionfolder (not the/edgefolder). - Any time you make changes, you must go back to the
Menu->Extensionspage, go to the extension's settings andReloadthe extension.
- Go to
about:debuggingand tick theEnable add-on debuggingcheckbox. - Click
Load Temporary Add-onand select/dist/firefox/manifest.json(not the/firefoxfolder). - Any time you make changes, you must go back to the
about:debuggingpage andReloadthe extension.
.github/: Github templatesbrowser/: extension API files common to all browsersbuild/: 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 testspackage.json: package info, dependencieswebpack.config.babel.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.
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.
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;
}
}