eslint-plugin-ziloen 0.1.2 → 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.
@@ -1,6 +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
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ default: () => src_default
24
+ });
25
+ module.exports = __toCommonJS(src_exports);
26
+
1
27
  // src/utils.ts
2
- import { ESLintUtils } from "@typescript-eslint/utils";
3
- var createEslintRule = ESLintUtils.RuleCreator((ruleName) => ruleName);
28
+ var import_utils = require("@typescript-eslint/utils");
29
+ var createEslintRule = import_utils.ESLintUtils.RuleCreator((ruleName) => ruleName);
4
30
 
5
31
  // src/rules/generic-spacing.ts
6
32
  var RULE_NAME = "generic-spacing";
@@ -99,21 +125,11 @@ var genericSpacing = createEslintRule({
99
125
  var generic_spacing_default = genericSpacing;
100
126
 
101
127
  // src/rules/jsx-strict-logical-expressions.ts
102
- import { ESLintUtils as ESLintUtils2, TSESTree } from "@typescript-eslint/utils";
103
- import { TypeFlags as TypeFlags2 } from "typescript";
128
+ var import_utils3 = require("@typescript-eslint/utils");
129
+ var import_tsutils = require("tsutils");
130
+ var import_typescript = require("typescript");
104
131
 
105
132
  // 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
133
  function getConstrainedTypeAtLocation(checker, node) {
118
134
  const nodeType = checker.getTypeAtLocation(node);
119
135
  const constrained = checker.getBaseConstraintOfType(nodeType);
@@ -148,23 +164,23 @@ var jsxStrictLogicalExpressions = createEslintRule({
148
164
  }
149
165
  },
150
166
  create(context, [options]) {
151
- const parserServices = ESLintUtils2.getParserServices(context);
167
+ const parserServices = import_utils3.ESLintUtils.getParserServices(context);
152
168
  const typeChecker = parserServices.program.getTypeChecker();
153
169
  function checkIdentifier(node) {
154
170
  const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
155
- const types = unionTypeParts(
171
+ const types = (0, import_tsutils.unionTypeParts)(
156
172
  getConstrainedTypeAtLocation(typeChecker, tsNode)
157
173
  );
158
174
  const hasPotentiallyFalseyString = types.some(
159
- (type) => isTypeFlagSet(type, TypeFlags2.StringLike) && (!type.isStringLiteral() || type.value === "")
175
+ (type) => (0, import_tsutils.isTypeFlagSet)(type, import_typescript.TypeFlags.StringLike) && (!type.isStringLiteral() || type.value === "")
160
176
  );
161
177
  if (!options.allowString && hasPotentiallyFalseyString) {
162
178
  return "conditionErrorFalseyString";
163
179
  }
164
180
  const hasPotentiallyFalseyNumber = types.some(
165
- (type) => isTypeFlagSet(
181
+ (type) => (0, import_tsutils.isTypeFlagSet)(
166
182
  type,
167
- TypeFlags2.NumberLike | TypeFlags2.BigIntLike
183
+ import_typescript.TypeFlags.NumberLike | import_typescript.TypeFlags.BigIntLike
168
184
  ) && (!type.isNumberLiteral() || type.value === 0)
169
185
  );
170
186
  if (!options.allowNumber && hasPotentiallyFalseyNumber) {
@@ -184,30 +200,30 @@ var jsxStrictLogicalExpressions = createEslintRule({
184
200
  }
185
201
  function determineNode(originalNode) {
186
202
  let nodeToEvaluate = originalNode;
187
- if (nodeToEvaluate.type === TSESTree.AST_NODE_TYPES.ChainExpression) {
203
+ if (nodeToEvaluate.type === import_utils3.TSESTree.AST_NODE_TYPES.ChainExpression) {
188
204
  nodeToEvaluate = nodeToEvaluate.expression;
189
205
  }
190
- if (nodeToEvaluate.type === TSESTree.AST_NODE_TYPES.MemberExpression && nodeToEvaluate.property.type !== TSESTree.AST_NODE_TYPES.PrivateIdentifier) {
206
+ if (nodeToEvaluate.type === import_utils3.TSESTree.AST_NODE_TYPES.MemberExpression && nodeToEvaluate.property.type !== import_utils3.TSESTree.AST_NODE_TYPES.PrivateIdentifier) {
191
207
  nodeToEvaluate = nodeToEvaluate.property;
192
208
  }
193
209
  return nodeToEvaluate;
194
210
  }
195
211
  function checkLogicalExpression(expressionNode, checkRightNode) {
196
212
  const leftNode = determineNode(expressionNode.left);
197
- if (leftNode.type === TSESTree.AST_NODE_TYPES.LogicalExpression) {
213
+ if (leftNode.type === import_utils3.TSESTree.AST_NODE_TYPES.LogicalExpression) {
198
214
  checkLogicalExpression(leftNode, true);
199
- } else if (leftNode.type === TSESTree.AST_NODE_TYPES.Identifier) {
215
+ } else if (leftNode.type === import_utils3.TSESTree.AST_NODE_TYPES.Identifier) {
200
216
  checkAndReportIdentifier(leftNode, expressionNode.left);
201
217
  }
202
218
  if (checkRightNode) {
203
219
  const rightNode = determineNode(expressionNode.right);
204
- if (rightNode.type === TSESTree.AST_NODE_TYPES.Identifier) {
220
+ if (rightNode.type === import_utils3.TSESTree.AST_NODE_TYPES.Identifier) {
205
221
  checkAndReportIdentifier(rightNode, expressionNode.right);
206
222
  }
207
223
  }
208
224
  }
209
225
  function checkJSXExpression(node) {
210
- if (node.expression.type === TSESTree.AST_NODE_TYPES.LogicalExpression && node.expression.operator === "&&") {
226
+ if (node.expression.type === import_utils3.TSESTree.AST_NODE_TYPES.LogicalExpression && node.expression.operator === "&&") {
211
227
  checkLogicalExpression(node.expression, false);
212
228
  }
213
229
  }
@@ -229,6 +245,3 @@ var ziloen = {
229
245
  }
230
246
  };
231
247
  var src_default = ziloen;
232
- export {
233
- src_default as default
234
- };
package/dist/index.js CHANGED
@@ -1,32 +1,6 @@
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
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- default: () => src_default
24
- });
25
- module.exports = __toCommonJS(src_exports);
26
-
27
1
  // src/utils.ts
28
- var import_utils = require("@typescript-eslint/utils");
29
- var createEslintRule = import_utils.ESLintUtils.RuleCreator((ruleName) => ruleName);
2
+ import { ESLintUtils } from "@typescript-eslint/utils";
3
+ var createEslintRule = ESLintUtils.RuleCreator((ruleName) => ruleName);
30
4
 
31
5
  // src/rules/generic-spacing.ts
32
6
  var RULE_NAME = "generic-spacing";
@@ -125,21 +99,11 @@ var genericSpacing = createEslintRule({
125
99
  var generic_spacing_default = genericSpacing;
126
100
 
127
101
  // src/rules/jsx-strict-logical-expressions.ts
128
- var import_utils3 = require("@typescript-eslint/utils");
129
- var import_typescript2 = require("typescript");
102
+ import { ESLintUtils as ESLintUtils2, TSESTree } from "@typescript-eslint/utils";
103
+ import { isTypeFlagSet, unionTypeParts } from "tsutils";
104
+ import { TypeFlags } from "typescript";
130
105
 
131
106
  // 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
107
  function getConstrainedTypeAtLocation(checker, node) {
144
108
  const nodeType = checker.getTypeAtLocation(node);
145
109
  const constrained = checker.getBaseConstraintOfType(nodeType);
@@ -174,7 +138,7 @@ var jsxStrictLogicalExpressions = createEslintRule({
174
138
  }
175
139
  },
176
140
  create(context, [options]) {
177
- const parserServices = import_utils3.ESLintUtils.getParserServices(context);
141
+ const parserServices = ESLintUtils2.getParserServices(context);
178
142
  const typeChecker = parserServices.program.getTypeChecker();
179
143
  function checkIdentifier(node) {
180
144
  const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
@@ -182,7 +146,7 @@ var jsxStrictLogicalExpressions = createEslintRule({
182
146
  getConstrainedTypeAtLocation(typeChecker, tsNode)
183
147
  );
184
148
  const hasPotentiallyFalseyString = types.some(
185
- (type) => isTypeFlagSet(type, import_typescript2.TypeFlags.StringLike) && (!type.isStringLiteral() || type.value === "")
149
+ (type) => isTypeFlagSet(type, TypeFlags.StringLike) && (!type.isStringLiteral() || type.value === "")
186
150
  );
187
151
  if (!options.allowString && hasPotentiallyFalseyString) {
188
152
  return "conditionErrorFalseyString";
@@ -190,7 +154,7 @@ var jsxStrictLogicalExpressions = createEslintRule({
190
154
  const hasPotentiallyFalseyNumber = types.some(
191
155
  (type) => isTypeFlagSet(
192
156
  type,
193
- import_typescript2.TypeFlags.NumberLike | import_typescript2.TypeFlags.BigIntLike
157
+ TypeFlags.NumberLike | TypeFlags.BigIntLike
194
158
  ) && (!type.isNumberLiteral() || type.value === 0)
195
159
  );
196
160
  if (!options.allowNumber && hasPotentiallyFalseyNumber) {
@@ -210,30 +174,30 @@ var jsxStrictLogicalExpressions = createEslintRule({
210
174
  }
211
175
  function determineNode(originalNode) {
212
176
  let nodeToEvaluate = originalNode;
213
- if (nodeToEvaluate.type === import_utils3.TSESTree.AST_NODE_TYPES.ChainExpression) {
177
+ if (nodeToEvaluate.type === TSESTree.AST_NODE_TYPES.ChainExpression) {
214
178
  nodeToEvaluate = nodeToEvaluate.expression;
215
179
  }
216
- if (nodeToEvaluate.type === import_utils3.TSESTree.AST_NODE_TYPES.MemberExpression && nodeToEvaluate.property.type !== import_utils3.TSESTree.AST_NODE_TYPES.PrivateIdentifier) {
180
+ if (nodeToEvaluate.type === TSESTree.AST_NODE_TYPES.MemberExpression && nodeToEvaluate.property.type !== TSESTree.AST_NODE_TYPES.PrivateIdentifier) {
217
181
  nodeToEvaluate = nodeToEvaluate.property;
218
182
  }
219
183
  return nodeToEvaluate;
220
184
  }
221
185
  function checkLogicalExpression(expressionNode, checkRightNode) {
222
186
  const leftNode = determineNode(expressionNode.left);
223
- if (leftNode.type === import_utils3.TSESTree.AST_NODE_TYPES.LogicalExpression) {
187
+ if (leftNode.type === TSESTree.AST_NODE_TYPES.LogicalExpression) {
224
188
  checkLogicalExpression(leftNode, true);
225
- } else if (leftNode.type === import_utils3.TSESTree.AST_NODE_TYPES.Identifier) {
189
+ } else if (leftNode.type === TSESTree.AST_NODE_TYPES.Identifier) {
226
190
  checkAndReportIdentifier(leftNode, expressionNode.left);
227
191
  }
228
192
  if (checkRightNode) {
229
193
  const rightNode = determineNode(expressionNode.right);
230
- if (rightNode.type === import_utils3.TSESTree.AST_NODE_TYPES.Identifier) {
194
+ if (rightNode.type === TSESTree.AST_NODE_TYPES.Identifier) {
231
195
  checkAndReportIdentifier(rightNode, expressionNode.right);
232
196
  }
233
197
  }
234
198
  }
235
199
  function checkJSXExpression(node) {
236
- if (node.expression.type === import_utils3.TSESTree.AST_NODE_TYPES.LogicalExpression && node.expression.operator === "&&") {
200
+ if (node.expression.type === TSESTree.AST_NODE_TYPES.LogicalExpression && node.expression.operator === "&&") {
237
201
  checkLogicalExpression(node.expression, false);
238
202
  }
239
203
  }
@@ -255,3 +219,6 @@ var ziloen = {
255
219
  }
256
220
  };
257
221
  var src_default = ziloen;
222
+ export {
223
+ src_default as default
224
+ };
package/package.json CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
2
  "name": "eslint-plugin-ziloen",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
+ "type": "module",
4
5
  "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.js"
11
+ }
12
+ },
5
13
  "files": [
6
14
  "dist"
7
15
  ],
@@ -18,6 +26,7 @@
18
26
  "eslint": "^8.52.0",
19
27
  "rimraf": "^5.0.5",
20
28
  "tsup": "^7.2.0",
29
+ "tsutils": "^3.21.0",
21
30
  "typescript": "^5.2.2",
22
31
  "unbuild": "^2.0.0"
23
32
  }