Add custom ESLint rule to check ES import statements

This makes sure that the guidance of
https://docs.google.com/presentation/d/1KaTDaKEcLmgv3Wum79gPP9mv9x2fm3kuEgx_b8wLVug/edit?usp=sharing
will be caught during build time. This prevent issues where duplication
of code in combination with Rollup can cause runtime issues.

Bug: 1060003
Change-Id: Ic8c8dfcc4e9890592791adc23044033b1aa3ca1b
Fixed: 1060123
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2096700
Commit-Queue: Tim van der Lippe <[email protected]>
Reviewed-by: Jack Franklin <[email protected]>
diff --git a/.eslintrc.js b/.eslintrc.js
index 649de7b..c90768f 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,3 +1,7 @@
+const path = require('path');
+const rulesDirPlugin = require('eslint-plugin-rulesdir')
+rulesDirPlugin.RULES_DIR = path.join(__dirname, 'scripts', 'eslint_rules', 'lib');
+
 module.exports = {
   'root': true,
 
@@ -8,6 +12,7 @@
   'plugins': [
     '@typescript-eslint',
     'mocha',
+    'rulesdir',
   ],
 
   'parserOptions': {'ecmaVersion': 9, 'sourceType': 'module'},
@@ -121,6 +126,9 @@
     'mocha/no-pending-tests': 2,
     // errors on {describe, it}.only
     'mocha/no-exclusive-tests': 2,
+
+    // DevTools specific rules
+    'rulesdir/es_modules_import': 2,
   },
   'overrides': [{
     'files': ['*.ts'],