eslint-fix-utils 0.1.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.
- package/LICENSE.md +20 -0
- package/README.md +176 -0
- package/lib/fixRemoveArrayElement.cjs +32 -0
- package/lib/fixRemoveArrayElement.cjs.map +1 -0
- package/lib/fixRemoveArrayElement.d.cts +7 -0
- package/lib/fixRemoveArrayElement.d.ts +7 -0
- package/lib/fixRemoveArrayElement.js +10 -0
- package/lib/fixRemoveArrayElement.js.map +1 -0
- package/lib/fixRemoveObjectProperty.cjs +32 -0
- package/lib/fixRemoveObjectProperty.cjs.map +1 -0
- package/lib/fixRemoveObjectProperty.d.cts +7 -0
- package/lib/fixRemoveObjectProperty.d.ts +7 -0
- package/lib/fixRemoveObjectProperty.js +10 -0
- package/lib/fixRemoveObjectProperty.js.map +1 -0
- package/lib/greet.cjs +38 -0
- package/lib/greet.cjs.map +1 -0
- package/lib/greet.d.cts +5 -0
- package/lib/greet.d.ts +5 -0
- package/lib/greet.js +14 -0
- package/lib/greet.js.map +1 -0
- package/lib/index.cjs +29 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +6 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -0
- package/lib/removeArrayElement.cjs +54 -0
- package/lib/removeArrayElement.cjs.map +1 -0
- package/lib/removeArrayElement.d.cts +8 -0
- package/lib/removeArrayElement.d.ts +8 -0
- package/lib/removeArrayElement.js +30 -0
- package/lib/removeArrayElement.js.map +1 -0
- package/lib/removeObjectProperty.cjs +39 -0
- package/lib/removeObjectProperty.cjs.map +1 -0
- package/lib/removeObjectProperty.d.cts +7 -0
- package/lib/removeObjectProperty.d.ts +7 -0
- package/lib/removeObjectProperty.js +15 -0
- package/lib/removeObjectProperty.js.map +1 -0
- package/lib/types.cjs +17 -0
- package/lib/types.cjs.map +1 -0
- package/lib/types.d.cts +7 -0
- package/lib/types.d.ts +7 -0
- package/lib/types.js +1 -0
- package/lib/types.js.map +1 -0
- package/package.json +93 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
'Software'), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<h1 align="center">ESLint Fix Utils</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
Utilities for ESLint rule fixers and suggestions.
|
|
5
|
+
๐งโ๐ง
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<!-- prettier-ignore-start -->
|
|
10
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
11
|
+
<a href="#contributors" target="_blank"><img alt="๐ช All Contributors: 2" src="https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-2-21bb42.svg" /></a>
|
|
12
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
13
|
+
<!-- prettier-ignore-end -->
|
|
14
|
+
<a href="https://github.com/JoshuaKGoldberg/eslint-fix-utils/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank"><img alt="๐ค Code of Conduct: Kept" src="https://img.shields.io/badge/%F0%9F%A4%9D_code_of_conduct-kept-21bb42" /></a>
|
|
15
|
+
<a href="https://codecov.io/gh/JoshuaKGoldberg/eslint-fix-utils" target="_blank"><img alt="๐งช Coverage" src="https://img.shields.io/codecov/c/github/JoshuaKGoldberg/eslint-fix-utils?label=%F0%9F%A7%AA%20coverage" /></a>
|
|
16
|
+
<a href="https://github.com/JoshuaKGoldberg/eslint-fix-utils/blob/main/LICENSE.md" target="_blank"><img alt="๐ License: MIT" src="https://img.shields.io/badge/%F0%9F%93%9D_license-MIT-21bb42.svg"></a>
|
|
17
|
+
<a href="http://npmjs.com/package/eslint-fix-utils"><img alt="๐ฆ npm version" src="https://img.shields.io/npm/v/eslint-fix-utils?color=21bb42&label=%F0%9F%93%A6%20npm" /></a>
|
|
18
|
+
<img alt="๐ช TypeScript: Strict" src="https://img.shields.io/badge/%F0%9F%92%AA_typescript-strict-21bb42.svg" />
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
If you're working on an ESLint plugin, install this as a dependency:
|
|
24
|
+
|
|
25
|
+
```shell
|
|
26
|
+
npm i eslint-fix-utils
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
You'll then be able to use any of its exported utilities in your rules.
|
|
30
|
+
|
|
31
|
+
### Fixer APIs
|
|
32
|
+
|
|
33
|
+
### `fixRemoveArrayElement`
|
|
34
|
+
|
|
35
|
+
Version of [`removeArrayElement`](#removearrayelement) that can be passed directly as a `fix` property.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { fixRemoveArrayElement } from "eslint-fix-utils";
|
|
39
|
+
|
|
40
|
+
// ...
|
|
41
|
+
|
|
42
|
+
export function report(node: ESTree.ArrayExpression) {
|
|
43
|
+
context.report({
|
|
44
|
+
fix: fixRemoveArrayElement(context, node, node.elements.length - 1),
|
|
45
|
+
messageId,
|
|
46
|
+
node,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### `fixRemoveObjectProperty`
|
|
52
|
+
|
|
53
|
+
Version of [`removeObjectProperty`](#removeobjectproperty) that can be passed directly as a `fix` property.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { fixRemoveObjectProperty } from "eslint-fix-utils";
|
|
57
|
+
|
|
58
|
+
// ...
|
|
59
|
+
|
|
60
|
+
export function report(node: ESTree.ArrayExpression) {
|
|
61
|
+
context.report({
|
|
62
|
+
fix: fixRemoveObjectProperty(context, node, node.elements.length - 1),
|
|
63
|
+
messageId,
|
|
64
|
+
node,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Full APIs
|
|
70
|
+
|
|
71
|
+
#### `removeArrayElement`
|
|
72
|
+
|
|
73
|
+
Removes an element from an array expression, along with any commas that are no longer necessary.
|
|
74
|
+
|
|
75
|
+
Parameters:
|
|
76
|
+
|
|
77
|
+
1. `context`
|
|
78
|
+
2. `fixer`
|
|
79
|
+
3. `elementOrIndex`: the child expression, spread element, or a numeric index of the child
|
|
80
|
+
4. `parentOrElements`: the array expression node, or its `.elements` array
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { removeArrayElement } from "eslint-fix-utils";
|
|
84
|
+
|
|
85
|
+
// ...
|
|
86
|
+
|
|
87
|
+
export function report(node: ESTree.ArrayExpression) {
|
|
88
|
+
context.report({
|
|
89
|
+
fix(fixer) {
|
|
90
|
+
// Removes the last element of the array:
|
|
91
|
+
return removeArrayElement(context, fixer, node, node.elements.length - 1);
|
|
92
|
+
},
|
|
93
|
+
messageId,
|
|
94
|
+
node,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```diff
|
|
100
|
+
[
|
|
101
|
+
'a',
|
|
102
|
+
- 'b',
|
|
103
|
+
- 'c'
|
|
104
|
+
+ 'b'
|
|
105
|
+
]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Trailing commas are removed so that the fixed code will work regardless of whether the language and location allows them.
|
|
109
|
+
|
|
110
|
+
#### `removeObjectProperty`
|
|
111
|
+
|
|
112
|
+
Removes a property from an object expression, along with any commas that are no longer necessary.
|
|
113
|
+
|
|
114
|
+
Parameters:
|
|
115
|
+
|
|
116
|
+
1. `context`
|
|
117
|
+
2. `fixer`
|
|
118
|
+
3. `property`: the property node
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import { removeObjectProperty } from "eslint-fix-utils";
|
|
122
|
+
|
|
123
|
+
// ...
|
|
124
|
+
|
|
125
|
+
export function report(node: ESTree.ObjectExpression) {
|
|
126
|
+
context.report({
|
|
127
|
+
fix(fixer) {
|
|
128
|
+
// Removes the last property of the object:
|
|
129
|
+
return removeObjectProperty(context, fixer, node.properties.length - 1);
|
|
130
|
+
},
|
|
131
|
+
messageId,
|
|
132
|
+
node,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
```diff
|
|
138
|
+
{
|
|
139
|
+
a: 1,
|
|
140
|
+
- b: 2,
|
|
141
|
+
- c: 3,
|
|
142
|
+
+ b: 2
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Trailing commas are removed so that the fixed code will work regardless of whether the language and location allows them.
|
|
147
|
+
|
|
148
|
+
## Development
|
|
149
|
+
|
|
150
|
+
See [`.github/CONTRIBUTING.md`](./.github/CONTRIBUTING.md), then [`.github/DEVELOPMENT.md`](./.github/DEVELOPMENT.md).
|
|
151
|
+
Thanks! ๐
|
|
152
|
+
|
|
153
|
+
## Contributors
|
|
154
|
+
|
|
155
|
+
<!-- spellchecker: disable -->
|
|
156
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
157
|
+
<!-- prettier-ignore-start -->
|
|
158
|
+
<!-- markdownlint-disable -->
|
|
159
|
+
<table>
|
|
160
|
+
<tbody>
|
|
161
|
+
<tr>
|
|
162
|
+
<td align="center" valign="top" width="14.28%"><a href="http://www.joshuakgoldberg.com/"><img src="https://avatars.githubusercontent.com/u/3335181?v=4?s=100" width="100px;" alt="Josh Goldberg โจ"/><br /><sub><b>Josh Goldberg โจ</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/eslint-fix-utils/commits?author=JoshuaKGoldberg" title="Code">๐ป</a> <a href="#content-JoshuaKGoldberg" title="Content">๐</a> <a href="https://github.com/JoshuaKGoldberg/eslint-fix-utils/commits?author=JoshuaKGoldberg" title="Documentation">๐</a> <a href="#ideas-JoshuaKGoldberg" title="Ideas, Planning, & Feedback">๐ค</a> <a href="#infra-JoshuaKGoldberg" title="Infrastructure (Hosting, Build-Tools, etc)">๐</a> <a href="#maintenance-JoshuaKGoldberg" title="Maintenance">๐ง</a> <a href="#projectManagement-JoshuaKGoldberg" title="Project Management">๐</a> <a href="https://github.com/JoshuaKGoldberg/eslint-fix-utils/commits?author=JoshuaKGoldberg" title="Tests">โ ๏ธ</a> <a href="#tool-JoshuaKGoldberg" title="Tools">๐ง</a></td>
|
|
163
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/michaelfaith"><img src="https://avatars.githubusercontent.com/u/8071845?v=4?s=100" width="100px;" alt="michael faith"/><br /><sub><b>michael faith</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/eslint-fix-utils/commits?author=michaelfaith" title="Code">๐ป</a> <a href="#content-michaelfaith" title="Content">๐</a> <a href="https://github.com/JoshuaKGoldberg/eslint-fix-utils/commits?author=michaelfaith" title="Documentation">๐</a> <a href="#ideas-michaelfaith" title="Ideas, Planning, & Feedback">๐ค</a> <a href="#infra-michaelfaith" title="Infrastructure (Hosting, Build-Tools, etc)">๐</a> <a href="#maintenance-michaelfaith" title="Maintenance">๐ง</a> <a href="#projectManagement-michaelfaith" title="Project Management">๐</a> <a href="https://github.com/JoshuaKGoldberg/eslint-fix-utils/commits?author=michaelfaith" title="Tests">โ ๏ธ</a> <a href="#tool-michaelfaith" title="Tools">๐ง</a></td>
|
|
164
|
+
</tr>
|
|
165
|
+
</tbody>
|
|
166
|
+
</table>
|
|
167
|
+
|
|
168
|
+
<!-- markdownlint-restore -->
|
|
169
|
+
<!-- prettier-ignore-end -->
|
|
170
|
+
|
|
171
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
172
|
+
<!-- spellchecker: enable -->
|
|
173
|
+
|
|
174
|
+
<!-- You can remove this notice if you don't want it ๐ no worries! -->
|
|
175
|
+
|
|
176
|
+
> ๐ This package was templated with [`create-typescript-app`](https://github.com/JoshuaKGoldberg/create-typescript-app) using the [`create` engine](https://create.bingo).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var fixRemoveArrayElement_exports = {};
|
|
20
|
+
__export(fixRemoveArrayElement_exports, {
|
|
21
|
+
fixRemoveArrayElement: () => fixRemoveArrayElement
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(fixRemoveArrayElement_exports);
|
|
24
|
+
var import_removeArrayElement = require("./removeArrayElement.js");
|
|
25
|
+
function fixRemoveArrayElement(context, elementOrIndex, parentOrElements) {
|
|
26
|
+
return (fixer) => (0, import_removeArrayElement.removeArrayElement)(context, fixer, elementOrIndex, parentOrElements);
|
|
27
|
+
}
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
fixRemoveArrayElement
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=fixRemoveArrayElement.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fixRemoveArrayElement.ts"],"sourcesContent":["import { Rule } from \"eslint\";\n\nimport {\n\tArrayElement,\n\tArrayElementsOrParent,\n\tremoveArrayElement,\n} from \"./removeArrayElement.js\";\n\nexport function fixRemoveArrayElement(\n\tcontext: Rule.RuleContext,\n\telementOrIndex: ArrayElement | number,\n\tparentOrElements: ArrayElementsOrParent,\n) {\n\treturn (fixer: Rule.RuleFixer) =>\n\t\tremoveArrayElement(context, fixer, elementOrIndex, parentOrElements);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gCAIO;AAEA,SAAS,sBACf,SACA,gBACA,kBACC;AACD,SAAO,CAAC,cACP,8CAAmB,SAAS,OAAO,gBAAgB,gBAAgB;AACrE;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Rule } from 'eslint';
|
|
2
|
+
import { ArrayElement, ArrayElementsOrParent } from './removeArrayElement.cjs';
|
|
3
|
+
import 'estree';
|
|
4
|
+
|
|
5
|
+
declare function fixRemoveArrayElement(context: Rule.RuleContext, elementOrIndex: ArrayElement | number, parentOrElements: ArrayElementsOrParent): (fixer: Rule.RuleFixer) => Generator<Rule.Fix, void, unknown>;
|
|
6
|
+
|
|
7
|
+
export { fixRemoveArrayElement };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Rule } from 'eslint';
|
|
2
|
+
import { ArrayElement, ArrayElementsOrParent } from './removeArrayElement.js';
|
|
3
|
+
import 'estree';
|
|
4
|
+
|
|
5
|
+
declare function fixRemoveArrayElement(context: Rule.RuleContext, elementOrIndex: ArrayElement | number, parentOrElements: ArrayElementsOrParent): (fixer: Rule.RuleFixer) => Generator<Rule.Fix, void, unknown>;
|
|
6
|
+
|
|
7
|
+
export { fixRemoveArrayElement };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
removeArrayElement
|
|
3
|
+
} from "./removeArrayElement.js";
|
|
4
|
+
function fixRemoveArrayElement(context, elementOrIndex, parentOrElements) {
|
|
5
|
+
return (fixer) => removeArrayElement(context, fixer, elementOrIndex, parentOrElements);
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
fixRemoveArrayElement
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=fixRemoveArrayElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fixRemoveArrayElement.ts"],"sourcesContent":["import { Rule } from \"eslint\";\n\nimport {\n\tArrayElement,\n\tArrayElementsOrParent,\n\tremoveArrayElement,\n} from \"./removeArrayElement.js\";\n\nexport function fixRemoveArrayElement(\n\tcontext: Rule.RuleContext,\n\telementOrIndex: ArrayElement | number,\n\tparentOrElements: ArrayElementsOrParent,\n) {\n\treturn (fixer: Rule.RuleFixer) =>\n\t\tremoveArrayElement(context, fixer, elementOrIndex, parentOrElements);\n}\n"],"mappings":"AAEA;AAAA,EAGC;AAAA,OACM;AAEA,SAAS,sBACf,SACA,gBACA,kBACC;AACD,SAAO,CAAC,UACP,mBAAmB,SAAS,OAAO,gBAAgB,gBAAgB;AACrE;","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var fixRemoveObjectProperty_exports = {};
|
|
20
|
+
__export(fixRemoveObjectProperty_exports, {
|
|
21
|
+
fixRemoveObjectProperty: () => fixRemoveObjectProperty
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(fixRemoveObjectProperty_exports);
|
|
24
|
+
var import_removeObjectProperty = require("./removeObjectProperty.js");
|
|
25
|
+
function fixRemoveObjectProperty(context, property) {
|
|
26
|
+
return (fixer) => (0, import_removeObjectProperty.removeObjectProperty)(context, fixer, property);
|
|
27
|
+
}
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
fixRemoveObjectProperty
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=fixRemoveObjectProperty.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fixRemoveObjectProperty.ts"],"sourcesContent":["import { Rule } from \"eslint\";\n\nimport {\n\tObjectProperty,\n\tremoveObjectProperty,\n} from \"./removeObjectProperty.js\";\n\nexport function fixRemoveObjectProperty(\n\tcontext: Rule.RuleContext,\n\tproperty: ObjectProperty,\n) {\n\treturn (fixer: Rule.RuleFixer) =>\n\t\tremoveObjectProperty(context, fixer, property);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kCAGO;AAEA,SAAS,wBACf,SACA,UACC;AACD,SAAO,CAAC,cACP,kDAAqB,SAAS,OAAO,QAAQ;AAC/C;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Rule } from 'eslint';
|
|
2
|
+
import { ObjectProperty } from './removeObjectProperty.cjs';
|
|
3
|
+
import 'estree';
|
|
4
|
+
|
|
5
|
+
declare function fixRemoveObjectProperty(context: Rule.RuleContext, property: ObjectProperty): (fixer: Rule.RuleFixer) => Generator<Rule.Fix, void, unknown>;
|
|
6
|
+
|
|
7
|
+
export { fixRemoveObjectProperty };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Rule } from 'eslint';
|
|
2
|
+
import { ObjectProperty } from './removeObjectProperty.js';
|
|
3
|
+
import 'estree';
|
|
4
|
+
|
|
5
|
+
declare function fixRemoveObjectProperty(context: Rule.RuleContext, property: ObjectProperty): (fixer: Rule.RuleFixer) => Generator<Rule.Fix, void, unknown>;
|
|
6
|
+
|
|
7
|
+
export { fixRemoveObjectProperty };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
removeObjectProperty
|
|
3
|
+
} from "./removeObjectProperty.js";
|
|
4
|
+
function fixRemoveObjectProperty(context, property) {
|
|
5
|
+
return (fixer) => removeObjectProperty(context, fixer, property);
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
fixRemoveObjectProperty
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=fixRemoveObjectProperty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/fixRemoveObjectProperty.ts"],"sourcesContent":["import { Rule } from \"eslint\";\n\nimport {\n\tObjectProperty,\n\tremoveObjectProperty,\n} from \"./removeObjectProperty.js\";\n\nexport function fixRemoveObjectProperty(\n\tcontext: Rule.RuleContext,\n\tproperty: ObjectProperty,\n) {\n\treturn (fixer: Rule.RuleFixer) =>\n\t\tremoveObjectProperty(context, fixer, property);\n}\n"],"mappings":"AAEA;AAAA,EAEC;AAAA,OACM;AAEA,SAAS,wBACf,SACA,UACC;AACD,SAAO,CAAC,UACP,qBAAqB,SAAS,OAAO,QAAQ;AAC/C;","names":[]}
|
package/lib/greet.cjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var greet_exports = {};
|
|
20
|
+
__export(greet_exports, {
|
|
21
|
+
greet: () => greet
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(greet_exports);
|
|
24
|
+
function greet(options) {
|
|
25
|
+
const {
|
|
26
|
+
logger = console.log.bind(console),
|
|
27
|
+
message,
|
|
28
|
+
times = 1
|
|
29
|
+
} = typeof options === "string" ? { message: options } : options;
|
|
30
|
+
for (let i = 0; i < times; i += 1) {
|
|
31
|
+
logger(message);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
greet
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=greet.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/greet.ts"],"sourcesContent":["import { GreetOptions } from \"./types.js\";\n\nexport function greet(options: GreetOptions | string) {\n\tconst {\n\t\tlogger = console.log.bind(console),\n\t\tmessage,\n\t\ttimes = 1,\n\t} = typeof options === \"string\" ? { message: options } : options;\n\n\tfor (let i = 0; i < times; i += 1) {\n\t\tlogger(message);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,SAAS,MAAM,SAAgC;AACrD,QAAM;AAAA,IACL,SAAS,QAAQ,IAAI,KAAK,OAAO;AAAA,IACjC;AAAA,IACA,QAAQ;AAAA,EACT,IAAI,OAAO,YAAY,WAAW,EAAE,SAAS,QAAQ,IAAI;AAEzD,WAAS,IAAI,GAAG,IAAI,OAAO,KAAK,GAAG;AAClC,WAAO,OAAO;AAAA,EACf;AACD;","names":[]}
|
package/lib/greet.d.cts
ADDED
package/lib/greet.d.ts
ADDED
package/lib/greet.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function greet(options) {
|
|
2
|
+
const {
|
|
3
|
+
logger = console.log.bind(console),
|
|
4
|
+
message,
|
|
5
|
+
times = 1
|
|
6
|
+
} = typeof options === "string" ? { message: options } : options;
|
|
7
|
+
for (let i = 0; i < times; i += 1) {
|
|
8
|
+
logger(message);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
greet
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=greet.js.map
|
package/lib/greet.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/greet.ts"],"sourcesContent":["import { GreetOptions } from \"./types.js\";\n\nexport function greet(options: GreetOptions | string) {\n\tconst {\n\t\tlogger = console.log.bind(console),\n\t\tmessage,\n\t\ttimes = 1,\n\t} = typeof options === \"string\" ? { message: options } : options;\n\n\tfor (let i = 0; i < times; i += 1) {\n\t\tlogger(message);\n\t}\n}\n"],"mappings":"AAEO,SAAS,MAAM,SAAgC;AACrD,QAAM;AAAA,IACL,SAAS,QAAQ,IAAI,KAAK,OAAO;AAAA,IACjC;AAAA,IACA,QAAQ;AAAA,EACT,IAAI,OAAO,YAAY,WAAW,EAAE,SAAS,QAAQ,IAAI;AAEzD,WAAS,IAAI,GAAG,IAAI,OAAO,KAAK,GAAG;AAClC,WAAO,OAAO;AAAA,EACf;AACD;","names":[]}
|
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var index_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(index_exports);
|
|
18
|
+
__reExport(index_exports, require("./fixRemoveArrayElement.js"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./fixRemoveObjectProperty.js"), module.exports);
|
|
20
|
+
__reExport(index_exports, require("./removeArrayElement.js"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./removeObjectProperty.js"), module.exports);
|
|
22
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
23
|
+
0 && (module.exports = {
|
|
24
|
+
...require("./fixRemoveArrayElement.js"),
|
|
25
|
+
...require("./fixRemoveObjectProperty.js"),
|
|
26
|
+
...require("./removeArrayElement.js"),
|
|
27
|
+
...require("./removeObjectProperty.js")
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./fixRemoveArrayElement.js\";\nexport * from \"./fixRemoveObjectProperty.js\";\nexport * from \"./removeArrayElement.js\";\nexport * from \"./removeObjectProperty.js\";\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,uCAAd;AACA,0BAAc,yCADd;AAEA,0BAAc,oCAFd;AAGA,0BAAc,sCAHd;","names":[]}
|
package/lib/index.d.cts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { fixRemoveArrayElement } from './fixRemoveArrayElement.cjs';
|
|
2
|
+
export { fixRemoveObjectProperty } from './fixRemoveObjectProperty.cjs';
|
|
3
|
+
export { ArrayElement, ArrayElementsOrParent, removeArrayElement } from './removeArrayElement.cjs';
|
|
4
|
+
export { ObjectProperty, removeObjectProperty } from './removeObjectProperty.cjs';
|
|
5
|
+
import 'eslint';
|
|
6
|
+
import 'estree';
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { fixRemoveArrayElement } from './fixRemoveArrayElement.js';
|
|
2
|
+
export { fixRemoveObjectProperty } from './fixRemoveObjectProperty.js';
|
|
3
|
+
export { ArrayElement, ArrayElementsOrParent, removeArrayElement } from './removeArrayElement.js';
|
|
4
|
+
export { ObjectProperty, removeObjectProperty } from './removeObjectProperty.js';
|
|
5
|
+
import 'eslint';
|
|
6
|
+
import 'estree';
|
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./fixRemoveArrayElement.js\";\nexport * from \"./fixRemoveObjectProperty.js\";\nexport * from \"./removeArrayElement.js\";\nexport * from \"./removeObjectProperty.js\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var removeArrayElement_exports = {};
|
|
20
|
+
__export(removeArrayElement_exports, {
|
|
21
|
+
removeArrayElement: () => removeArrayElement
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(removeArrayElement_exports);
|
|
24
|
+
function* removeArrayElement(context, fixer, elementOrIndex, parentOrElements) {
|
|
25
|
+
const elements = Array.isArray(parentOrElements) ? parentOrElements : parentOrElements.elements;
|
|
26
|
+
const [element, index] = getElementAndIndex(elements, elementOrIndex);
|
|
27
|
+
if (!element) {
|
|
28
|
+
throw new Error("Cannot remove a null (blank) array element.");
|
|
29
|
+
}
|
|
30
|
+
const tokenAfter = context.sourceCode.getTokenAfter(element);
|
|
31
|
+
const tokenBefore = context.sourceCode.getTokenBefore(element);
|
|
32
|
+
if (index > 0 && tokenAfter?.value !== "," && tokenBefore?.value === ",") {
|
|
33
|
+
yield fixer.remove(tokenBefore);
|
|
34
|
+
}
|
|
35
|
+
yield fixer.remove(element);
|
|
36
|
+
if (tokenAfter?.value === ",") {
|
|
37
|
+
yield fixer.remove(tokenAfter);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function getElementAndIndex(elements, elementOrIndex) {
|
|
41
|
+
if (typeof elementOrIndex === "number") {
|
|
42
|
+
return [elements[elementOrIndex], elementOrIndex];
|
|
43
|
+
}
|
|
44
|
+
const index = elements.indexOf(elementOrIndex);
|
|
45
|
+
if (index === -1) {
|
|
46
|
+
throw new Error("Node is not a child of the parent array.");
|
|
47
|
+
}
|
|
48
|
+
return [elements[index], index];
|
|
49
|
+
}
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
removeArrayElement
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=removeArrayElement.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/removeArrayElement.ts"],"sourcesContent":["import { Rule } from \"eslint\";\nimport * as ESTree from \"estree\";\n\nexport type ArrayElement = ESTree.Expression | ESTree.SpreadElement;\n\nexport type ArrayElementsOrParent =\n\t| ESTree.ArrayExpression\n\t| ESTree.ArrayExpression[\"elements\"];\n\nexport function* removeArrayElement(\n\tcontext: Rule.RuleContext,\n\tfixer: Rule.RuleFixer,\n\telementOrIndex: ArrayElement | number,\n\tparentOrElements: ArrayElementsOrParent,\n) {\n\tconst elements = Array.isArray(parentOrElements)\n\t\t? parentOrElements\n\t\t: parentOrElements.elements;\n\tconst [element, index] = getElementAndIndex(elements, elementOrIndex);\n\n\tif (!element) {\n\t\tthrow new Error(\"Cannot remove a null (blank) array element.\");\n\t}\n\n\tconst tokenAfter = context.sourceCode.getTokenAfter(element);\n\tconst tokenBefore = context.sourceCode.getTokenBefore(element);\n\n\t// If this is the last line and it's not the only entry, then the line above this one\n\t// will become the last line, and should not have a trailing comma.\n\tif (index > 0 && tokenAfter?.value !== \",\" && tokenBefore?.value === \",\") {\n\t\tyield fixer.remove(tokenBefore);\n\t}\n\n\tyield fixer.remove(element);\n\n\t// If this is not the last entry, then we need to remove the comma from this line.\n\tif (tokenAfter?.value === \",\") {\n\t\tyield fixer.remove(tokenAfter);\n\t}\n}\n\nfunction getElementAndIndex(\n\telements: (ArrayElement | null)[],\n\telementOrIndex: ArrayElement | number,\n) {\n\tif (typeof elementOrIndex === \"number\") {\n\t\treturn [elements[elementOrIndex], elementOrIndex] as const;\n\t}\n\n\tconst index = elements.indexOf(elementOrIndex);\n\n\tif (index === -1) {\n\t\tthrow new Error(\"Node is not a child of the parent array.\");\n\t}\n\n\treturn [elements[index], index] as const;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,UAAU,mBAChB,SACA,OACA,gBACA,kBACC;AACD,QAAM,WAAW,MAAM,QAAQ,gBAAgB,IAC5C,mBACA,iBAAiB;AACpB,QAAM,CAAC,SAAS,KAAK,IAAI,mBAAmB,UAAU,cAAc;AAEpE,MAAI,CAAC,SAAS;AACb,UAAM,IAAI,MAAM,6CAA6C;AAAA,EAC9D;AAEA,QAAM,aAAa,QAAQ,WAAW,cAAc,OAAO;AAC3D,QAAM,cAAc,QAAQ,WAAW,eAAe,OAAO;AAI7D,MAAI,QAAQ,KAAK,YAAY,UAAU,OAAO,aAAa,UAAU,KAAK;AACzE,UAAM,MAAM,OAAO,WAAW;AAAA,EAC/B;AAEA,QAAM,MAAM,OAAO,OAAO;AAG1B,MAAI,YAAY,UAAU,KAAK;AAC9B,UAAM,MAAM,OAAO,UAAU;AAAA,EAC9B;AACD;AAEA,SAAS,mBACR,UACA,gBACC;AACD,MAAI,OAAO,mBAAmB,UAAU;AACvC,WAAO,CAAC,SAAS,cAAc,GAAG,cAAc;AAAA,EACjD;AAEA,QAAM,QAAQ,SAAS,QAAQ,cAAc;AAE7C,MAAI,UAAU,IAAI;AACjB,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC3D;AAEA,SAAO,CAAC,SAAS,KAAK,GAAG,KAAK;AAC/B;","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Rule } from 'eslint';
|
|
2
|
+
import * as ESTree from 'estree';
|
|
3
|
+
|
|
4
|
+
type ArrayElement = ESTree.Expression | ESTree.SpreadElement;
|
|
5
|
+
type ArrayElementsOrParent = ESTree.ArrayExpression | ESTree.ArrayExpression["elements"];
|
|
6
|
+
declare function removeArrayElement(context: Rule.RuleContext, fixer: Rule.RuleFixer, elementOrIndex: ArrayElement | number, parentOrElements: ArrayElementsOrParent): Generator<Rule.Fix, void, unknown>;
|
|
7
|
+
|
|
8
|
+
export { type ArrayElement, type ArrayElementsOrParent, removeArrayElement };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Rule } from 'eslint';
|
|
2
|
+
import * as ESTree from 'estree';
|
|
3
|
+
|
|
4
|
+
type ArrayElement = ESTree.Expression | ESTree.SpreadElement;
|
|
5
|
+
type ArrayElementsOrParent = ESTree.ArrayExpression | ESTree.ArrayExpression["elements"];
|
|
6
|
+
declare function removeArrayElement(context: Rule.RuleContext, fixer: Rule.RuleFixer, elementOrIndex: ArrayElement | number, parentOrElements: ArrayElementsOrParent): Generator<Rule.Fix, void, unknown>;
|
|
7
|
+
|
|
8
|
+
export { type ArrayElement, type ArrayElementsOrParent, removeArrayElement };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function* removeArrayElement(context, fixer, elementOrIndex, parentOrElements) {
|
|
2
|
+
const elements = Array.isArray(parentOrElements) ? parentOrElements : parentOrElements.elements;
|
|
3
|
+
const [element, index] = getElementAndIndex(elements, elementOrIndex);
|
|
4
|
+
if (!element) {
|
|
5
|
+
throw new Error("Cannot remove a null (blank) array element.");
|
|
6
|
+
}
|
|
7
|
+
const tokenAfter = context.sourceCode.getTokenAfter(element);
|
|
8
|
+
const tokenBefore = context.sourceCode.getTokenBefore(element);
|
|
9
|
+
if (index > 0 && tokenAfter?.value !== "," && tokenBefore?.value === ",") {
|
|
10
|
+
yield fixer.remove(tokenBefore);
|
|
11
|
+
}
|
|
12
|
+
yield fixer.remove(element);
|
|
13
|
+
if (tokenAfter?.value === ",") {
|
|
14
|
+
yield fixer.remove(tokenAfter);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function getElementAndIndex(elements, elementOrIndex) {
|
|
18
|
+
if (typeof elementOrIndex === "number") {
|
|
19
|
+
return [elements[elementOrIndex], elementOrIndex];
|
|
20
|
+
}
|
|
21
|
+
const index = elements.indexOf(elementOrIndex);
|
|
22
|
+
if (index === -1) {
|
|
23
|
+
throw new Error("Node is not a child of the parent array.");
|
|
24
|
+
}
|
|
25
|
+
return [elements[index], index];
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
removeArrayElement
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=removeArrayElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/removeArrayElement.ts"],"sourcesContent":["import { Rule } from \"eslint\";\nimport * as ESTree from \"estree\";\n\nexport type ArrayElement = ESTree.Expression | ESTree.SpreadElement;\n\nexport type ArrayElementsOrParent =\n\t| ESTree.ArrayExpression\n\t| ESTree.ArrayExpression[\"elements\"];\n\nexport function* removeArrayElement(\n\tcontext: Rule.RuleContext,\n\tfixer: Rule.RuleFixer,\n\telementOrIndex: ArrayElement | number,\n\tparentOrElements: ArrayElementsOrParent,\n) {\n\tconst elements = Array.isArray(parentOrElements)\n\t\t? parentOrElements\n\t\t: parentOrElements.elements;\n\tconst [element, index] = getElementAndIndex(elements, elementOrIndex);\n\n\tif (!element) {\n\t\tthrow new Error(\"Cannot remove a null (blank) array element.\");\n\t}\n\n\tconst tokenAfter = context.sourceCode.getTokenAfter(element);\n\tconst tokenBefore = context.sourceCode.getTokenBefore(element);\n\n\t// If this is the last line and it's not the only entry, then the line above this one\n\t// will become the last line, and should not have a trailing comma.\n\tif (index > 0 && tokenAfter?.value !== \",\" && tokenBefore?.value === \",\") {\n\t\tyield fixer.remove(tokenBefore);\n\t}\n\n\tyield fixer.remove(element);\n\n\t// If this is not the last entry, then we need to remove the comma from this line.\n\tif (tokenAfter?.value === \",\") {\n\t\tyield fixer.remove(tokenAfter);\n\t}\n}\n\nfunction getElementAndIndex(\n\telements: (ArrayElement | null)[],\n\telementOrIndex: ArrayElement | number,\n) {\n\tif (typeof elementOrIndex === \"number\") {\n\t\treturn [elements[elementOrIndex], elementOrIndex] as const;\n\t}\n\n\tconst index = elements.indexOf(elementOrIndex);\n\n\tif (index === -1) {\n\t\tthrow new Error(\"Node is not a child of the parent array.\");\n\t}\n\n\treturn [elements[index], index] as const;\n}\n"],"mappings":"AASO,UAAU,mBAChB,SACA,OACA,gBACA,kBACC;AACD,QAAM,WAAW,MAAM,QAAQ,gBAAgB,IAC5C,mBACA,iBAAiB;AACpB,QAAM,CAAC,SAAS,KAAK,IAAI,mBAAmB,UAAU,cAAc;AAEpE,MAAI,CAAC,SAAS;AACb,UAAM,IAAI,MAAM,6CAA6C;AAAA,EAC9D;AAEA,QAAM,aAAa,QAAQ,WAAW,cAAc,OAAO;AAC3D,QAAM,cAAc,QAAQ,WAAW,eAAe,OAAO;AAI7D,MAAI,QAAQ,KAAK,YAAY,UAAU,OAAO,aAAa,UAAU,KAAK;AACzE,UAAM,MAAM,OAAO,WAAW;AAAA,EAC/B;AAEA,QAAM,MAAM,OAAO,OAAO;AAG1B,MAAI,YAAY,UAAU,KAAK;AAC9B,UAAM,MAAM,OAAO,UAAU;AAAA,EAC9B;AACD;AAEA,SAAS,mBACR,UACA,gBACC;AACD,MAAI,OAAO,mBAAmB,UAAU;AACvC,WAAO,CAAC,SAAS,cAAc,GAAG,cAAc;AAAA,EACjD;AAEA,QAAM,QAAQ,SAAS,QAAQ,cAAc;AAE7C,MAAI,UAAU,IAAI;AACjB,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC3D;AAEA,SAAO,CAAC,SAAS,KAAK,GAAG,KAAK;AAC/B;","names":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var removeObjectProperty_exports = {};
|
|
20
|
+
__export(removeObjectProperty_exports, {
|
|
21
|
+
removeObjectProperty: () => removeObjectProperty
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(removeObjectProperty_exports);
|
|
24
|
+
function* removeObjectProperty(context, fixer, property) {
|
|
25
|
+
const tokenAfter = context.sourceCode.getTokenAfter(property);
|
|
26
|
+
const tokenBefore = context.sourceCode.getTokenBefore(property);
|
|
27
|
+
if (tokenAfter?.value !== "," && tokenBefore?.value === ",") {
|
|
28
|
+
yield fixer.remove(tokenBefore);
|
|
29
|
+
}
|
|
30
|
+
yield fixer.remove(property);
|
|
31
|
+
if (tokenAfter?.value === ",") {
|
|
32
|
+
yield fixer.remove(tokenAfter);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
removeObjectProperty
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=removeObjectProperty.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/removeObjectProperty.ts"],"sourcesContent":["import { Rule } from \"eslint\";\nimport * as ESTree from \"estree\";\n\nexport type ObjectProperty = ESTree.Property | ESTree.SpreadElement;\n\nexport function* removeObjectProperty(\n\tcontext: Rule.RuleContext,\n\tfixer: Rule.RuleFixer,\n\tproperty: ObjectProperty,\n) {\n\tconst tokenAfter = context.sourceCode.getTokenAfter(property);\n\tconst tokenBefore = context.sourceCode.getTokenBefore(property);\n\n\t// If this is not the only entry, then the line above this one\n\t// will become the last line, and should not have a trailing comma.\n\tif (tokenAfter?.value !== \",\" && tokenBefore?.value === \",\") {\n\t\tyield fixer.remove(tokenBefore);\n\t}\n\n\tyield fixer.remove(property);\n\n\t// If this is not the last entry, then we need to remove the comma from this line.\n\tif (tokenAfter?.value === \",\") {\n\t\tyield fixer.remove(tokenAfter);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKO,UAAU,qBAChB,SACA,OACA,UACC;AACD,QAAM,aAAa,QAAQ,WAAW,cAAc,QAAQ;AAC5D,QAAM,cAAc,QAAQ,WAAW,eAAe,QAAQ;AAI9D,MAAI,YAAY,UAAU,OAAO,aAAa,UAAU,KAAK;AAC5D,UAAM,MAAM,OAAO,WAAW;AAAA,EAC/B;AAEA,QAAM,MAAM,OAAO,QAAQ;AAG3B,MAAI,YAAY,UAAU,KAAK;AAC9B,UAAM,MAAM,OAAO,UAAU;AAAA,EAC9B;AACD;","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Rule } from 'eslint';
|
|
2
|
+
import * as ESTree from 'estree';
|
|
3
|
+
|
|
4
|
+
type ObjectProperty = ESTree.Property | ESTree.SpreadElement;
|
|
5
|
+
declare function removeObjectProperty(context: Rule.RuleContext, fixer: Rule.RuleFixer, property: ObjectProperty): Generator<Rule.Fix, void, unknown>;
|
|
6
|
+
|
|
7
|
+
export { type ObjectProperty, removeObjectProperty };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Rule } from 'eslint';
|
|
2
|
+
import * as ESTree from 'estree';
|
|
3
|
+
|
|
4
|
+
type ObjectProperty = ESTree.Property | ESTree.SpreadElement;
|
|
5
|
+
declare function removeObjectProperty(context: Rule.RuleContext, fixer: Rule.RuleFixer, property: ObjectProperty): Generator<Rule.Fix, void, unknown>;
|
|
6
|
+
|
|
7
|
+
export { type ObjectProperty, removeObjectProperty };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function* removeObjectProperty(context, fixer, property) {
|
|
2
|
+
const tokenAfter = context.sourceCode.getTokenAfter(property);
|
|
3
|
+
const tokenBefore = context.sourceCode.getTokenBefore(property);
|
|
4
|
+
if (tokenAfter?.value !== "," && tokenBefore?.value === ",") {
|
|
5
|
+
yield fixer.remove(tokenBefore);
|
|
6
|
+
}
|
|
7
|
+
yield fixer.remove(property);
|
|
8
|
+
if (tokenAfter?.value === ",") {
|
|
9
|
+
yield fixer.remove(tokenAfter);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
removeObjectProperty
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=removeObjectProperty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/removeObjectProperty.ts"],"sourcesContent":["import { Rule } from \"eslint\";\nimport * as ESTree from \"estree\";\n\nexport type ObjectProperty = ESTree.Property | ESTree.SpreadElement;\n\nexport function* removeObjectProperty(\n\tcontext: Rule.RuleContext,\n\tfixer: Rule.RuleFixer,\n\tproperty: ObjectProperty,\n) {\n\tconst tokenAfter = context.sourceCode.getTokenAfter(property);\n\tconst tokenBefore = context.sourceCode.getTokenBefore(property);\n\n\t// If this is not the only entry, then the line above this one\n\t// will become the last line, and should not have a trailing comma.\n\tif (tokenAfter?.value !== \",\" && tokenBefore?.value === \",\") {\n\t\tyield fixer.remove(tokenBefore);\n\t}\n\n\tyield fixer.remove(property);\n\n\t// If this is not the last entry, then we need to remove the comma from this line.\n\tif (tokenAfter?.value === \",\") {\n\t\tyield fixer.remove(tokenAfter);\n\t}\n}\n"],"mappings":"AAKO,UAAU,qBAChB,SACA,OACA,UACC;AACD,QAAM,aAAa,QAAQ,WAAW,cAAc,QAAQ;AAC5D,QAAM,cAAc,QAAQ,WAAW,eAAe,QAAQ;AAI9D,MAAI,YAAY,UAAU,OAAO,aAAa,UAAU,KAAK;AAC5D,UAAM,MAAM,OAAO,WAAW;AAAA,EAC/B;AAEA,QAAM,MAAM,OAAO,QAAQ;AAG3B,MAAI,YAAY,UAAU,KAAK;AAC9B,UAAM,MAAM,OAAO,UAAU;AAAA,EAC9B;AACD;","names":[]}
|
package/lib/types.cjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
17
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["export interface GreetOptions {\n\tlogger?: (message: string) => void;\n\tmessage: string;\n\ttimes?: number;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/lib/types.d.cts
ADDED
package/lib/types.d.ts
ADDED
package/lib/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-fix-utils",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Utilities for ESLint rule fixers and suggestions. ๐งโ๐ง",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/JoshuaKGoldberg/eslint-fix-utils.git"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Josh Goldberg โจ",
|
|
12
|
+
"email": "npm@joshuakgoldberg.com"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": {
|
|
18
|
+
"import": "./lib/index.d.ts",
|
|
19
|
+
"require": "./lib/index.d.cts"
|
|
20
|
+
},
|
|
21
|
+
"import": "./lib/index.js",
|
|
22
|
+
"require": "./lib/index.cjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"main": "lib/index.js",
|
|
26
|
+
"files": [
|
|
27
|
+
"LICENSE.md",
|
|
28
|
+
"README.md",
|
|
29
|
+
"lib/",
|
|
30
|
+
"package.json"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsup",
|
|
34
|
+
"format": "prettier .",
|
|
35
|
+
"lint": "eslint . --max-warnings 0",
|
|
36
|
+
"lint:knip": "knip",
|
|
37
|
+
"lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line",
|
|
38
|
+
"lint:packages": "pnpm dedupe --check",
|
|
39
|
+
"lint:spelling": "cspell \"**\" \".github/**/*\"",
|
|
40
|
+
"prepare": "husky",
|
|
41
|
+
"test": "vitest",
|
|
42
|
+
"tsc": "tsc"
|
|
43
|
+
},
|
|
44
|
+
"lint-staged": {
|
|
45
|
+
"*": "prettier --ignore-unknown --write"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@eslint-community/eslint-plugin-eslint-comments": "4.4.1",
|
|
49
|
+
"@eslint/js": "9.17.0",
|
|
50
|
+
"@release-it/conventional-changelog": "10.0.0",
|
|
51
|
+
"@types/eslint-plugin-markdown": "2.0.2",
|
|
52
|
+
"@types/estree": "^1.0.6",
|
|
53
|
+
"@types/node": "22.10.2",
|
|
54
|
+
"@vitest/coverage-v8": "2.1.8",
|
|
55
|
+
"@vitest/eslint-plugin": "1.1.20",
|
|
56
|
+
"console-fail-test": "0.5.0",
|
|
57
|
+
"cspell": "8.17.2",
|
|
58
|
+
"eslint": "9.17.0",
|
|
59
|
+
"eslint-plugin-jsdoc": "50.6.1",
|
|
60
|
+
"eslint-plugin-jsonc": "2.18.2",
|
|
61
|
+
"eslint-plugin-markdown": "5.1.0",
|
|
62
|
+
"eslint-plugin-n": "17.15.1",
|
|
63
|
+
"eslint-plugin-package-json": "0.19.0",
|
|
64
|
+
"eslint-plugin-perfectionist": "4.6.0",
|
|
65
|
+
"eslint-plugin-regexp": "2.7.0",
|
|
66
|
+
"eslint-plugin-yml": "1.16.0",
|
|
67
|
+
"husky": "9.1.7",
|
|
68
|
+
"knip": "5.42.2",
|
|
69
|
+
"lint-staged": "15.3.0",
|
|
70
|
+
"markdownlint": "0.37.2",
|
|
71
|
+
"markdownlint-cli": "0.43.0",
|
|
72
|
+
"prettier": "3.4.2",
|
|
73
|
+
"prettier-plugin-curly": "0.3.1",
|
|
74
|
+
"prettier-plugin-packagejson": "2.5.6",
|
|
75
|
+
"prettier-plugin-sh": "0.14.0",
|
|
76
|
+
"release-it": "17.11.0",
|
|
77
|
+
"sentences-per-line": "0.3.0",
|
|
78
|
+
"tsup": "8.3.5",
|
|
79
|
+
"typescript": "5.7.2",
|
|
80
|
+
"typescript-eslint": "8.19.0",
|
|
81
|
+
"vitest": "2.1.8"
|
|
82
|
+
},
|
|
83
|
+
"peerDependencies": {
|
|
84
|
+
"@types/estree": ">=1",
|
|
85
|
+
"eslint": ">=8"
|
|
86
|
+
},
|
|
87
|
+
"engines": {
|
|
88
|
+
"node": ">=18.3.0"
|
|
89
|
+
},
|
|
90
|
+
"publishConfig": {
|
|
91
|
+
"provenance": true
|
|
92
|
+
}
|
|
93
|
+
}
|