eslint-plugin-ziloen 0.0.110 → 0.1.1
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/dist/{index.cjs → index.js} +64 -28
- package/dist/index.mjs +36 -21
- package/package.json +16 -20
|
@@ -1,12 +1,36 @@
|
|
|
1
|
-
|
|
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);
|
|
2
19
|
|
|
3
|
-
|
|
4
|
-
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
default: () => src_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
5
26
|
|
|
6
|
-
|
|
27
|
+
// src/utils.ts
|
|
28
|
+
var import_utils = require("@typescript-eslint/utils");
|
|
29
|
+
var createEslintRule = import_utils.ESLintUtils.RuleCreator((ruleName) => ruleName);
|
|
7
30
|
|
|
8
|
-
|
|
9
|
-
|
|
31
|
+
// src/rules/generic-spacing.ts
|
|
32
|
+
var RULE_NAME = "generic-spacing";
|
|
33
|
+
var messageId = "genericSpacingMismatch";
|
|
10
34
|
function removeSpaceAround(node, context) {
|
|
11
35
|
const params = node.params;
|
|
12
36
|
if (!params.length)
|
|
@@ -51,8 +75,8 @@ function removeSpaceAround(node, context) {
|
|
|
51
75
|
});
|
|
52
76
|
}
|
|
53
77
|
}
|
|
54
|
-
|
|
55
|
-
name: RULE_NAME
|
|
78
|
+
var genericSpacing = createEslintRule({
|
|
79
|
+
name: RULE_NAME,
|
|
56
80
|
meta: {
|
|
57
81
|
type: "layout",
|
|
58
82
|
docs: {
|
|
@@ -77,7 +101,7 @@ const genericSpacing = createEslintRule({
|
|
|
77
101
|
TSTypeParameter(node) {
|
|
78
102
|
if (!node.default)
|
|
79
103
|
return;
|
|
80
|
-
const startNode = node.constraint
|
|
104
|
+
const startNode = node.constraint ?? node.name;
|
|
81
105
|
const endNode = node.default;
|
|
82
106
|
const start = startNode.range[1];
|
|
83
107
|
const end = endNode.range[0];
|
|
@@ -98,9 +122,16 @@ const genericSpacing = createEslintRule({
|
|
|
98
122
|
};
|
|
99
123
|
}
|
|
100
124
|
});
|
|
125
|
+
var generic_spacing_default = genericSpacing;
|
|
101
126
|
|
|
127
|
+
// src/rules/jsx-strict-logical-expressions.ts
|
|
128
|
+
var import_utils3 = require("@typescript-eslint/utils");
|
|
129
|
+
var import_typescript2 = require("typescript");
|
|
130
|
+
|
|
131
|
+
// src/tsutils.ts
|
|
132
|
+
var import_typescript = require("typescript");
|
|
102
133
|
function isUnionType(type) {
|
|
103
|
-
return (type.flags &
|
|
134
|
+
return (type.flags & import_typescript.TypeFlags.Union) !== 0;
|
|
104
135
|
}
|
|
105
136
|
function unionTypeParts(type) {
|
|
106
137
|
return isUnionType(type) ? type.types : [type];
|
|
@@ -108,16 +139,17 @@ function unionTypeParts(type) {
|
|
|
108
139
|
function isFlagSet(obj, flag) {
|
|
109
140
|
return (obj.flags & flag) !== 0;
|
|
110
141
|
}
|
|
111
|
-
|
|
142
|
+
var isTypeFlagSet = isFlagSet;
|
|
112
143
|
function getConstrainedTypeAtLocation(checker, node) {
|
|
113
144
|
const nodeType = checker.getTypeAtLocation(node);
|
|
114
145
|
const constrained = checker.getBaseConstraintOfType(nodeType);
|
|
115
146
|
return constrained ?? nodeType;
|
|
116
147
|
}
|
|
117
148
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
149
|
+
// src/rules/jsx-strict-logical-expressions.ts
|
|
150
|
+
var RULE_NAME2 = "jsx-strict-logical-expressions";
|
|
151
|
+
var jsxStrictLogicalExpressions = createEslintRule({
|
|
152
|
+
name: RULE_NAME2,
|
|
121
153
|
defaultOptions: [{ allowString: false, allowNumber: false }],
|
|
122
154
|
meta: {
|
|
123
155
|
docs: {
|
|
@@ -142,7 +174,7 @@ const jsxStrictLogicalExpressions = createEslintRule({
|
|
|
142
174
|
}
|
|
143
175
|
},
|
|
144
176
|
create(context, [options]) {
|
|
145
|
-
const parserServices =
|
|
177
|
+
const parserServices = import_utils3.ESLintUtils.getParserServices(context);
|
|
146
178
|
const typeChecker = parserServices.program.getTypeChecker();
|
|
147
179
|
function checkIdentifier(node) {
|
|
148
180
|
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
|
@@ -150,7 +182,7 @@ const jsxStrictLogicalExpressions = createEslintRule({
|
|
|
150
182
|
getConstrainedTypeAtLocation(typeChecker, tsNode)
|
|
151
183
|
);
|
|
152
184
|
const hasPotentiallyFalseyString = types.some(
|
|
153
|
-
(type) => isTypeFlagSet(type,
|
|
185
|
+
(type) => isTypeFlagSet(type, import_typescript2.TypeFlags.StringLike) && (!type.isStringLiteral() || type.value === "")
|
|
154
186
|
);
|
|
155
187
|
if (!options.allowString && hasPotentiallyFalseyString) {
|
|
156
188
|
return "conditionErrorFalseyString";
|
|
@@ -158,7 +190,7 @@ const jsxStrictLogicalExpressions = createEslintRule({
|
|
|
158
190
|
const hasPotentiallyFalseyNumber = types.some(
|
|
159
191
|
(type) => isTypeFlagSet(
|
|
160
192
|
type,
|
|
161
|
-
|
|
193
|
+
import_typescript2.TypeFlags.NumberLike | import_typescript2.TypeFlags.BigIntLike
|
|
162
194
|
) && (!type.isNumberLiteral() || type.value === 0)
|
|
163
195
|
);
|
|
164
196
|
if (!options.allowNumber && hasPotentiallyFalseyNumber) {
|
|
@@ -178,30 +210,30 @@ const jsxStrictLogicalExpressions = createEslintRule({
|
|
|
178
210
|
}
|
|
179
211
|
function determineNode(originalNode) {
|
|
180
212
|
let nodeToEvaluate = originalNode;
|
|
181
|
-
if (nodeToEvaluate.type ===
|
|
213
|
+
if (nodeToEvaluate.type === import_utils3.TSESTree.AST_NODE_TYPES.ChainExpression) {
|
|
182
214
|
nodeToEvaluate = nodeToEvaluate.expression;
|
|
183
215
|
}
|
|
184
|
-
if (nodeToEvaluate.type ===
|
|
216
|
+
if (nodeToEvaluate.type === import_utils3.TSESTree.AST_NODE_TYPES.MemberExpression && nodeToEvaluate.property.type !== import_utils3.TSESTree.AST_NODE_TYPES.PrivateIdentifier) {
|
|
185
217
|
nodeToEvaluate = nodeToEvaluate.property;
|
|
186
218
|
}
|
|
187
219
|
return nodeToEvaluate;
|
|
188
220
|
}
|
|
189
221
|
function checkLogicalExpression(expressionNode, checkRightNode) {
|
|
190
222
|
const leftNode = determineNode(expressionNode.left);
|
|
191
|
-
if (leftNode.type ===
|
|
223
|
+
if (leftNode.type === import_utils3.TSESTree.AST_NODE_TYPES.LogicalExpression) {
|
|
192
224
|
checkLogicalExpression(leftNode, true);
|
|
193
|
-
} else if (leftNode.type ===
|
|
225
|
+
} else if (leftNode.type === import_utils3.TSESTree.AST_NODE_TYPES.Identifier) {
|
|
194
226
|
checkAndReportIdentifier(leftNode, expressionNode.left);
|
|
195
227
|
}
|
|
196
228
|
if (checkRightNode) {
|
|
197
229
|
const rightNode = determineNode(expressionNode.right);
|
|
198
|
-
if (rightNode.type ===
|
|
230
|
+
if (rightNode.type === import_utils3.TSESTree.AST_NODE_TYPES.Identifier) {
|
|
199
231
|
checkAndReportIdentifier(rightNode, expressionNode.right);
|
|
200
232
|
}
|
|
201
233
|
}
|
|
202
234
|
}
|
|
203
235
|
function checkJSXExpression(node) {
|
|
204
|
-
if (node.expression.type ===
|
|
236
|
+
if (node.expression.type === import_utils3.TSESTree.AST_NODE_TYPES.LogicalExpression && node.expression.operator === "&&") {
|
|
205
237
|
checkLogicalExpression(node.expression, false);
|
|
206
238
|
}
|
|
207
239
|
}
|
|
@@ -210,12 +242,16 @@ const jsxStrictLogicalExpressions = createEslintRule({
|
|
|
210
242
|
};
|
|
211
243
|
}
|
|
212
244
|
});
|
|
245
|
+
var jsx_strict_logical_expressions_default = jsxStrictLogicalExpressions;
|
|
213
246
|
|
|
214
|
-
|
|
247
|
+
// src/index.ts
|
|
248
|
+
var ziloen = {
|
|
249
|
+
meta: {
|
|
250
|
+
name: "ziloen"
|
|
251
|
+
},
|
|
215
252
|
rules: {
|
|
216
|
-
"generic-spacing":
|
|
217
|
-
"jsx-strict-logical-expressions":
|
|
253
|
+
"generic-spacing": generic_spacing_default,
|
|
254
|
+
"jsx-strict-logical-expressions": jsx_strict_logical_expressions_default
|
|
218
255
|
}
|
|
219
256
|
};
|
|
220
|
-
|
|
221
|
-
module.exports = index;
|
|
257
|
+
var src_default = ziloen;
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
3
|
+
var createEslintRule = ESLintUtils.RuleCreator((ruleName) => ruleName);
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const messageId = "genericSpacingMismatch";
|
|
5
|
+
// src/rules/generic-spacing.ts
|
|
6
|
+
var RULE_NAME = "generic-spacing";
|
|
7
|
+
var messageId = "genericSpacingMismatch";
|
|
8
8
|
function removeSpaceAround(node, context) {
|
|
9
9
|
const params = node.params;
|
|
10
10
|
if (!params.length)
|
|
@@ -49,8 +49,8 @@ function removeSpaceAround(node, context) {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
name: RULE_NAME
|
|
52
|
+
var genericSpacing = createEslintRule({
|
|
53
|
+
name: RULE_NAME,
|
|
54
54
|
meta: {
|
|
55
55
|
type: "layout",
|
|
56
56
|
docs: {
|
|
@@ -75,7 +75,7 @@ const genericSpacing = createEslintRule({
|
|
|
75
75
|
TSTypeParameter(node) {
|
|
76
76
|
if (!node.default)
|
|
77
77
|
return;
|
|
78
|
-
const startNode = node.constraint
|
|
78
|
+
const startNode = node.constraint ?? node.name;
|
|
79
79
|
const endNode = node.default;
|
|
80
80
|
const start = startNode.range[1];
|
|
81
81
|
const end = endNode.range[0];
|
|
@@ -96,7 +96,14 @@ const genericSpacing = createEslintRule({
|
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
|
+
var generic_spacing_default = genericSpacing;
|
|
99
100
|
|
|
101
|
+
// src/rules/jsx-strict-logical-expressions.ts
|
|
102
|
+
import { ESLintUtils as ESLintUtils2, TSESTree } from "@typescript-eslint/utils";
|
|
103
|
+
import { TypeFlags as TypeFlags2 } from "typescript";
|
|
104
|
+
|
|
105
|
+
// src/tsutils.ts
|
|
106
|
+
import { TypeFlags } from "typescript";
|
|
100
107
|
function isUnionType(type) {
|
|
101
108
|
return (type.flags & TypeFlags.Union) !== 0;
|
|
102
109
|
}
|
|
@@ -106,16 +113,17 @@ function unionTypeParts(type) {
|
|
|
106
113
|
function isFlagSet(obj, flag) {
|
|
107
114
|
return (obj.flags & flag) !== 0;
|
|
108
115
|
}
|
|
109
|
-
|
|
116
|
+
var isTypeFlagSet = isFlagSet;
|
|
110
117
|
function getConstrainedTypeAtLocation(checker, node) {
|
|
111
118
|
const nodeType = checker.getTypeAtLocation(node);
|
|
112
119
|
const constrained = checker.getBaseConstraintOfType(nodeType);
|
|
113
120
|
return constrained ?? nodeType;
|
|
114
121
|
}
|
|
115
122
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
123
|
+
// src/rules/jsx-strict-logical-expressions.ts
|
|
124
|
+
var RULE_NAME2 = "jsx-strict-logical-expressions";
|
|
125
|
+
var jsxStrictLogicalExpressions = createEslintRule({
|
|
126
|
+
name: RULE_NAME2,
|
|
119
127
|
defaultOptions: [{ allowString: false, allowNumber: false }],
|
|
120
128
|
meta: {
|
|
121
129
|
docs: {
|
|
@@ -140,7 +148,7 @@ const jsxStrictLogicalExpressions = createEslintRule({
|
|
|
140
148
|
}
|
|
141
149
|
},
|
|
142
150
|
create(context, [options]) {
|
|
143
|
-
const parserServices =
|
|
151
|
+
const parserServices = ESLintUtils2.getParserServices(context);
|
|
144
152
|
const typeChecker = parserServices.program.getTypeChecker();
|
|
145
153
|
function checkIdentifier(node) {
|
|
146
154
|
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
|
@@ -148,7 +156,7 @@ const jsxStrictLogicalExpressions = createEslintRule({
|
|
|
148
156
|
getConstrainedTypeAtLocation(typeChecker, tsNode)
|
|
149
157
|
);
|
|
150
158
|
const hasPotentiallyFalseyString = types.some(
|
|
151
|
-
(type) => isTypeFlagSet(type,
|
|
159
|
+
(type) => isTypeFlagSet(type, TypeFlags2.StringLike) && (!type.isStringLiteral() || type.value === "")
|
|
152
160
|
);
|
|
153
161
|
if (!options.allowString && hasPotentiallyFalseyString) {
|
|
154
162
|
return "conditionErrorFalseyString";
|
|
@@ -156,7 +164,7 @@ const jsxStrictLogicalExpressions = createEslintRule({
|
|
|
156
164
|
const hasPotentiallyFalseyNumber = types.some(
|
|
157
165
|
(type) => isTypeFlagSet(
|
|
158
166
|
type,
|
|
159
|
-
|
|
167
|
+
TypeFlags2.NumberLike | TypeFlags2.BigIntLike
|
|
160
168
|
) && (!type.isNumberLiteral() || type.value === 0)
|
|
161
169
|
);
|
|
162
170
|
if (!options.allowNumber && hasPotentiallyFalseyNumber) {
|
|
@@ -208,12 +216,19 @@ const jsxStrictLogicalExpressions = createEslintRule({
|
|
|
208
216
|
};
|
|
209
217
|
}
|
|
210
218
|
});
|
|
219
|
+
var jsx_strict_logical_expressions_default = jsxStrictLogicalExpressions;
|
|
211
220
|
|
|
212
|
-
|
|
221
|
+
// src/index.ts
|
|
222
|
+
var ziloen = {
|
|
223
|
+
meta: {
|
|
224
|
+
name: "ziloen"
|
|
225
|
+
},
|
|
213
226
|
rules: {
|
|
214
|
-
"generic-spacing":
|
|
215
|
-
"jsx-strict-logical-expressions":
|
|
227
|
+
"generic-spacing": generic_spacing_default,
|
|
228
|
+
"jsx-strict-logical-expressions": jsx_strict_logical_expressions_default
|
|
216
229
|
}
|
|
217
230
|
};
|
|
218
|
-
|
|
219
|
-
export {
|
|
231
|
+
var src_default = ziloen;
|
|
232
|
+
export {
|
|
233
|
+
src_default as default
|
|
234
|
+
};
|
package/package.json
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-ziloen",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"homepage": "https://github.com/ziloen/eslint-config",
|
|
7
|
-
"main": "./dist/index.cjs",
|
|
8
|
-
"module": "./dist/index.mjs",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"main": "./dist/index.js",
|
|
9
5
|
"files": [
|
|
10
6
|
"dist"
|
|
11
7
|
],
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "rimraf dist && tsup src/index.ts --format esm,cjs --clean",
|
|
10
|
+
"release": "pnpm run build && bumpp --commit --no-push && npm publish"
|
|
15
11
|
},
|
|
16
|
-
"
|
|
17
|
-
"@types/
|
|
18
|
-
"@
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@types/eslint": "^8.44.6",
|
|
14
|
+
"@types/node": "^20.8.7",
|
|
15
|
+
"@typescript-eslint/rule-tester": "^6.8.0",
|
|
16
|
+
"@typescript-eslint/utils": "^6.8.0",
|
|
17
|
+
"bumpp": "^9.2.0",
|
|
18
|
+
"eslint": "^8.52.0",
|
|
19
19
|
"rimraf": "^5.0.5",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
"scripts": {
|
|
24
|
-
"build": "rimraf dist && unbuild",
|
|
25
|
-
"stub": "unbuild --stub",
|
|
26
|
-
"test": "vitest"
|
|
20
|
+
"tsup": "^7.2.0",
|
|
21
|
+
"typescript": "^5.2.2",
|
|
22
|
+
"unbuild": "^2.0.0"
|
|
27
23
|
}
|
|
28
|
-
}
|
|
24
|
+
}
|