angular-eslint-zoneless 1.1.0 → 1.2.1

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/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { ConfigObject } from "@eslint/core";
2
2
  declare const plugin: {
3
3
  configs: {
4
4
  readonly recommended: ConfigObject<import("@eslint/core").RulesConfig>;
5
+ readonly all: ConfigObject<import("@eslint/core").RulesConfig>;
5
6
  };
6
7
  meta: {
7
8
  name: string;
@@ -27,6 +28,7 @@ declare const plugin: {
27
28
  "no-ngzone-testing": import("@eslint/core").RuleDefinition<import("@eslint/core").RuleDefinitionTypeOptions>;
28
29
  "no-detectchanges-testing": import("@eslint/core").RuleDefinition<import("@eslint/core").RuleDefinitionTypeOptions>;
29
30
  "no-zonejs-testing-functions": import("@eslint/core").RuleDefinition<import("@eslint/core").RuleDefinitionTypeOptions>;
31
+ "no-changedetectorref": import("@eslint/core").RuleDefinition<import("@eslint/core").RuleDefinitionTypeOptions>;
30
32
  "no-subscribe-in-component-constructor": import("@eslint/core").RuleDefinition<import("@eslint/core").RuleDefinitionTypeOptions>;
31
33
  };
32
34
  };
package/index.js CHANGED
@@ -32,6 +32,7 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
+ const noChangedetectorref = __importStar(require("./rules/no-changedetectorref.js"));
35
36
  const noContentDecorator = __importStar(require("./rules/no-content-decorator.js"));
36
37
  const noDetectchangesTesting = __importStar(require("./rules/no-detectchanges-testing.js"));
37
38
  const noEagerChangeDetection = __importStar(require("./rules/no-eager-change-detection.js"));
@@ -59,6 +60,9 @@ const plugin = {
59
60
  configs: {
60
61
  get recommended() {
61
62
  return recommended;
63
+ },
64
+ get all() {
65
+ return all;
62
66
  }
63
67
  },
64
68
  meta: { name, version },
@@ -82,6 +86,7 @@ const plugin = {
82
86
  [noNgzoneTesting.ruleName]: noNgzoneTesting.ruleDefinition,
83
87
  [noDetectchangesTesting.ruleName]: noDetectchangesTesting.ruleDefinition,
84
88
  [noZonejsTestingFunctions.ruleName]: noZonejsTestingFunctions.ruleDefinition,
89
+ [noChangedetectorref.ruleName]: noChangedetectorref.ruleDefinition,
85
90
  [noSubscribeInComponentConstructor.ruleName]: noSubscribeInComponentConstructor.ruleDefinition,
86
91
  },
87
92
  };
@@ -111,4 +116,14 @@ const recommended = {
111
116
  [`${name}/${noZonejsTestingFunctions.ruleName}`]: "error",
112
117
  },
113
118
  };
119
+ const all = {
120
+ plugins: {
121
+ [name]: plugin
122
+ },
123
+ rules: {
124
+ ...recommended.rules,
125
+ [`${name}/${noChangedetectorref.ruleName}`]: "error",
126
+ [`${name}/${noSubscribeInComponentConstructor.ruleName}`]: "error",
127
+ },
128
+ };
114
129
  module.exports = plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "angular-eslint-zoneless",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "Angular zoneless lint rules for ESLint",
