1. 20 Aug, 2018 4 commits
  2. 19 Aug, 2018 1 commit
  3. 17 Aug, 2018 35 commits
    • Florian Müllner's avatar
      ci: Allow gradual switch to new style · 518f34eb
      Florian Müllner authored
      It doesn't make too much sense to declare parts of the existing style
      "legacy", but then enforce it via CI. To allow for a gradual switch,
      generate a report with all issues that eslint considers errors in both
      configurations.
      
      !63
      518f34eb
    • Florian Müllner's avatar
      ci: Add "source_check" stage · 47630ff6
      Florian Müllner authored
      More testing is always good, and the static analysis that eslint
      provides goes well beyond what js60 offers, so run it as part of
      the CI.
      
      This will also ensure that new contributions comply with the style
      rules we have set up.
      
      !63
      47630ff6
    • Florian Müllner's avatar
      style: Disable a couple of indent warnings · 7835847e
      Florian Müllner authored
      There are some arrays of object literals where the 4-space indent is
      applied to the properties instead of the objects themselves:
      
      ```
          let foos = [
            { bar: 42,
              baz: 23 },
            { bar: 43,
              baz: 23 }
          ];
      ```
      
      While this would be easy to fix, we'd mess up git-blame for quite a lot
      of code, so simply shut off the warnings for now.
      
      !63
      7835847e
    • Florian Müllner's avatar
      cleanup: Mark non-exported classes as const · a6c07b0a
      Florian Müllner authored
      They aren't supposed to be accessed from other modules - they should be
      marked as exported otherwise - so make sure that gjs warns about any
      intents to do so.
      
      !63
      a6c07b0a
    • Florian Müllner's avatar
      cleanup: Mark globals used from other modules as exported · 08d8a45c
      Florian Müllner authored
      eslint cannot figure out that those symbols are used from other modules
      via imports, so they trigger unused-variable errors. To fix, explicitly
      mark those symbols as exported.
      
      !63
      08d8a45c
    • Florian Müllner's avatar
      cleanup: Mark unused (but useful) variables as ignored · e5a9f744
      Florian Müllner authored
      While we aren't using those destructured variables, they are still useful
      to document the meaning of those elements. We don't want eslint to keep
      warning about them though, so mark them accordingly.
      
      !63
      e5a9f744
    • Florian Müllner's avatar
      cleanup: Remove some unhelpful unused variables in destructuring · efab270c
      Florian Müllner authored
      We aren't using them, and they don't add much in terms of clarity,
      so drop them to fix a couple of eslint errors.
      
      !63
      efab270c
    • Florian Müllner's avatar
      cleanup: Mark unused arguments as unused · ace718c5
      Florian Müllner authored
      This will stop eslint from warning about them, while keeping their
      self-documenting benefit.
      
      !63
      ace718c5
    • Florian Müllner's avatar
      cleanup: Remove some unhelpful unused arguments · 628fd7c9
      Florian Müllner authored
      Those unused arguments aren't bugs - unbeknownst to eslint, they all
      correspond to valid signal parameters - but they don't contribute
      anything to clarity, so just remove them anyway.
      
      !63
      628fd7c9
    • Florian Müllner's avatar
      lint: Allow marking variables/arguments as unused · 198b4685
      Florian Müllner authored
      Unused variables or arguments can indicate bugs, but they can also
      help document the code, in particular in case of signal handlers
      and destructuring.
      
      Account for this by keeping the error, but set up patterns that allow
      us to opt out of if for individual variables/arguments. For arguments
      we pick a '_' prefix, while for variables we go with a suffix instead,
      to not accidentally exempt private module-scope variables.
      
      !63
      198b4685
    • Florian Müllner's avatar
      lint: Add "legacy" configuration · 886f9ae3
      Florian Müllner authored
      Regarding coding style, gjs is moving in a direction that departs quite
      significantly from the established style, in particular when indenting
      multi-line array/object literals or method arguments:
      
      Currently we are keeping those elements aligned, while the gjs rules now
      expect them to use the regular 4-space indentation.
      
      There are certainly good arguments that can be made for that move - it's
      much less prone to leading to overly-long lines, and matches popluar JS
      styles elsewhere. But switching coding style implies large diffs which
      interfere with git-blame and friends, so in order to allow for a more
      gradual change, add a separate set of "legacy" rules that match more
      closely the style we would expect up to now.
      
      It also disables the rules for quotes and template strings - the former
      because we cannot match the current style to use double-quotes for
      translatable strings and single-quotes otherwise, the latter because
      template strings are still relatively new, so we haven't adopted them
      yet.
      
      !63
      886f9ae3
    • Florian Müllner's avatar
      lint: Don't require indent for GObject.registerClass() · 6868eca3
      Florian Müllner authored
      That function will eventually be replaced with decorators, and we don't
      want to re-indent all GObject classes when that happens, so allow class
      declarations with no indent:
      
          GObject.registerClass(
          class Foo extends GObject.Object {
          });
      
      !63
      6868eca3
    • Florian Müllner's avatar
      lint: Tweak indenting rule · 3b4c846f
      Florian Müllner authored
      I simply cannot deal with multi-line trinary expressions where the
      two "branches" don't align, so add an exception for them.
      
      And while the strict 4-line indent for objects is growing on me for
      "regular" objects:
      
          let foo = new Foo({
              bar: 42,
              baz: 'bam'
          });
      
      I do prefer the current style of compact braces and aligned properties
      for object lists:
      
          let entries = [
              { name: 'foo',
                visible: true },
              { name: 'bar',
                halign: Gtk.Align.START }
          ];
      
      So allow the latter style as well, at least for the time being.
      
      !63
      3b4c846f
    • Florian Müllner's avatar
      lint: Allow single-line braces · 7e63efa8
      Florian Müllner authored
      When using arrow functions, we only omit the braces when we are using
      the return value:
      
          this.get_children().filter(w => w.visible);
      
      When braces are used, eslint by default enforces line breaks, but
      there are cases where the expression is hardly less concise than
      the above:
      
          this.get_children().forEach(w => { w.destroy(); });
      
      So change the default to allow this.
      
      !63
      7e63efa8
    • Florian Müllner's avatar
      lint: Allow multiple spaces before key values · a8e130cc
      Florian Müllner authored
      This is useful for imitating namespaced flags/enums:
      
      ```
      const FooFlags = {
          NONE :   0,
          SMEAGLY: 1 << 0,
          SMOGLEY: 1 << 1,
          MUGGLY:  1 << 2
      };
      ```
      
      !63
      a8e130cc
    • Florian Müllner's avatar
      lint: Enforce arrow notation · f5cef233
      Florian Müllner authored
      We replaced all Lang.bind() calls with arrow functions or the standardized
      Function.prototype.bind(), at least for the former eslint has some options
      to ensure that the old custom doesn't sneak back in.
      
      !63
      f5cef233
    • Florian Müllner's avatar
      lint: Require spaces inside braces in object literals · 4448897d
      Florian Müllner authored
      Prohibiting spaces where the established GNOME style has required
      them for a decade would be a harsh change for no good reason.
      
      !63
      4448897d
    • Florian Müllner's avatar
      lint: Tweak the whitelist of globals · 030b3d21
      Florian Müllner authored
      gjs doesn't include any gettext wrappers, and obviously can't know
      about our custom log wrappers, so include those in the list of
      globals.
      
      !63
      030b3d21
    • Florian Müllner's avatar
      lint: Import eslint rules from gjs · 50658e7c
      Florian Müllner authored
      gjs started to run eslint during its CI a while ago, so there is an
      existing rules set we can use as a starting point for our own setup.
      
      As we will adapt those rules to our code base, we don't want those
      changes to make it harder to synchronize the copy with future gjs
      changes, so include the rules from a separate file rather than using
      the configuration directly.
      
      !63
      50658e7c
    • Florian Müllner's avatar
      style: Use space after catch · 58dddbd5
      Florian Müllner authored
      We currently use a consistent style of not adding spaces in catch
      clauses, however that's inconsistent with the style we use for any
      other statement. There's not really a good reason to stick with it,
      so switch to the style gjs/eslint default to.
      
      !62
      58dddbd5
    • Florian Müllner's avatar
      style: Fix indentation errors · 9644bc56
      Florian Müllner authored
      While we have some style inconsistencies - mostly regarding split lines,
      i.e. aligning to the first arguments vs. a four-space indent - there are
      a couple of places where the spacing is simply wrong. Fix those.
      
      Spotted by eslint.
      
      !62
      9644bc56
    • Florian Müllner's avatar
      style: Fix stray/missing spaces · cfd098cb
      Florian Müllner authored
      Spotted by eslint
      
      !62
      cfd098cb
    • Florian Müllner's avatar
      style: Fix missing/stray semi-colons · deea1dbd
      Florian Müllner authored
      Spotted by eslint
      
      !62
      deea1dbd
    • Florian Müllner's avatar
      style: Avoid trailing commas in array destructuring · e456e7e4
      Florian Müllner authored
      When destructuring multiple return values, we often use trailing commas
      to indicate that there are additional elements that we are ignoring.
      
      There isn't anything inherently wrong with that, but it's a style that's
      too confusing for eslint - on the one hand we require a space after a
      comma, on the other hand we require no space before closing brackets.
      
      !62
      e456e7e4
    • Florian Müllner's avatar
      style: Use consistent object literal spacing · 12c327dd
      Florian Müllner authored
      We expect spaces inside the braces of object literals ({ foo: bar }),
      so fix the few places that miss them for consistency.
      
      !62
      12c327dd
    • Florian Müllner's avatar
      style: Use consistent array bracket spacing · e8714c67
      Florian Müllner authored
      We *usually* don't put spaces inside brackets of array literals, except
      when we do :-(
      
      Fix up the few places that are messed up to make the style consistent.
      
      !62
      e8714c67
    • Florian Müllner's avatar
      style: Use consistent spacing in destructured imports · 5fea727e
      Florian Müllner authored
      This is a relatively new pattern in our code, which may explain why we
      failed so far to adopt a consistent style. Current we omit spaces about
      twice as much as we add them, but the latter is consistent with the
      style we use for object literals and (non-imports) destructuring, so
      go with that.
      
      It's also the style used by Builder's 'gi' snippet, so there's another
      precedent.
      
      !62
      5fea727e
    • Florian Müllner's avatar
      cleanup: Remove unused variables · 5acd5cd2
      Florian Müllner authored
      Spotted by eslint.
      
      !62
      5acd5cd2
    • Florian Müllner's avatar
      cleanup: Don't assign variables needlessly · 62fcf0da
      Florian Müllner authored
      In case of application windows and auth handlers, the object is managed
      by an existing object - the application or corresponding channel - the
      moment it is created. It isn't necessary to store the returned object
      in an otherwise unused variable.
      
      !62
      62fcf0da
    • Florian Müllner's avatar
      chatView: Adjust weird comment style · d2c1c11d
      Florian Müllner authored
      Having a comment on the same line as the code is fine, as long as the
      comment fits the line; once it needs splitting up, it is better off
      above the code it is commenting on.
      
      !62
      d2c1c11d
    • Florian Müllner's avatar
      roomList: Avoid odd arrow function pattern · ccf0559c
      Florian Müllner authored
      Multi-line arrow functions should always follow the 4-space indent
      pattern, it's not worth making an exception for functions that
      consist of a single statement that is split into more than one
      line.
      
      !62
      ccf0559c
    • Florian Müllner's avatar
    • Florian Müllner's avatar
      serverRoomManager: Clarify some code · ffe1f0f7
      Florian Müllner authored
      g_list_store_insert_with_valuesv() takes an array of column numbers
      and an array of corresponding values, which can be expressed more
      clearly with the help of destructuring.
      
      !62
      ffe1f0f7
    • Florian Müllner's avatar
      networkManager: Clarify some code · ec561d6d
      Florian Müllner authored
      A network can be matched on its name, ID, or any of its servers, all
      transformed to lowercase. We can express that a bit more directly for
      some additional clarity.
      
      !62
      ec561d6d
    • Florian Müllner's avatar
      userList: Remove some dead code · 2162d93f
      Florian Müllner authored
      This code has been disabled for over four years, before we moved the
      user list into a popover. Even if we decide at one point to add a
      list header again, this code is unlikely to be useful ...
      
      !62
      2162d93f