mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[eslint-import-resolver] support mapping plugins to directories (#17667)
* [eslint-import-resolver] support mapping plugins to directories * use shorthand syntax
This commit is contained in:
parent
977cd51f6a
commit
6db8fea28e
2 changed files with 24 additions and 6 deletions
|
@ -29,6 +29,7 @@ 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.
|
||||
|
||||
## Settings Usage
|
||||
To specify additional config add a `:` after the resolver name and specify the argument as key-value pairs:
|
||||
|
@ -51,6 +52,12 @@ settings:
|
|||
# that directory and we will look for plugins there
|
||||
pluginDirs:
|
||||
- ./kibana-plugins
|
||||
|
||||
# if you have some other special configuration supply a map of plugin
|
||||
# ids to the directory containing their code
|
||||
pluginMap:
|
||||
plugin1: plugins/plugin1
|
||||
plugin2: plugins/plugin2
|
||||
```
|
||||
|
||||
See [the resolvers docs](https://github.com/benmosher/eslint-plugin-import#resolvers) or the [resolver spec](https://github.com/benmosher/eslint-plugin-import/blob/master/resolvers/README.md#resolvesource-file-config---found-boolean-path-string-) for more details.
|
||||
|
|
|
@ -23,13 +23,24 @@ module.exports = function getPlugins(config, kibanaPath, projectRoot) {
|
|||
...pluginPaths.map(path => resolve(path, 'package.json')),
|
||||
];
|
||||
|
||||
return glob.sync(globPatterns).map(pkgJsonPath => {
|
||||
const path = dirname(pkgJsonPath);
|
||||
const pkg = require(pkgJsonPath);
|
||||
const pluginsFromMap = Object.keys(config.pluginMap || {}).map(name => {
|
||||
const directory = resolveToRoot(config.pluginMap[name]);
|
||||
return {
|
||||
name: pkg.name,
|
||||
directory: path,
|
||||
publicDirectory: resolve(path, 'public'),
|
||||
name,
|
||||
directory,
|
||||
publicDirectory: resolve(directory, 'public'),
|
||||
};
|
||||
});
|
||||
|
||||
return pluginsFromMap.concat(
|
||||
glob.sync(globPatterns).map(pkgJsonPath => {
|
||||
const path = dirname(pkgJsonPath);
|
||||
const pkg = require(pkgJsonPath);
|
||||
return {
|
||||
name: pkg.name,
|
||||
directory: path,
|
||||
publicDirectory: resolve(path, 'public'),
|
||||
};
|
||||
})
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue