|
27 | 27 |
|
28 | 28 | import { Linter } from "../index";
|
29 | 29 |
|
| 30 | +export interface NoRestrictedImportPathCommonOptions { |
| 31 | + name: string; |
| 32 | + message?: string; |
| 33 | +} |
| 34 | + |
| 35 | +export type EitherImportNamesOrAllowImportName = |
| 36 | + | { importNames?: string[]; allowImportNames?: never } |
| 37 | + | { allowImportNames?: string[]; importNames?: never } |
| 38 | + |
| 39 | +export type ValidNoRestrictedImportPathOptions = NoRestrictedImportPathCommonOptions & EitherImportNamesOrAllowImportName; |
| 40 | + |
| 41 | +export interface NoRestrictedImportPatternCommonOptions { |
| 42 | + message?: string; |
| 43 | + caseSensitive?: boolean; |
| 44 | +} |
| 45 | + |
| 46 | +// Base type for group or regex constraint, ensuring mutual exclusivity |
| 47 | +export type EitherGroupOrRegEx = |
| 48 | + | { group: string[]; regex?: never } |
| 49 | + | { regex: string; group?: never }; |
| 50 | + |
| 51 | +// Base type for import name specifiers, ensuring mutual exclusivity |
| 52 | +export type EitherNameSpecifiers = |
| 53 | + | { importNames: string[]; allowImportNames?: never; importNamePattern?: never; allowImportNamePattern?: never } |
| 54 | + | { importNamePattern: string; allowImportNames?: never; importNames?: never; allowImportNamePattern?: never } |
| 55 | + | { allowImportNames: string[]; importNames?: never; importNamePattern?: never; allowImportNamePattern?: never } |
| 56 | + | { allowImportNamePattern: string; importNames?: never; allowImportNames?: never; importNamePattern?: never } |
| 57 | + |
| 58 | +// Adds oneOf and not constraints, ensuring group or regex are present and mutually exclusive sets for importNames, allowImportNames, etc., as per the schema. |
| 59 | +export type ValidNoRestrictedImportPatternOptions = NoRestrictedImportPatternCommonOptions & EitherGroupOrRegEx & EitherNameSpecifiers; |
| 60 | + |
30 | 61 | export interface ECMAScript6 extends Linter.RulesRecord {
|
31 | 62 | /**
|
32 | 63 | * Rule to require braces around arrow function bodies.
|
@@ -291,23 +322,12 @@ export interface ECMAScript6 extends Linter.RulesRecord {
|
291 | 322 | [
|
292 | 323 | ...Array<
|
293 | 324 | | string
|
294 |
| - | { |
295 |
| - name: string; |
296 |
| - importNames?: string[] | undefined; |
297 |
| - message?: string | undefined; |
298 |
| - } |
| 325 | + | ValidNoRestrictedImportPathOptions |
299 | 326 | | Partial<{
|
300 |
| - paths: Array< |
301 |
| - | string |
302 |
| - | { |
303 |
| - name: string; |
304 |
| - importNames?: string[] | undefined; |
305 |
| - message?: string | undefined; |
306 |
| - } |
307 |
| - >; |
308 |
| - patterns: string[]; |
309 |
| - }> |
310 |
| - >, |
| 327 | + paths: Array<string | ValidNoRestrictedImportPathOptions>; |
| 328 | + patterns: Array<string | ValidNoRestrictedImportPatternOptions>; |
| 329 | + }> |
| 330 | + > |
311 | 331 | ]
|
312 | 332 | >;
|
313 | 333 |
|
|
0 commit comments