GNOME Shell Style Guide

Gjs Style Guide

We defer most of our style guidelines to the ones in the Gjs Style Guide, so be sure to read it before developing the JavaScript code for GNOME Shell.


List external imports first, then list internal imports. Keep both sets in the alphabetical order and separate them by a blank line.

Imports of GNOME Shell C modules, such as should be in the external imports set. This includes imports of modules that were copied from other projects, such as and

Only imports of the local GNOME Shell JavaScript modules should be in the internal imports set.

  // Sample list of imports
  const Big =;
  const Clutter =;
  const Gtk =;
  const Lang = imports.lang;
  const Shell =;
  const Main = imports.ui.main;
  const Overlay = imports.ui.overlay;
  const Panel = imports.ui.panel;


Place class methods into separate sections headed by the method type and maintained in the following order:

  //// Public methods ////
  //// Protected methods ////
  //// Pure virtual protected methods ////
  //// Private methods ////

Have a comment on top of each method describing what the method does. Describe the return value if the method has one. There is no need to explicitly describe each argument if the method description makes it obvious what they are.

Protected Methods and Variables

Protected methods and variables, as well as private ones, should begin with an underscore.


Use single quotes (e.g. 'foo') for untranslated strings/constants, and double quotes (e.g. "foo") for strings that should be translated. (gettext doesn't understand javascript, so it treats it as C, so you must use double-quotes on translated strings, or they won't get picked up into the .po files.)

Wrapper Classes

When creating a javascript wrapper for a ClutterActor:

  • Store a pointer from the wrapper to the actor in

  • Store a back-pointer from the actor to the wrapper in, if useful. (This is used by the drag-and-drop code, for instance, to find an acceptDrop() method for an actor.

  • Connect to the actor's destroy signal and perform cleanup there; don't assume that the actor will only be destroyed via codepaths in the wrapper. The wrapper may have a destroy() method of its own, but if so, it should just call;

Projects/GnomeShell/StyleGuide (last edited 2013-11-22 17:00:04 by WilliamJonMcCann)