mirror of
https://github.com/elastic/kibana.git
synced 2025-06-29 03:24:45 -04:00
Updates files outside of x-pack to be triple-licensed under Elastic License 2.0, AGPL 3.0, or SSPL 1.0.
122 lines
2.5 KiB
JavaScript
122 lines
2.5 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
|
|
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
*/
|
|
|
|
const { RuleTester } = require('eslint');
|
|
const rule = require('./no_unsafe_console');
|
|
const dedent = require('dedent');
|
|
|
|
const ruleTester = new RuleTester({
|
|
parser: require.resolve('@typescript-eslint/parser'),
|
|
parserOptions: {
|
|
sourceType: 'module',
|
|
ecmaVersion: 2018,
|
|
},
|
|
});
|
|
|
|
ruleTester.run('@kbn/eslint/no_unsafe_console', rule, {
|
|
valid: [
|
|
{
|
|
code: dedent`
|
|
unsafeConsole
|
|
`,
|
|
},
|
|
],
|
|
|
|
invalid: [
|
|
{
|
|
code: dedent`
|
|
unsafeConsole.debug('something to debug')
|
|
`,
|
|
errors: [
|
|
{
|
|
line: 1,
|
|
message: 'Unexpected unsafeConsole statement.',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
code: dedent`
|
|
unsafeConsole.error()
|
|
`,
|
|
errors: [
|
|
{
|
|
line: 1,
|
|
message: 'Unexpected unsafeConsole statement.',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
code: dedent`
|
|
unsafeConsole.info('some info')
|
|
`,
|
|
errors: [
|
|
{
|
|
line: 1,
|
|
message: 'Unexpected unsafeConsole statement.',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
code: dedent`
|
|
unsafeConsole.log('something to log')
|
|
`,
|
|
errors: [
|
|
{
|
|
line: 1,
|
|
message: 'Unexpected unsafeConsole statement.',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
code: dedent`
|
|
unsafeConsole.trace()
|
|
`,
|
|
errors: [
|
|
{
|
|
line: 1,
|
|
message: 'Unexpected unsafeConsole statement.',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
code: dedent`
|
|
unsafeConsole.warn('something to warn')
|
|
`,
|
|
errors: [
|
|
{
|
|
line: 1,
|
|
message: 'Unexpected unsafeConsole statement.',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
code: dedent`
|
|
unsafeConsole.anyOtherMethodName()
|
|
`,
|
|
errors: [
|
|
{
|
|
line: 1,
|
|
message: 'Unexpected unsafeConsole statement.',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
code: dedent`
|
|
const { debug } = unsafeConsole
|
|
debug('something to debug')
|
|
`,
|
|
errors: [
|
|
{
|
|
line: 1,
|
|
message: 'Unexpected unsafeConsole statement.',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
});
|