# Conflicts: # packages/elastic-eslint-config-kibana/javascript.js # packages/kbn-eslint-plugin-eslint/rules/disallow_license_headers.test.js # packages/kbn-eslint-plugin-eslint/rules/no_restricted_paths.test.js # packages/kbn-eslint-plugin-eslint/rules/require_license_header.test.js # src/dev/eslint/lint_files.ts # x-pack/plugins/security_solution/public/common/components/markdown_editor/plugins/timeline/processor.tsx # yarn.lock Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
81 lines
1.7 KiB
JavaScript
81 lines
1.7 KiB
JavaScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
* Side Public License, v 1.
|
|
*/
|
|
|
|
const { RuleTester } = require('eslint');
|
|
const rule = require('./module_migration');
|
|
const dedent = require('dedent');
|
|
|
|
const ruleTester = new RuleTester({
|
|
parser: require.resolve('@babel/eslint-parser'),
|
|
parserOptions: {
|
|
ecmaVersion: 2018,
|
|
requireConfigFile: false,
|
|
},
|
|
});
|
|
|
|
ruleTester.run('@kbn/eslint/module-migration', rule, {
|
|
valid: [
|
|
{
|
|
code: dedent`
|
|
import "bar"
|
|
require('bar')
|
|
export { foo } from "bar"
|
|
export const foo2 = 'bar'
|
|
`,
|
|
|
|
options: [
|
|
[
|
|
{
|
|
from: 'foo',
|
|
to: 'bar',
|
|
},
|
|
],
|
|
],
|
|
},
|
|
],
|
|
|
|
invalid: [
|
|
{
|
|
code: dedent`
|
|
import "foo"
|
|
require('foo/foo2')
|
|
export { foo } from 'foo'
|
|
export const foo2 = 'bar'
|
|
`,
|
|
|
|
options: [
|
|
[
|
|
{
|
|
from: 'foo',
|
|
to: 'bar',
|
|
},
|
|
],
|
|
],
|
|
errors: [
|
|
{
|
|
line: 1,
|
|
message: 'Imported module "foo" should be "bar"',
|
|
},
|
|
{
|
|
line: 2,
|
|
message: 'Imported module "foo/foo2" should be "bar/foo2"',
|
|
},
|
|
{
|
|
line: 3,
|
|
message: 'Re-exported module "foo" should be "bar"',
|
|
},
|
|
],
|
|
output: dedent`
|
|
import 'bar'
|
|
require('bar/foo2')
|
|
export { foo } from 'bar'
|
|
export const foo2 = 'bar'
|
|
`,
|
|
},
|
|
],
|
|
});
|