@fookiejs/eslint-plugin 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.
Files changed (210) hide show
  1. package/README.md +512 -0
  2. package/dist/index.d.ts +164 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +167 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/rules/consistent-return.d.ts +7 -0
  7. package/dist/rules/consistent-return.d.ts.map +1 -0
  8. package/dist/rules/consistent-return.js +56 -0
  9. package/dist/rules/consistent-return.js.map +1 -0
  10. package/dist/rules/exhaustive-switch.d.ts +5 -0
  11. package/dist/rules/exhaustive-switch.d.ts.map +1 -0
  12. package/dist/rules/exhaustive-switch.js +83 -0
  13. package/dist/rules/exhaustive-switch.js.map +1 -0
  14. package/dist/rules/index.d.ts +50 -0
  15. package/dist/rules/index.d.ts.map +1 -0
  16. package/dist/rules/index.js +50 -0
  17. package/dist/rules/index.js.map +1 -0
  18. package/dist/rules/no-any.d.ts +5 -0
  19. package/dist/rules/no-any.d.ts.map +1 -0
  20. package/dist/rules/no-any.js +20 -0
  21. package/dist/rules/no-any.js.map +1 -0
  22. package/dist/rules/no-array-mutating-methods.d.ts +5 -0
  23. package/dist/rules/no-array-mutating-methods.d.ts.map +1 -0
  24. package/dist/rules/no-array-mutating-methods.js +65 -0
  25. package/dist/rules/no-array-mutating-methods.js.map +1 -0
  26. package/dist/rules/no-async-without-await.d.ts +5 -0
  27. package/dist/rules/no-async-without-await.d.ts.map +1 -0
  28. package/dist/rules/no-async-without-await.js +45 -0
  29. package/dist/rules/no-async-without-await.js.map +1 -0
  30. package/dist/rules/no-catch-instanceof.d.ts +5 -0
  31. package/dist/rules/no-catch-instanceof.d.ts.map +1 -0
  32. package/dist/rules/no-catch-instanceof.js +55 -0
  33. package/dist/rules/no-catch-instanceof.js.map +1 -0
  34. package/dist/rules/no-catch-unknown.d.ts +5 -0
  35. package/dist/rules/no-catch-unknown.d.ts.map +1 -0
  36. package/dist/rules/no-catch-unknown.js +32 -0
  37. package/dist/rules/no-catch-unknown.js.map +1 -0
  38. package/dist/rules/no-class-mutation.d.ts +5 -0
  39. package/dist/rules/no-class-mutation.d.ts.map +1 -0
  40. package/dist/rules/no-class-mutation.js +44 -0
  41. package/dist/rules/no-class-mutation.js.map +1 -0
  42. package/dist/rules/no-comments.d.ts +5 -0
  43. package/dist/rules/no-comments.d.ts.map +1 -0
  44. package/dist/rules/no-comments.js +27 -0
  45. package/dist/rules/no-comments.js.map +1 -0
  46. package/dist/rules/no-default-export.d.ts +5 -0
  47. package/dist/rules/no-default-export.d.ts.map +1 -0
  48. package/dist/rules/no-default-export.js +22 -0
  49. package/dist/rules/no-default-export.js.map +1 -0
  50. package/dist/rules/no-define-property.d.ts +5 -0
  51. package/dist/rules/no-define-property.d.ts.map +1 -0
  52. package/dist/rules/no-define-property.js +37 -0
  53. package/dist/rules/no-define-property.js.map +1 -0
  54. package/dist/rules/no-delete.d.ts +5 -0
  55. package/dist/rules/no-delete.d.ts.map +1 -0
  56. package/dist/rules/no-delete.js +35 -0
  57. package/dist/rules/no-delete.js.map +1 -0
  58. package/dist/rules/no-empty-string.d.ts +5 -0
  59. package/dist/rules/no-empty-string.d.ts.map +1 -0
  60. package/dist/rules/no-empty-string.js +24 -0
  61. package/dist/rules/no-empty-string.js.map +1 -0
  62. package/dist/rules/no-eval.d.ts +5 -0
  63. package/dist/rules/no-eval.d.ts.map +1 -0
  64. package/dist/rules/no-eval.js +33 -0
  65. package/dist/rules/no-eval.js.map +1 -0
  66. package/dist/rules/no-floating-promise.d.ts +5 -0
  67. package/dist/rules/no-floating-promise.d.ts.map +1 -0
  68. package/dist/rules/no-floating-promise.js +74 -0
  69. package/dist/rules/no-floating-promise.js.map +1 -0
  70. package/dist/rules/no-for-in.d.ts +5 -0
  71. package/dist/rules/no-for-in.d.ts.map +1 -0
  72. package/dist/rules/no-for-in.js +24 -0
  73. package/dist/rules/no-for-in.js.map +1 -0
  74. package/dist/rules/no-generic-names.d.ts +12 -0
  75. package/dist/rules/no-generic-names.d.ts.map +1 -0
  76. package/dist/rules/no-generic-names.js +104 -0
  77. package/dist/rules/no-generic-names.js.map +1 -0
  78. package/dist/rules/no-implicit-coercion.d.ts +7 -0
  79. package/dist/rules/no-implicit-coercion.d.ts.map +1 -0
  80. package/dist/rules/no-implicit-coercion.js +33 -0
  81. package/dist/rules/no-implicit-coercion.js.map +1 -0
  82. package/dist/rules/no-legacy-globals.d.ts +7 -0
  83. package/dist/rules/no-legacy-globals.d.ts.map +1 -0
  84. package/dist/rules/no-legacy-globals.js +58 -0
  85. package/dist/rules/no-legacy-globals.js.map +1 -0
  86. package/dist/rules/no-loop-func.d.ts +5 -0
  87. package/dist/rules/no-loop-func.d.ts.map +1 -0
  88. package/dist/rules/no-loop-func.js +50 -0
  89. package/dist/rules/no-loop-func.js.map +1 -0
  90. package/dist/rules/no-map-set-mutation.d.ts +5 -0
  91. package/dist/rules/no-map-set-mutation.d.ts.map +1 -0
  92. package/dist/rules/no-map-set-mutation.js +69 -0
  93. package/dist/rules/no-map-set-mutation.js.map +1 -0
  94. package/dist/rules/no-mutable-exports.d.ts +5 -0
  95. package/dist/rules/no-mutable-exports.d.ts.map +1 -0
  96. package/dist/rules/no-mutable-exports.js +29 -0
  97. package/dist/rules/no-mutable-exports.js.map +1 -0
  98. package/dist/rules/no-nan-array-indexof.d.ts +5 -0
  99. package/dist/rules/no-nan-array-indexof.d.ts.map +1 -0
  100. package/dist/rules/no-nan-array-indexof.js +33 -0
  101. package/dist/rules/no-nan-array-indexof.js.map +1 -0
  102. package/dist/rules/no-nan-in-math-result.d.ts +5 -0
  103. package/dist/rules/no-nan-in-math-result.d.ts.map +1 -0
  104. package/dist/rules/no-nan-in-math-result.js +58 -0
  105. package/dist/rules/no-nan-in-math-result.js.map +1 -0
  106. package/dist/rules/no-nan.d.ts +5 -0
  107. package/dist/rules/no-nan.d.ts.map +1 -0
  108. package/dist/rules/no-nan.js +26 -0
  109. package/dist/rules/no-nan.js.map +1 -0
  110. package/dist/rules/no-new-wrappers.d.ts +5 -0
  111. package/dist/rules/no-new-wrappers.d.ts.map +1 -0
  112. package/dist/rules/no-new-wrappers.js +47 -0
  113. package/dist/rules/no-new-wrappers.js.map +1 -0
  114. package/dist/rules/no-new.d.ts +5 -0
  115. package/dist/rules/no-new.d.ts.map +1 -0
  116. package/dist/rules/no-new.js +111 -0
  117. package/dist/rules/no-new.js.map +1 -0
  118. package/dist/rules/no-non-null-assertion.d.ts +5 -0
  119. package/dist/rules/no-non-null-assertion.d.ts.map +1 -0
  120. package/dist/rules/no-non-null-assertion.js +22 -0
  121. package/dist/rules/no-non-null-assertion.js.map +1 -0
  122. package/dist/rules/no-null-undefined.d.ts +7 -0
  123. package/dist/rules/no-null-undefined.d.ts.map +1 -0
  124. package/dist/rules/no-null-undefined.js +34 -0
  125. package/dist/rules/no-null-undefined.js.map +1 -0
  126. package/dist/rules/no-nullish-operators.d.ts +7 -0
  127. package/dist/rules/no-nullish-operators.d.ts.map +1 -0
  128. package/dist/rules/no-nullish-operators.js +31 -0
  129. package/dist/rules/no-nullish-operators.js.map +1 -0
  130. package/dist/rules/no-object-assign-mutation.d.ts +5 -0
  131. package/dist/rules/no-object-assign-mutation.d.ts.map +1 -0
  132. package/dist/rules/no-object-assign-mutation.js +36 -0
  133. package/dist/rules/no-object-assign-mutation.js.map +1 -0
  134. package/dist/rules/no-param-reassign.d.ts +5 -0
  135. package/dist/rules/no-param-reassign.d.ts.map +1 -0
  136. package/dist/rules/no-param-reassign.js +89 -0
  137. package/dist/rules/no-param-reassign.js.map +1 -0
  138. package/dist/rules/no-parseint-nan.d.ts +5 -0
  139. package/dist/rules/no-parseint-nan.d.ts.map +1 -0
  140. package/dist/rules/no-parseint-nan.js +64 -0
  141. package/dist/rules/no-parseint-nan.js.map +1 -0
  142. package/dist/rules/no-placeholder-names.d.ts +12 -0
  143. package/dist/rules/no-placeholder-names.d.ts.map +1 -0
  144. package/dist/rules/no-placeholder-names.js +107 -0
  145. package/dist/rules/no-placeholder-names.js.map +1 -0
  146. package/dist/rules/no-process-env.d.ts +5 -0
  147. package/dist/rules/no-process-env.d.ts.map +1 -0
  148. package/dist/rules/no-process-env.js +31 -0
  149. package/dist/rules/no-process-env.js.map +1 -0
  150. package/dist/rules/no-prototype-mutation.d.ts +5 -0
  151. package/dist/rules/no-prototype-mutation.d.ts.map +1 -0
  152. package/dist/rules/no-prototype-mutation.js +30 -0
  153. package/dist/rules/no-prototype-mutation.js.map +1 -0
  154. package/dist/rules/no-require.d.ts +5 -0
  155. package/dist/rules/no-require.d.ts.map +1 -0
  156. package/dist/rules/no-require.js +37 -0
  157. package/dist/rules/no-require.js.map +1 -0
  158. package/dist/rules/no-shadow.d.ts +5 -0
  159. package/dist/rules/no-shadow.d.ts.map +1 -0
  160. package/dist/rules/no-shadow.js +103 -0
  161. package/dist/rules/no-shadow.js.map +1 -0
  162. package/dist/rules/no-string-concat.d.ts +5 -0
  163. package/dist/rules/no-string-concat.d.ts.map +1 -0
  164. package/dist/rules/no-string-concat.js +36 -0
  165. package/dist/rules/no-string-concat.js.map +1 -0
  166. package/dist/rules/no-throw-literal.d.ts +5 -0
  167. package/dist/rules/no-throw-literal.d.ts.map +1 -0
  168. package/dist/rules/no-throw-literal.js +33 -0
  169. package/dist/rules/no-throw-literal.js.map +1 -0
  170. package/dist/rules/no-type-assertion.d.ts +5 -0
  171. package/dist/rules/no-type-assertion.d.ts.map +1 -0
  172. package/dist/rules/no-type-assertion.js +25 -0
  173. package/dist/rules/no-type-assertion.js.map +1 -0
  174. package/dist/rules/no-typeof.d.ts +5 -0
  175. package/dist/rules/no-typeof.d.ts.map +1 -0
  176. package/dist/rules/no-typeof.js +24 -0
  177. package/dist/rules/no-typeof.js.map +1 -0
  178. package/dist/rules/no-unknown.d.ts +5 -0
  179. package/dist/rules/no-unknown.d.ts.map +1 -0
  180. package/dist/rules/no-unknown.js +22 -0
  181. package/dist/rules/no-unknown.js.map +1 -0
  182. package/dist/rules/prefer-includes.d.ts +5 -0
  183. package/dist/rules/prefer-includes.d.ts.map +1 -0
  184. package/dist/rules/prefer-includes.js +50 -0
  185. package/dist/rules/prefer-includes.js.map +1 -0
  186. package/dist/rules/prefer-readonly-params.d.ts +5 -0
  187. package/dist/rules/prefer-readonly-params.d.ts.map +1 -0
  188. package/dist/rules/prefer-readonly-params.js +100 -0
  189. package/dist/rules/prefer-readonly-params.js.map +1 -0
  190. package/dist/rules/require-boolean-condition.d.ts +5 -0
  191. package/dist/rules/require-boolean-condition.d.ts.map +1 -0
  192. package/dist/rules/require-boolean-condition.js +60 -0
  193. package/dist/rules/require-boolean-condition.js.map +1 -0
  194. package/dist/rules/require-curly.d.ts +5 -0
  195. package/dist/rules/require-curly.d.ts.map +1 -0
  196. package/dist/rules/require-curly.js +55 -0
  197. package/dist/rules/require-curly.js.map +1 -0
  198. package/dist/rules/require-explicit-return-type.d.ts +5 -0
  199. package/dist/rules/require-explicit-return-type.d.ts.map +1 -0
  200. package/dist/rules/require-explicit-return-type.js +66 -0
  201. package/dist/rules/require-explicit-return-type.js.map +1 -0
  202. package/dist/rules/require-private-constructor.d.ts +5 -0
  203. package/dist/rules/require-private-constructor.d.ts.map +1 -0
  204. package/dist/rules/require-private-constructor.js +34 -0
  205. package/dist/rules/require-private-constructor.js.map +1 -0
  206. package/dist/rules/same-type-comparison.d.ts +5 -0
  207. package/dist/rules/same-type-comparison.d.ts.map +1 -0
  208. package/dist/rules/same-type-comparison.js +71 -0
  209. package/dist/rules/same-type-comparison.js.map +1 -0
  210. package/package.json +46 -0
@@ -0,0 +1,26 @@
1
+ import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
2
+ const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/fookiejs/eslint-plugin-fookie/blob/main/docs/rules/${name}.md`);
3
+ export const noNan = createRule({
4
+ name: "no-nan",
5
+ meta: {
6
+ type: "problem",
7
+ docs: {
8
+ description: "Disallow the use of NaN keyword",
9
+ },
10
+ schema: [],
11
+ messages: {
12
+ noNaN: "Do not use NaN directly. Use Number.isNaN() to check for NaN values.",
13
+ },
14
+ },
15
+ defaultOptions: [],
16
+ create(context) {
17
+ return {
18
+ Identifier(node) {
19
+ if (node.name === "NaN") {
20
+ context.report({ node, messageId: "noNaN" });
21
+ }
22
+ },
23
+ };
24
+ },
25
+ });
26
+ //# sourceMappingURL=no-nan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-nan.js","sourceRoot":"","sources":["../../src/rules/no-nan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEhE,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CACP,yEAAyE,IAAI,KAAK,CACrF,CAAA;AAKD,MAAM,CAAC,MAAM,KAAK,GAAG,UAAU,CAAsB;IACnD,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,iCAAiC;SAC/C;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,KAAK,EACH,sEAAsE;SACzE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,UAAU,CAAC,IAAyB;gBAClC,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;oBACxB,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAA;gBAC9C,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export declare const noNewWrappers: ESLintUtils.RuleModule<"noNewWrapper", [], unknown, ESLintUtils.RuleListener> & {
3
+ name: string;
4
+ };
5
+ //# sourceMappingURL=no-new-wrappers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-new-wrappers.d.ts","sourceRoot":"","sources":["../../src/rules/no-new-wrappers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAY,MAAM,0BAA0B,CAAA;AAmBhF,eAAO,MAAM,aAAa;;CA+BxB,CAAA"}
@@ -0,0 +1,47 @@
1
+ import { AST_NODE_TYPES, ESLintUtils, TSESTree } from "@typescript-eslint/utils";
2
+ const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/fookiejs/eslint-plugin-fookie/blob/main/docs/rules/${name}.md`);
3
+ function getWrapperReplacement(name) {
4
+ if (name === "String")
5
+ return "use a string literal or String(x) without new";
6
+ if (name === "Number")
7
+ return "use a number literal or Number(x) without new";
8
+ if (name === "Boolean")
9
+ return "use true / false or Boolean(x) without new";
10
+ if (name === "Object")
11
+ return "use an object literal {}";
12
+ if (name === "Array")
13
+ return "use an array literal []";
14
+ return false;
15
+ }
16
+ export const noNewWrappers = createRule({
17
+ name: "no-new-wrappers",
18
+ meta: {
19
+ type: "problem",
20
+ docs: {
21
+ description: "Disallow primitive wrapper constructors: new String(), new Number(), new Boolean(), new Object(), new Array()",
22
+ },
23
+ schema: [],
24
+ messages: {
25
+ noNewWrapper: "Do not use 'new {{name}}()'. Instead: {{replacement}}.",
26
+ },
27
+ },
28
+ defaultOptions: [],
29
+ create(context) {
30
+ return {
31
+ NewExpression(node) {
32
+ if (node.callee.type !== AST_NODE_TYPES.Identifier)
33
+ return;
34
+ const name = node.callee.name;
35
+ const replacement = getWrapperReplacement(name);
36
+ if (replacement !== false) {
37
+ context.report({
38
+ node,
39
+ messageId: "noNewWrapper",
40
+ data: { name, replacement },
41
+ });
42
+ }
43
+ },
44
+ };
45
+ },
46
+ });
47
+ //# sourceMappingURL=no-new-wrappers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-new-wrappers.js","sourceRoot":"","sources":["../../src/rules/no-new-wrappers.ts"],"names":[],"mappings":"A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E;qBAC5B,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export declare const noNew: ESLintUtils.RuleModule<"noNew", [], unknown, ESLintUtils.RuleListener> & {
3
+ name: string;
4
+ };
5
+ //# sourceMappingURL=no-new.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-new.d.ts","sourceRoot":"","sources":["../../src/rules/no-new.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAY,MAAM,0BAA0B,CAAA;AA6DhE,eAAO,MAAM,KAAK;;CAiEhB,CAAA"}
@@ -0,0 +1,111 @@
1
+ import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
2
+ const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/fookiejs/eslint-plugin-fookie/blob/main/docs/rules/${name}.md`);
3
+ const ALLOWED_BUILTINS = new Set([
4
+ "Error",
5
+ "TypeError",
6
+ "RangeError",
7
+ "ReferenceError",
8
+ "SyntaxError",
9
+ "URIError",
10
+ "EvalError",
11
+ "Map",
12
+ "Set",
13
+ "WeakMap",
14
+ "WeakSet",
15
+ "WeakRef",
16
+ "Promise",
17
+ "URL",
18
+ "URLSearchParams",
19
+ "Date",
20
+ "RegExp",
21
+ "ArrayBuffer",
22
+ "SharedArrayBuffer",
23
+ "DataView",
24
+ "Int8Array",
25
+ "Uint8Array",
26
+ "Uint8ClampedArray",
27
+ "Int16Array",
28
+ "Uint16Array",
29
+ "Int32Array",
30
+ "Uint32Array",
31
+ "Float32Array",
32
+ "Float64Array",
33
+ "BigInt64Array",
34
+ "BigUint64Array",
35
+ "Worker",
36
+ "Blob",
37
+ "File",
38
+ "FormData",
39
+ "Headers",
40
+ "Request",
41
+ "Response",
42
+ "ReadableStream",
43
+ "WritableStream",
44
+ "TransformStream",
45
+ "MutationObserver",
46
+ "IntersectionObserver",
47
+ "ResizeObserver",
48
+ "PerformanceObserver",
49
+ "EventTarget",
50
+ "CustomEvent",
51
+ "AbortController",
52
+ ]);
53
+ export const noNew = createRule({
54
+ name: "no-new",
55
+ meta: {
56
+ type: "suggestion",
57
+ docs: {
58
+ description: "Disallow new keyword for user-defined classes. Use static factory methods instead.",
59
+ },
60
+ schema: [],
61
+ messages: {
62
+ noNew: "Do not use 'new {{name}}(...)'. Use a static factory method like '{{name}}.create(...)' instead.",
63
+ },
64
+ },
65
+ defaultOptions: [],
66
+ create(context) {
67
+ function getEnclosingClassName(node) {
68
+ let current = node.parent;
69
+ while (current) {
70
+ if (current.type === "MethodDefinition" &&
71
+ current.static === true) {
72
+ const classBody = current.parent;
73
+ if (classBody?.type === "ClassBody") {
74
+ const classNode = classBody.parent;
75
+ return classNode.id?.name ?? null;
76
+ }
77
+ }
78
+ current = current.parent;
79
+ }
80
+ return null;
81
+ }
82
+ return {
83
+ NewExpression(node) {
84
+ const callee = node.callee;
85
+ if (callee.type === "Identifier") {
86
+ if (ALLOWED_BUILTINS.has(callee.name))
87
+ return;
88
+ const enclosingClass = getEnclosingClassName(node);
89
+ if (enclosingClass === callee.name)
90
+ return;
91
+ context.report({
92
+ node,
93
+ messageId: "noNew",
94
+ data: { name: callee.name },
95
+ });
96
+ return;
97
+ }
98
+ if (callee.type === "MemberExpression") {
99
+ const prop = callee.property;
100
+ const name = prop.type === "Identifier" ? prop.name : context.getSourceCode().getText(callee);
101
+ context.report({
102
+ node,
103
+ messageId: "noNew",
104
+ data: { name },
105
+ });
106
+ }
107
+ },
108
+ };
109
+ },
110
+ });
111
+ //# sourceMappingURL=no-new.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-new.js","sourceRoot":"","sources":["../../src/rules/no-new.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEhE,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,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AAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export declare const noNonNullAssertion: ESLintUtils.RuleModule<"noNonNull", [], unknown, ESLintUtils.RuleListener> & {
3
+ name: string;
4
+ };
5
+ //# sourceMappingURL=no-non-null-assertion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-non-null-assertion.d.ts","sourceRoot":"","sources":["../../src/rules/no-non-null-assertion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAY,MAAM,0BAA0B,CAAA;AAUhE,eAAO,MAAM,kBAAkB;;CAmB7B,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
2
+ const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/fookiejs/eslint-plugin-fookie/blob/main/docs/rules/${name}.md`);
3
+ export const noNonNullAssertion = createRule({
4
+ name: "no-non-null-assertion",
5
+ meta: {
6
+ type: "problem",
7
+ docs: { description: "Disallow the non-null assertion operator (!)" },
8
+ schema: [],
9
+ messages: {
10
+ noNonNull: "Do not use the non-null assertion operator (!). Narrow the type properly instead.",
11
+ },
12
+ },
13
+ defaultOptions: [],
14
+ create(context) {
15
+ return {
16
+ TSNonNullExpression(node) {
17
+ context.report({ node, messageId: "noNonNull" });
18
+ },
19
+ };
20
+ },
21
+ });
22
+ //# sourceMappingURL=no-non-null-assertion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-non-null-assertion.js","sourceRoot":"","sources":["../../src/rules/no-non-null-assertion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEhE,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CACP,yEAAyE,IAAI,KAAK,CACrF,CAAA;AAKD,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAsB;IAChE,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,EAAE,WAAW,EAAE,8CAA8C,EAAE;QACrE,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,SAAS,EACP,mFAAmF;SACtF;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,mBAAmB,CAAC,IAAkC;gBACpD,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAA;YAClD,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ type MessageIds = "noNull" | "noUndefined" | "noVoidExpr";
3
+ export declare const noNullUndefined: ESLintUtils.RuleModule<MessageIds, [], unknown, ESLintUtils.RuleListener> & {
4
+ name: string;
5
+ };
6
+ export {};
7
+ //# sourceMappingURL=no-null-undefined.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-null-undefined.d.ts","sourceRoot":"","sources":["../../src/rules/no-null-undefined.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAY,MAAM,0BAA0B,CAAA;AAQhE,KAAK,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,YAAY,CAAA;AAEzD,eAAO,MAAM,eAAe;;CAmC1B,CAAA"}
@@ -0,0 +1,34 @@
1
+ import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
2
+ const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/fookiejs/eslint-plugin-fookie/blob/main/docs/rules/${name}.md`);
3
+ export const noNullUndefined = createRule({
4
+ name: "no-null-undefined",
5
+ meta: {
6
+ type: "problem",
7
+ docs: {
8
+ description: "Disallow null, undefined, and void expressions as values",
9
+ },
10
+ schema: [],
11
+ messages: {
12
+ noNull: "Do not use null. Model absence with optional types (T | undefined or T?) instead.",
13
+ noUndefined: "Do not use undefined as a value. Return nothing or use optional types instead.",
14
+ noVoidExpr: "Do not use void expressions. void 0 is just undefined, which is also forbidden here.",
15
+ },
16
+ },
17
+ defaultOptions: [],
18
+ create(context) {
19
+ return {
20
+ "Literal[value=null]"(node) {
21
+ context.report({ node, messageId: "noNull" });
22
+ },
23
+ "Identifier[name='undefined']"(node) {
24
+ context.report({ node, messageId: "noUndefined" });
25
+ },
26
+ UnaryExpression(node) {
27
+ if (node.operator === "void") {
28
+ context.report({ node, messageId: "noVoidExpr" });
29
+ }
30
+ },
31
+ };
32
+ },
33
+ });
34
+ //# sourceMappingURL=no-null-undefined.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-null-undefined.js","sourceRoot":"","sources":["../../src/rules/no-null-undefined.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEhE,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CACP,yEAAyE,IAAI,KAAK,CACrF,CAAA;AAKD,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAsB;IAC7D,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,0DAA0D;SACxE;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,MAAM,EACJ,mFAAmF;YACrF,WAAW,EACT,gFAAgF;YAClF,UAAU,EACR,sFAAsF;SACzF;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,qBAAqB,CAAC,IAAsB;gBAC1C,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAA;YAC/C,CAAC;YAED,8BAA8B,CAAC,IAAyB;gBACtD,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAA;YACpD,CAAC;YAED,eAAe,CAAC,IAA8B;gBAC5C,IAAI,IAAI,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;oBAC7B,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAA;gBACnD,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ type MessageIds = "noNullish" | "noOptionalChain";
3
+ export declare const noNullishOperators: ESLintUtils.RuleModule<MessageIds, [], unknown, ESLintUtils.RuleListener> & {
4
+ name: string;
5
+ };
6
+ export {};
7
+ //# sourceMappingURL=no-nullish-operators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-nullish-operators.d.ts","sourceRoot":"","sources":["../../src/rules/no-nullish-operators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAY,MAAM,0BAA0B,CAAA;AAQhE,KAAK,UAAU,GAAG,WAAW,GAAG,iBAAiB,CAAA;AAEjD,eAAO,MAAM,kBAAkB;;CA8B7B,CAAA"}
@@ -0,0 +1,31 @@
1
+ import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
2
+ const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/fookiejs/eslint-plugin-fookie/blob/main/docs/rules/${name}.md`);
3
+ export const noNullishOperators = createRule({
4
+ name: "no-nullish-operators",
5
+ meta: {
6
+ type: "problem",
7
+ docs: {
8
+ description: "Disallow nullish coalescing (??) and optional chaining (?.) operators",
9
+ },
10
+ schema: [],
11
+ messages: {
12
+ noNullish: "Do not use the nullish coalescing operator (??). null and undefined are forbidden — design types that don't need this.",
13
+ noOptionalChain: "Do not use optional chaining (?.). null and undefined are forbidden — design types that guarantee presence.",
14
+ },
15
+ },
16
+ defaultOptions: [],
17
+ create(context) {
18
+ return {
19
+ "LogicalExpression[operator='??']"(node) {
20
+ context.report({ node, messageId: "noNullish" });
21
+ },
22
+ "MemberExpression[optional=true]"(node) {
23
+ context.report({ node, messageId: "noOptionalChain" });
24
+ },
25
+ "CallExpression[optional=true]"(node) {
26
+ context.report({ node, messageId: "noOptionalChain" });
27
+ },
28
+ };
29
+ },
30
+ });
31
+ //# sourceMappingURL=no-nullish-operators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-nullish-operators.js","sourceRoot":"","sources":["../../src/rules/no-nullish-operators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEhE,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CACP,yEAAyE,IAAI,KAAK,CACrF,CAAA;AAKD,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAsB;IAChE,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,uEAAuE;SAC1E;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,SAAS,EACP,wHAAwH;YAC1H,eAAe,EACb,6GAA6G;SAChH;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,kCAAkC,CAAC,IAAgC;gBACjE,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAA;YAClD,CAAC;YACD,iCAAiC,CAAC,IAA+B;gBAC/D,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC,CAAA;YACxD,CAAC;YACD,+BAA+B,CAAC,IAA6B;gBAC3D,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC,CAAA;YACxD,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export declare const noObjectAssignMutation: ESLintUtils.RuleModule<"noObjectAssignMutation", [], unknown, ESLintUtils.RuleListener> & {
3
+ name: string;
4
+ };
5
+ //# sourceMappingURL=no-object-assign-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-object-assign-mutation.d.ts","sourceRoot":"","sources":["../../src/rules/no-object-assign-mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAY,MAAM,0BAA0B,CAAA;AAUhE,eAAO,MAAM,sBAAsB;;CAqCjC,CAAA"}
@@ -0,0 +1,36 @@
1
+ import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
2
+ const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/fookiejs/eslint-plugin-fookie/blob/main/docs/rules/${name}.md`);
3
+ export const noObjectAssignMutation = createRule({
4
+ name: "no-object-assign-mutation",
5
+ meta: {
6
+ type: "problem",
7
+ docs: {
8
+ description: "Disallow Object.assign() with an existing object as the first argument. Use a fresh {} target to avoid mutating existing references.",
9
+ },
10
+ schema: [],
11
+ messages: {
12
+ noObjectAssignMutation: "Object.assign() with an existing reference as target mutates it in place. Use Object.assign({}, ...) or spread syntax { ...obj } instead.",
13
+ },
14
+ },
15
+ defaultOptions: [],
16
+ create(context) {
17
+ return {
18
+ CallExpression(node) {
19
+ if (node.callee.type !== "MemberExpression" ||
20
+ node.callee.object.type !== "Identifier" ||
21
+ node.callee.object.name !== "Object" ||
22
+ node.callee.property.type !== "Identifier" ||
23
+ node.callee.property.name !== "assign") {
24
+ return;
25
+ }
26
+ if (node.arguments.length === 0)
27
+ return;
28
+ const firstArg = node.arguments[0];
29
+ if (firstArg && firstArg.type !== "ObjectExpression") {
30
+ context.report({ node, messageId: "noObjectAssignMutation" });
31
+ }
32
+ },
33
+ };
34
+ },
35
+ });
36
+ //# sourceMappingURL=no-object-assign-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-object-assign-mutation.js","sourceRoot":"","sources":["../../src/rules/no-object-assign-mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEhE,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CACP,yEAAyE,IAAI,KAAK,CACrF,CAAA;AAKD,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAAsB;IACpE,IAAI,EAAE,2BAA2B;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,sIAAsI;SACzI;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,sBAAsB,EACpB,2IAA2I;SAC9I;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,cAAc,CAAC,IAA6B;gBAC1C,IACE,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kBAAkB;oBACvC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY;oBACxC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ;oBACpC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY;oBAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,EACtC,CAAC;oBACD,OAAM;gBACR,CAAC;gBAED,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;oBAAE,OAAM;gBAEvC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;gBAClC,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;oBACrD,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,wBAAwB,EAAE,CAAC,CAAA;gBAC/D,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export declare const noParamReassign: ESLintUtils.RuleModule<"noParamReassign", [], unknown, ESLintUtils.RuleListener> & {
3
+ name: string;
4
+ };
5
+ //# sourceMappingURL=no-param-reassign.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-param-reassign.d.ts","sourceRoot":"","sources":["../../src/rules/no-param-reassign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAY,MAAM,0BAA0B,CAAA;AA6ChF,eAAO,MAAM,eAAe;;CA+D1B,CAAA"}
@@ -0,0 +1,89 @@
1
+ import { AST_NODE_TYPES, ESLintUtils, TSESTree } from "@typescript-eslint/utils";
2
+ const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/fookiejs/eslint-plugin-fookie/blob/main/docs/rules/${name}.md`);
3
+ function getParamNames(params) {
4
+ const names = new Set();
5
+ for (const param of params) {
6
+ collectBindingNames(param, names);
7
+ }
8
+ return names;
9
+ }
10
+ function collectBindingNames(node, names) {
11
+ switch (node.type) {
12
+ case AST_NODE_TYPES.Identifier:
13
+ names.add(node.name);
14
+ break;
15
+ case AST_NODE_TYPES.AssignmentPattern:
16
+ collectBindingNames(node.left, names);
17
+ break;
18
+ case AST_NODE_TYPES.RestElement:
19
+ collectBindingNames(node.argument, names);
20
+ break;
21
+ case AST_NODE_TYPES.ObjectPattern:
22
+ for (const prop of node.properties) {
23
+ collectBindingNames(prop, names);
24
+ }
25
+ break;
26
+ case AST_NODE_TYPES.ArrayPattern:
27
+ for (const el of node.elements) {
28
+ if (el !== null)
29
+ collectBindingNames(el, names);
30
+ }
31
+ break;
32
+ case AST_NODE_TYPES.Property:
33
+ collectBindingNames(node.value, names);
34
+ break;
35
+ }
36
+ }
37
+ export const noParamReassign = createRule({
38
+ name: "no-param-reassign",
39
+ meta: {
40
+ type: "problem",
41
+ docs: { description: "Disallow reassignment of function parameters" },
42
+ schema: [],
43
+ messages: {
44
+ noParamReassign: "Do not reassign parameter '{{name}}'. Mutating parameters makes data flow harder to reason about.",
45
+ },
46
+ },
47
+ defaultOptions: [],
48
+ create(context) {
49
+ let paramScopeStack = [];
50
+ function enterFunction(node) {
51
+ paramScopeStack = [...paramScopeStack, getParamNames(node.params)];
52
+ }
53
+ function exitFunction() {
54
+ paramScopeStack = paramScopeStack.slice(0, -1);
55
+ }
56
+ function currentParams() {
57
+ return paramScopeStack[paramScopeStack.length - 1] ?? new Set();
58
+ }
59
+ return {
60
+ FunctionDeclaration: enterFunction,
61
+ FunctionExpression: enterFunction,
62
+ ArrowFunctionExpression: enterFunction,
63
+ "FunctionDeclaration:exit": exitFunction,
64
+ "FunctionExpression:exit": exitFunction,
65
+ "ArrowFunctionExpression:exit": exitFunction,
66
+ AssignmentExpression(node) {
67
+ const left = node.left;
68
+ if (left.type === AST_NODE_TYPES.Identifier && currentParams().has(left.name)) {
69
+ context.report({
70
+ node,
71
+ messageId: "noParamReassign",
72
+ data: { name: left.name },
73
+ });
74
+ }
75
+ },
76
+ UpdateExpression(node) {
77
+ const arg = node.argument;
78
+ if (arg.type === AST_NODE_TYPES.Identifier && currentParams().has(arg.name)) {
79
+ context.report({
80
+ node,
81
+ messageId: "noParamReassign",
82
+ data: { name: arg.name },
83
+ });
84
+ }
85
+ },
86
+ };
87
+ },
88
+ });
89
+ //# sourceMappingURL=no-param-reassign.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-param-reassign.js","sourceRoot":"","sources":["../../src/rules/no-param-reassign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEhF,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CACP,yEAAyE,IAAI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BACzB,IAAI,GAAG,CAAC,IAAI,KAAK,cAAc,CAAC,UAAU,IAAI,aAAa,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC5E,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAE,iBAAiB;wBAC5B,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE;qBACzB,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export declare const noParseIntNan: ESLintUtils.RuleModule<"noParseIntNan", [], unknown, ESLintUtils.RuleListener> & {
3
+ name: string;
4
+ };
5
+ //# sourceMappingURL=no-parseint-nan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-parseint-nan.d.ts","sourceRoot":"","sources":["../../src/rules/no-parseint-nan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAY,MAAM,0BAA0B,CAAA;AA4BhE,eAAO,MAAM,aAAa;;CAiDxB,CAAA"}
@@ -0,0 +1,64 @@
1
+ import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
2
+ const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/fookiejs/eslint-plugin-fookie/blob/main/docs/rules/${name}.md`);
3
+ const ARITHMETIC_OPS = new Set(["+", "-", "*", "/", "%", "**"]);
4
+ function isParseCall(node) {
5
+ if (node.type !== "CallExpression")
6
+ return false;
7
+ const callee = node.callee;
8
+ if (callee.type === "Identifier") {
9
+ return callee.name === "parseInt" || callee.name === "parseFloat";
10
+ }
11
+ if (callee.type === "MemberExpression") {
12
+ const prop = callee.property;
13
+ return (prop.type === "Identifier" &&
14
+ (prop.name === "parseInt" || prop.name === "parseFloat"));
15
+ }
16
+ return false;
17
+ }
18
+ export const noParseIntNan = createRule({
19
+ name: "no-parseint-nan",
20
+ meta: {
21
+ type: "problem",
22
+ docs: {
23
+ description: "Disallow using parseInt/parseFloat results directly in arithmetic without a NaN guard",
24
+ },
25
+ schema: [],
26
+ messages: {
27
+ noParseIntNan: "{{fn}}() can return NaN for invalid input. Guard with Number.isNaN() before using in arithmetic.",
28
+ },
29
+ },
30
+ defaultOptions: [],
31
+ create(context) {
32
+ function getFnName(node) {
33
+ const callee = node.callee;
34
+ if (callee.type === "Identifier")
35
+ return callee.name;
36
+ if (callee.type === "MemberExpression" &&
37
+ callee.property.type === "Identifier") {
38
+ return callee.property.name;
39
+ }
40
+ return "parseInt/parseFloat";
41
+ }
42
+ return {
43
+ BinaryExpression(node) {
44
+ if (!ARITHMETIC_OPS.has(node.operator))
45
+ return;
46
+ if (isParseCall(node.left)) {
47
+ context.report({
48
+ node: node.left,
49
+ messageId: "noParseIntNan",
50
+ data: { fn: getFnName(node.left) },
51
+ });
52
+ }
53
+ if (isParseCall(node.right)) {
54
+ context.report({
55
+ node: node.right,
56
+ messageId: "noParseIntNan",
57
+ data: { fn: getFnName(node.right) },
58
+ });
59
+ }
60
+ },
61
+ };
62
+ },
63
+ });
64
+ //# sourceMappingURL=no-parseint-nan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-parseint-nan.js","sourceRoot":"","sources":["../../src/rules/no-parseint-nan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAEhE,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CACP,yEAAyE,IAAI,KAAK,CACrF,CAAA;AAKD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;AAE/D,SAAS,WAAW,CAAC,IAAmB;IACtC,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB;QAAE,OAA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AAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC;oBAAE,OAAM;gBAE9C,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC3B,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,IAAI,CAAC,IAAI;wBACf,SAAS,EAAE,eAAe;wBAC1B,IAAI,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,IAA+B,CAAC,EAAE;qBAC9D,CAAC,CAAA;gBACJ,CAAC;gBACD,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC5B,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,IAAI,CAAC,KAAK;wBAChB,SAAS,EAAE,eAAe;wBAC1B,IAAI,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,KAAgC,CAAC,EAAE;qBAC/D,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ type Options = [
3
+ {
4
+ blocklist?: string[];
5
+ allowSingleLetterInLoops?: boolean;
6
+ }?
7
+ ];
8
+ export declare const noPlaceholderNames: ESLintUtils.RuleModule<"placeholderName", Options, unknown, ESLintUtils.RuleListener> & {
9
+ name: string;
10
+ };
11
+ export {};
12
+ //# sourceMappingURL=no-placeholder-names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-placeholder-names.d.ts","sourceRoot":"","sources":["../../src/rules/no-placeholder-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAY,MAAM,0BAA0B,CAAA;AAmBhF,KAAK,OAAO,GAAG;IACb;QACE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;QACpB,wBAAwB,CAAC,EAAE,OAAO,CAAA;KACnC,CAAC;CACH,CAAA;AA8CD,eAAO,MAAM,kBAAkB;;CAyD7B,CAAA"}