kibana/packages/kbn-eslint-plugin-eslint
Kurt bcc46b60e9
Changing load/dump in source files (#190641)
## Summary

Updates usage of `js-yaml` `load` and `dump` to `safeLoad` and
`safeDump`, in preparation for a major version update of dependency,
where the default behavior will be that of the safe function variants.


## Note to reviewers
`safeDump` will throw if it encounters invalid types (e.g. `undefined`),
whereas the `dump` function will still write the file including the
invalid types. This may have an affect within your use cases - if
throwing is not acceptable or is unhandled. To avoid this the
`skipInvalid` option can be used (see
https://github.com/nodeca/js-yaml#dump-object---options-) - this will
write the file, stripping out any invalid types from the input.

Please consider this when reviewing the changes to your code. If the
`skipInvalid` option is needed, please add it, or let us know to make
the change.

---------

Co-authored-by: Sid <siddharthmantri1@gmail.com>
Co-authored-by: “jeramysoucy” <jeramy.soucy@elastic.co>
Co-authored-by: Elena Shostak <elena.shostak@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Maxim Palenov <maxim.palenov@elastic.co>
2024-08-21 07:29:36 -04:00
..
__fixtures__ [eslint] add rule to prevent export* in plugin index files (#109357) 2021-09-01 18:05:45 -07:00
helpers Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
rules Changing load/dump in source files (#190641) 2024-08-21 07:29:36 -04:00
index.js Changing load/dump in source files (#190641) 2024-08-21 07:29:36 -04:00
jest.config.js Elastic License 2.0 (#90099) 2021-02-03 18:12:39 -08:00
kibana.jsonc Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
lib.js Elastic License 2.0 (#90099) 2021-02-03 18:12:39 -08:00
package.json add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
README.mdx Harden console functions (#171367) 2024-02-09 09:13:52 -05:00

---
id: kibDevDocsOpsEslintPluginEslint
slug: /kibana-dev-docs/ops/eslint-plugin-eslint
title: "@kbn/eslint-plugin-eslint"
description: A package holding an eslint plugin with custom rules used on Kibana
date: 2022-05-17
tags: ['kibana', 'dev', 'contributor', 'operations', 'eslint', 'plugin']
---

An ESLint plugin exposing custom rules used and built specifically for development within Kibana. 
Next you can find information on each on.

## disallow-license-headers

Disallows a given group of license header texts on a group of files.

```javascript
module.exports = {
  overrides: [
    {    
      files: ['**/*.{js,mjs,ts,tsx}'],
      rules: {
        '@kbn/eslint/disallow-license-headers': [
          'error',
          {
            licenses: [
              "LICENSE_TEXT"
            ],
          },
        ],
      }
    }
  ]    
}
```

## module_migration

Offers a way to force a migration from a given node module into another as an alternative.

```javascript
module.exports = {
  overrides: [
    {    
      files: ['**/*.{js,mjs,ts,tsx}'],
      rules: {
        '@kbn/eslint/module_migration': [
          'error',
          [
            {
              from: 'expect.js',
              to: '@kbn/expect',
            }
          ],
        ],
      }
    }
  ]    
}
```

## no_async_foreach

Disallows passing an async function to .forEach which will avoid promise rejections from being handled. asyncForEach() or a similar helper from "@kbn/std" should be used instead.

## no_async_promise_body

Disallows the usage of an async function as a constructor for a Promise function without a try catch in place.

## no_constructor_args_in_property_initializers

Disallows the usage of constructor arguments into class property initializers.

## no_export_all

Disables the usage of `export *`.

## no_this_in_property_initializers

Disallows the usage of `this` into class property initializers and enforce to define the property value into the constructor.

## no_trailing_import_slash

Disables the usage of a trailing slash in a node module import.

## require-license-header

Requires a given license header text on a group of files.

```javascript
module.exports = {
  overrides: [
    {    
      files: ['**/*.{js,mjs,ts,tsx}'],
      rules: {
        '@kbn/eslint/require-license-header': [
          'error',
          {
            license: "LICENSE_TEXT"
          },
        ],
      }
    }
  ]    
}
```

## no_unsafe_console

Disables the usage of kbn-security-hardening/console/unsafeConsole.