Skip to content

Commit

Permalink
fix: support import type for nestjs
Browse files Browse the repository at this point in the history
  • Loading branch information
tianyingchun committed Oct 24, 2024
1 parent b16a914 commit 6cacdb9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/tidy-ads-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hyperse/eslint-config-hyperse": patch
---

support `import type` for nestjs
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,4 @@ we need to disable vscode editor language formatter for `json, jsonc`
```

1. Isolated Modules - isolatedModules (default:`true`)
2. Verbatim Module Syntax - verbatimModuleSyntax (default:`false`)
2. Verbatim Module Syntax - verbatimModuleSyntax (default:`true`)
4 changes: 2 additions & 2 deletions src/main/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
typescript,
vitest,
} from '../rules/index.js';
import { defaults } from './defaults.js';
import { overrides } from './overrides.js';

export const base = defineFlatConfig([
...typescript,
Expand All @@ -20,5 +20,5 @@ export const base = defineFlatConfig([
...sonar,
...jsonc,
...mdx,
...defaults,
...overrides,
]);
12 changes: 11 additions & 1 deletion src/main/defaults.ts → src/main/overrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ import type { FlatESLintConfig } from 'eslint-define-config';
import { defineFlatConfig } from 'eslint-define-config';
import tseslint from 'typescript-eslint';

export const defaults = defineFlatConfig([
export const overrides = defineFlatConfig([
{
...tseslint.configs.base,
languageOptions: {
// https://typescript-eslint.io/users/configs/#stylistic-type-checked
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
// https://github.com/typescript-eslint/typescript-eslint/issues/10200
// Support `nestjs` decorator metadata, constructor DI class, we can not import type for `nestjs`
emitDecoratorMetadata: true,
},
},
files: ['**/*.ts', '**/*.tsx'],
rules: {
'@typescript-eslint/no-unused-vars': [
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"incremental": true,
"declaration": true,
"isolatedModules": true,
"verbatimModuleSyntax": false,
"verbatimModuleSyntax": true,
"newLine": "lf",
"baseUrl": ".",
"rootDir": ".",
Expand Down
1 change: 1 addition & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"incremental": false,
"declaration": true,
"sourceMap": false,
"verbatimModuleSyntax": false,
"outDir": "./dist",
"rootDir": "./src",
"baseUrl": "./"
Expand Down

0 comments on commit 6cacdb9

Please sign in to comment.