From 1f14c03d2696ce02537c08aba683bdd587de5e6b Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Mon, 31 Oct 2022 03:53:04 -0700 Subject: [PATCH] docs(eslint-plugin): [consistent-type-imports] make a note about `parserOptions.emitDecoratorMetadata` (#5904) * docs(eslint-plugin): [consistent-type-imports] make a note about `parserOptions.emitDecoratorMetadata` * Update consistent-type-imports.md * Update consistent-type-imports.md * Update consistent-type-imports.md * Update consistent-type-imports.md --- .../eslint-plugin/docs/rules/consistent-type-imports.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/eslint-plugin/docs/rules/consistent-type-imports.md b/packages/eslint-plugin/docs/rules/consistent-type-imports.md index 6e6912d34cf..745930d0d54 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-imports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-imports.md @@ -48,6 +48,12 @@ type T = import('Foo').Foo; const x: import('Bar') = 1; ``` +## Usage with `emitDecoratorMetadata` + +The `emitDecoratorMetadata` compiler option changes the code the TypeScript emits. In short - it causes TypeScript to create references to value imports when they are used in a type-only location. If you are using `emitDecoratorMetadata` then our tooling will require additional information in order for the rule to work correctly. + +If you are using [type-aware linting](https://typescript-eslint.io/docs/linting/typed-linting), then you just need to ensure that the `tsconfig.json` you've configured for `parserOptions.project` has `emitDecoratorMetadata` turned on. Otherwise you can explicitly tell our tooling to analyze your code as if the compiler option was turned on [by setting `parserOptions.emitDecoratorMetadata` to `true`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/README.md#parseroptionsemitdecoratormetadata). + ## When Not To Use It - If you specifically want to use both import kinds for stylistic reasons, you can disable this rule.