Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 8357bf9

Browse files
committed
Fix generating nested relative path import
1 parent 5e52613 commit 8357bf9

File tree

4 files changed

+9
-22
lines changed

4 files changed

+9
-22
lines changed

scripts/generate-rule-files.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ async function main(): Promise<void> {
8787
const failedRules: string[] = [];
8888
for (const [ruleName, { meta }] of Object.entries(rules)) {
8989
try {
90+
const nestedDepth: number = ruleName.split('/').length;
91+
9092
const rulePath: string = path.resolve(ruleProviderDir, `${ruleName}.d.ts`);
91-
let ruleContent: string = "import type { RuleConfig } from '../rule-config';";
93+
let ruleContent: string = `import type { RuleConfig } from '${'../'.repeat(nestedDepth)}rule-config';`;
9294

9395
const ruleNamePascalCase: string = pascalCase(ruleName);
9496

src/rules/node/no-unsupported-features/es-builtins.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import type { LiteralUnion } from '../../../utility-types';
21
import type { RuleConfig } from '../../rule-config';
32

43
/**
54
* Option.
65
*/
76
export interface NoUnsupportedFeaturesEsBuiltinsOption {
87
version?: string;
9-
ignores?: LiteralUnion<
8+
ignores?: (
109
| 'Array.from'
1110
| 'Array.of'
1211
| 'BigInt'
@@ -70,7 +69,7 @@ export interface NoUnsupportedFeaturesEsBuiltinsOption {
7069
| 'Atomics'
7170
| 'SharedArrayBuffer'
7271
| 'globalThis'
73-
>[];
72+
)[];
7473
}
7574

7675
/**

src/rules/node/no-unsupported-features/es-syntax.d.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
1-
import type { LiteralUnion } from '../../../utility-types';
21
import type { RuleConfig } from '../../rule-config';
32

43
/**
54
* Option.
65
*/
76
export interface NoUnsupportedFeaturesEsSyntaxOption {
8-
/**
9-
* As mentioned above, this rule reads the [engines](https://docs.npmjs.com/cli/v7/configuring-npm/package-json) field of `package.json`. But, you can overwrite the version by `version` option.
10-
*
11-
* The `version` option accepts [the valid version range of `node-semver`](https://github.com/npm/node-semver#range-grammar).
12-
*
13-
* @see [version](https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-unsupported-features/es-syntax.md#version)
14-
*/
157
version?: string;
16-
/**
17-
* If you are using transpilers, maybe you want to ignore the warnings about some features.
18-
*
19-
* @see [ignores](https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-unsupported-features/es-syntax.md#ignores)
20-
*/
21-
ignores?: LiteralUnion<
8+
ignores?: (
229
| 'arrowFunctions'
2310
| 'binaryNumericLiterals'
2411
| 'blockScopedFunctions'
@@ -54,7 +41,7 @@ export interface NoUnsupportedFeaturesEsSyntaxOption {
5441
| 'optionalCatchBinding'
5542
| 'bigint'
5643
| 'dynamicImport'
57-
>[];
44+
)[];
5845
}
5946

6047
/**

src/rules/node/no-unsupported-features/node-builtins.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import type { LiteralUnion } from '../../../utility-types';
21
import type { RuleConfig } from '../../rule-config';
32

43
/**
54
* Option.
65
*/
76
export interface NoUnsupportedFeaturesNodeBuiltinsOption {
87
version?: string;
9-
ignores?: LiteralUnion<
8+
ignores?: (
109
| 'queueMicrotask'
1110
| 'require.resolve.paths'
1211
| 'Buffer.alloc'
@@ -163,7 +162,7 @@ export interface NoUnsupportedFeaturesNodeBuiltinsOption {
163162
| 'vm.Module'
164163
| 'vm.compileFunction'
165164
| 'worker_threads'
166-
>[];
165+
)[];
167166
}
168167

169168
/**

0 commit comments

Comments
 (0)