Add eslint-plugin-rulesdir to node_modules
This plugin needs to be used to write our own custom ESLint plugins that
live in our repository. It replaces the `rulesdir` CLI option, as the
solution of putting it in `.eslintrc.js` is compatible with code editor
plugins.
I also discovered that we were incorrectly running clang-format on
`node_modules`, as I recently fixed the PRESUBMIT. To make sure that
doens't happen again, add a `.clang-format` that disables the formatting
in that folder.
DISABLE_THIRD_PARTY_CHECK=Add new node_module
Bug: 1060123
Change-Id: Ib2c0d23f499604deeea51cb06192bce3a7aa89af
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2096449
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
diff --git a/node_modules/.clang-format b/node_modules/.clang-format
new file mode 100644
index 0000000..37f3d57
--- /dev/null
+++ b/node_modules/.clang-format
@@ -0,0 +1 @@
+DisableFormat: true
\ No newline at end of file
diff --git a/node_modules/eslint-plugin-rulesdir/.eslintignore b/node_modules/eslint-plugin-rulesdir/.eslintignore
new file mode 100644
index 0000000..09a8422
--- /dev/null
+++ b/node_modules/eslint-plugin-rulesdir/.eslintignore
@@ -0,0 +1 @@
+!.eslintrc.js
diff --git a/node_modules/eslint-plugin-rulesdir/.eslintrc.js b/node_modules/eslint-plugin-rulesdir/.eslintrc.js
new file mode 100644
index 0000000..b70f5cb
--- /dev/null
+++ b/node_modules/eslint-plugin-rulesdir/.eslintrc.js
@@ -0,0 +1,29 @@
+'use strict';
+
+const fs = require('fs');
+const path = require('path');
+const PACKAGE_NAME = require('./package').name;
+
+const SYMLINK_LOCATION = path.join(__dirname, 'node_modules', PACKAGE_NAME);
+
+// Symlink node_modules/{package name} to this directory
+// so that ESLint resolves this plugin name correctly.
+// (Yes, this plugin still has to hack node_modules to bootstrap itself.)
+if (!fs.existsSync(SYMLINK_LOCATION)) {
+ fs.symlinkSync(__dirname, SYMLINK_LOCATION);
+}
+
+require('.').RULES_DIR = path.resolve('tests');
+
+module.exports = {
+ extends: 'airbnb-base',
+ parserOptions: {
+ sourceType: 'script',
+ },
+ rules: {
+ 'global-require': 'off',
+ 'import/no-dynamic-require': 'off',
+ 'rulesdir/fake-rule': 'error',
+ },
+ plugins: [PACKAGE_NAME],
+};
diff --git a/node_modules/eslint-plugin-rulesdir/.npmignore b/node_modules/eslint-plugin-rulesdir/.npmignore
new file mode 100644
index 0000000..c2658d7
--- /dev/null
+++ b/node_modules/eslint-plugin-rulesdir/.npmignore
@@ -0,0 +1 @@
+node_modules/
diff --git a/node_modules/eslint-plugin-rulesdir/LICENSE.md b/node_modules/eslint-plugin-rulesdir/LICENSE.md
new file mode 100644
index 0000000..efa2b86
--- /dev/null
+++ b/node_modules/eslint-plugin-rulesdir/LICENSE.md
@@ -0,0 +1,25 @@
+The MIT License (MIT)
+=====================
+
+Copyright © 2017 Teddy Katz
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the “Software”), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/eslint-plugin-rulesdir/README.md b/node_modules/eslint-plugin-rulesdir/README.md
new file mode 100644
index 0000000..5a94c8c
--- /dev/null
+++ b/node_modules/eslint-plugin-rulesdir/README.md
@@ -0,0 +1,63 @@
+# eslint-plugin-rulesdir
+
+Allows a local directory containing ESLint rules directory to be easily used. This is a substitute for the `--rulesdir` option that can be used without a command-line flag.
+
+**Experimental:** This plugin is currently a proof-of-concept. Its API is likely to change in the future.
+
+## Installation
+
+You'll first need to install [ESLint](http://eslint.org):
+
+```
+$ npm i eslint --save-dev
+```
+
+Next, install `eslint-plugin-rulesdir`:
+
+```
+$ npm install eslint-plugin-rulesdir --save-dev
+```
+
+**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-rulesdir` globally.
+
+## Usage
+
+To use this plugin, you must load it manually first and set its `RULES_DIR` property to a path. The path is resolved from the current working directory, and indicates where you would like the plugin to load your rules from. This is easiest if you use a JavaScript config file (`.eslintrc.js`), and use a local installation of ESLint.
+
+```js
+// .eslintrc.js
+const rulesDirPlugin = require('eslint-plugin-rulesdir');
+rulesDirPlugin.RULES_DIR = 'tools/eslint-rules'; // (an example folder where your rules might be stored)
+```
+
+Then you should add `rulesdir` to the plugins section of your `.eslintrc.js` file.
+
+```js
+{
+ plugins: [
+ 'rulesdir'
+ ]
+}
+```
+
+Finally, you can configure your local rules, prefixed with `rulesdir/`.
+
+```js
+{
+ rules: {
+ //
+ 'rulesdir/my-internal-foo-rule': 'error',
+ 'rulesdir/my-internal-bar-rule': ['warn', 2]
+ }
+}
+```
+
+All of the rules from your configured rules directory will be available. In this example, we assumed there were rule files in `tools/eslint-rules/my-internal-foo-rule.js` and `tools/eslint-rules/my-internal-bar-rule.js`.
+
+## Prior Art
+
+* [`eslint-plugin-local-rules`](https://github.com/cletusw/eslint-plugin-local-rules)
+
+## License
+
+[MIT](https://github.com/not-an-aardvark/eslint-plugin-rulesdir/blob/master/LICENSE.md)
diff --git a/node_modules/eslint-plugin-rulesdir/index.js b/node_modules/eslint-plugin-rulesdir/index.js
new file mode 100644
index 0000000..7ad98c9
--- /dev/null
+++ b/node_modules/eslint-plugin-rulesdir/index.js
@@ -0,0 +1,34 @@
+/**
+ * @fileoverview Allows a local ESLint rules directory to be used without a command-line flag
+ * @author Teddy Katz
+ */
+
+'use strict';
+
+//------------------------------------------------------------------------------
+// Requirements
+//------------------------------------------------------------------------------
+
+const fs = require('fs');
+const path = require('path');
+
+//------------------------------------------------------------------------------
+// Plugin Definition
+//------------------------------------------------------------------------------
+
+const cache = {};
+module.exports = {
+ get rules() {
+ const RULES_DIR = module.exports.RULES_DIR;
+ if (typeof module.exports.RULES_DIR !== 'string') {
+ throw new Error('To use eslint-plugin-rulesdir, you must load it beforehand and set the `RULES_DIR` property on the module to a string.');
+ }
+ if (!cache[RULES_DIR]) {
+ cache[RULES_DIR] = fs.readdirSync(RULES_DIR)
+ .filter(filename => filename.endsWith('.js'))
+ .map(filename => path.resolve(RULES_DIR, filename))
+ .reduce((rules, absolutePath) => Object.assign(rules, { [path.basename(absolutePath, '.js')]: require(absolutePath) }), {});
+ }
+ return cache[RULES_DIR];
+ },
+};
diff --git a/node_modules/eslint-plugin-rulesdir/package.json b/node_modules/eslint-plugin-rulesdir/package.json
new file mode 100644
index 0000000..bc1772a
--- /dev/null
+++ b/node_modules/eslint-plugin-rulesdir/package.json
@@ -0,0 +1,24 @@
+{
+ "author": "Teddy Katz",
+ "description": "Allows a local ESLint rules directory to be used without a command-line flag",
+ "devDependencies": {
+ "eslint": ">=3",
+ "eslint-config-airbnb-base": "^11.2.0",
+ "eslint-plugin-import": "^2.6.1"
+ },
+ "engines": {
+ "node": ">=4.0.0"
+ },
+ "keywords": [
+ "eslint",
+ "eslintplugin",
+ "eslint-plugin"
+ ],
+ "license": "MIT",
+ "name": "eslint-plugin-rulesdir",
+ "scripts": {
+ "lint": "eslint .eslintrc.js *.js **/*.js",
+ "test": "npm run lint"
+ },
+ "version": "0.1.0"
+}
\ No newline at end of file
diff --git a/node_modules/eslint-plugin-rulesdir/tests/fake-rule.js b/node_modules/eslint-plugin-rulesdir/tests/fake-rule.js
new file mode 100644
index 0000000..4825474
--- /dev/null
+++ b/node_modules/eslint-plugin-rulesdir/tests/fake-rule.js
@@ -0,0 +1,6 @@
+// This rule doesn't do anything.
+// it only exists to make sure a rule is found and the plugin is working.
+
+'use strict';
+
+module.exports = { create: () => ({}) };