Merge branch 'stable-3.3'

* stable-3.3:
  Add eslint rule

in this branch eslint rule is added to bazlets by referring following
location :

https://gerrit.googlesource.com/gerrit/
    +/refs/heads/master/tools/js

Change-Id: Ie38bb3e6c20fd45ebb06c2b845b405933b58e6c4
diff --git a/gerrit_api.bzl b/gerrit_api.bzl
index c307ade..62f3938 100644
--- a/gerrit_api.bzl
+++ b/gerrit_api.bzl
@@ -7,9 +7,9 @@
 gerrit_api is rule for fetching Gerrit plugin API using Bazel.
 """
 
-def gerrit_api(version = "3.3.4",
-               plugin_api_sha1 = "3dc1507083f558ddde2c3b1cd1b85efaa6ea9aa2",
-               acceptance_framework_sha1 = "70dce08e44b47630cf8321c8ad2800e87259a223"):
+def gerrit_api(version = "3.4.0",
+               plugin_api_sha1 = "9938efcf30a708e1a660f26e2ded993c42f397a4",
+               acceptance_framework_sha1 = "4c34e156c90738504280eb8f0023aababab35cf2"):
     gerrit_api_version(
         name = "gerrit_api_version",
         version = version,
diff --git a/tools/js/BUILD b/tools/js/BUILD
index fedaf7f..1faf6b3 100644
--- a/tools/js/BUILD
+++ b/tools/js/BUILD
@@ -1 +1,2 @@
 exports_files(["run_npm_binary.py"])
+exports_files(["eslint-chdir.js"])
diff --git a/tools/js/eslint-chdir.js b/tools/js/eslint-chdir.js
new file mode 100644
index 0000000..5aea704
--- /dev/null
+++ b/tools/js/eslint-chdir.js
@@ -0,0 +1,30 @@
+/**
+ * @license
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Eslint 7 introduced a breaking change - it uses the current workdir instead
+// of the configuration file directory for resolving relative paths:
+// https://eslint.org/docs/user-guide/migrating-to-7.0.0#base-path-change
+// This file is loaded before the eslint and sets the current directory
+// back to the location of configuration file.
+
+const path = require('path');
+const configParamIndex =
+    process.argv.findIndex(arg => arg === '-c' || arg === '---config');
+if (configParamIndex >= 0 && configParamIndex + 1 < process.argv.length) {
+  const dirName = path.dirname(process.argv[configParamIndex + 1]);
+  process.chdir(dirName);
+}
diff --git a/tools/js/eslint.bzl b/tools/js/eslint.bzl
index 9633dd7..fde8e51 100644
--- a/tools/js/eslint.bzl
+++ b/tools/js/eslint.bzl
@@ -57,9 +57,12 @@
         config,
         ignore,
          "@com_googlesource_gerrit_bazlets//tools/js/eslint-rules:eslint-rules-srcs",
+         "@com_googlesource_gerrit_bazlets//tools/js:eslint-chdir.js",
         eslint_rules_toplevel_file,
     ] + plugins + data
     common_templated_args = [
+        "--node_options=--require=$$(rlocation $(rootpath \
+            @com_googlesource_gerrit_bazlets//tools/js:eslint-chdir.js))",
         "--ext",
         ",".join(extensions),
         "-c",