From 24378083cdf5b93c10e8064d0b19ca692d5ca11a Mon Sep 17 00:00:00 2001 From: Bishoy Boktor <65934617+boktorbb-amzn@users.noreply.github.com> Date: Thu, 4 Mar 2021 14:23:59 -0800 Subject: [PATCH] Renames kbn-eslint-import-resolver-kibana to osd-eslint-import-resolver-opensearch-dashboards (#37) (#45) Signed-off-by: Bishoy Boktor --- .../README.md | 22 ++++++++-------- .../import_resolver_opensearch_dashboards.js} | 8 +++--- .../lib/debug.js | 2 +- .../lib/get_is_path_request.js | 0 .../lib/get_opensearch_dashboards_path.js} | 26 +++++++++---------- .../lib/get_path_type.js | 2 +- .../lib/get_project_root.js | 0 .../lib/get_webpack_config.js | 10 +++---- .../lib/index.js | 2 +- .../lib/resolve_webpack_alias.js | 0 .../package.json | 8 +++--- .../yarn.lock | 0 12 files changed, 40 insertions(+), 40 deletions(-) rename packages/{kbn-eslint-import-resolver-kibana => osd-eslint-import-resolver-opensearch-dashboards}/README.md (72%) rename packages/{kbn-eslint-import-resolver-kibana/import_resolver_kibana.js => osd-eslint-import-resolver-opensearch-dashboards/import_resolver_opensearch_dashboards.js} (92%) rename packages/{kbn-eslint-import-resolver-kibana => osd-eslint-import-resolver-opensearch-dashboards}/lib/debug.js (97%) rename packages/{kbn-eslint-import-resolver-kibana => osd-eslint-import-resolver-opensearch-dashboards}/lib/get_is_path_request.js (100%) rename packages/{kbn-eslint-import-resolver-kibana/lib/get_kibana_path.js => osd-eslint-import-resolver-opensearch-dashboards/lib/get_opensearch_dashboards_path.js} (51%) rename packages/{kbn-eslint-import-resolver-kibana => osd-eslint-import-resolver-opensearch-dashboards}/lib/get_path_type.js (93%) rename packages/{kbn-eslint-import-resolver-kibana => osd-eslint-import-resolver-opensearch-dashboards}/lib/get_project_root.js (100%) rename packages/{kbn-eslint-import-resolver-kibana => osd-eslint-import-resolver-opensearch-dashboards}/lib/get_webpack_config.js (77%) rename packages/{kbn-eslint-import-resolver-kibana => osd-eslint-import-resolver-opensearch-dashboards}/lib/index.js (95%) rename packages/{kbn-eslint-import-resolver-kibana => osd-eslint-import-resolver-opensearch-dashboards}/lib/resolve_webpack_alias.js (100%) rename packages/{kbn-eslint-import-resolver-kibana => osd-eslint-import-resolver-opensearch-dashboards}/package.json (68%) rename packages/{kbn-eslint-import-resolver-kibana => osd-eslint-import-resolver-opensearch-dashboards}/yarn.lock (100%) diff --git a/packages/kbn-eslint-import-resolver-kibana/README.md b/packages/osd-eslint-import-resolver-opensearch-dashboards/README.md similarity index 72% rename from packages/kbn-eslint-import-resolver-kibana/README.md rename to packages/osd-eslint-import-resolver-opensearch-dashboards/README.md index b4d37c02c80..b917b91eaa8 100755 --- a/packages/kbn-eslint-import-resolver-kibana/README.md +++ b/packages/osd-eslint-import-resolver-opensearch-dashboards/README.md @@ -1,13 +1,13 @@ -# @kbn/eslint-import-resolver-kibana +# @osd/eslint-import-resolver-opensearch-dashboards -Resolver for Kibana imports, meant to be used with [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import). +Resolver for OpenSearch Dashboards imports, meant to be used with [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import). ## Installation -To install this utility use `yarn` to link to the package from the Kibana project: +To install this utility use `yarn` to link to the package from the OpenSearch Dashboards project: ```sh -yarn add --dev link:../../kibana/packages/kbn-eslint-import-resolver-kibana +yarn add --dev link:../../opensearchDashboards/packages/osd-eslint-import-resolver-opensearch-dashboards ``` ## Usage @@ -17,7 +17,7 @@ Specify this resolver with the `import/resolver` setting in your eslint config f ```yml # .eslintrc.yml settings: - import/resolver: "@kbn/eslint-import-resolver-kibana" + import/resolver: "@osd/eslint-import-resolver-opensearch-dashboards" ``` ## Settings @@ -27,9 +27,9 @@ settings: Property | Default | Description -------- | ------- | ----------- rootPackageName | `null` | The `"name"` property of the root `package.json` file. If your project has multiple `package.json` files then specify this setting to tell the resolver which `package.json` file sits at the root of your project. -pluginPaths | `[]` if `rootPackageName` is set, otherwise `[.]` | Array of relative paths which contain a Kibana plugin. Plugins must contain a `package.json` file to be valid. -pluginDirs | `[]` | Array of relative paths pointing to directories which contain Kibana plugins. Plugins must contain a `package.json` file to be valid. -pluginMap | `{}` | A map of plugin ids to relative paths, explicitly pointing to the location where Kibana should map `plugin/{pluginId}` import statements. Directories do not need to contain a `package.json` file to work. +pluginPaths | `[]` if `rootPackageName` is set, otherwise `[.]` | Array of relative paths which contain a OpenSearch Dashboards plugin. Plugins must contain a `package.json` file to be valid. +pluginDirs | `[]` | Array of relative paths pointing to directories which contain OpenSearch Dashboards plugins. Plugins must contain a `package.json` file to be valid. +pluginMap | `{}` | A map of plugin ids to relative paths, explicitly pointing to the location where OpenSearch Dashboards should map `plugin/{pluginId}` import statements. Directories do not need to contain a `package.json` file to work. ## Settings Usage To specify additional config add a `:` after the resolver name and specify the argument as key-value pairs: @@ -38,7 +38,7 @@ To specify additional config add a `:` after the resolver name and specify the a # .eslintrc.yml settings: import/resolver: - "@kbn/eslint-import-resolver-kibana": + "@osd/eslint-import-resolver-opensearch-dashboards": # if your project has multiple package.json files rootPackageName: my-project @@ -51,7 +51,7 @@ settings: # if all of your plugins have the same parent directory you can specify # that directory and we will look for plugins there pluginDirs: - - ./kibana-plugins + - ./opensearch-dashboards-plugins # if you have some other special configuration supply a map of plugin # ids to the directory containing their code @@ -64,6 +64,6 @@ See [the resolvers docs](https://github.com/benmosher/eslint-plugin-import#resol ## Debugging -For debugging output from this resolver, run your linter with `DEBUG=eslint-plugin-import:resolver:kibana`. +For debugging output from this resolver, run your linter with `DEBUG=eslint-plugin-import:resolver:opensearchDashboards`. This resolver defers to [*eslint-import-resolver-node*](https://www.npmjs.com/package/eslint-import-resolver-node) and [*eslint-import-resolver-webpack*](https://www.npmjs.com/package/eslint-import-resolver-webpack) for all of it's actual resolution logic. To get debugging output from all resolvers use `DEBUG=eslint-plugin-import:resolver:*`. diff --git a/packages/kbn-eslint-import-resolver-kibana/import_resolver_kibana.js b/packages/osd-eslint-import-resolver-opensearch-dashboards/import_resolver_opensearch_dashboards.js similarity index 92% rename from packages/kbn-eslint-import-resolver-kibana/import_resolver_kibana.js rename to packages/osd-eslint-import-resolver-opensearch-dashboards/import_resolver_opensearch_dashboards.js index c2a28ef23a1..67e59ff4443 100755 --- a/packages/kbn-eslint-import-resolver-kibana/import_resolver_kibana.js +++ b/packages/osd-eslint-import-resolver-opensearch-dashboards/import_resolver_opensearch_dashboards.js @@ -23,7 +23,7 @@ const webpackResolver = require('eslint-import-resolver-webpack'); const nodeResolver = require('eslint-import-resolver-node'); const { - getKibanaPath, + getOpenSearchDashboardsPath, getProjectRoot, getWebpackConfig, isFile, @@ -39,8 +39,8 @@ function initContext(file, config) { } const projectRoot = getProjectRoot(file, config); - const kibanaPath = getKibanaPath(config, projectRoot); - const webpackConfig = getWebpackConfig(kibanaPath, projectRoot, config); + const opensearchDashboardsPath = getOpenSearchDashboardsPath(config, projectRoot); + const webpackConfig = getWebpackConfig(opensearchDashboardsPath, projectRoot, config); const aliasEntries = Object.entries(webpackConfig.resolve.alias || {}); context = { @@ -65,7 +65,7 @@ function tryNodeResolver(importRequest, file, config) { ); } -exports.resolve = function resolveKibanaPath(importRequest, file, config) { +exports.resolve = function resolveOpenSearchDashboardsPath(importRequest, file, config) { config = config || {}; if (config.forceNode) { diff --git a/packages/kbn-eslint-import-resolver-kibana/lib/debug.js b/packages/osd-eslint-import-resolver-opensearch-dashboards/lib/debug.js similarity index 97% rename from packages/kbn-eslint-import-resolver-kibana/lib/debug.js rename to packages/osd-eslint-import-resolver-opensearch-dashboards/lib/debug.js index 40894a97c8f..d09647df981 100755 --- a/packages/kbn-eslint-import-resolver-kibana/lib/debug.js +++ b/packages/osd-eslint-import-resolver-opensearch-dashboards/lib/debug.js @@ -17,4 +17,4 @@ * under the License. */ -exports.debug = require('debug')('eslint-plugin-import:resolver:kibana'); +exports.debug = require('debug')('eslint-plugin-import:resolver:opensearchDashboards'); diff --git a/packages/kbn-eslint-import-resolver-kibana/lib/get_is_path_request.js b/packages/osd-eslint-import-resolver-opensearch-dashboards/lib/get_is_path_request.js similarity index 100% rename from packages/kbn-eslint-import-resolver-kibana/lib/get_is_path_request.js rename to packages/osd-eslint-import-resolver-opensearch-dashboards/lib/get_is_path_request.js diff --git a/packages/kbn-eslint-import-resolver-kibana/lib/get_kibana_path.js b/packages/osd-eslint-import-resolver-opensearch-dashboards/lib/get_opensearch_dashboards_path.js similarity index 51% rename from packages/kbn-eslint-import-resolver-kibana/lib/get_kibana_path.js rename to packages/osd-eslint-import-resolver-opensearch-dashboards/lib/get_opensearch_dashboards_path.js index 3856281d153..20f9d4bae4c 100755 --- a/packages/kbn-eslint-import-resolver-kibana/lib/get_kibana_path.js +++ b/packages/osd-eslint-import-resolver-opensearch-dashboards/lib/get_opensearch_dashboards_path.js @@ -24,25 +24,25 @@ const { debug } = require('./debug'); const DEFAULT_PLUGIN_PATH = '../..'; /* - * Resolves the path to Kibana, either from default setting or config + * Resolves the path to OpenSearch Dashboards, either from default setting or config */ -exports.getKibanaPath = function (config, projectRoot) { - const inConfig = config != null && config.kibanaPath; +exports.getOpenSearchDashboardsPath = function (config, projectRoot) { + const inConfig = config != null && config.opensearchDashboardsPath; - // We only allow `.` in the config as we need it for Kibana itself - if (inConfig && config.kibanaPath !== '.') { + // We only allow `.` in the config as we need it for OpenSearch Dashboards itself + if (inConfig && config.opensearchDashboardsPath !== '.') { throw new Error( - 'The `kibanaPath` option has been removed from `eslint-import-resolver-kibana`. ' + - 'During development your plugin must live in `./plugins/{pluginName}` ' + - 'inside the Kibana folder or `../kibana-extra/{pluginName}` ' + - 'relative to the Kibana folder to work with this package.' + 'The `opensearchDashboardsPath` option has been removed from `eslint-import-resolver-opensearch-dashboards`. ' + + 'During development your plugin must live in `./plugins/{pluginName}` ' + + 'inside the OpenSearch Dashboards folder or `../opensearch-dashboards-extra/{pluginName}` ' + + 'relative to the OpenSearch Dashboards folder to work with this package.' ); } - const kibanaPath = inConfig - ? resolve(projectRoot, config.kibanaPath) + const opensearchDashboardsPath = inConfig + ? resolve(projectRoot, config.opensearchDashboardsPath) : resolve(projectRoot, DEFAULT_PLUGIN_PATH); - debug(`Resolved Kibana path: ${kibanaPath}`); - return kibanaPath; + debug(`Resolved OpenSearch Dashboards path: ${opensearchDashboardsPath}`); + return opensearchDashboardsPath; }; diff --git a/packages/kbn-eslint-import-resolver-kibana/lib/get_path_type.js b/packages/osd-eslint-import-resolver-opensearch-dashboards/lib/get_path_type.js similarity index 93% rename from packages/kbn-eslint-import-resolver-kibana/lib/get_path_type.js rename to packages/osd-eslint-import-resolver-opensearch-dashboards/lib/get_path_type.js index 445a3cad385..66c2eb90f61 100644 --- a/packages/kbn-eslint-import-resolver-kibana/lib/get_path_type.js +++ b/packages/osd-eslint-import-resolver-opensearch-dashboards/lib/get_path_type.js @@ -23,7 +23,7 @@ const LRU = require('lru-cache'); const DIR = Symbol('dir'); const FILE = Symbol('file'); -const cache = process.env.KIBANA_RESOLVER_HARD_CACHE ? new Map() : new LRU({ maxAge: 1000 }); +const cache = process.env.OPENSEARCH_DASHBOARDS_RESOLVER_HARD_CACHE ? new Map() : new LRU({ maxAge: 1000 }); function getPathType(path) { const cached = cache.get(path); diff --git a/packages/kbn-eslint-import-resolver-kibana/lib/get_project_root.js b/packages/osd-eslint-import-resolver-opensearch-dashboards/lib/get_project_root.js similarity index 100% rename from packages/kbn-eslint-import-resolver-kibana/lib/get_project_root.js rename to packages/osd-eslint-import-resolver-opensearch-dashboards/lib/get_project_root.js diff --git a/packages/kbn-eslint-import-resolver-kibana/lib/get_webpack_config.js b/packages/osd-eslint-import-resolver-opensearch-dashboards/lib/get_webpack_config.js similarity index 77% rename from packages/kbn-eslint-import-resolver-kibana/lib/get_webpack_config.js rename to packages/osd-eslint-import-resolver-opensearch-dashboards/lib/get_webpack_config.js index 60a03ae8a10..57461c03a49 100755 --- a/packages/kbn-eslint-import-resolver-kibana/lib/get_webpack_config.js +++ b/packages/osd-eslint-import-resolver-opensearch-dashboards/lib/get_webpack_config.js @@ -19,17 +19,17 @@ const { resolve } = require('path'); -exports.getWebpackConfig = function (kibanaPath) { +exports.getWebpackConfig = function (opensearchDashboardsPath) { return { - context: kibanaPath, + context: opensearchDashboardsPath, resolve: { extensions: ['.js', '.json', '.ts', '.tsx'], mainFields: ['browser', 'main'], - modules: ['node_modules', resolve(kibanaPath, 'node_modules')], + modules: ['node_modules', resolve(opensearchDashboardsPath, 'node_modules')], alias: { // Dev defaults for test bundle https://github.com/elastic/kibana/blob/6998f074542e8c7b32955db159d15661aca253d7/src/core_plugins/tests_bundle/index.js#L73-L78 - fixtures: resolve(kibanaPath, 'src/fixtures'), - test_utils: resolve(kibanaPath, 'src/test_utils/public'), + fixtures: resolve(opensearchDashboardsPath, 'src/fixtures'), + test_utils: resolve(opensearchDashboardsPath, 'src/test_utils/public'), }, unsafeCache: true, }, diff --git a/packages/kbn-eslint-import-resolver-kibana/lib/index.js b/packages/osd-eslint-import-resolver-opensearch-dashboards/lib/index.js similarity index 95% rename from packages/kbn-eslint-import-resolver-kibana/lib/index.js rename to packages/osd-eslint-import-resolver-opensearch-dashboards/lib/index.js index 54ada9a76b2..fd1e830d558 100644 --- a/packages/kbn-eslint-import-resolver-kibana/lib/index.js +++ b/packages/osd-eslint-import-resolver-opensearch-dashboards/lib/index.js @@ -19,7 +19,7 @@ module.exports = Object.assign( {}, - require('./get_kibana_path'), + require('./get_opensearch_dashboards_path'), require('./get_project_root'), require('./get_webpack_config'), require('./get_path_type'), diff --git a/packages/kbn-eslint-import-resolver-kibana/lib/resolve_webpack_alias.js b/packages/osd-eslint-import-resolver-opensearch-dashboards/lib/resolve_webpack_alias.js similarity index 100% rename from packages/kbn-eslint-import-resolver-kibana/lib/resolve_webpack_alias.js rename to packages/osd-eslint-import-resolver-opensearch-dashboards/lib/resolve_webpack_alias.js diff --git a/packages/kbn-eslint-import-resolver-kibana/package.json b/packages/osd-eslint-import-resolver-opensearch-dashboards/package.json similarity index 68% rename from packages/kbn-eslint-import-resolver-kibana/package.json rename to packages/osd-eslint-import-resolver-opensearch-dashboards/package.json index ffbd94810a4..b728174bc55 100755 --- a/packages/kbn-eslint-import-resolver-kibana/package.json +++ b/packages/osd-eslint-import-resolver-opensearch-dashboards/package.json @@ -1,11 +1,11 @@ { - "name": "@kbn/eslint-import-resolver-kibana", - "description": "eslint-plugin-import resolver for Kibana", + "name": "@osd/eslint-import-resolver-opensearch-dashboards", + "description": "eslint-plugin-import resolver for OpenSearch Dashboards", "private": true, "version": "2.0.0", - "main": "import_resolver_kibana.js", + "main": "import_resolver_opensearch_dashboards.js", "license": "Apache-2.0", - "kibana": { + "opensearchDashboards": { "devOnly": true }, "repository": { diff --git a/packages/kbn-eslint-import-resolver-kibana/yarn.lock b/packages/osd-eslint-import-resolver-opensearch-dashboards/yarn.lock similarity index 100% rename from packages/kbn-eslint-import-resolver-kibana/yarn.lock rename to packages/osd-eslint-import-resolver-opensearch-dashboards/yarn.lock