diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2019-08-04 16:43:43 -0700 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2019-08-13 22:18:32 -0700 |
commit | f52d56095dede8646ebecdea3ff19840ecaff3e0 (patch) | |
tree | 51d117099002c1120ac83a2a4c2d6b27daeb4928 /.eslintrc.yml | |
parent | 2a30bfd7450232e93e2332a5929298863fe3bb0d (diff) | |
download | gjs-f52d56095dede8646ebecdea3ff19840ecaff3e0.tar.gz |
CI: Add a rule to prevent unnecessary _init() functions
We have a built-in eslint rule to prevent unnecessary constructors that
only chain up to super(). We should have an analogous rule for GObject
_init() functions, which play the same role as a constructor. We can
build a custom rule with no-restricted-syntax.
Diffstat (limited to '.eslintrc.yml')
-rw-r--r-- | .eslintrc.yml | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/.eslintrc.yml b/.eslintrc.yml index 60f21be3..53d5fbd3 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -114,6 +114,21 @@ rules: - object: imports property: mainloop message: Use GLib main loops and timeouts + no-restricted-syntax: + - error + - selector: >- + MethodDefinition[key.name="_init"] > + FunctionExpression[params.length=1] > + BlockStatement[body.length=1] + CallExpression[arguments.length=1][callee.object.type="Super"][callee.property.name="_init"] > + Identifier:first-child + message: _init() that only calls super._init() is unnecessary + - selector: >- + MethodDefinition[key.name="_init"] > + FunctionExpression[params.length=0] > + BlockStatement[body.length=1] + CallExpression[arguments.length=0][callee.object.type="Super"][callee.property.name="_init"] + message: _init() that only calls super._init() is unnecessary no-return-assign: error no-return-await: error no-self-compare: error |