[ESLint] enforce enum members are explicitly initialized
As per the DevTools style guide; this was a rule enforced previously by
the component bridges.
Bug: 1130536
Change-Id: I281f2d355a78dedd0433b7967f7b26e2e71c8791
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2562348
Commit-Queue: Jack Franklin <[email protected]>
Commit-Queue: Tim van der Lippe <[email protected]>
Auto-Submit: Jack Franklin <[email protected]>
Reviewed-by: Tim van der Lippe <[email protected]>
diff --git a/.eslintrc.js b/.eslintrc.js
index d8ac543..5ad3c84 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,5 +1,9 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
const path = require('path');
-const rulesDirPlugin = require('eslint-plugin-rulesdir')
+const rulesDirPlugin = require('eslint-plugin-rulesdir');
rulesDirPlugin.RULES_DIR = path.join(__dirname, 'scripts', 'eslint_rules', 'lib');
module.exports = {
@@ -153,6 +157,11 @@
'no-unused-vars': 0,
'@typescript-eslint/no-unused-vars': [2, {'argsIgnorePattern': '^_'}],
'rulesdir/kebab_case_events': 2,
+ /**
+ * Enforce that enum members are explicitly defined:
+ * const enum Foo { A = 'a' } rather than const enum Foo { A }
+ */
+ '@typescript-eslint/prefer-enum-initializers': 2,
}
}]
};