eslint-fix-utils 0.4.2 → 0.4.3

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.
package/README.md CHANGED
@@ -35,20 +35,20 @@ You'll then be able to use any of its exported utilities in your rules.
35
35
  Version of [`addObjectProperty`](#addobjectproperty) that can be passed directly as a `fix` property.
36
36
 
37
37
  ```ts
38
- import { fixAddObjectProperty } from "eslint-fix-utils";
38
+ import { fixAddObjectProperty } from 'eslint-fix-utils';
39
39
 
40
40
  // ...
41
41
 
42
42
  export function report(
43
- node: ESTree.ObjectExpression,
44
- propertyKey: string,
45
- propertyValue: string,
43
+ node: ESTree.ObjectExpression,
44
+ propertyKey: string,
45
+ propertyValue: string,
46
46
  ) {
47
- context.report({
48
- fix: fixAddObjectProperty(context, node, propertyKey, propertyValue),
49
- messageId,
50
- node,
51
- });
47
+ context.report({
48
+ fix: fixAddObjectProperty(context, node, propertyKey, propertyValue),
49
+ messageId,
50
+ node,
51
+ });
52
52
  }
53
53
  ```
54
54
 
@@ -57,16 +57,16 @@ export function report(
57
57
  Version of [`removeArrayElement`](#removearrayelement) that can be passed directly as a `fix` property.
58
58
 
59
59
  ```ts
60
- import { fixRemoveArrayElement } from "eslint-fix-utils";
60
+ import { fixRemoveArrayElement } from 'eslint-fix-utils';
61
61
 
62
62
  // ...
63
63
 
64
64
  export function report(index: number, node: ESTree.ArrayExpression) {
65
- context.report({
66
- fix: fixRemoveArrayElement(context, index, node.elements),
67
- messageId,
68
- node: node.elements[index],
69
- });
65
+ context.report({
66
+ fix: fixRemoveArrayElement(context, index, node.elements),
67
+ messageId,
68
+ node: node.elements[index],
69
+ });
70
70
  }
71
71
  ```
72
72
 
@@ -75,16 +75,16 @@ export function report(index: number, node: ESTree.ArrayExpression) {
75
75
  Version of [`removeObjectProperty`](#removeobjectproperty) that can be passed directly as a `fix` property.
76
76
 
77
77
  ```ts
78
- import { fixRemoveObjectProperty } from "eslint-fix-utils";
78
+ import { fixRemoveObjectProperty } from 'eslint-fix-utils';
79
79
 
80
80
  // ...
81
81
 
82
82
  export function report(index: number, node: ESTree.ObjectExpression) {
83
- context.report({
84
- fix: fixRemoveObjectProperty(context, node.properties[index]),
85
- messageId,
86
- node: node.properties[index],
87
- });
83
+ context.report({
84
+ fix: fixRemoveObjectProperty(context, node.properties[index]),
85
+ messageId,
86
+ node: node.properties[index],
87
+ });
88
88
  }
89
89
  ```
90
90
 
@@ -142,19 +142,19 @@ Parameters:
142
142
  4. `parentOrElements`: the array expression node, or its `.elements` array
143
143
 
144
144
  ```ts
145
- import { removeArrayElement } from "eslint-fix-utils";
145
+ import { removeArrayElement } from 'eslint-fix-utils';
146
146
 
147
147
  // ...
148
148
 
149
149
  export function report(index: number, node: ESTree.ArrayExpression) {
150
- context.report({
151
- fix(fixer) {
152
- // Removes the last element of the array:
153
- return removeArrayElement(context, fixer, index, node.elements);
154
- },
155
- messageId,
156
- node: node.elements[index],
157
- });
150
+ context.report({
151
+ fix(fixer) {
152
+ // Removes the last element of the array:
153
+ return removeArrayElement(context, fixer, index, node.elements);
154
+ },
155
+ messageId,
156
+ node: node.elements[index],
157
+ });
158
158
  }
159
159
  ```
160
160
 
@@ -180,19 +180,19 @@ Parameters:
180
180
  3. `property`: the property node
181
181
 
182
182
  ```ts
183
- import { removeObjectProperty } from "eslint-fix-utils";
183
+ import { removeObjectProperty } from 'eslint-fix-utils';
184
184
 
185
185
  // ...
186
186
 
187
187
  export function report(index: number, node: ESTree.ObjectExpression) {
188
- context.report({
189
- fix(fixer) {
190
- // Removes the last property of the object:
191
- return removeObjectProperty(context, fixer, node.properties[index]);
192
- },
193
- messageId,
194
- node: node.properties[index],
195
- });
188
+ context.report({
189
+ fix(fixer) {
190
+ // Removes the last property of the object:
191
+ return removeObjectProperty(context, fixer, node.properties[index]);
192
+ },
193
+ messageId,
194
+ node: node.properties[index],
195
+ });
196
196
  }
197
197
  ```
198
198
 
@@ -217,7 +217,6 @@ Thanks! 🔧
217
217
  <!-- spellchecker: disable -->
218
218
  <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
219
219
  <!-- prettier-ignore-start -->
220
- <!-- markdownlint-disable -->
221
220
  <table>
222
221
  <tbody>
223
222
  <tr>
@@ -228,7 +227,6 @@ Thanks! 🔧
228
227
  </tbody>
229
228
  </table>
230
229
 
231
- <!-- markdownlint-restore -->
232
230
  <!-- prettier-ignore-end -->
233
231
 
234
232
  <!-- ALL-CONTRIBUTORS-LIST:END -->
package/lib/index.d.mts CHANGED
@@ -1,441 +1,6 @@
1
1
  import { Rule } from "eslint";
2
+ import * as ESTree from "estree";
2
3
 
3
- //#region node_modules/.pnpm/@types+estree@1.0.6/node_modules/@types/estree/index.d.ts
4
- // This definition file follows a somewhat unusual format. ESTree allows
5
- // runtime type checks based on the `type` parameter. In order to explain this
6
- // to typescript we want to use discriminated union types:
7
- // https://github.com/Microsoft/TypeScript/pull/9163
8
- //
9
- // For ESTree this is a bit tricky because the high level interfaces like
10
- // Node or Function are pulling double duty. We want to pass common fields down
11
- // to the interfaces that extend them (like Identifier or
12
- // ArrowFunctionExpression), but you can't extend a type union or enforce
13
- // common fields on them. So we've split the high level interfaces into two
14
- // types, a base type which passes down inherited fields, and a type union of
15
- // all types which extend the base type. Only the type union is exported, and
16
- // the union is how other types refer to the collection of inheriting types.
17
- //
18
- // This makes the definitions file here somewhat more difficult to maintain,
19
- // but it has the notable advantage of making ESTree much easier to use as
20
- // an end user.
21
- interface BaseNodeWithoutComments {
22
- // Every leaf interface that extends BaseNode must specify a type property.
23
- // The type property should be a string literal. For example, Identifier
24
- // has: `type: "Identifier"`
25
- type: string;
26
- loc?: SourceLocation | null | undefined;
27
- range?: [number, number] | undefined;
28
- }
29
- interface BaseNode extends BaseNodeWithoutComments {
30
- leadingComments?: Comment[] | undefined;
31
- trailingComments?: Comment[] | undefined;
32
- }
33
- interface Comment extends BaseNodeWithoutComments {
34
- type: "Line" | "Block";
35
- value: string;
36
- }
37
- interface SourceLocation {
38
- source?: string | null | undefined;
39
- start: Position;
40
- end: Position;
41
- }
42
- interface Position {
43
- /** >= 1 */
44
- line: number;
45
- /** >= 0 */
46
- column: number;
47
- }
48
- interface BaseFunction extends BaseNode {
49
- params: Pattern[];
50
- generator?: boolean | undefined;
51
- async?: boolean | undefined; // The body is either BlockStatement or Expression because arrow functions
52
- // can have a body that's either. FunctionDeclarations and
53
- // FunctionExpressions have only BlockStatement bodies.
54
- body: BlockStatement | Expression;
55
- }
56
- type Statement = ExpressionStatement | BlockStatement | StaticBlock | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | Declaration;
57
- interface BaseStatement extends BaseNode {}
58
- interface EmptyStatement extends BaseStatement {
59
- type: "EmptyStatement";
60
- }
61
- interface BlockStatement extends BaseStatement {
62
- type: "BlockStatement";
63
- body: Statement[];
64
- innerComments?: Comment[] | undefined;
65
- }
66
- interface StaticBlock extends Omit<BlockStatement, "type"> {
67
- type: "StaticBlock";
68
- }
69
- interface ExpressionStatement extends BaseStatement {
70
- type: "ExpressionStatement";
71
- expression: Expression;
72
- }
73
- interface IfStatement extends BaseStatement {
74
- type: "IfStatement";
75
- test: Expression;
76
- consequent: Statement;
77
- alternate?: Statement | null | undefined;
78
- }
79
- interface LabeledStatement extends BaseStatement {
80
- type: "LabeledStatement";
81
- label: Identifier;
82
- body: Statement;
83
- }
84
- interface BreakStatement extends BaseStatement {
85
- type: "BreakStatement";
86
- label?: Identifier | null | undefined;
87
- }
88
- interface ContinueStatement extends BaseStatement {
89
- type: "ContinueStatement";
90
- label?: Identifier | null | undefined;
91
- }
92
- interface WithStatement extends BaseStatement {
93
- type: "WithStatement";
94
- object: Expression;
95
- body: Statement;
96
- }
97
- interface SwitchStatement extends BaseStatement {
98
- type: "SwitchStatement";
99
- discriminant: Expression;
100
- cases: SwitchCase[];
101
- }
102
- interface ReturnStatement extends BaseStatement {
103
- type: "ReturnStatement";
104
- argument?: Expression | null | undefined;
105
- }
106
- interface ThrowStatement extends BaseStatement {
107
- type: "ThrowStatement";
108
- argument: Expression;
109
- }
110
- interface TryStatement extends BaseStatement {
111
- type: "TryStatement";
112
- block: BlockStatement;
113
- handler?: CatchClause | null | undefined;
114
- finalizer?: BlockStatement | null | undefined;
115
- }
116
- interface WhileStatement extends BaseStatement {
117
- type: "WhileStatement";
118
- test: Expression;
119
- body: Statement;
120
- }
121
- interface DoWhileStatement extends BaseStatement {
122
- type: "DoWhileStatement";
123
- body: Statement;
124
- test: Expression;
125
- }
126
- interface ForStatement extends BaseStatement {
127
- type: "ForStatement";
128
- init?: VariableDeclaration | Expression | null | undefined;
129
- test?: Expression | null | undefined;
130
- update?: Expression | null | undefined;
131
- body: Statement;
132
- }
133
- interface BaseForXStatement extends BaseStatement {
134
- left: VariableDeclaration | Pattern;
135
- right: Expression;
136
- body: Statement;
137
- }
138
- interface ForInStatement extends BaseForXStatement {
139
- type: "ForInStatement";
140
- }
141
- interface DebuggerStatement extends BaseStatement {
142
- type: "DebuggerStatement";
143
- }
144
- type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration;
145
- interface BaseDeclaration extends BaseStatement {}
146
- interface MaybeNamedFunctionDeclaration extends BaseFunction, BaseDeclaration {
147
- type: "FunctionDeclaration";
148
- /** It is null when a function declaration is a part of the `export default function` statement */
149
- id: Identifier | null;
150
- body: BlockStatement;
151
- }
152
- interface FunctionDeclaration extends MaybeNamedFunctionDeclaration {
153
- id: Identifier;
154
- }
155
- interface VariableDeclaration extends BaseDeclaration {
156
- type: "VariableDeclaration";
157
- declarations: VariableDeclarator[];
158
- kind: "var" | "let" | "const";
159
- }
160
- interface VariableDeclarator extends BaseNode {
161
- type: "VariableDeclarator";
162
- id: Pattern;
163
- init?: Expression | null | undefined;
164
- }
165
- interface ExpressionMap {
166
- ArrayExpression: ArrayExpression;
167
- ArrowFunctionExpression: ArrowFunctionExpression;
168
- AssignmentExpression: AssignmentExpression;
169
- AwaitExpression: AwaitExpression;
170
- BinaryExpression: BinaryExpression;
171
- CallExpression: CallExpression;
172
- ChainExpression: ChainExpression;
173
- ClassExpression: ClassExpression;
174
- ConditionalExpression: ConditionalExpression;
175
- FunctionExpression: FunctionExpression;
176
- Identifier: Identifier;
177
- ImportExpression: ImportExpression;
178
- Literal: Literal;
179
- LogicalExpression: LogicalExpression;
180
- MemberExpression: MemberExpression;
181
- MetaProperty: MetaProperty;
182
- NewExpression: NewExpression;
183
- ObjectExpression: ObjectExpression;
184
- SequenceExpression: SequenceExpression;
185
- TaggedTemplateExpression: TaggedTemplateExpression;
186
- TemplateLiteral: TemplateLiteral;
187
- ThisExpression: ThisExpression;
188
- UnaryExpression: UnaryExpression;
189
- UpdateExpression: UpdateExpression;
190
- YieldExpression: YieldExpression;
191
- }
192
- type Expression = ExpressionMap[keyof ExpressionMap];
193
- interface BaseExpression extends BaseNode {}
194
- type ChainElement = SimpleCallExpression | MemberExpression;
195
- interface ChainExpression extends BaseExpression {
196
- type: "ChainExpression";
197
- expression: ChainElement;
198
- }
199
- interface ThisExpression extends BaseExpression {
200
- type: "ThisExpression";
201
- }
202
- interface ArrayExpression extends BaseExpression {
203
- type: "ArrayExpression";
204
- elements: Array<Expression | SpreadElement | null>;
205
- }
206
- interface ObjectExpression extends BaseExpression {
207
- type: "ObjectExpression";
208
- properties: Array<Property | SpreadElement>;
209
- }
210
- interface PrivateIdentifier extends BaseNode {
211
- type: "PrivateIdentifier";
212
- name: string;
213
- }
214
- interface Property extends BaseNode {
215
- type: "Property";
216
- key: Expression | PrivateIdentifier;
217
- value: Expression | Pattern; // Could be an AssignmentProperty
218
- kind: "init" | "get" | "set";
219
- method: boolean;
220
- shorthand: boolean;
221
- computed: boolean;
222
- }
223
- interface PropertyDefinition extends BaseNode {
224
- type: "PropertyDefinition";
225
- key: Expression | PrivateIdentifier;
226
- value?: Expression | null | undefined;
227
- computed: boolean;
228
- static: boolean;
229
- }
230
- interface FunctionExpression extends BaseFunction, BaseExpression {
231
- id?: Identifier | null | undefined;
232
- type: "FunctionExpression";
233
- body: BlockStatement;
234
- }
235
- interface SequenceExpression extends BaseExpression {
236
- type: "SequenceExpression";
237
- expressions: Expression[];
238
- }
239
- interface UnaryExpression extends BaseExpression {
240
- type: "UnaryExpression";
241
- operator: UnaryOperator;
242
- prefix: true;
243
- argument: Expression;
244
- }
245
- interface BinaryExpression extends BaseExpression {
246
- type: "BinaryExpression";
247
- operator: BinaryOperator;
248
- left: Expression | PrivateIdentifier;
249
- right: Expression;
250
- }
251
- interface AssignmentExpression extends BaseExpression {
252
- type: "AssignmentExpression";
253
- operator: AssignmentOperator;
254
- left: Pattern | MemberExpression;
255
- right: Expression;
256
- }
257
- interface UpdateExpression extends BaseExpression {
258
- type: "UpdateExpression";
259
- operator: UpdateOperator;
260
- argument: Expression;
261
- prefix: boolean;
262
- }
263
- interface LogicalExpression extends BaseExpression {
264
- type: "LogicalExpression";
265
- operator: LogicalOperator;
266
- left: Expression;
267
- right: Expression;
268
- }
269
- interface ConditionalExpression extends BaseExpression {
270
- type: "ConditionalExpression";
271
- test: Expression;
272
- alternate: Expression;
273
- consequent: Expression;
274
- }
275
- interface BaseCallExpression extends BaseExpression {
276
- callee: Expression | Super;
277
- arguments: Array<Expression | SpreadElement>;
278
- }
279
- type CallExpression = SimpleCallExpression | NewExpression;
280
- interface SimpleCallExpression extends BaseCallExpression {
281
- type: "CallExpression";
282
- optional: boolean;
283
- }
284
- interface NewExpression extends BaseCallExpression {
285
- type: "NewExpression";
286
- }
287
- interface MemberExpression extends BaseExpression, BasePattern {
288
- type: "MemberExpression";
289
- object: Expression | Super;
290
- property: Expression | PrivateIdentifier;
291
- computed: boolean;
292
- optional: boolean;
293
- }
294
- type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
295
- interface BasePattern extends BaseNode {}
296
- interface SwitchCase extends BaseNode {
297
- type: "SwitchCase";
298
- test?: Expression | null | undefined;
299
- consequent: Statement[];
300
- }
301
- interface CatchClause extends BaseNode {
302
- type: "CatchClause";
303
- param: Pattern | null;
304
- body: BlockStatement;
305
- }
306
- interface Identifier extends BaseNode, BaseExpression, BasePattern {
307
- type: "Identifier";
308
- name: string;
309
- }
310
- type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
311
- interface SimpleLiteral extends BaseNode, BaseExpression {
312
- type: "Literal";
313
- value: string | boolean | number | null;
314
- raw?: string | undefined;
315
- }
316
- interface RegExpLiteral extends BaseNode, BaseExpression {
317
- type: "Literal";
318
- value?: RegExp | null | undefined;
319
- regex: {
320
- pattern: string;
321
- flags: string;
322
- };
323
- raw?: string | undefined;
324
- }
325
- interface BigIntLiteral extends BaseNode, BaseExpression {
326
- type: "Literal";
327
- value?: bigint | null | undefined;
328
- bigint: string;
329
- raw?: string | undefined;
330
- }
331
- type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
332
- type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "**" | "|" | "^" | "&" | "in" | "instanceof";
333
- type LogicalOperator = "||" | "&&" | "??";
334
- type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "**=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "||=" | "&&=" | "??=";
335
- type UpdateOperator = "++" | "--";
336
- interface ForOfStatement extends BaseForXStatement {
337
- type: "ForOfStatement";
338
- await: boolean;
339
- }
340
- interface Super extends BaseNode {
341
- type: "Super";
342
- }
343
- interface SpreadElement extends BaseNode {
344
- type: "SpreadElement";
345
- argument: Expression;
346
- }
347
- interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
348
- type: "ArrowFunctionExpression";
349
- expression: boolean;
350
- body: BlockStatement | Expression;
351
- }
352
- interface YieldExpression extends BaseExpression {
353
- type: "YieldExpression";
354
- argument?: Expression | null | undefined;
355
- delegate: boolean;
356
- }
357
- interface TemplateLiteral extends BaseExpression {
358
- type: "TemplateLiteral";
359
- quasis: TemplateElement[];
360
- expressions: Expression[];
361
- }
362
- interface TaggedTemplateExpression extends BaseExpression {
363
- type: "TaggedTemplateExpression";
364
- tag: Expression;
365
- quasi: TemplateLiteral;
366
- }
367
- interface TemplateElement extends BaseNode {
368
- type: "TemplateElement";
369
- tail: boolean;
370
- value: {
371
- /** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */cooked?: string | null | undefined;
372
- raw: string;
373
- };
374
- }
375
- interface AssignmentProperty extends Property {
376
- value: Pattern;
377
- kind: "init";
378
- method: boolean; // false
379
- }
380
- interface ObjectPattern extends BasePattern {
381
- type: "ObjectPattern";
382
- properties: Array<AssignmentProperty | RestElement>;
383
- }
384
- interface ArrayPattern extends BasePattern {
385
- type: "ArrayPattern";
386
- elements: Array<Pattern | null>;
387
- }
388
- interface RestElement extends BasePattern {
389
- type: "RestElement";
390
- argument: Pattern;
391
- }
392
- interface AssignmentPattern extends BasePattern {
393
- type: "AssignmentPattern";
394
- left: Pattern;
395
- right: Expression;
396
- }
397
- interface BaseClass extends BaseNode {
398
- superClass?: Expression | null | undefined;
399
- body: ClassBody;
400
- }
401
- interface ClassBody extends BaseNode {
402
- type: "ClassBody";
403
- body: Array<MethodDefinition | PropertyDefinition | StaticBlock>;
404
- }
405
- interface MethodDefinition extends BaseNode {
406
- type: "MethodDefinition";
407
- key: Expression | PrivateIdentifier;
408
- value: FunctionExpression;
409
- kind: "constructor" | "method" | "get" | "set";
410
- computed: boolean;
411
- static: boolean;
412
- }
413
- interface MaybeNamedClassDeclaration extends BaseClass, BaseDeclaration {
414
- type: "ClassDeclaration";
415
- /** It is null when a class declaration is a part of the `export default class` statement */
416
- id: Identifier | null;
417
- }
418
- interface ClassDeclaration extends MaybeNamedClassDeclaration {
419
- id: Identifier;
420
- }
421
- interface ClassExpression extends BaseClass, BaseExpression {
422
- type: "ClassExpression";
423
- id?: Identifier | null | undefined;
424
- }
425
- interface MetaProperty extends BaseExpression {
426
- type: "MetaProperty";
427
- meta: Identifier;
428
- property: Identifier;
429
- }
430
- interface ImportExpression extends BaseExpression {
431
- type: "ImportExpression";
432
- source: Expression;
433
- }
434
- interface AwaitExpression extends BaseExpression {
435
- type: "AwaitExpression";
436
- argument: Expression;
437
- }
438
- //#endregion
439
4
  //#region src/addObjectProperty.d.ts
440
5
  /**
441
6
  * Given an ObjectProperty, and a rule fixer, this function yields the addition
@@ -448,7 +13,7 @@ interface AwaitExpression extends BaseExpression {
448
13
  * @param propertyValue The value for the new property
449
14
  * @yields fixer addition for the new property into the object expression, as well as any necessary commas
450
15
  */
451
- declare function addObjectProperty(context: Rule.RuleContext, fixer: Rule.RuleFixer, objectExpression: ObjectExpression, propertyKey: string, propertyValue: unknown): Generator<Rule.Fix, void>;
16
+ declare function addObjectProperty(context: Rule.RuleContext, fixer: Rule.RuleFixer, objectExpression: ESTree.ObjectExpression, propertyKey: string, propertyValue: unknown): Generator<Rule.Fix, void>;
452
17
  //#endregion
453
18
  //#region src/fixAddObjectProperty.d.ts
454
19
  /**
@@ -463,11 +28,11 @@ declare function addObjectProperty(context: Rule.RuleContext, fixer: Rule.RuleFi
463
28
  * adds a new property to an object expression, along with any commas that
464
29
  * are needed.
465
30
  */
466
- declare const fixAddObjectProperty: (context: Rule.RuleContext, objectExpression: ObjectExpression, propertyKey: string, propertyValue: unknown) => ((fixer: Rule.RuleFixer) => Generator<Rule.Fix, void>);
31
+ declare const fixAddObjectProperty: (context: Rule.RuleContext, objectExpression: ESTree.ObjectExpression, propertyKey: string, propertyValue: unknown) => ((fixer: Rule.RuleFixer) => Generator<Rule.Fix, void>);
467
32
  //#endregion
468
33
  //#region src/removeArrayElement.d.ts
469
- type ArrayElement = Expression | SpreadElement;
470
- type ArrayElementsOrParent = ArrayExpression | ArrayExpression["elements"];
34
+ type ArrayElement = ESTree.Expression | ESTree.SpreadElement;
35
+ type ArrayElementsOrParent = ESTree.ArrayExpression | ESTree.ArrayExpression["elements"];
471
36
  /**
472
37
  * Given an ArrayExpression or the list of elements an ArrayExpression has,
473
38
  * the index or node within that array that you want to remove, and a rule fixer,
@@ -500,7 +65,7 @@ declare function removeArrayElement(context: Rule.RuleContext, fixer: Rule.RuleF
500
65
  declare const fixRemoveArrayElement: (context: Rule.RuleContext, elementOrIndex: ArrayElement | number, parentOrElements: ArrayElementsOrParent) => ((fixer: Rule.RuleFixer) => Generator<Rule.Fix, void>);
501
66
  //#endregion
502
67
  //#region src/removeObjectProperty.d.ts
503
- type ObjectProperty = Property | SpreadElement;
68
+ type ObjectProperty = ESTree.Property | ESTree.SpreadElement;
504
69
  /**
505
70
  * Given an ObjectProperty, and a rule fixer, this function yields removals for
506
71
  * the node itself, as well as any trailing commas that are no longer necessary.
package/lib/index.mjs CHANGED
@@ -30,7 +30,6 @@ function* addObjectProperty(context, fixer, objectExpression, propertyKey, prope
30
30
  const textToInsert = ` ${`${JSON.stringify(propertyKey)}: ${JSON.stringify(propertyValue)}`}\n`;
31
31
  yield fixer.insertTextAfterRange(insertPosition, textToInsert);
32
32
  }
33
-
34
33
  //#endregion
35
34
  //#region src/fixAddObjectProperty.ts
36
35
  /**
@@ -48,7 +47,6 @@ function* addObjectProperty(context, fixer, objectExpression, propertyKey, prope
48
47
  const fixAddObjectProperty = (context, objectExpression, propertyKey, propertyValue) => {
49
48
  return (fixer) => addObjectProperty(context, fixer, objectExpression, propertyKey, propertyValue);
50
49
  };
51
-
52
50
  //#endregion
53
51
  //#region src/removeArrayElement.ts
54
52
  /**
@@ -79,7 +77,6 @@ function getElementAndIndex(elements, elementOrIndex) {
79
77
  if (index === -1) throw new Error("Node is not a child of the parent array.");
80
78
  return [elements[index], index];
81
79
  }
82
-
83
80
  //#endregion
84
81
  //#region src/fixRemoveArrayElement.ts
85
82
  /**
@@ -98,7 +95,6 @@ function getElementAndIndex(elements, elementOrIndex) {
98
95
  const fixRemoveArrayElement = (context, elementOrIndex, parentOrElements) => {
99
96
  return (fixer) => removeArrayElement(context, fixer, elementOrIndex, parentOrElements);
100
97
  };
101
-
102
98
  //#endregion
103
99
  //#region src/removeObjectProperty.ts
104
100
  /**
@@ -117,7 +113,6 @@ function* removeObjectProperty(context, fixer, property) {
117
113
  yield fixer.remove(property);
118
114
  if (tokenAfter?.value === ",") yield fixer.remove(tokenAfter);
119
115
  }
120
-
121
116
  //#endregion
122
117
  //#region src/fixRemoveObjectProperty.ts
123
118
  /**
@@ -133,6 +128,5 @@ function* removeObjectProperty(context, fixer, property) {
133
128
  const fixRemoveObjectProperty = (context, property) => {
134
129
  return (fixer) => removeObjectProperty(context, fixer, property);
135
130
  };
136
-
137
131
  //#endregion
138
- export { addObjectProperty, fixAddObjectProperty, fixRemoveArrayElement, fixRemoveObjectProperty, removeArrayElement, removeObjectProperty };
132
+ export { addObjectProperty, fixAddObjectProperty, fixRemoveArrayElement, fixRemoveObjectProperty, removeArrayElement, removeObjectProperty };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-fix-utils",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Utilities for ESLint rule fixers and suggestions. 🧑‍🔧",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,42 +31,39 @@
31
31
  "module": "lib/index.mjs",
32
32
  "types": "lib/index.d.mts",
33
33
  "files": [
34
- "CHANGELOG.md",
35
34
  "lib/"
36
35
  ],
37
- "lint-staged": {
38
- "*": "prettier --ignore-unknown --write"
39
- },
40
36
  "devDependencies": {
41
- "@eslint-community/eslint-plugin-eslint-comments": "4.6.0",
37
+ "@eslint-community/eslint-plugin-eslint-comments": "4.7.0",
42
38
  "@eslint/js": "10.0.1",
39
+ "@eslint/json": "2.0.0",
40
+ "@eslint/markdown": "8.0.1",
41
+ "@ianvs/prettier-plugin-sort-imports": "4.7.1",
43
42
  "@types/estree": "1.0.6",
44
- "@types/node": "24.10.0",
45
- "@vitest/coverage-v8": "4.0.15",
43
+ "@types/node": "24.13.0",
44
+ "@vitest/coverage-v8": "4.1.2",
46
45
  "@vitest/eslint-plugin": "1.6.9",
47
46
  "console-fail-test": "0.6.1",
48
- "cspell": "9.7.0",
49
- "eslint": "10.0.0",
50
- "eslint-plugin-jsdoc": "62.7.0",
51
- "eslint-plugin-jsonc": "3.1.0",
52
- "eslint-plugin-n": "17.24.0",
53
- "eslint-plugin-package-json": "0.89.0",
54
- "eslint-plugin-perfectionist": "5.6.0",
55
- "eslint-plugin-regexp": "3.0.0",
56
- "eslint-plugin-yml": "3.3.0",
57
- "husky": "9.1.7",
58
- "knip": "5.85.0",
59
- "lint-staged": "16.2.0",
60
- "markdownlint": "0.40.0",
61
- "markdownlint-cli": "0.47.0",
62
- "prettier": "3.8.0",
47
+ "eslint": "10.6.0",
48
+ "eslint-plugin-jsdoc": "63.0.0",
49
+ "eslint-plugin-jsonc": "3.2.0",
50
+ "eslint-plugin-n": "18.2.1",
51
+ "eslint-plugin-package-json": "1.5.0",
52
+ "eslint-plugin-perfectionist": "5.9.0",
53
+ "eslint-plugin-regexp": "3.1.0",
54
+ "eslint-plugin-yml": "3.5.0",
55
+ "jiti": "2.7.0",
56
+ "knip": "6.24.0",
57
+ "prettier": "3.9.1",
63
58
  "prettier-plugin-curly": "0.4.0",
64
59
  "prettier-plugin-packagejson": "3.0.0",
65
60
  "prettier-plugin-sh": "0.18.0",
66
- "tsdown": "0.20.0",
67
- "typescript": "5.9.2",
68
- "typescript-eslint": "8.56.0",
69
- "vitest": "4.0.15"
61
+ "pretty-quick": "4.2.2",
62
+ "simple-git-hooks": "2.13.1",
63
+ "tsdown": "0.22.0",
64
+ "typescript": "6.0.3",
65
+ "typescript-eslint": "8.62.0",
66
+ "vitest": "4.1.2"
70
67
  },
71
68
  "peerDependencies": {
72
69
  "@types/estree": ">=1",
@@ -85,9 +82,7 @@
85
82
  "format": "prettier .",
86
83
  "lint": "eslint . --max-warnings 0",
87
84
  "lint:knip": "knip",
88
- "lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\"",
89
- "lint:spelling": "cspell \"**\" \".github/**/*\"",
90
85
  "test": "vitest",
91
- "type-check": "tsc"
86
+ "typecheck": "tsc"
92
87
  }
93
88
  }
package/CHANGELOG.md DELETED
@@ -1,50 +0,0 @@
1
- # Changelog
2
-
3
- # [0.4.0](https://github.com/michaelfaith/eslint-fix-utils/compare/0.3.0...0.4.0) (2025-06-12)
4
-
5
- ### Features
6
-
7
- - bundle esm-only ([#170](https://github.com/michaelfaith/eslint-fix-utils/issues/170)) ([62e4938](https://github.com/michaelfaith/eslint-fix-utils/commit/62e4938aa6e67db31611e59b6fe19692069a56de)), closes [#167](https://github.com/michaelfaith/eslint-fix-utils/issues/167)
8
-
9
- # [0.3.0](https://github.com/michaelfaith/eslint-fix-utils/compare/0.2.1...0.3.0) (2025-06-11)
10
-
11
- ### Bug Fixes
12
-
13
- - bump to create-typescript-app@2 with transitions action ([#79](https://github.com/michaelfaith/eslint-fix-utils/issues/79)) ([0bb023f](https://github.com/michaelfaith/eslint-fix-utils/commit/0bb023f96c18632b1c688d3210ae2567cee4b8e0)), closes [#75](https://github.com/michaelfaith/eslint-fix-utils/issues/75)
14
-
15
- ### Features
16
-
17
- - remove support for node 18 ([#169](https://github.com/michaelfaith/eslint-fix-utils/issues/169)) ([1b076be](https://github.com/michaelfaith/eslint-fix-utils/commit/1b076be4533fc4e91e6c7af430ea2c597eb6d87b)), closes [#166](https://github.com/michaelfaith/eslint-fix-utils/issues/166)
18
-
19
- ## [0.4.2](https://github.com/michaelfaith/eslint-fix-utils/compare/v0.4.1...v0.4.2) (2026-03-01)
20
-
21
-
22
- ### Bug Fixes
23
-
24
- * update repo references ([#430](https://github.com/michaelfaith/eslint-fix-utils/issues/430)) ([60ee8aa](https://github.com/michaelfaith/eslint-fix-utils/commit/60ee8aab7989ab4f904c7fe98e9169061530de5d))
25
-
26
- ## [0.4.1](https://github.com/michaelfaith/eslint-fix-utils/compare/0.4.0...v0.4.1) (2026-02-01)
27
-
28
-
29
- ### Features
30
-
31
- * add functions for adding a new property to an object ([#399](https://github.com/michaelfaith/eslint-fix-utils/issues/399)) ([47daa1b](https://github.com/michaelfaith/eslint-fix-utils/commit/47daa1be7da85f7939573057c6a649aa35cfdd77))
32
-
33
- ## [0.2.1](https://github.com/michaelfaith/eslint-fix-utils/compare/0.2.0...0.2.1) (2025-01-28)
34
-
35
- ### Bug Fixes
36
-
37
- - make `@types/estree` peer dependency optional ([#25](https://github.com/michaelfaith/eslint-fix-utils/issues/25)) ([f6ddd9d](https://github.com/michaelfaith/eslint-fix-utils/commit/f6ddd9d20de032992202d9287be3c7abee4f0d15)), closes [#24](https://github.com/michaelfaith/eslint-fix-utils/issues/24)
38
-
39
- # [0.2.0](https://github.com/michaelfaith/eslint-fix-utils/compare/0.1.0...0.2.0) (2025-01-23)
40
-
41
- ### Features
42
-
43
- - empty commit to trigger 0.2.0 ([1658b2d](https://github.com/michaelfaith/eslint-fix-utils/commit/1658b2d849fe9f636f24f154831ad8eeecb5721c))
44
-
45
- # 0.1.0 (2025-01-19)
46
-
47
- ### Features
48
-
49
- - initial functionality ✨ ([6bf5c33](https://github.com/michaelfaith/eslint-fix-utils/commit/6bf5c3329eb47c43d38128328fd4501277b3c8ad))
50
- - initialized repo ✨ ([31c7630](https://github.com/michaelfaith/eslint-fix-utils/commit/31c7630c769a8a57b9be85247c6546baceae82f2))