eslint-plugin-ziloen 0.1.3 → 0.1.4
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 +6 -16
- package/dist/index.js +4 -14
- package/package.json +9 -2
package/dist/index.cjs
CHANGED
|
@@ -126,20 +126,10 @@ var generic_spacing_default = genericSpacing;
|
|
|
126
126
|
|
|
127
127
|
// src/rules/jsx-strict-logical-expressions.ts
|
|
128
128
|
var import_utils3 = require("@typescript-eslint/utils");
|
|
129
|
-
var
|
|
129
|
+
var import_tsutils = require("tsutils");
|
|
130
|
+
var import_typescript = require("typescript");
|
|
130
131
|
|
|
131
132
|
// src/tsutils.ts
|
|
132
|
-
var import_typescript = require("typescript");
|
|
133
|
-
function isUnionType(type) {
|
|
134
|
-
return (type.flags & import_typescript.TypeFlags.Union) !== 0;
|
|
135
|
-
}
|
|
136
|
-
function unionTypeParts(type) {
|
|
137
|
-
return isUnionType(type) ? type.types : [type];
|
|
138
|
-
}
|
|
139
|
-
function isFlagSet(obj, flag) {
|
|
140
|
-
return (obj.flags & flag) !== 0;
|
|
141
|
-
}
|
|
142
|
-
var isTypeFlagSet = isFlagSet;
|
|
143
133
|
function getConstrainedTypeAtLocation(checker, node) {
|
|
144
134
|
const nodeType = checker.getTypeAtLocation(node);
|
|
145
135
|
const constrained = checker.getBaseConstraintOfType(nodeType);
|
|
@@ -178,19 +168,19 @@ var jsxStrictLogicalExpressions = createEslintRule({
|
|
|
178
168
|
const typeChecker = parserServices.program.getTypeChecker();
|
|
179
169
|
function checkIdentifier(node) {
|
|
180
170
|
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
|
181
|
-
const types = unionTypeParts(
|
|
171
|
+
const types = (0, import_tsutils.unionTypeParts)(
|
|
182
172
|
getConstrainedTypeAtLocation(typeChecker, tsNode)
|
|
183
173
|
);
|
|
184
174
|
const hasPotentiallyFalseyString = types.some(
|
|
185
|
-
(type) => isTypeFlagSet(type,
|
|
175
|
+
(type) => (0, import_tsutils.isTypeFlagSet)(type, import_typescript.TypeFlags.StringLike) && (!type.isStringLiteral() || type.value === "")
|
|
186
176
|
);
|
|
187
177
|
if (!options.allowString && hasPotentiallyFalseyString) {
|
|
188
178
|
return "conditionErrorFalseyString";
|
|
189
179
|
}
|
|
190
180
|
const hasPotentiallyFalseyNumber = types.some(
|
|
191
|
-
(type) => isTypeFlagSet(
|
|
181
|
+
(type) => (0, import_tsutils.isTypeFlagSet)(
|
|
192
182
|
type,
|
|
193
|
-
|
|
183
|
+
import_typescript.TypeFlags.NumberLike | import_typescript.TypeFlags.BigIntLike
|
|
194
184
|
) && (!type.isNumberLiteral() || type.value === 0)
|
|
195
185
|
);
|
|
196
186
|
if (!options.allowNumber && hasPotentiallyFalseyNumber) {
|
package/dist/index.js
CHANGED
|
@@ -100,20 +100,10 @@ var generic_spacing_default = genericSpacing;
|
|
|
100
100
|
|
|
101
101
|
// src/rules/jsx-strict-logical-expressions.ts
|
|
102
102
|
import { ESLintUtils as ESLintUtils2, TSESTree } from "@typescript-eslint/utils";
|
|
103
|
-
import {
|
|
103
|
+
import { isTypeFlagSet, unionTypeParts } from "tsutils";
|
|
104
|
+
import { TypeFlags } from "typescript";
|
|
104
105
|
|
|
105
106
|
// src/tsutils.ts
|
|
106
|
-
import { TypeFlags } from "typescript";
|
|
107
|
-
function isUnionType(type) {
|
|
108
|
-
return (type.flags & TypeFlags.Union) !== 0;
|
|
109
|
-
}
|
|
110
|
-
function unionTypeParts(type) {
|
|
111
|
-
return isUnionType(type) ? type.types : [type];
|
|
112
|
-
}
|
|
113
|
-
function isFlagSet(obj, flag) {
|
|
114
|
-
return (obj.flags & flag) !== 0;
|
|
115
|
-
}
|
|
116
|
-
var isTypeFlagSet = isFlagSet;
|
|
117
107
|
function getConstrainedTypeAtLocation(checker, node) {
|
|
118
108
|
const nodeType = checker.getTypeAtLocation(node);
|
|
119
109
|
const constrained = checker.getBaseConstraintOfType(nodeType);
|
|
@@ -156,7 +146,7 @@ var jsxStrictLogicalExpressions = createEslintRule({
|
|
|
156
146
|
getConstrainedTypeAtLocation(typeChecker, tsNode)
|
|
157
147
|
);
|
|
158
148
|
const hasPotentiallyFalseyString = types.some(
|
|
159
|
-
(type) => isTypeFlagSet(type,
|
|
149
|
+
(type) => isTypeFlagSet(type, TypeFlags.StringLike) && (!type.isStringLiteral() || type.value === "")
|
|
160
150
|
);
|
|
161
151
|
if (!options.allowString && hasPotentiallyFalseyString) {
|
|
162
152
|
return "conditionErrorFalseyString";
|
|
@@ -164,7 +154,7 @@ var jsxStrictLogicalExpressions = createEslintRule({
|
|
|
164
154
|
const hasPotentiallyFalseyNumber = types.some(
|
|
165
155
|
(type) => isTypeFlagSet(
|
|
166
156
|
type,
|
|
167
|
-
|
|
157
|
+
TypeFlags.NumberLike | TypeFlags.BigIntLike
|
|
168
158
|
) && (!type.isNumberLiteral() || type.value === 0)
|
|
169
159
|
);
|
|
170
160
|
if (!options.allowNumber && hasPotentiallyFalseyNumber) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-ziloen",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
|
-
"module": "./dist/index.
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"require": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
7
13
|
"files": [
|
|
8
14
|
"dist"
|
|
9
15
|
],
|
|
@@ -20,6 +26,7 @@
|
|
|
20
26
|
"eslint": "^8.52.0",
|
|
21
27
|
"rimraf": "^5.0.5",
|
|
22
28
|
"tsup": "^7.2.0",
|
|
29
|
+
"tsutils": "^3.21.0",
|
|
23
30
|
"typescript": "^5.2.2",
|
|
24
31
|
"unbuild": "^2.0.0"
|
|
25
32
|
}
|