eslint-fix-utils 0.3.0 → 0.4.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/CHANGELOG.md +37 -0
- package/lib/index.d.ts +1 -2
- package/lib/index.js +1 -2
- package/package.json +8 -14
- package/lib/index.cjs +0 -91
- package/lib/index.d.cts +0 -66
- package/lib/index.d.cts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
# [0.4.0](https://github.com/JoshuaKGoldberg/eslint-fix-utils/compare/0.3.0...0.4.0) (2025-06-12)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* bundle esm-only ([#170](https://github.com/JoshuaKGoldberg/eslint-fix-utils/issues/170)) ([62e4938](https://github.com/JoshuaKGoldberg/eslint-fix-utils/commit/62e4938aa6e67db31611e59b6fe19692069a56de)), closes [#167](https://github.com/JoshuaKGoldberg/eslint-fix-utils/issues/167)
|
|
9
|
+
|
|
10
|
+
# [0.3.0](https://github.com/JoshuaKGoldberg/eslint-fix-utils/compare/0.2.1...0.3.0) (2025-06-11)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- bump to create-typescript-app@2 with transitions action ([#79](https://github.com/JoshuaKGoldberg/eslint-fix-utils/issues/79)) ([0bb023f](https://github.com/JoshuaKGoldberg/eslint-fix-utils/commit/0bb023f96c18632b1c688d3210ae2567cee4b8e0)), closes [#75](https://github.com/JoshuaKGoldberg/eslint-fix-utils/issues/75)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- remove support for node 18 ([#169](https://github.com/JoshuaKGoldberg/eslint-fix-utils/issues/169)) ([1b076be](https://github.com/JoshuaKGoldberg/eslint-fix-utils/commit/1b076be4533fc4e91e6c7af430ea2c597eb6d87b)), closes [#166](https://github.com/JoshuaKGoldberg/eslint-fix-utils/issues/166)
|
|
19
|
+
|
|
20
|
+
## [0.2.1](https://github.com/JoshuaKGoldberg/eslint-fix-utils/compare/0.2.0...0.2.1) (2025-01-28)
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
- make `@types/estree` peer dependency optional ([#25](https://github.com/JoshuaKGoldberg/eslint-fix-utils/issues/25)) ([f6ddd9d](https://github.com/JoshuaKGoldberg/eslint-fix-utils/commit/f6ddd9d20de032992202d9287be3c7abee4f0d15)), closes [#24](https://github.com/JoshuaKGoldberg/eslint-fix-utils/issues/24)
|
|
25
|
+
|
|
26
|
+
# [0.2.0](https://github.com/JoshuaKGoldberg/eslint-fix-utils/compare/0.1.0...0.2.0) (2025-01-23)
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
- empty commit to trigger 0.2.0 ([1658b2d](https://github.com/JoshuaKGoldberg/eslint-fix-utils/commit/1658b2d849fe9f636f24f154831ad8eeecb5721c))
|
|
31
|
+
|
|
32
|
+
# 0.1.0 (2025-01-19)
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
- initial functionality ✨ ([6bf5c33](https://github.com/JoshuaKGoldberg/eslint-fix-utils/commit/6bf5c3329eb47c43d38128328fd4501277b3c8ad))
|
|
37
|
+
- initialized repo ✨ ([31c7630](https://github.com/JoshuaKGoldberg/eslint-fix-utils/commit/31c7630c769a8a57b9be85247c6546baceae82f2))
|
package/lib/index.d.ts
CHANGED
|
@@ -62,5 +62,4 @@ declare function removeObjectProperty(context: Rule.RuleContext, fixer: Rule.Rul
|
|
|
62
62
|
*/
|
|
63
63
|
declare const fixRemoveObjectProperty: (context: Rule.RuleContext, property: ObjectProperty) => ((fixer: Rule.RuleFixer) => Generator<Rule.Fix, void>);
|
|
64
64
|
//#endregion
|
|
65
|
-
export { ArrayElement, ArrayElementsOrParent, ObjectProperty, fixRemoveArrayElement, fixRemoveObjectProperty, removeArrayElement, removeObjectProperty };
|
|
66
|
-
//# sourceMappingURL=index.d.ts.map
|
|
65
|
+
export { ArrayElement, ArrayElementsOrParent, ObjectProperty, fixRemoveArrayElement, fixRemoveObjectProperty, removeArrayElement, removeObjectProperty };
|
package/lib/index.js
CHANGED
|
@@ -84,5 +84,4 @@ const fixRemoveObjectProperty = (context, property) => {
|
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
//#endregion
|
|
87
|
-
export { fixRemoveArrayElement, fixRemoveObjectProperty, removeArrayElement, removeObjectProperty };
|
|
88
|
-
//# sourceMappingURL=index.js.map
|
|
87
|
+
export { fixRemoveArrayElement, fixRemoveObjectProperty, removeArrayElement, removeObjectProperty };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-fix-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Utilities for ESLint rule fixers and suggestions. 🧑🔧",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,22 +14,16 @@
|
|
|
14
14
|
"type": "module",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
|
-
"types":
|
|
18
|
-
|
|
19
|
-
"require": "./lib/index.d.cts"
|
|
20
|
-
},
|
|
21
|
-
"import": "./lib/index.js",
|
|
22
|
-
"require": "./lib/index.cjs"
|
|
17
|
+
"types": "./lib/index.d.ts",
|
|
18
|
+
"default": "./lib/index.js"
|
|
23
19
|
}
|
|
24
20
|
},
|
|
25
|
-
"main": "lib/index.
|
|
21
|
+
"main": "lib/index.js",
|
|
26
22
|
"module": "lib/index.js",
|
|
27
23
|
"types": "lib/index.d.ts",
|
|
28
24
|
"files": [
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"lib/",
|
|
32
|
-
"package.json"
|
|
25
|
+
"CHANGELOG.md",
|
|
26
|
+
"lib/"
|
|
33
27
|
],
|
|
34
28
|
"scripts": {
|
|
35
29
|
"build": "tsdown",
|
|
@@ -62,13 +56,13 @@
|
|
|
62
56
|
"eslint-plugin-jsdoc": "50.7.0",
|
|
63
57
|
"eslint-plugin-jsonc": "2.20.0",
|
|
64
58
|
"eslint-plugin-markdown": "5.1.0",
|
|
65
|
-
"eslint-plugin-n": "17.
|
|
59
|
+
"eslint-plugin-n": "17.19.0",
|
|
66
60
|
"eslint-plugin-package-json": "0.33.0",
|
|
67
61
|
"eslint-plugin-perfectionist": "4.14.0",
|
|
68
62
|
"eslint-plugin-regexp": "2.8.0",
|
|
69
63
|
"eslint-plugin-yml": "1.18.0",
|
|
70
64
|
"husky": "9.1.7",
|
|
71
|
-
"knip": "5.
|
|
65
|
+
"knip": "5.60.0",
|
|
72
66
|
"lint-staged": "16.1.0",
|
|
73
67
|
"markdownlint": "0.38.0",
|
|
74
68
|
"markdownlint-cli": "0.45.0",
|
package/lib/index.cjs
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/removeArrayElement.ts
|
|
3
|
-
/**
|
|
4
|
-
* Given an ArrayExpression or the list of elements an ArrayExpression has,
|
|
5
|
-
* the index or node within that array that you want to remove, and a rule fixer,
|
|
6
|
-
* this function yields removals for the node itself, as well as any trailing
|
|
7
|
-
* commas that are no longer necessary.
|
|
8
|
-
* @param context ESLint Rule Context
|
|
9
|
-
* @param fixer Rule fixer
|
|
10
|
-
* @param elementOrIndex The child expression, spread element, or a numeric
|
|
11
|
-
* index of the child
|
|
12
|
-
* @param parentOrElements The array expression node, or its `.elements` array
|
|
13
|
-
* @yields fixer removals for the node itself, as well as any trailing commas
|
|
14
|
-
* that are no longer necessary.
|
|
15
|
-
*/
|
|
16
|
-
function* removeArrayElement(context, fixer, elementOrIndex, parentOrElements) {
|
|
17
|
-
const elements = Array.isArray(parentOrElements) ? parentOrElements : parentOrElements.elements;
|
|
18
|
-
const [element, index] = getElementAndIndex(elements, elementOrIndex);
|
|
19
|
-
if (!element) throw new Error("Cannot remove a null (blank) array element.");
|
|
20
|
-
const tokenAfter = context.sourceCode.getTokenAfter(element);
|
|
21
|
-
const tokenBefore = context.sourceCode.getTokenBefore(element);
|
|
22
|
-
if (index > 0 && tokenAfter?.value !== "," && tokenBefore?.value === ",") yield fixer.remove(tokenBefore);
|
|
23
|
-
yield fixer.remove(element);
|
|
24
|
-
if (tokenAfter?.value === ",") yield fixer.remove(tokenAfter);
|
|
25
|
-
}
|
|
26
|
-
function getElementAndIndex(elements, elementOrIndex) {
|
|
27
|
-
if (typeof elementOrIndex === "number") return [elements[elementOrIndex], elementOrIndex];
|
|
28
|
-
const index = elements.indexOf(elementOrIndex);
|
|
29
|
-
if (index === -1) throw new Error("Node is not a child of the parent array.");
|
|
30
|
-
return [elements[index], index];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/fixRemoveArrayElement.ts
|
|
35
|
-
/**
|
|
36
|
-
* Given an ArrayExpression or the list of elements an ArrayExpression has, and
|
|
37
|
-
* the index or node within that array that you want to remove, this function
|
|
38
|
-
* returns a fixer function that you can provide to a report descriptor that
|
|
39
|
-
* will remove that node along with any trailing comma.
|
|
40
|
-
* @param context ESLint Rule Context
|
|
41
|
-
* @param elementOrIndex The child expression, spread element, or a numeric
|
|
42
|
-
* index of the child
|
|
43
|
-
* @param parentOrElements The array expression node, or its `.elements` array
|
|
44
|
-
* @returns a fixer function that you can provide to a report descriptor, that
|
|
45
|
-
* removes an element from an array expression, along with any commas that are
|
|
46
|
-
* no longer necessary.
|
|
47
|
-
*/
|
|
48
|
-
const fixRemoveArrayElement = (context, elementOrIndex, parentOrElements) => {
|
|
49
|
-
return (fixer) => removeArrayElement(context, fixer, elementOrIndex, parentOrElements);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region src/removeObjectProperty.ts
|
|
54
|
-
/**
|
|
55
|
-
* Given an ObjectProperty, and a rule fixer, this function yields removals for
|
|
56
|
-
* the node itself, as well as any trailing commas that are no longer necessary.
|
|
57
|
-
* @param context ESLint Rule Context
|
|
58
|
-
* @param fixer Rule fixer
|
|
59
|
-
* @param property The property node
|
|
60
|
-
* @yields fixer removals for the node itself, as well as any trailing commas
|
|
61
|
-
* that are no longer necessary.
|
|
62
|
-
*/
|
|
63
|
-
function* removeObjectProperty(context, fixer, property) {
|
|
64
|
-
const tokenAfter = context.sourceCode.getTokenAfter(property);
|
|
65
|
-
const tokenBefore = context.sourceCode.getTokenBefore(property);
|
|
66
|
-
if (tokenAfter?.value !== "," && tokenBefore?.value === ",") yield fixer.remove(tokenBefore);
|
|
67
|
-
yield fixer.remove(property);
|
|
68
|
-
if (tokenAfter?.value === ",") yield fixer.remove(tokenAfter);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/fixRemoveObjectProperty.ts
|
|
73
|
-
/**
|
|
74
|
-
* Given an ObjectProperty, this function returns a fixer function that you can
|
|
75
|
-
* provide to a report descriptor that will remove that node along with any
|
|
76
|
-
* trailing comma.
|
|
77
|
-
* @param context ESLint Rule Context
|
|
78
|
-
* @param property The property node
|
|
79
|
-
* @returns a fixer function that you can provide to a report descriptor, that
|
|
80
|
-
* removes a property from an object expression, along with any commas that
|
|
81
|
-
* are no longer necessary.
|
|
82
|
-
*/
|
|
83
|
-
const fixRemoveObjectProperty = (context, property) => {
|
|
84
|
-
return (fixer) => removeObjectProperty(context, fixer, property);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
//#endregion
|
|
88
|
-
exports.fixRemoveArrayElement = fixRemoveArrayElement;
|
|
89
|
-
exports.fixRemoveObjectProperty = fixRemoveObjectProperty;
|
|
90
|
-
exports.removeArrayElement = removeArrayElement;
|
|
91
|
-
exports.removeObjectProperty = removeObjectProperty;
|
package/lib/index.d.cts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Rule } from "eslint";
|
|
2
|
-
import * as ESTree$1 from "estree";
|
|
3
|
-
import * as ESTree from "estree";
|
|
4
|
-
|
|
5
|
-
//#region src/removeArrayElement.d.ts
|
|
6
|
-
type ArrayElement = ESTree$1.Expression | ESTree$1.SpreadElement;
|
|
7
|
-
type ArrayElementsOrParent = ESTree$1.ArrayExpression | ESTree$1.ArrayExpression["elements"];
|
|
8
|
-
/**
|
|
9
|
-
* Given an ArrayExpression or the list of elements an ArrayExpression has,
|
|
10
|
-
* the index or node within that array that you want to remove, and a rule fixer,
|
|
11
|
-
* this function yields removals for the node itself, as well as any trailing
|
|
12
|
-
* commas that are no longer necessary.
|
|
13
|
-
* @param context ESLint Rule Context
|
|
14
|
-
* @param fixer Rule fixer
|
|
15
|
-
* @param elementOrIndex The child expression, spread element, or a numeric
|
|
16
|
-
* index of the child
|
|
17
|
-
* @param parentOrElements The array expression node, or its `.elements` array
|
|
18
|
-
* @yields fixer removals for the node itself, as well as any trailing commas
|
|
19
|
-
* that are no longer necessary.
|
|
20
|
-
*/
|
|
21
|
-
declare function removeArrayElement(context: Rule.RuleContext, fixer: Rule.RuleFixer, elementOrIndex: ArrayElement | number, parentOrElements: ArrayElementsOrParent): Generator<Rule.Fix, void>;
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/fixRemoveArrayElement.d.ts
|
|
24
|
-
/**
|
|
25
|
-
* Given an ArrayExpression or the list of elements an ArrayExpression has, and
|
|
26
|
-
* the index or node within that array that you want to remove, this function
|
|
27
|
-
* returns a fixer function that you can provide to a report descriptor that
|
|
28
|
-
* will remove that node along with any trailing comma.
|
|
29
|
-
* @param context ESLint Rule Context
|
|
30
|
-
* @param elementOrIndex The child expression, spread element, or a numeric
|
|
31
|
-
* index of the child
|
|
32
|
-
* @param parentOrElements The array expression node, or its `.elements` array
|
|
33
|
-
* @returns a fixer function that you can provide to a report descriptor, that
|
|
34
|
-
* removes an element from an array expression, along with any commas that are
|
|
35
|
-
* no longer necessary.
|
|
36
|
-
*/
|
|
37
|
-
declare const fixRemoveArrayElement: (context: Rule.RuleContext, elementOrIndex: ArrayElement | number, parentOrElements: ArrayElementsOrParent) => ((fixer: Rule.RuleFixer) => Generator<Rule.Fix, void>);
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/removeObjectProperty.d.ts
|
|
40
|
-
type ObjectProperty = ESTree.Property | ESTree.SpreadElement;
|
|
41
|
-
/**
|
|
42
|
-
* Given an ObjectProperty, and a rule fixer, this function yields removals for
|
|
43
|
-
* the node itself, as well as any trailing commas that are no longer necessary.
|
|
44
|
-
* @param context ESLint Rule Context
|
|
45
|
-
* @param fixer Rule fixer
|
|
46
|
-
* @param property The property node
|
|
47
|
-
* @yields fixer removals for the node itself, as well as any trailing commas
|
|
48
|
-
* that are no longer necessary.
|
|
49
|
-
*/
|
|
50
|
-
declare function removeObjectProperty(context: Rule.RuleContext, fixer: Rule.RuleFixer, property: ObjectProperty): Generator<Rule.Fix, void>;
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region src/fixRemoveObjectProperty.d.ts
|
|
53
|
-
/**
|
|
54
|
-
* Given an ObjectProperty, this function returns a fixer function that you can
|
|
55
|
-
* provide to a report descriptor that will remove that node along with any
|
|
56
|
-
* trailing comma.
|
|
57
|
-
* @param context ESLint Rule Context
|
|
58
|
-
* @param property The property node
|
|
59
|
-
* @returns a fixer function that you can provide to a report descriptor, that
|
|
60
|
-
* removes a property from an object expression, along with any commas that
|
|
61
|
-
* are no longer necessary.
|
|
62
|
-
*/
|
|
63
|
-
declare const fixRemoveObjectProperty: (context: Rule.RuleContext, property: ObjectProperty) => ((fixer: Rule.RuleFixer) => Generator<Rule.Fix, void>);
|
|
64
|
-
//#endregion
|
|
65
|
-
export { ArrayElement, ArrayElementsOrParent, ObjectProperty, fixRemoveArrayElement, fixRemoveObjectProperty, removeArrayElement, removeObjectProperty };
|
|
66
|
-
//# sourceMappingURL=index.d.cts.map
|
package/lib/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":["context: Rule.RuleContext","fixer: Rule.RuleFixer","elementOrIndex: ArrayElement | number","parentOrElements: ArrayElementsOrParent","context: Rule.RuleContext","elementOrIndex: ArrayElement | number","parentOrElements: ArrayElementsOrParent","fixer: Rule.RuleFixer","context: Rule.RuleContext","fixer: Rule.RuleFixer","property: ObjectProperty","context: Rule.RuleContext","property: ObjectProperty","fixer: Rule.RuleFixer"],"sources":["../src/removeArrayElement.ts","../src/fixRemoveArrayElement.ts","../src/removeObjectProperty.ts","../src/fixRemoveObjectProperty.ts"],"sourcesContent":[],"mappings":";;;;;KAGY,YAAA,GAAe,QAAA,CAAO,aAAa,QAAA,CAAO;KAE1C,qBAAA,GACT,QAAA,CAAO,kBACP,QAAA,CAAO;;AAJV;;;;AAAsD;AAEtD;;;;AAEU;AAeV;;AACU,iBADO,kBAAA,CACF,OAAA,EAAL,IAAA,CAAK,WAAA,EAAA,KAAA,EACP,IAAA,CAAK,SADE,EAAA,cAAA,EAEE,YAFF,GAAA,MAAA,EAAA,gBAAA,EAGI,qBAHJ,CAAA,EAIZ,SAJY,CAIF,IAAA,CAAK,GAJH,EAAA,IAAA,CAAA;;;;;;AApBf;;;;AAAsD;AAEtD;;;;AAEU;AAeO,cCDJ,qBDCI,EAAA,CAAA,OAAA,ECAP,IAAA,CAAK,WDAE,EAAA,cAAA,ECCA,YDDA,GAAA,MAAA,EAAA,gBAAA,ECEE,qBDFF,EAAA,GAAA,CAAA,CAAA,KAAA,ECGL,IAAA,CAAK,SDHA,EAAA,GCGc,SDHd,CCGwB,IAAA,CAAK,GDH7B,EAAA,IAAA,CAAA,CAAA;;;KEnBL,cAAA,GAAiB,MAAA,CAAO,WAAW,MAAA,CAAO;;;AFAtD;;;;AAAsD;AAEtD;;AACG,iBEQc,oBAAA,CFRP,OAAA,EESA,IAAA,CAAK,WFTL,EAAA,KAAA,EEUF,IAAA,CAAK,SFVH,EAAA,QAAA,EEWC,cFXD,CAAA,EEYP,SFZO,CEYG,IAAA,CAAK,GFZR,EAAA,IAAA,CAAA;;;;;;AAHV;;;;AAAsD;AAEtD;;AACG,cGWU,uBHXH,EAAA,CAAA,OAAA,EGYA,IAAA,CAAK,WHZL,EAAA,QAAA,EGaC,cHbD,EAAA,GAAA,CAAA,CAAA,KAAA,EGcE,IAAA,CAAK,SHdP,EAAA,GGcqB,SHdrB,CGc+B,IAAA,CAAK,GHdpC,EAAA,IAAA,CAAA,CAAA"}
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["context: Rule.RuleContext","fixer: Rule.RuleFixer","elementOrIndex: ArrayElement | number","parentOrElements: ArrayElementsOrParent","context: Rule.RuleContext","elementOrIndex: ArrayElement | number","parentOrElements: ArrayElementsOrParent","fixer: Rule.RuleFixer","context: Rule.RuleContext","fixer: Rule.RuleFixer","property: ObjectProperty","context: Rule.RuleContext","property: ObjectProperty","fixer: Rule.RuleFixer"],"sources":["../src/removeArrayElement.ts","../src/fixRemoveArrayElement.ts","../src/removeObjectProperty.ts","../src/fixRemoveObjectProperty.ts"],"sourcesContent":[],"mappings":";;;;;KAGY,YAAA,GAAe,QAAA,CAAO,aAAa,QAAA,CAAO;KAE1C,qBAAA,GACT,QAAA,CAAO,kBACP,QAAA,CAAO;;AAJV;;;;AAAsD;AAEtD;;;;AAEU;AAeV;;AACU,iBADO,kBAAA,CACF,OAAA,EAAL,IAAA,CAAK,WAAA,EAAA,KAAA,EACP,IAAA,CAAK,SADE,EAAA,cAAA,EAEE,YAFF,GAAA,MAAA,EAAA,gBAAA,EAGI,qBAHJ,CAAA,EAIZ,SAJY,CAIF,IAAA,CAAK,GAJH,EAAA,IAAA,CAAA;;;;;;AApBf;;;;AAAsD;AAEtD;;;;AAEU;AAeO,cCDJ,qBDCI,EAAA,CAAA,OAAA,ECAP,IAAA,CAAK,WDAE,EAAA,cAAA,ECCA,YDDA,GAAA,MAAA,EAAA,gBAAA,ECEE,qBDFF,EAAA,GAAA,CAAA,CAAA,KAAA,ECGL,IAAA,CAAK,SDHA,EAAA,GCGc,SDHd,CCGwB,IAAA,CAAK,GDH7B,EAAA,IAAA,CAAA,CAAA;;;KEnBL,cAAA,GAAiB,MAAA,CAAO,WAAW,MAAA,CAAO;;;AFAtD;;;;AAAsD;AAEtD;;AACG,iBEQc,oBAAA,CFRP,OAAA,EESA,IAAA,CAAK,WFTL,EAAA,KAAA,EEUF,IAAA,CAAK,SFVH,EAAA,QAAA,EEWC,cFXD,CAAA,EEYP,SFZO,CEYG,IAAA,CAAK,GFZR,EAAA,IAAA,CAAA;;;;;;AAHV;;;;AAAsD;AAEtD;;AACG,cGWU,uBHXH,EAAA,CAAA,OAAA,EGYA,IAAA,CAAK,WHZL,EAAA,QAAA,EGaC,cHbD,EAAA,GAAA,CAAA,CAAA,KAAA,EGcE,IAAA,CAAK,SHdP,EAAA,GGcqB,SHdrB,CGc+B,IAAA,CAAK,GHdpC,EAAA,IAAA,CAAA,CAAA"}
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["context: Rule.RuleContext","fixer: Rule.RuleFixer","elementOrIndex: ArrayElement | number","parentOrElements: ArrayElementsOrParent","elements: (ArrayElement | null)[]","context: Rule.RuleContext","elementOrIndex: ArrayElement | number","parentOrElements: ArrayElementsOrParent","fixer: Rule.RuleFixer","context: Rule.RuleContext","fixer: Rule.RuleFixer","property: ObjectProperty","context: Rule.RuleContext","property: ObjectProperty","fixer: Rule.RuleFixer"],"sources":["../src/removeArrayElement.ts","../src/fixRemoveArrayElement.ts","../src/removeObjectProperty.ts","../src/fixRemoveObjectProperty.ts"],"sourcesContent":["import type { Rule } from \"eslint\";\nimport type * 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\n/**\n * Given an ArrayExpression or the list of elements an ArrayExpression has,\n * the index or node within that array that you want to remove, and a rule fixer,\n * this function yields removals for the node itself, as well as any trailing\n * commas that are no longer necessary.\n * @param context ESLint Rule Context\n * @param fixer Rule fixer\n * @param elementOrIndex The child expression, spread element, or a numeric\n * index of the child\n * @param parentOrElements The array expression node, or its `.elements` array\n * @yields fixer removals for the node itself, as well as any trailing commas\n * that are no longer necessary.\n */\nexport function* removeArrayElement(\n\tcontext: Rule.RuleContext,\n\tfixer: Rule.RuleFixer,\n\telementOrIndex: ArrayElement | number,\n\tparentOrElements: ArrayElementsOrParent,\n): Generator<Rule.Fix, void> {\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","import type { Rule } from \"eslint\";\n\nimport {\n\ttype ArrayElement,\n\ttype ArrayElementsOrParent,\n\tremoveArrayElement,\n} from \"./removeArrayElement\";\n\n/**\n * Given an ArrayExpression or the list of elements an ArrayExpression has, and\n * the index or node within that array that you want to remove, this function\n * returns a fixer function that you can provide to a report descriptor that\n * will remove that node along with any trailing comma.\n * @param context ESLint Rule Context\n * @param elementOrIndex The child expression, spread element, or a numeric\n * index of the child\n * @param parentOrElements The array expression node, or its `.elements` array\n * @returns a fixer function that you can provide to a report descriptor, that\n * removes an element from an array expression, along with any commas that are\n * no longer necessary.\n */\nexport const fixRemoveArrayElement = (\n\tcontext: Rule.RuleContext,\n\telementOrIndex: ArrayElement | number,\n\tparentOrElements: ArrayElementsOrParent,\n): ((fixer: Rule.RuleFixer) => Generator<Rule.Fix, void>) => {\n\treturn (fixer: Rule.RuleFixer) =>\n\t\tremoveArrayElement(context, fixer, elementOrIndex, parentOrElements);\n};\n","import type { Rule } from \"eslint\";\nimport type * as ESTree from \"estree\";\n\nexport type ObjectProperty = ESTree.Property | ESTree.SpreadElement;\n\n/**\n * Given an ObjectProperty, and a rule fixer, this function yields removals for\n * the node itself, as well as any trailing commas that are no longer necessary.\n * @param context ESLint Rule Context\n * @param fixer Rule fixer\n * @param property The property node\n * @yields fixer removals for the node itself, as well as any trailing commas\n * that are no longer necessary.\n */\nexport function* removeObjectProperty(\n\tcontext: Rule.RuleContext,\n\tfixer: Rule.RuleFixer,\n\tproperty: ObjectProperty,\n): Generator<Rule.Fix, void> {\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","import type { Rule } from \"eslint\";\n\nimport {\n\ttype ObjectProperty,\n\tremoveObjectProperty,\n} from \"./removeObjectProperty\";\n\n/**\n * Given an ObjectProperty, this function returns a fixer function that you can\n * provide to a report descriptor that will remove that node along with any\n * trailing comma.\n * @param context ESLint Rule Context\n * @param property The property node\n * @returns a fixer function that you can provide to a report descriptor, that\n * removes a property from an object expression, along with any commas that\n * are no longer necessary.\n */\nexport const fixRemoveObjectProperty = (\n\tcontext: Rule.RuleContext,\n\tproperty: ObjectProperty,\n): ((fixer: Rule.RuleFixer) => Generator<Rule.Fix, void>) => {\n\treturn (fixer: Rule.RuleFixer) =>\n\t\tremoveObjectProperty(context, fixer, property);\n};\n"],"mappings":";;;;;;;;;;;;;;AAsBA,UAAiB,mBAChBA,SACAC,OACAC,gBACAC,kBAC4B;CAC5B,MAAM,WAAW,MAAM,QAAQ,iBAAiB,GAC7C,mBACA,iBAAiB;CACpB,MAAM,CAAC,SAAS,MAAM,GAAG,mBAAmB,UAAU,eAAe;AAErE,MAAK,QACJ,OAAM,IAAI,MAAM;CAGjB,MAAM,aAAa,QAAQ,WAAW,cAAc,QAAQ;CAC5D,MAAM,cAAc,QAAQ,WAAW,eAAe,QAAQ;AAI9D,KAAI,QAAQ,KAAK,YAAY,UAAU,OAAO,aAAa,UAAU,IACpE,OAAM,MAAM,OAAO,YAAY;AAGhC,OAAM,MAAM,OAAO,QAAQ;AAG3B,KAAI,YAAY,UAAU,IACzB,OAAM,MAAM,OAAO,WAAW;AAE/B;AAED,SAAS,mBACRC,UACAF,gBACC;AACD,YAAW,mBAAmB,SAC7B,QAAO,CAAC,SAAS,iBAAiB,cAAe;CAGlD,MAAM,QAAQ,SAAS,QAAQ,eAAe;AAE9C,KAAI,UAAU,GACb,OAAM,IAAI,MAAM;AAGjB,QAAO,CAAC,SAAS,QAAQ,KAAM;AAC/B;;;;;;;;;;;;;;;;;AChDD,MAAa,wBAAwB,CACpCG,SACAC,gBACAC,qBAC4D;AAC5D,QAAO,CAACC,UACP,mBAAmB,SAAS,OAAO,gBAAgB,iBAAiB;AACrE;;;;;;;;;;;;;ACdD,UAAiB,qBAChBC,SACAC,OACAC,UAC4B;CAC5B,MAAM,aAAa,QAAQ,WAAW,cAAc,SAAS;CAC7D,MAAM,cAAc,QAAQ,WAAW,eAAe,SAAS;AAI/D,KAAI,YAAY,UAAU,OAAO,aAAa,UAAU,IACvD,OAAM,MAAM,OAAO,YAAY;AAGhC,OAAM,MAAM,OAAO,SAAS;AAG5B,KAAI,YAAY,UAAU,IACzB,OAAM,MAAM,OAAO,WAAW;AAE/B;;;;;;;;;;;;;;ACjBD,MAAa,0BAA0B,CACtCC,SACAC,aAC4D;AAC5D,QAAO,CAACC,UACP,qBAAqB,SAAS,OAAO,SAAS;AAC/C"}
|