5
5
  "keywords": [
6
6
  "angular",
@@ -0,0 +1,3 @@
1
+ import type { RuleDefinition } from "@eslint/core";
2
+ export declare const ruleName = "no-changedetectorref";
3
+ export declare const ruleDefinition: RuleDefinition;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ruleDefinition = exports.ruleName = void 0;
4
+ const is_import_identifier_1 = require("../utils/is-import-identifier");
5
+ exports.ruleName = "no-changedetectorref";
6
+ const messageId = "noChangedetectorref";
7
+ exports.ruleDefinition = {
8
+ meta: {
9
+ type: "problem",
10
+ messages: {
11
+ [messageId]: `\`ChangeDetectorRef()\` should be avoided in a zoneless application, use signals and resources reactivity instead.`,
12
+ },
13
+ docs: {
14
+ description: `Checks that \`ChangeDetectorRef()\` is not used.`,
15
+ url: 'https://github.com/cyrilletuzi/angular-eslint-zoneless/blob/main/docs/rules/NO_CHANGEDETECTORREF.md',
16
+ },
17
+ schema: [],
18
+ },
19
+ create(context) {
20
+ return {
21
+ "Identifier[name='ChangeDetectorRef']"(node) {
22
+ /* Ignore the import identifier, otherwise the rule reports twice */
23
+ if (!(0, is_import_identifier_1.isImportIdentifier)(node)) {
24
+ context.report({
25
+ node,
26
+ messageId,
27
+ });
28
+ }
29
+ },
30
+ };
31
+ },
32
+ };
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-content-decorator";
6
5
  const messageId = "noContentDecorator";
7
6
  exports.ruleDefinition = {
@@ -19,16 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- Decorator(node) {
23
- if (node.expression.type === utils_1.AST_NODE_TYPES.CallExpression &&
24
- node.expression.callee.type === utils_1.AST_NODE_TYPES.Identifier &&
25
- (node.expression.callee.name === "ContentChild" ||
26
- node.expression.callee.name === "ContentChildren")) {
27
- context.report({
28
- node,
29
- messageId,
30
- });
31
- }
21
+ "Decorator > CallExpression[callee.type='Identifier'][callee.name=/^(ContentChild|ContentChildren)$/]"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
32
26
  },
33
27
  };
34
28
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  const angular_class_decorator_1 = require("../utils/angular-class-decorator");
6
5
  exports.ruleName = "no-detectchanges-testing";
7
6
  const messageId = "noDetectchangesTesting";
@@ -19,12 +18,10 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- CallExpression(node) {
23
- if (node.callee.type === utils_1.AST_NODE_TYPES.MemberExpression &&
24
- node.callee.property.type === utils_1.AST_NODE_TYPES.Identifier &&
25
- node.callee.property.name === "detectChanges" &&
26
- // Report only in tests, otherwise it will report on `ChangeDetectorRef.detectChanges()`
27
- !(0, angular_class_decorator_1.isInAngularClass)(node, ["Component", "Directive"])) {
21
+ "CallExpression > MemberExpression[property.type='Identifier'][property.name='detectChanges'][computed=false]"(node) {
22
+ if (
23
+ // Report only in tests, otherwise it will report on `ChangeDetectorRef.detectChanges()`
24
+ !(0, angular_class_decorator_1.isInAngularClass)(node, ["Component", "Directive"])) {
28
25
  context.report({
29
26
  node,
30
27
  messageId,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-eager-change-detection";
6
5
  const messageId = "noEagerChangeDetection";
7
6
  exports.ruleDefinition = {
@@ -19,16 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- MemberExpression(node) {
23
- if (node.object.type === utils_1.AST_NODE_TYPES.Identifier &&
24
- node.object.name === "ChangeDetectionStrategy" &&
25
- node.property.type === utils_1.AST_NODE_TYPES.Identifier &&
26
- (node.property.name === "Eager" || node.property.name === "Default")) {
27
- context.report({
28
- node,
29
- messageId,
30
- });
31
- }
21
+ "MemberExpression[object.type='Identifier'][object.name='ChangeDetectionStrategy'][property.type='Identifier'][property.name=/^(Eager|Default)$/]"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
32
26
  },
33
27
  };
34
28
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-input-decorator";
6
5
  const messageId = "noInputDecorator";
7
6
  exports.ruleDefinition = {
@@ -19,15 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- Decorator(node) {
23
- if (node.expression.type === utils_1.AST_NODE_TYPES.CallExpression &&
24
- node.expression.callee.type === utils_1.AST_NODE_TYPES.Identifier &&
25
- node.expression.callee.name === "Input") {
26
- context.report({
27
- node,
28
- messageId,
29
- });
30
- }
21
+ "Decorator > CallExpression[callee.type='Identifier'][callee.name='Input']"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
31
26
  },
32
27
  };
33
28
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-ngaftercontentchecked";
6
5
  const messageId = "noNgaftercontentchecked";
7
6
  exports.ruleDefinition = {
@@ -19,14 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- MethodDefinition(node) {
23
- if (node.key.type === utils_1.AST_NODE_TYPES.Identifier &&
24
- node.key.name === "ngAfterContentChecked") {
25
- context.report({
26
- node,
27
- messageId,
28
- });
29
- }
21
+ "MethodDefinition[key.type='Identifier'][key.name='ngAfterContentChecked']"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
30
26
  },
31
27
  };
32
28
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-ngaftercontentinit";
6
5
  const messageId = "noNgaftercontentinit";
7
6
  exports.ruleDefinition = {
@@ -19,14 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- MethodDefinition(node) {
23
- if (node.key.type === utils_1.AST_NODE_TYPES.Identifier &&
24
- node.key.name === "ngAfterContentInit") {
25
- context.report({
26
- node,
27
- messageId,
28
- });
29
- }
21
+ "MethodDefinition[key.type='Identifier'][key.name='ngAfterContentInit']"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
30
26
  },
31
27
  };
32
28
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-ngafterviewchecked";
6
5
  const messageId = "noNgafterviewchecked";
7
6
  exports.ruleDefinition = {
@@ -19,14 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- MethodDefinition(node) {
23
- if (node.key.type === utils_1.AST_NODE_TYPES.Identifier &&
24
- node.key.name === "ngAfterViewChecked") {
25
- context.report({
26
- node,
27
- messageId,
28
- });
29
- }
21
+ "MethodDefinition[key.type='Identifier'][key.name='ngAfterViewChecked']"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
30
26
  },
31
27
  };
32
28
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-ngafterviewinit";
6
5
  const messageId = "noNgafterviewinit";
7
6
  exports.ruleDefinition = {
@@ -19,14 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- MethodDefinition(node) {
23
- if (node.key.type === utils_1.AST_NODE_TYPES.Identifier &&
24
- node.key.name === "ngAfterViewInit") {
25
- context.report({
26
- node,
27
- messageId,
28
- });
29
- }
21
+ "MethodDefinition[key.type='Identifier'][key.name='ngAfterViewInit']"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
30
26
  },
31
27
  };
32
28
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-ngdocheck";
6
5
  const messageId = "noNgdocheck";
7
6
  exports.ruleDefinition = {
@@ -19,14 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- MethodDefinition(node) {
23
- if (node.key.type === utils_1.AST_NODE_TYPES.Identifier &&
24
- node.key.name === "ngDoCheck") {
25
- context.report({
26
- node,
27
- messageId,
28
- });
29
- }
21
+ "MethodDefinition[key.type='Identifier'][key.name='ngDoCheck']"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
30
26
  },
31
27
  };
32
28
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-ngonchanges";
6
5
  const messageId = "noNgonchanges";
7
6
  exports.ruleDefinition = {
@@ -19,14 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- MethodDefinition(node) {
23
- if (node.key.type === utils_1.AST_NODE_TYPES.Identifier &&
24
- node.key.name === "ngOnChanges") {
25
- context.report({
26
- node,
27
- messageId,
28
- });
29
- }
21
+ "MethodDefinition[key.type='Identifier'][key.name='ngOnChanges']"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
30
26
  },
31
27
  };
32
28
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-ngondestroy";
6
5
  const messageId = "noNgondestroy";
7
6
  exports.ruleDefinition = {
@@ -19,14 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- MethodDefinition(node) {
23
- if (node.key.type === utils_1.AST_NODE_TYPES.Identifier &&
24
- node.key.name === "ngOnDestroy") {
25
- context.report({
26
- node,
27
- messageId,
28
- });
29
- }
21
+ "MethodDefinition[key.type='Identifier'][key.name='ngOnDestroy']"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
30
26
  },
31
27
  };
32
28
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-ngoninit";
6
5
  const messageId = "noNgoninit";
7
6
  exports.ruleDefinition = {
@@ -19,14 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- MethodDefinition(node) {
23
- if (node.key.type === utils_1.AST_NODE_TYPES.Identifier &&
24
- node.key.name === "ngOnInit") {
25
- context.report({
26
- node,
27
- messageId,
28
- });
29
- }
21
+ "MethodDefinition[key.type='Identifier'][key.name='ngOnInit']"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
30
26
  },
31
27
  };
32
28
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-ngzone-testing";
6
5
  const messageId = "noNgzoneTesting";
7
6
  exports.ruleDefinition = {
@@ -18,14 +17,11 @@ exports.ruleDefinition = {
18
17
  },
19
18
  create(context) {
20
19
  return {
21
- MemberExpression(node) {
22
- if (node.property.type === utils_1.AST_NODE_TYPES.Identifier &&
23
- node.property.name === "ngZone") {
24
- context.report({
25
- node,
26
- messageId,
27
- });
28
- }
20
+ "MemberExpression[property.type='Identifier'][property.name='ngZone'][computed=false]"(node) {
21
+ context.report({
22
+ node,
23
+ messageId,
24
+ });
29
25
  },
30
26
  };
31
27
  },
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
+ const is_import_identifier_1 = require("../utils/is-import-identifier");
4
5
  exports.ruleName = "no-ngzone";
5
6
  const messageId = "noNgzone";
6
7
  exports.ruleDefinition = {
@@ -18,8 +19,8 @@ exports.ruleDefinition = {
18
19
  },
19
20
  create(context) {
20
21
  return {
21
- Identifier(node) {
22
- if (node.name === 'NgZone') {
22
+ "Identifier[name='NgZone']"(node) {
23
+ if (!(0, is_import_identifier_1.isImportIdentifier)(node)) {
23
24
  context.report({
24
25
  node,
25
26
  messageId,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-output-decorator";
6
5
  const messageId = "noOutputDecorator";
7
6
  exports.ruleDefinition = {
@@ -19,15 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- Decorator(node) {
23
- if (node.expression.type === utils_1.AST_NODE_TYPES.CallExpression &&
24
- node.expression.callee.type === utils_1.AST_NODE_TYPES.Identifier &&
25
- node.expression.callee.name === "Output") {
26
- context.report({
27
- node,
28
- messageId,
29
- });
30
- }
21
+ "Decorator > CallExpression[callee.type='Identifier'][callee.name='Output']"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
31
26
  },
32
27
  };
33
28
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-providezonechangedetection";
6
5
  const messageId = "noProvidezonechangedetection";
7
6
  exports.ruleDefinition = {
@@ -19,14 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- CallExpression(node) {
23
- if (node.callee.type === utils_1.AST_NODE_TYPES.Identifier &&
24
- node.callee.name === "provideZoneChangeDetection") {
25
- context.report({
26
- node,
27
- messageId,
28
- });
29
- }
21
+ "CallExpression[callee.type='Identifier'][callee.name='provideZoneChangeDetection']"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
30
26
  },
31
27
  };
32
28
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  const in_constructor_1 = require("../utils/in-constructor");
6
5
  exports.ruleName = "no-subscribe-in-component-constructor";
7
6
  const messageId = "noSubscribeInComponentConstructor";
@@ -19,11 +18,8 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- CallExpression(node) {
23
- if (node.callee.type === utils_1.AST_NODE_TYPES.MemberExpression &&
24
- node.callee.property.type === utils_1.AST_NODE_TYPES.Identifier &&
25
- node.callee.property.name === 'subscribe' &&
26
- (0, in_constructor_1.isInAngularComponentConstructor)(node)) {
21
+ "CallExpression > MemberExpression[property.type='Identifier'][property.name='subscribe'][computed=false]"(node) {
22
+ if ((0, in_constructor_1.isInAngularComponentConstructor)(node)) {
27
23
  context.report({
28
24
  node,
29
25
  messageId,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-view-decorator";
6
5
  const messageId = "noViewDecorator";
7
6
  exports.ruleDefinition = {
@@ -19,16 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- Decorator(node) {
23
- if (node.expression.type === utils_1.AST_NODE_TYPES.CallExpression &&
24
- node.expression.callee.type === utils_1.AST_NODE_TYPES.Identifier &&
25
- (node.expression.callee.name === "ViewChild" ||
26
- node.expression.callee.name === "ViewChildren")) {
27
- context.report({
28
- node,
29
- messageId,
30
- });
31
- }
21
+ "Decorator > CallExpression[callee.type='Identifier'][callee.name=/^(ViewChild|ViewChildren)$/]"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
32
26
  },
33
27
  };
34
28
  },
@@ -18,13 +18,11 @@ exports.ruleDefinition = {
18
18
  },
19
19
  create(context) {
20
20
  return {
21
- ImportDeclaration(node) {
22
- if (node.source.value === "zone.js") {
23
- context.report({
24
- node,
25
- messageId,
26
- });
27
- }
21
+ "ImportDeclaration[source.value='zone.js']"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
28
26
  },
29
27
  };
30
28
  },
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruleDefinition = exports.ruleName = void 0;
4
- const utils_1 = require("@typescript-eslint/utils");
5
4
  exports.ruleName = "no-zonejs-testing-functions";
6
5
  const messageId = "noZonejsTestingFunctions";
7
6
  exports.ruleDefinition = {
@@ -19,24 +18,11 @@ exports.ruleDefinition = {
19
18
  },
20
19
  create(context) {
21
20
  return {
22
- CallExpression(node) {
23
- if (node.callee.type === utils_1.AST_NODE_TYPES.Identifier) {
24
- const testingFunctions = new Set([
25
- "fakeAsync",
26
- "discardPeriodicTasks",
27
- "flush",
28
- "flushMicrotasks",
29
- "resetFakeAsyncZone",
30
- "tick",
31
- "waitForAsync",
32
- ]);
33
- if (testingFunctions.has(node.callee.name)) {
34
- context.report({
35
- node,
36
- messageId,
37
- });
38
- }
39
- }
21
+ "CallExpression[callee.type='Identifier'][callee.name=/^(fakeAsync|discardPeriodicTasks|flush|flushMicrotasks|resetFakeAsyncZone|tick|waitForAsync)$/]"(node) {
22
+ context.report({
23
+ node,
24
+ messageId,
25
+ });
40
26
  },
41
27
  };
42
28
  },
@@ -0,0 +1,2 @@
1
+ import { type TSESTree } from "@typescript-eslint/utils";
2
+ export declare function isImportIdentifier(node: TSESTree.Identifier): boolean;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isImportIdentifier = isImportIdentifier;
4
+ const utils_1 = require("@typescript-eslint/utils");
5
+ function isImportIdentifier(node) {
6
+ return node.parent.type === utils_1.AST_NODE_TYPES.ImportSpecifier;
7
+ }