eslint-plugin-mgw-eslint-rules 2.3.32 → 2.3.34

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.js CHANGED
@@ -3200,11 +3200,11 @@ var require_getParserServices = __commonJS({
3200
3200
  "node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js"(exports2) {
3201
3201
  "use strict";
3202
3202
  Object.defineProperty(exports2, "__esModule", { value: true });
3203
- exports2.getParserServices = getParserServices;
3203
+ exports2.getParserServices = getParserServices3;
3204
3204
  var parserSeemsToBeTSESLint_1 = require_parserSeemsToBeTSESLint();
3205
3205
  var ERROR_MESSAGE_REQUIRES_PARSER_SERVICES = "You have used a rule which requires type information, but don't have parserOptions set to generate type information for this file. See https://tseslint.com/typed-linting for enabling linting with type information.";
3206
3206
  var ERROR_MESSAGE_UNKNOWN_PARSER = 'Note: detected a parser other than @typescript-eslint/parser. Make sure the parser is configured to forward "parserOptions.project" to @typescript-eslint/parser.';
3207
- function getParserServices(context, allowWithoutFullTypeInformation = false) {
3207
+ function getParserServices3(context, allowWithoutFullTypeInformation = false) {
3208
3208
  const parser = context.parserPath || context.languageOptions.parser?.meta?.name;
3209
3209
  if (context.sourceCode.parserServices?.esTreeNodeToTSNodeMap == null || context.sourceCode.parserServices.tsNodeToESTreeNodeMap == null) {
3210
3210
  throwError(parser);
@@ -44026,6 +44026,7 @@ var rule2 = createRule2({
44026
44026
 
44027
44027
  // src/rules/enforce-angular-signal-call.ts
44028
44028
  var import_utils3 = __toESM(require_dist4());
44029
+ var import_eslint_utils = __toESM(require_eslint_utils3());
44029
44030
  var RULE_NAME3 = "enforce-angular-signal-call";
44030
44031
  var createRule3 = import_utils3.ESLintUtils.RuleCreator((name) => `https://github.com/developpement-megao/mgw-eslint-rules/docs/rules/${name}.md`);
44031
44032
  var rule3 = createRule3({
@@ -44043,36 +44044,33 @@ var rule3 = createRule3({
44043
44044
  },
44044
44045
  defaultOptions: [],
44045
44046
  create(context) {
44047
+ const services = (0, import_eslint_utils.getParserServices)(context);
44048
+ const checker = services.program.getTypeChecker();
44046
44049
  function isSignal(type) {
44047
44050
  const withoutGeneric = type.split("<")[0];
44048
- return !!withoutGeneric && ["Signal", "WritableSignal", "InputSignal"].includes(withoutGeneric);
44049
- }
44050
- const { sourceCode } = context;
44051
- const services = sourceCode.parserServices;
44052
- if (!services || !services.program || !services.esTreeNodeToTSNodeMap) {
44053
- return {};
44051
+ if (withoutGeneric) {
44052
+ return ["Signal", "WritableSignal", "InputSignal"].includes(withoutGeneric);
44053
+ }
44054
+ return false;
44054
44055
  }
44055
- const checker = services.program.getTypeChecker();
44056
44056
  return {
44057
44057
  Identifier(node) {
44058
- const variableNode = services.esTreeNodeToTSNodeMap?.get(node);
44059
- if (variableNode) {
44060
- const type = checker.getTypeAtLocation(variableNode);
44061
- const typeName = checker.typeToString(type);
44062
- if (isSignal(typeName)) {
44063
- const parent = node.parent;
44064
- if (!parent || parent.type !== import_utils3.AST_NODE_TYPES.CallExpression) {
44065
- return;
44066
- }
44067
- const callee = parent.callee;
44068
- if (callee.type !== import_utils3.AST_NODE_TYPES.Identifier || callee.name !== node.name) {
44069
- return;
44070
- }
44071
- context.report({
44072
- node,
44073
- messageId: "useGetter"
44074
- });
44058
+ const variableNode = services.esTreeNodeToTSNodeMap.get(node);
44059
+ const type = checker.getTypeAtLocation(variableNode);
44060
+ const typeName = checker.typeToString(type);
44061
+ if (isSignal(typeName)) {
44062
+ const parent = node.parent;
44063
+ if (!parent || parent.type !== import_utils3.AST_NODE_TYPES.CallExpression) {
44064
+ return;
44075
44065
  }
44066
+ const callee = parent.callee;
44067
+ if (callee.type !== import_utils3.AST_NODE_TYPES.Identifier || callee.name !== node.name) {
44068
+ return;
44069
+ }
44070
+ context.report({
44071
+ node,
44072
+ messageId: "useGetter"
44073
+ });
44076
44074
  }
44077
44075
  }
44078
44076
  };
@@ -44248,6 +44246,7 @@ var rule6 = createRule6({
44248
44246
 
44249
44247
  // src/rules/reactive-naming-convention.ts
44250
44248
  var import_utils7 = __toESM(require_dist4());
44249
+ var import_eslint_utils2 = __toESM(require_eslint_utils3());
44251
44250
  var RULE_NAME7 = "reactive-naming-convention";
44252
44251
  var createRule7 = import_utils7.ESLintUtils.RuleCreator((name) => `https://github.com/developpement-megao/mgw-eslint-rules/docs/rules/${name}.md`);
44253
44252
  var rule7 = createRule7({
@@ -44269,32 +44268,32 @@ var rule7 = createRule7({
44269
44268
  },
44270
44269
  defaultOptions: [],
44271
44270
  create(context) {
44272
- const parserServices = context.sourceCode.parserServices;
44273
- if (!parserServices?.program || !parserServices.esTreeNodeToTSNodeMap) {
44274
- return {};
44275
- }
44271
+ const services = (0, import_eslint_utils2.getParserServices)(context);
44272
+ const checker = services.program.getTypeChecker();
44276
44273
  const listeReactiveWritableTypes = ["Subject", "WritableSignal", "InputSignal"];
44277
44274
  const listeReactiveReadonlyTypes = ["Signal", "Observable", "Promise"];
44278
- const checker = parserServices.program.getTypeChecker();
44275
+ function getTypeWithoutGeneric(type) {
44276
+ return type.split("<")[0];
44277
+ }
44279
44278
  function checkNode(node, messageId) {
44280
44279
  const name = node.name;
44281
- if (!name || name === "_" || !parserServices?.esTreeNodeToTSNodeMap) {
44280
+ if (!name || name === "_") {
44282
44281
  return;
44283
44282
  }
44284
- const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
44283
+ const tsNode = services.esTreeNodeToTSNodeMap.get(node);
44285
44284
  const type = checker.getTypeAtLocation(tsNode);
44286
44285
  const typeName = checker.typeToString(type);
44287
- const isReactiveWritableTypes = listeReactiveWritableTypes.some((t) => new RegExp(`${t}<.+>`).test(typeName));
44286
+ const typeNameWithoutGeneric = getTypeWithoutGeneric(typeName);
44287
+ if (!typeNameWithoutGeneric) {
44288
+ return;
44289
+ }
44290
+ const isReactiveWritableTypes = listeReactiveWritableTypes.includes(typeNameWithoutGeneric);
44288
44291
  const suffix = isReactiveWritableTypes ? "$$" : "$";
44289
- if ((isReactiveWritableTypes || listeReactiveReadonlyTypes.some((t) => new RegExp(`${t}<.+>`).test(typeName))) && (!name.endsWith(suffix) || suffix === "$" && name.endsWith("$$"))) {
44292
+ if ((isReactiveWritableTypes || listeReactiveReadonlyTypes.includes(typeNameWithoutGeneric)) && (!name.endsWith(suffix) || suffix === "$" && name.endsWith("$$"))) {
44290
44293
  context.report({
44291
44294
  node,
44292
44295
  messageId,
44293
- data: {
44294
- typeName,
44295
- name,
44296
- suffix
44297
- },
44296
+ data: { name, suffix },
44298
44297
  fix(fixer) {
44299
44298
  const baseName = name.replace(/\$+$/, "");
44300
44299
  const newName = `${baseName}${suffix}`;