dlinter-ts-react 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1157 @@
1
+ import { Linter } from "eslint";
2
+ //#region node_modules/@types/json-schema/index.d.ts
3
+ // ==================================================================================================
4
+ // JSON Schema Draft 04
5
+ // ==================================================================================================
6
+ /**
7
+ * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1
8
+ */
9
+ type JSONSchema4TypeName = "string" //
10
+ | "number" | "integer" | "boolean" | "object" | "array" | "null" | "any";
11
+ /**
12
+ * @see https://tools.ietf.org/html/draft-zyp-json-schema-04#section-3.5
13
+ */
14
+ type JSONSchema4Type = string //
15
+ | number | boolean | JSONSchema4Object | JSONSchema4Array | null;
16
+ // Workaround for infinite type recursion
17
+ interface JSONSchema4Object {
18
+ [key: string]: JSONSchema4Type;
19
+ }
20
+ // Workaround for infinite type recursion
21
+ // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
22
+ interface JSONSchema4Array extends Array<JSONSchema4Type> {}
23
+ /**
24
+ * Meta schema
25
+ *
26
+ * Recommended values:
27
+ * - 'http://json-schema.org/schema#'
28
+ * - 'http://json-schema.org/hyper-schema#'
29
+ * - 'http://json-schema.org/draft-04/schema#'
30
+ * - 'http://json-schema.org/draft-04/hyper-schema#'
31
+ * - 'http://json-schema.org/draft-03/schema#'
32
+ * - 'http://json-schema.org/draft-03/hyper-schema#'
33
+ *
34
+ * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5
35
+ */
36
+ type JSONSchema4Version = string;
37
+ /**
38
+ * JSON Schema V4
39
+ * @see https://tools.ietf.org/html/draft-zyp-json-schema-04
40
+ */
41
+ interface JSONSchema4 {
42
+ id?: string | undefined;
43
+ $ref?: string | undefined;
44
+ $schema?: JSONSchema4Version | undefined;
45
+ /**
46
+ * This attribute is a string that provides a short description of the
47
+ * instance property.
48
+ *
49
+ * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.21
50
+ */
51
+ title?: string | undefined;
52
+ /**
53
+ * This attribute is a string that provides a full description of the of
54
+ * purpose the instance property.
55
+ *
56
+ * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.22
57
+ */
58
+ description?: string | undefined;
59
+ default?: JSONSchema4Type | undefined;
60
+ multipleOf?: number | undefined;
61
+ maximum?: number | undefined;
62
+ exclusiveMaximum?: boolean | undefined;
63
+ minimum?: number | undefined;
64
+ exclusiveMinimum?: boolean | undefined;
65
+ maxLength?: number | undefined;
66
+ minLength?: number | undefined;
67
+ pattern?: string | undefined;
68
+ /**
69
+ * May only be defined when "items" is defined, and is a tuple of JSONSchemas.
70
+ *
71
+ * This provides a definition for additional items in an array instance
72
+ * when tuple definitions of the items is provided. This can be false
73
+ * to indicate additional items in the array are not allowed, or it can
74
+ * be a schema that defines the schema of the additional items.
75
+ *
76
+ * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.6
77
+ */
78
+ additionalItems?: boolean | JSONSchema4 | undefined;
79
+ /**
80
+ * This attribute defines the allowed items in an instance array, and
81
+ * MUST be a schema or an array of schemas. The default value is an
82
+ * empty schema which allows any value for items in the instance array.
83
+ *
84
+ * When this attribute value is a schema and the instance value is an
85
+ * array, then all the items in the array MUST be valid according to the
86
+ * schema.
87
+ *
88
+ * When this attribute value is an array of schemas and the instance
89
+ * value is an array, each position in the instance array MUST conform
90
+ * to the schema in the corresponding position for this array. This
91
+ * called tuple typing. When tuple typing is used, additional items are
92
+ * allowed, disallowed, or constrained by the "additionalItems"
93
+ * (Section 5.6) attribute using the same rules as
94
+ * "additionalProperties" (Section 5.4) for objects.
95
+ *
96
+ * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.5
97
+ */
98
+ items?: JSONSchema4 | JSONSchema4[] | undefined;
99
+ maxItems?: number | undefined;
100
+ minItems?: number | undefined;
101
+ uniqueItems?: boolean | undefined;
102
+ maxProperties?: number | undefined;
103
+ minProperties?: number | undefined;
104
+ /**
105
+ * This attribute indicates if the instance must have a value, and not
106
+ * be undefined. This is false by default, making the instance
107
+ * optional.
108
+ *
109
+ * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.7
110
+ */
111
+ required?: boolean | string[] | undefined;
112
+ /**
113
+ * This attribute defines a schema for all properties that are not
114
+ * explicitly defined in an object type definition. If specified, the
115
+ * value MUST be a schema or a boolean. If false is provided, no
116
+ * additional properties are allowed beyond the properties defined in
117
+ * the schema. The default value is an empty schema which allows any
118
+ * value for additional properties.
119
+ *
120
+ * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.4
121
+ */
122
+ additionalProperties?: boolean | JSONSchema4 | undefined;
123
+ definitions?: {
124
+ [k: string]: JSONSchema4;
125
+ } | undefined;
126
+ /**
127
+ * This attribute is an object with property definitions that define the
128
+ * valid values of instance object property values. When the instance
129
+ * value is an object, the property values of the instance object MUST
130
+ * conform to the property definitions in this object. In this object,
131
+ * each property definition's value MUST be a schema, and the property's
132
+ * name MUST be the name of the instance property that it defines. The
133
+ * instance property value MUST be valid according to the schema from
134
+ * the property definition. Properties are considered unordered, the
135
+ * order of the instance properties MAY be in any order.
136
+ *
137
+ * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.2
138
+ */
139
+ properties?: {
140
+ [k: string]: JSONSchema4;
141
+ } | undefined;
142
+ /**
143
+ * This attribute is an object that defines the schema for a set of
144
+ * property names of an object instance. The name of each property of
145
+ * this attribute's object is a regular expression pattern in the ECMA
146
+ * 262/Perl 5 format, while the value is a schema. If the pattern
147
+ * matches the name of a property on the instance object, the value of
148
+ * the instance's property MUST be valid against the pattern name's
149
+ * schema value.
150
+ *
151
+ * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.3
152
+ */
153
+ patternProperties?: {
154
+ [k: string]: JSONSchema4;
155
+ } | undefined;
156
+ dependencies?: {
157
+ [k: string]: JSONSchema4 | string[];
158
+ } | undefined;
159
+ /**
160
+ * This provides an enumeration of all possible values that are valid
161
+ * for the instance property. This MUST be an array, and each item in
162
+ * the array represents a possible value for the instance value. If
163
+ * this attribute is defined, the instance value MUST be one of the
164
+ * values in the array in order for the schema to be valid.
165
+ *
166
+ * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.19
167
+ */
168
+ enum?: JSONSchema4Type[] | undefined;
169
+ /**
170
+ * A single type, or a union of simple types
171
+ */
172
+ type?: JSONSchema4TypeName | JSONSchema4TypeName[] | undefined;
173
+ allOf?: JSONSchema4[] | undefined;
174
+ anyOf?: JSONSchema4[] | undefined;
175
+ oneOf?: JSONSchema4[] | undefined;
176
+ not?: JSONSchema4 | undefined;
177
+ /**
178
+ * The value of this property MUST be another schema which will provide
179
+ * a base schema which the current schema will inherit from. The
180
+ * inheritance rules are such that any instance that is valid according
181
+ * to the current schema MUST be valid according to the referenced
182
+ * schema. This MAY also be an array, in which case, the instance MUST
183
+ * be valid for all the schemas in the array. A schema that extends
184
+ * another schema MAY define additional attributes, constrain existing
185
+ * attributes, or add other constraints.
186
+ *
187
+ * Conceptually, the behavior of extends can be seen as validating an
188
+ * instance against all constraints in the extending schema as well as
189
+ * the extended schema(s).
190
+ *
191
+ * @see https://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.26
192
+ */
193
+ extends?: string | string[] | undefined;
194
+ /**
195
+ * @see https://tools.ietf.org/html/draft-zyp-json-schema-04#section-5.6
196
+ */
197
+ [k: string]: any;
198
+ format?: string | undefined;
199
+ }
200
+ //#endregion
201
+ //#region node_modules/@eslint/core/dist/esm/types.d.ts
202
+ /**
203
+ * Represents an error inside of a file.
204
+ */
205
+ interface FileError {
206
+ message: string;
207
+ line: number;
208
+ column: number;
209
+ endLine?: number;
210
+ endColumn?: number;
211
+ }
212
+ /**
213
+ * Represents a problem found in a file.
214
+ */
215
+ interface FileProblem {
216
+ ruleId: string | null;
217
+ message: string;
218
+ loc: SourceLocation;
219
+ }
220
+ /**
221
+ * Represents the start and end coordinates of a node inside the source.
222
+ */
223
+ interface SourceLocation {
224
+ start: Position;
225
+ end: Position;
226
+ }
227
+ /**
228
+ * Represents a location coordinate inside the source. ESLint-style formats
229
+ * have just `line` and `column` while others may have `offset` as well.
230
+ */
231
+ interface Position {
232
+ line: number;
233
+ column: number;
234
+ }
235
+ /**
236
+ * Represents a range of characters in the source.
237
+ */
238
+ type SourceRange = [number, number];
239
+ /**
240
+ * What the rule is responsible for finding:
241
+ * - `problem` means the rule has noticed a potential error.
242
+ * - `suggestion` means the rule suggests an alternate or better approach.
243
+ * - `layout` means the rule is looking at spacing, indentation, etc.
244
+ */
245
+ type RuleType = "problem" | "suggestion" | "layout";
246
+ /**
247
+ * The type of fix the rule can provide:
248
+ * - `code` means the rule can fix syntax.
249
+ * - `whitespace` means the rule can fix spacing and indentation.
250
+ */
251
+ type RuleFixType = "code" | "whitespace";
252
+ /**
253
+ * An object containing visitor information for a rule. Each method is either the
254
+ * name of a node type or a selector, or is a method that will be called at specific
255
+ * times during the traversal.
256
+ */
257
+ type RuleVisitor = Record<string, ((...args: any[]) => void) | undefined>;
258
+ /**
259
+ * Rule meta information used for documentation.
260
+ */
261
+ interface RulesMetaDocs {
262
+ /**
263
+ * A short description of the rule.
264
+ */
265
+ description?: string | undefined;
266
+ /**
267
+ * The URL to the documentation for the rule.
268
+ */
269
+ url?: string | undefined;
270
+ /**
271
+ * Indicates if the rule is generally recommended for all users.
272
+ *
273
+ * Note - this will always be a boolean for core rules, but may be used in any way by plugins.
274
+ */
275
+ recommended?: unknown;
276
+ /**
277
+ * Indicates if the rule is frozen (no longer accepting feature requests).
278
+ */
279
+ frozen?: boolean | undefined;
280
+ /**
281
+ * The dialects of the languages that the rule is intended to lint.
282
+ * @example
283
+ * ["JavaScript", "TypeScript"]
284
+ */
285
+ dialects?: string[] | undefined;
286
+ }
287
+ /**
288
+ * Meta information about a rule.
289
+ */
290
+ interface RulesMeta<MessageIds extends string = string, RuleOptions = unknown[], ExtRuleDocs = unknown> {
291
+ /**
292
+ * Properties that are used when documenting the rule.
293
+ */
294
+ docs?: (RulesMetaDocs & ExtRuleDocs) | undefined;
295
+ /**
296
+ * The type of rule.
297
+ */
298
+ type?: RuleType | undefined;
299
+ /**
300
+ * The schema for the rule options. Required if the rule has options.
301
+ */
302
+ schema?: JSONSchema4 | JSONSchema4[] | false | undefined;
303
+ /**
304
+ * Any default options to be recursively merged on top of any user-provided options.
305
+ */
306
+ defaultOptions?: RuleOptions;
307
+ /**
308
+ * The messages that the rule can report.
309
+ */
310
+ messages?: Record<MessageIds, string>;
311
+ /**
312
+ * Indicates whether the rule has been deprecated or provides additional metadata about the deprecation. Omit if not deprecated.
313
+ */
314
+ deprecated?: boolean | DeprecatedInfo | undefined;
315
+ /**
316
+ * @deprecated Use deprecated.replacedBy instead.
317
+ * The name of the rule(s) this rule was replaced by, if it was deprecated.
318
+ */
319
+ replacedBy?: readonly string[] | undefined;
320
+ /**
321
+ * Indicates if the rule is fixable, and if so, what type of fix it provides.
322
+ */
323
+ fixable?: RuleFixType | undefined;
324
+ /**
325
+ * Indicates if the rule may provide suggestions.
326
+ */
327
+ hasSuggestions?: boolean | undefined;
328
+ /**
329
+ * The language the rule is intended to lint.
330
+ * @deprecated Use `languages` instead.
331
+ */
332
+ language?: string;
333
+ /**
334
+ * The dialects of `language` that the rule is intended to lint.
335
+ * @deprecated Use `docs.dialects` instead.
336
+ */
337
+ dialects?: string[];
338
+ /**
339
+ * Languages supported by this rule in the format `"plugin/language"`.
340
+ * Use `"*"` for any language or `"plugin/*"` for any language from a specific plugin.
341
+ * @example
342
+ * ["js/js", "markdown/gfm", "json/jsonc", "css/css"]
343
+ */
344
+ languages?: string[] | undefined;
345
+ }
346
+ /**
347
+ * Provides additional metadata about a deprecation.
348
+ */
349
+ interface DeprecatedInfo {
350
+ /**
351
+ * General message presented to the user, e.g. for the key rule why the rule
352
+ * is deprecated or for info how to replace the rule.
353
+ */
354
+ message?: string;
355
+ /**
356
+ * URL to more information about this deprecation in general.
357
+ */
358
+ url?: string;
359
+ /**
360
+ * An empty array explicitly states that there is no replacement.
361
+ */
362
+ replacedBy?: ReplacedByInfo[];
363
+ /**
364
+ * The package version since when the rule is deprecated (should use full
365
+ * semver without a leading "v").
366
+ */
367
+ deprecatedSince?: string;
368
+ /**
369
+ * The estimated version when the rule is removed (probably the next major
370
+ * version). null means the rule is "frozen" (will be available but will not
371
+ * be changed).
372
+ */
373
+ availableUntil?: string | null;
374
+ }
375
+ /**
376
+ * Provides metadata about a replacement
377
+ */
378
+ interface ReplacedByInfo {
379
+ /**
380
+ * General message presented to the user, e.g. how to replace the rule
381
+ */
382
+ message?: string;
383
+ /**
384
+ * URL to more information about this replacement in general
385
+ */
386
+ url?: string;
387
+ /**
388
+ * Name should be "eslint" if the replacement is an ESLint core rule. Omit
389
+ * the property if the replacement is in the same plugin.
390
+ */
391
+ plugin?: ExternalSpecifier;
392
+ /**
393
+ * Name and documentation of the replacement rule
394
+ */
395
+ rule?: ExternalSpecifier;
396
+ }
397
+ /**
398
+ * Specifies the name and url of an external resource. At least one property
399
+ * should be set.
400
+ */
401
+ interface ExternalSpecifier {
402
+ /**
403
+ * Name of the referenced plugin / rule.
404
+ */
405
+ name?: string;
406
+ /**
407
+ * URL pointing to documentation for the plugin / rule.
408
+ */
409
+ url?: string;
410
+ }
411
+ /**
412
+ * Generic type for `RuleContext`.
413
+ */
414
+ interface RuleContextTypeOptions {
415
+ LangOptions: LanguageOptions;
416
+ Code: SourceCode;
417
+ RuleOptions: unknown[];
418
+ Node: unknown;
419
+ MessageIds: string;
420
+ }
421
+ /**
422
+ * Represents the context object that is passed to a rule. This object contains
423
+ * information about the current state of the linting process and is the rule's
424
+ * view into the outside world.
425
+ */
426
+ interface RuleContext<Options extends RuleContextTypeOptions = RuleContextTypeOptions> {
427
+ /**
428
+ * The current working directory for the session.
429
+ */
430
+ cwd: string;
431
+ /**
432
+ * The filename of the file being linted.
433
+ */
434
+ filename: string;
435
+ /**
436
+ * The physical filename of the file being linted.
437
+ */
438
+ physicalFilename: string;
439
+ /**
440
+ * The source code object that the rule is running on.
441
+ */
442
+ sourceCode: Options["Code"];
443
+ /**
444
+ * Shared settings for the configuration.
445
+ */
446
+ settings: SettingsConfig;
447
+ /**
448
+ * The language options for the configuration.
449
+ */
450
+ languageOptions: Options["LangOptions"];
451
+ /**
452
+ * The rule ID.
453
+ */
454
+ id: string;
455
+ /**
456
+ * The rule's configured options.
457
+ */
458
+ options: Options["RuleOptions"];
459
+ /**
460
+ * The report function that the rule should use to report problems.
461
+ * @param violation The violation to report.
462
+ */
463
+ report(violation: ViolationReport<Options["Node"], Options["MessageIds"]>): void;
464
+ }
465
+ /**
466
+ * Manager of text edits for a rule fix.
467
+ */
468
+ interface RuleTextEditor<EditableSyntaxElement = unknown> {
469
+ /**
470
+ * Inserts text after the specified node or token.
471
+ * @param syntaxElement The node or token to insert after.
472
+ * @param text The edit to insert after the node or token.
473
+ */
474
+ insertTextAfter(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
475
+ /**
476
+ * Inserts text after the specified range.
477
+ * @param range The range to insert after.
478
+ * @param text The edit to insert after the range.
479
+ */
480
+ insertTextAfterRange(range: SourceRange, text: string): RuleTextEdit;
481
+ /**
482
+ * Inserts text before the specified node or token.
483
+ * @param syntaxElement A syntax element with location information to insert before.
484
+ * @param text The edit to insert before the node or token.
485
+ */
486
+ insertTextBefore(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
487
+ /**
488
+ * Inserts text before the specified range.
489
+ * @param range The range to insert before.
490
+ * @param text The edit to insert before the range.
491
+ */
492
+ insertTextBeforeRange(range: SourceRange, text: string): RuleTextEdit;
493
+ /**
494
+ * Removes the specified node or token.
495
+ * @param syntaxElement A syntax element with location information to remove.
496
+ * @returns The edit to remove the node or token.
497
+ */
498
+ remove(syntaxElement: EditableSyntaxElement): RuleTextEdit;
499
+ /**
500
+ * Removes the specified range.
501
+ * @param range The range to remove.
502
+ * @returns The edit to remove the range.
503
+ */
504
+ removeRange(range: SourceRange): RuleTextEdit;
505
+ /**
506
+ * Replaces the specified node or token with the given text.
507
+ * @param syntaxElement A syntax element with location information to replace.
508
+ * @param text The text to replace the node or token with.
509
+ * @returns The edit to replace the node or token.
510
+ */
511
+ replaceText(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
512
+ /**
513
+ * Replaces the specified range with the given text.
514
+ * @param range The range to replace.
515
+ * @param text The text to replace the range with.
516
+ * @returns The edit to replace the range.
517
+ */
518
+ replaceTextRange(range: SourceRange, text: string): RuleTextEdit;
519
+ }
520
+ /**
521
+ * Represents a fix for a rule violation implemented as a text edit.
522
+ */
523
+ interface RuleTextEdit {
524
+ /**
525
+ * The range to replace.
526
+ */
527
+ range: SourceRange;
528
+ /**
529
+ * The text to insert.
530
+ */
531
+ text: string;
532
+ }
533
+ /**
534
+ * Fixes a violation.
535
+ * @param fixer The text editor to apply the fix.
536
+ * @returns The fix(es) for the violation.
537
+ */
538
+ type RuleFixer = (fixer: RuleTextEditor) => RuleTextEdit | Iterable<RuleTextEdit> | null;
539
+ /**
540
+ * Data that can be used to fill placeholders in error messages.
541
+ */
542
+ type MessagePlaceholderData = Record<string, string | number | boolean | bigint | null | undefined>;
543
+ interface ViolationReportBase<MessageIds extends string = string> {
544
+ /**
545
+ * The data to insert into the message.
546
+ */
547
+ data?: MessagePlaceholderData | undefined;
548
+ /**
549
+ * The fix to be applied for the violation.
550
+ */
551
+ fix?: RuleFixer | null | undefined;
552
+ /**
553
+ * An array of suggested fixes for the problem. These fixes may change the
554
+ * behavior of the code, so they are not applied automatically.
555
+ */
556
+ suggest?: SuggestedEdit<MessageIds>[] | null | undefined;
557
+ }
558
+ type ViolationMessage<MessageIds extends string = string> = {
559
+ message: string;
560
+ } | {
561
+ messageId: MessageIds;
562
+ };
563
+ type ViolationLocation<Node> = {
564
+ loc: SourceLocation | Position;
565
+ } | {
566
+ node: Node;
567
+ };
568
+ type ViolationReport<Node = unknown, MessageIds extends string = string> = ViolationReportBase<MessageIds> & ViolationMessage<MessageIds> & ViolationLocation<Node>;
569
+ interface SuggestedEditBase {
570
+ /**
571
+ * The data to insert into the message.
572
+ */
573
+ data?: MessagePlaceholderData | undefined;
574
+ /**
575
+ * The fix to be applied for the suggestion.
576
+ */
577
+ fix: RuleFixer;
578
+ }
579
+ type SuggestionMessage<MessageIds extends string = string> = {
580
+ desc: string;
581
+ } | {
582
+ messageId: MessageIds;
583
+ };
584
+ /**
585
+ * A suggested edit for a rule violation.
586
+ */
587
+ type SuggestedEdit<MessageIds extends string = string> = SuggestedEditBase & SuggestionMessage<MessageIds>;
588
+ /**
589
+ * The normalized version of a lint suggestion.
590
+ */
591
+ interface LintSuggestion {
592
+ /** A short description. */
593
+ desc: string;
594
+ /** Fix result info. */
595
+ fix: RuleTextEdit;
596
+ /** Id referencing a message for the description. */
597
+ messageId?: string | undefined;
598
+ }
599
+ /**
600
+ * The normalized version of a lint violation message.
601
+ */
602
+ interface LintMessage {
603
+ /** The 1-based column number. */
604
+ column: number;
605
+ /** The 1-based line number. */
606
+ line: number;
607
+ /** The 1-based column number of the end location. */
608
+ endColumn?: number | undefined;
609
+ /** The 1-based line number of the end location. */
610
+ endLine?: number | undefined;
611
+ /** The ID of the rule which makes this message. */
612
+ ruleId: string | null;
613
+ /** The reported message. */
614
+ message: string;
615
+ /** The ID of the message in the rule's meta. */
616
+ messageId?: string | undefined;
617
+ /** If `true` then this is a fatal error. */
618
+ fatal?: true | undefined;
619
+ /** The severity of this message. */
620
+ severity: Exclude<SeverityLevel, 0>;
621
+ /** Information for autofix. */
622
+ fix?: RuleTextEdit | undefined;
623
+ /** Information for suggestions. */
624
+ suggestions?: LintSuggestion[] | undefined;
625
+ }
626
+ /**
627
+ * Generic options for the `RuleDefinition` type.
628
+ */
629
+ interface RuleDefinitionTypeOptions {
630
+ LangOptions: LanguageOptions;
631
+ Code: SourceCode;
632
+ RuleOptions: unknown[];
633
+ Visitor: RuleVisitor;
634
+ Node: unknown;
635
+ MessageIds: string;
636
+ ExtRuleDocs: unknown;
637
+ }
638
+ /**
639
+ * The definition of an ESLint rule.
640
+ */
641
+ interface RuleDefinition<Options extends RuleDefinitionTypeOptions = RuleDefinitionTypeOptions> {
642
+ /**
643
+ * The meta information for the rule.
644
+ */
645
+ meta?: RulesMeta<Options["MessageIds"], Options["RuleOptions"], Options["ExtRuleDocs"]>;
646
+ /**
647
+ * Creates the visitor that ESLint uses to apply the rule during traversal.
648
+ * @param context The rule context.
649
+ * @returns The rule visitor.
650
+ */
651
+ create(context: RuleContext<{
652
+ LangOptions: Options["LangOptions"];
653
+ Code: Options["Code"];
654
+ RuleOptions: Options["RuleOptions"];
655
+ Node: Options["Node"];
656
+ MessageIds: Options["MessageIds"];
657
+ }>): Options["Visitor"];
658
+ }
659
+ /**
660
+ * The human readable severity level used in a configuration.
661
+ */
662
+ type SeverityName = "off" | "warn" | "error";
663
+ /**
664
+ * The numeric severity level for a rule.
665
+ *
666
+ * - `0` means off.
667
+ * - `1` means warn.
668
+ * - `2` means error.
669
+ */
670
+ type SeverityLevel = 0 | 1 | 2;
671
+ /**
672
+ * The severity of a rule in a configuration.
673
+ */
674
+ type Severity = SeverityName | SeverityLevel;
675
+ /**
676
+ * Represents the metadata for an object, such as a plugin or processor.
677
+ */
678
+ interface ObjectMetaProperties {
679
+ /** @deprecated Use `meta.name` instead. */
680
+ name?: string | undefined;
681
+ /** @deprecated Use `meta.version` instead. */
682
+ version?: string | undefined;
683
+ meta?: {
684
+ name?: string | undefined;
685
+ version?: string | undefined;
686
+ };
687
+ }
688
+ /**
689
+ * The configuration for a rule.
690
+ */
691
+ type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
692
+ /**
693
+ * A collection of rules and their configurations.
694
+ */
695
+ interface RulesConfig {
696
+ [key: string]: RuleConfig;
697
+ }
698
+ /**
699
+ * A collection of settings.
700
+ */
701
+ interface SettingsConfig {
702
+ [key: string]: unknown;
703
+ }
704
+ /** @deprecated Only supported in legacy eslintrc config format. */
705
+ type GlobalAccess = boolean | "off" | "readable" | "readonly" | "writable" | "writeable";
706
+ /** @deprecated Only supported in legacy eslintrc config format. */
707
+ interface GlobalsConfig {
708
+ [name: string]: GlobalAccess;
709
+ }
710
+ /**
711
+ * The ECMAScript version of the code being linted.
712
+ * @deprecated Only supported in legacy eslintrc config format.
713
+ */
714
+ type EcmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | 2026 | "latest";
715
+ /**
716
+ * The type of JavaScript source code.
717
+ * @deprecated Only supported in legacy eslintrc config format.
718
+ */
719
+ type JavaScriptSourceType = "script" | "module" | "commonjs";
720
+ /**
721
+ * Parser options.
722
+ * @deprecated Only supported in legacy eslintrc config format.
723
+ * @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options)
724
+ */
725
+ interface JavaScriptParserOptionsConfig {
726
+ /**
727
+ * Allow the use of reserved words as identifiers (if `ecmaVersion` is 3).
728
+ *
729
+ * @default false
730
+ */
731
+ allowReserved?: boolean | undefined;
732
+ /**
733
+ * Accepts any valid ECMAScript version number or `'latest'`:
734
+ *
735
+ * - A version: es3, es5, es6, es7, es8, es9, es10, es11, es12, es13, es14, ..., or
736
+ * - A year: es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, ..., or
737
+ * - `'latest'`
738
+ *
739
+ * When it's a version or a year, the value must be a number - so do not include the `es` prefix.
740
+ *
741
+ * Specifies the version of ECMAScript syntax you want to use. This is used by the parser to determine how to perform scope analysis, and it affects the default
742
+ *
743
+ * @default 5
744
+ */
745
+ ecmaVersion?: EcmaVersion | undefined;
746
+ /**
747
+ * The type of JavaScript source code. Possible values are "script" for
748
+ * traditional script files, "module" for ECMAScript modules (ESM), and
749
+ * "commonjs" for CommonJS files.
750
+ *
751
+ * @default 'script'
752
+ *
753
+ * @see https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options
754
+ */
755
+ sourceType?: JavaScriptSourceType | undefined;
756
+ /**
757
+ * An object indicating which additional language features you'd like to use.
758
+ *
759
+ * @see https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options
760
+ */
761
+ ecmaFeatures?: {
762
+ globalReturn?: boolean | undefined;
763
+ impliedStrict?: boolean | undefined;
764
+ jsx?: boolean | undefined;
765
+ [key: string]: any;
766
+ } | undefined;
767
+ [key: string]: any;
768
+ }
769
+ /** @deprecated Only supported in legacy eslintrc config format. */
770
+ interface EnvironmentConfig {
771
+ /** The definition of global variables. */
772
+ globals?: GlobalsConfig | undefined;
773
+ /** The parser options that will be enabled under this environment. */
774
+ parserOptions?: JavaScriptParserOptionsConfig | undefined;
775
+ }
776
+ /**
777
+ * File information passed to a processor.
778
+ */
779
+ interface ProcessorFile {
780
+ text: string;
781
+ filename: string;
782
+ }
783
+ /**
784
+ * A processor is an object that can preprocess and postprocess files.
785
+ */
786
+ interface Processor<T extends string | ProcessorFile = string | ProcessorFile> extends ObjectMetaProperties {
787
+ /** If `true` then it means the processor supports autofix. */
788
+ supportsAutofix?: boolean | undefined;
789
+ /** The function to extract code blocks. */
790
+ preprocess?(text: string, filename: string): T[];
791
+ /** The function to merge messages. */
792
+ postprocess?(messages: LintMessage[][], filename: string): LintMessage[];
793
+ }
794
+ /**
795
+ * Generic options for the `Language` type.
796
+ */
797
+ interface LanguageTypeOptions {
798
+ LangOptions: LanguageOptions;
799
+ Code: SourceCode;
800
+ RootNode: unknown;
801
+ Node: unknown;
802
+ }
803
+ /**
804
+ * Represents a plugin language.
805
+ */
806
+ interface Language<Options extends LanguageTypeOptions = {
807
+ LangOptions: LanguageOptions;
808
+ Code: SourceCode;
809
+ RootNode: unknown;
810
+ Node: unknown;
811
+ }> {
812
+ /**
813
+ * Indicates how ESLint should read the file.
814
+ */
815
+ fileType: "text";
816
+ /**
817
+ * First line number returned from the parser (text mode only).
818
+ */
819
+ lineStart: 0 | 1;
820
+ /**
821
+ * First column number returned from the parser (text mode only).
822
+ */
823
+ columnStart: 0 | 1;
824
+ /**
825
+ * The property to read the node type from. Used in selector querying.
826
+ */
827
+ nodeTypeKey: string;
828
+ /**
829
+ * The traversal path that tools should take when evaluating the AST
830
+ */
831
+ visitorKeys?: Record<string, string[]>;
832
+ /**
833
+ * Default language options. User-defined options are merged with this object.
834
+ */
835
+ defaultLanguageOptions?: Options["LangOptions"];
836
+ /**
837
+ * Validates languageOptions for this language.
838
+ */
839
+ validateLanguageOptions(languageOptions: Options["LangOptions"]): void;
840
+ /**
841
+ * Normalizes languageOptions for this language.
842
+ */
843
+ normalizeLanguageOptions?(languageOptions: Options["LangOptions"]): Options["LangOptions"];
844
+ /**
845
+ * Helper for esquery that allows languages to match nodes against
846
+ * class. esquery currently has classes like `function` that will
847
+ * match all the various function nodes. This method allows languages
848
+ * to implement similar shorthands.
849
+ */
850
+ matchesSelectorClass?(className: string, node: Options["Node"], ancestry: Options["Node"][]): boolean;
851
+ /**
852
+ * Parses the given file input into its component parts. This file should not
853
+ * throws errors for parsing errors but rather should return any parsing
854
+ * errors as parse of the ParseResult object.
855
+ */
856
+ parse(file: File, context: LanguageContext<Options["LangOptions"]>): ParseResult<Options["RootNode"]>;
857
+ /**
858
+ * Creates SourceCode object that ESLint uses to work with a file.
859
+ */
860
+ createSourceCode(file: File, input: OkParseResult<Options["RootNode"]>, context: LanguageContext<Options["LangOptions"]>): Options["Code"];
861
+ }
862
+ /**
863
+ * Plugin-defined options for the language.
864
+ */
865
+ type LanguageOptions = Record<string, unknown>;
866
+ /**
867
+ * The context object that is passed to the language plugin methods.
868
+ */
869
+ interface LanguageContext<LangOptions = LanguageOptions> {
870
+ languageOptions: LangOptions;
871
+ }
872
+ /**
873
+ * Represents a file read by ESLint.
874
+ */
875
+ interface File {
876
+ /**
877
+ * The path that ESLint uses for this file. May be a virtual path
878
+ * if it was returned by a processor.
879
+ */
880
+ path: string;
881
+ /**
882
+ * The path to the file on disk. This always maps directly to a file
883
+ * regardless of whether it was returned from a processor.
884
+ */
885
+ physicalPath: string;
886
+ /**
887
+ * Indicates if the original source contained a byte-order marker.
888
+ * ESLint strips the BOM from the `body`, but this info is needed
889
+ * to correctly apply autofixing.
890
+ */
891
+ bom: boolean;
892
+ /**
893
+ * The body of the file to parse.
894
+ */
895
+ body: string | Uint8Array;
896
+ }
897
+ /**
898
+ * Represents the successful result of parsing a file.
899
+ */
900
+ interface OkParseResult<RootNode = unknown> {
901
+ /**
902
+ * Indicates if the parse was successful. If true, the parse was successful
903
+ * and ESLint should continue on to create a SourceCode object and run rules;
904
+ * if false, ESLint should just report the error(s) without doing anything
905
+ * else.
906
+ */
907
+ ok: true;
908
+ /**
909
+ * The abstract syntax tree created by the parser. (only when ok: true)
910
+ */
911
+ ast: RootNode;
912
+ /**
913
+ * Any additional data that the parser wants to provide.
914
+ */
915
+ [key: string]: any;
916
+ }
917
+ /**
918
+ * Represents the unsuccessful result of parsing a file.
919
+ */
920
+ interface NotOkParseResult {
921
+ /**
922
+ * Indicates if the parse was successful. If true, the parse was successful
923
+ * and ESLint should continue on to create a SourceCode object and run rules;
924
+ * if false, ESLint should just report the error(s) without doing anything
925
+ * else.
926
+ */
927
+ ok: false;
928
+ /**
929
+ * Any parsing errors, whether fatal or not. (only when ok: false)
930
+ */
931
+ errors: FileError[];
932
+ /**
933
+ * Any additional data that the parser wants to provide.
934
+ */
935
+ [key: string]: any;
936
+ }
937
+ type ParseResult<RootNode = unknown> = OkParseResult<RootNode> | NotOkParseResult;
938
+ /**
939
+ * Represents inline configuration found in the source code.
940
+ */
941
+ interface InlineConfigElement {
942
+ /**
943
+ * The location of the inline config element.
944
+ */
945
+ loc: SourceLocation;
946
+ /**
947
+ * The interpreted configuration from the inline config element.
948
+ */
949
+ config: {
950
+ rules: RulesConfig;
951
+ };
952
+ }
953
+ /**
954
+ * Generic options for the `SourceCodeBase` type.
955
+ */
956
+ interface SourceCodeBaseTypeOptions {
957
+ LangOptions: LanguageOptions;
958
+ RootNode: unknown;
959
+ SyntaxElementWithLoc: unknown;
960
+ ConfigNode: unknown;
961
+ }
962
+ /**
963
+ * Represents the basic interface for a source code object.
964
+ */
965
+ interface SourceCodeBase<Options extends SourceCodeBaseTypeOptions = {
966
+ LangOptions: LanguageOptions;
967
+ RootNode: unknown;
968
+ SyntaxElementWithLoc: unknown;
969
+ ConfigNode: unknown;
970
+ }> {
971
+ /**
972
+ * Root of the AST.
973
+ */
974
+ ast: Options["RootNode"];
975
+ /**
976
+ * The traversal path that tools should take when evaluating the AST.
977
+ * When present, this overrides the `visitorKeys` on the language for
978
+ * just this source code object.
979
+ */
980
+ visitorKeys?: Record<string, string[]>;
981
+ /**
982
+ * Retrieves the equivalent of `loc` for a given node or token.
983
+ * @param syntaxElement The node or token to get the location for.
984
+ * @returns The location of the node or token.
985
+ */
986
+ getLoc(syntaxElement: Options["SyntaxElementWithLoc"]): SourceLocation;
987
+ /**
988
+ * Retrieves the equivalent of `range` for a given node or token.
989
+ * @param syntaxElement The node or token to get the range for.
990
+ * @returns The range of the node or token.
991
+ */
992
+ getRange(syntaxElement: Options["SyntaxElementWithLoc"]): SourceRange;
993
+ /**
994
+ * Traversal of AST.
995
+ */
996
+ traverse(): Iterable<TraversalStep>;
997
+ /**
998
+ * Applies language options passed in from the ESLint core.
999
+ */
1000
+ applyLanguageOptions?(languageOptions: Options["LangOptions"]): void;
1001
+ /**
1002
+ * Return all of the inline areas where ESLint should be disabled/enabled
1003
+ * along with any problems found in evaluating the directives.
1004
+ */
1005
+ getDisableDirectives?(): {
1006
+ directives: Directive[];
1007
+ problems: FileProblem[];
1008
+ };
1009
+ /**
1010
+ * Returns an array of all inline configuration nodes found in the
1011
+ * source code.
1012
+ */
1013
+ getInlineConfigNodes?(): Options["ConfigNode"][];
1014
+ /**
1015
+ * Applies configuration found inside of the source code. This method is only
1016
+ * called when ESLint is running with inline configuration allowed.
1017
+ */
1018
+ applyInlineConfig?(): {
1019
+ configs: InlineConfigElement[];
1020
+ problems: FileProblem[];
1021
+ };
1022
+ /**
1023
+ * Called by ESLint core to indicate that it has finished providing
1024
+ * information. We now add in all the missing variables and ensure that
1025
+ * state-changing methods cannot be called by rules.
1026
+ * @returns {void}
1027
+ */
1028
+ finalize?(): void;
1029
+ }
1030
+ /**
1031
+ * Represents the source of a text file being linted.
1032
+ */
1033
+ interface TextSourceCode<Options extends SourceCodeBaseTypeOptions = {
1034
+ LangOptions: LanguageOptions;
1035
+ RootNode: unknown;
1036
+ SyntaxElementWithLoc: unknown;
1037
+ ConfigNode: unknown;
1038
+ }> extends SourceCodeBase<Options> {
1039
+ /**
1040
+ * The body of the file that you'd like rule developers to access.
1041
+ */
1042
+ text: string;
1043
+ }
1044
+ /**
1045
+ * Represents the source of a binary file being linted.
1046
+ */
1047
+ interface BinarySourceCode<Options extends SourceCodeBaseTypeOptions = {
1048
+ LangOptions: LanguageOptions;
1049
+ RootNode: unknown;
1050
+ SyntaxElementWithLoc: unknown;
1051
+ ConfigNode: unknown;
1052
+ }> extends SourceCodeBase<Options> {
1053
+ /**
1054
+ * The body of the file that you'd like rule developers to access.
1055
+ */
1056
+ body: Uint8Array;
1057
+ }
1058
+ type SourceCode<Options extends SourceCodeBaseTypeOptions = {
1059
+ LangOptions: LanguageOptions;
1060
+ RootNode: unknown;
1061
+ SyntaxElementWithLoc: unknown;
1062
+ ConfigNode: unknown;
1063
+ }> = TextSourceCode<Options> | BinarySourceCode<Options>;
1064
+ /**
1065
+ * Represents a traversal step visiting the AST.
1066
+ */
1067
+ interface VisitTraversalStep {
1068
+ kind: 1;
1069
+ target: unknown;
1070
+ phase: 1 | 2;
1071
+ args: unknown[];
1072
+ }
1073
+ /**
1074
+ * Represents a traversal step calling a function.
1075
+ */
1076
+ interface CallTraversalStep {
1077
+ kind: 2;
1078
+ target: string;
1079
+ phase?: string;
1080
+ args: unknown[];
1081
+ }
1082
+ type TraversalStep = VisitTraversalStep | CallTraversalStep;
1083
+ /**
1084
+ * The type of disable directive. This determines how ESLint will disable rules.
1085
+ */
1086
+ type DirectiveType = "disable" | "enable" | "disable-line" | "disable-next-line";
1087
+ /**
1088
+ * Represents a disable directive.
1089
+ */
1090
+ interface Directive {
1091
+ /**
1092
+ * The type of directive.
1093
+ */
1094
+ type: DirectiveType;
1095
+ /**
1096
+ * The node of the directive. May be in the AST or a comment/token.
1097
+ */
1098
+ node: unknown;
1099
+ /**
1100
+ * The value of the directive.
1101
+ */
1102
+ value: string;
1103
+ /**
1104
+ * The justification for the directive.
1105
+ */
1106
+ justification?: string;
1107
+ }
1108
+ //#endregion
1109
+ //#region src/configs/recommended.types.d.ts
1110
+ /**
1111
+ * Consumer-defined infrastructure edge: which import specifiers and runtime
1112
+ * globals count as "infrastructure" that views must never touch directly.
1113
+ * Example for a Wails project: `{ importPatterns: ['(^|/)wailsjs(/|$)'], runtimeGlobals: ['window.go'] }`.
1114
+ */
1115
+ interface InfrastructureBoundaryOptions {
1116
+ /** Regex sources matched against import specifiers. */
1117
+ readonly importPatterns: readonly string[];
1118
+ /** `object.property` member paths (e.g. `window.go`). */
1119
+ readonly runtimeGlobals: readonly string[];
1120
+ }
1121
+ /**
1122
+ * Options for the recommended preset factory.
1123
+ */
1124
+ interface RecommendedConfigOptions {
1125
+ /** Infrastructure edge definition. Omitted → boundary rule stays off. */
1126
+ readonly infrastructure?: InfrastructureBoundaryOptions;
1127
+ /** Delivery-layer globs (composition-only files). Default: `src/App.tsx` + `src/app/**`. */
1128
+ readonly deliveryGlobs?: readonly string[];
1129
+ /** tsconfig used by the import resolver. Default: `./tsconfig.json`. */
1130
+ readonly tsconfigPath?: string;
1131
+ }
1132
+ //#endregion
1133
+ //#region src/configs/recommended.d.ts
1134
+ /**
1135
+ * Builds the full governance preset: bundled third-party plugin stack plus
1136
+ * every dlinter architecture rule, composed with the glob topology proven in
1137
+ * autoreas-bridge (views / hooks / delivery / role files / tests).
1138
+ * @param options - project-specific knobs: infrastructure edge, delivery globs, tsconfig path.
1139
+ * @returns flat config array ready to spread into `eslint.config.js`.
1140
+ */
1141
+ declare function createRecommendedConfig(options?: RecommendedConfigOptions): Linter.Config[];
1142
+ //#endregion
1143
+ //#region src/index.d.ts
1144
+ declare const dlinter: {
1145
+ configs: Record<string, Linter.Config<RulesConfig>[]>;
1146
+ meta?: ObjectMetaProperties["meta"] & {
1147
+ namespace?: string | undefined;
1148
+ };
1149
+ environments?: Record<string, EnvironmentConfig> | undefined;
1150
+ languages?: Record<string, Language> | undefined;
1151
+ processors?: Record<string, Processor> | undefined;
1152
+ rules?: Record<string, RuleDefinition> | undefined;
1153
+ name?: string | undefined;
1154
+ version?: string | undefined;
1155
+ };
1156
+ //#endregion
1157
+ export { type InfrastructureBoundaryOptions, type RecommendedConfigOptions, createRecommendedConfig, dlinter as default };