mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
(cherry picked from commit 703580f944
)
Co-authored-by: Spencer <spencer@elastic.co>
This commit is contained in:
parent
187031607e
commit
1b7e51b683
2 changed files with 47 additions and 1 deletions
|
@ -12,7 +12,8 @@ const KIBANA_ROOT = findKibanaRoot();
|
|||
|
||||
function checkModuleNameNode(context, mappings, node, desc = 'Imported') {
|
||||
const mapping = mappings.find(
|
||||
(mapping) => mapping.from === node.value || node.value.startsWith(`${mapping.from}/`)
|
||||
(mapping) =>
|
||||
mapping.from === node.value || (!mapping.exact && node.value.startsWith(`${mapping.from}/`))
|
||||
);
|
||||
|
||||
if (!mapping) {
|
||||
|
@ -85,6 +86,10 @@ module.exports = {
|
|||
exclude: {
|
||||
type: 'array',
|
||||
},
|
||||
exact: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
anyOf: [
|
||||
{
|
||||
|
|
|
@ -37,6 +37,21 @@ ruleTester.run('@kbn/eslint/module-migration', rule, {
|
|||
],
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
code: dedent`
|
||||
import "foo/bar"
|
||||
`,
|
||||
options: [
|
||||
[
|
||||
{
|
||||
from: 'foo',
|
||||
to: 'bar',
|
||||
exact: true,
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
invalid: [
|
||||
|
@ -148,5 +163,31 @@ ruleTester.run('@kbn/eslint/module-migration', rule, {
|
|||
import '../../common/foo'
|
||||
`,
|
||||
},
|
||||
|
||||
{
|
||||
code: dedent`
|
||||
import 'foo'
|
||||
import 'foo/bar'
|
||||
`,
|
||||
options: [
|
||||
[
|
||||
{
|
||||
from: 'foo',
|
||||
to: 'bar',
|
||||
exact: true,
|
||||
},
|
||||
],
|
||||
],
|
||||
errors: [
|
||||
{
|
||||
line: 1,
|
||||
message: 'Imported module "foo" should be "bar"',
|
||||
},
|
||||
],
|
||||
output: dedent`
|
||||
import 'bar'
|
||||
import 'foo/bar'
|
||||
`,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue