eslint-plugin-nextfriday 5.0.1 → 5.0.2

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/lib/index.js CHANGED
@@ -4,7 +4,7 @@ import path from "path";
4
4
  import emojiRegex from "emoji-regex";
5
5
  //#region package.json
6
6
  var name = "eslint-plugin-nextfriday";
7
- var version = "5.0.1";
7
+ var version = "5.0.2";
8
8
  //#endregion
9
9
  //#region src/rules/boolean-naming-prefix.ts
10
10
  const createRule$26 = ESLintUtils.RuleCreator((name) => `https://github.com/next-friday/eslint-plugin-nextfriday/blob/main/docs/rules/${name.replaceAll("-", "_").toUpperCase()}.md`);
@@ -134,10 +134,15 @@ const SCREAMING_SNAKE_CASE_REGEX$1 = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
134
134
  const SNAKE_CASE_REGEX = /^[a-z]+_[a-z0-9_]*$/;
135
135
  const toScreamingSnakeCase = (str) => str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toUpperCase();
136
136
  const isMagicLiteral = (init) => {
137
- if (init.type === AST_NODE_TYPES.Literal) return typeof init.value === "string" || typeof init.value === "number";
137
+ if (init.type === AST_NODE_TYPES.Literal) return typeof init.value === "string" || typeof init.value === "number" || typeof init.value === "bigint" || "regex" in init;
138
138
  if (init.type === AST_NODE_TYPES.UnaryExpression) {
139
139
  const { argument, operator } = init;
140
- return (operator === "-" || operator === "+") && argument.type === AST_NODE_TYPES.Literal && typeof argument.value === "number";
140
+ if (operator !== "-" && operator !== "+") return false;
141
+ return argument.type === AST_NODE_TYPES.Literal && (typeof argument.value === "number" || typeof argument.value === "bigint");
142
+ }
143
+ if (init.type === AST_NODE_TYPES.NewExpression) {
144
+ if (init.callee.type !== AST_NODE_TYPES.Identifier || init.callee.name !== "RegExp") return false;
145
+ return init.arguments.every((arg) => arg.type === AST_NODE_TYPES.Literal && typeof arg.value === "string");
141
146
  }
142
147
  return false;
143
148
  };
@@ -151,7 +156,7 @@ const enforceConstantCase = createRule$25({
151
156
  name: "enforce-constant-case",
152
157
  meta: {
153
158
  type: "suggestion",
154
- docs: { description: "Enforce SCREAMING_SNAKE_CASE for global magic-number and magic-text constants" },
159
+ docs: { description: "Enforce SCREAMING_SNAKE_CASE for global magic-number, magic-text, bigint, and RegExp constants" },
155
160
  messages: {
156
161
  useScreamingSnakeCase: "Constant '{{ name }}' should use SCREAMING_SNAKE_CASE. Rename to '{{ suggestion }}'.",
157
162
  noSnakeCase: "Global constant '{{ name }}' should not use snake_case. Rename to '{{ suggestion }}'."