@angular-eslint/eslint-plugin 19.6.1-alpha.3 → 20.0.0-alpha.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/README.md CHANGED
@@ -43,12 +43,12 @@ Please see https://github.com/angular-eslint/angular-eslint for full usage instr
43
43
  <!-- prettier-ignore-start -->
44
44
  | Rule | Description | :white_check_mark: | :wrench: | :bulb: |
45
45
  | --- | --- | --- | --- | --- |
46
- | [`component-class-suffix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/component-class-suffix.md) | Classes decorated with @Component must have suffix "Component" (or custom) in their name. See more at https://angular.dev/style-guide#style-02-03 | :white_check_mark: | | |
46
+ | [`component-class-suffix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/component-class-suffix.md) | Classes decorated with @Component must have suffix "Component" (or custom) in their name. Note: As of v20, this is no longer recommended by the Angular Team. | | | |
47
47
  | [`component-max-inline-declarations`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/component-max-inline-declarations.md) | Enforces a maximum number of lines in inline template, styles and animations. See more at https://angular.dev/style-guide#style-05-04 | | | |
48
48
  | [`component-selector`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/component-selector.md) | Component selectors should follow given naming rules. See more at https://angular.dev/style-guide#style-02-07, https://angular.dev/style-guide#style-05-02 and https://angular.dev/style-guide#style-05-03. | | | |
49
49
  | [`consistent-component-styles`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/consistent-component-styles.md) | Ensures consistent usage of `styles`/`styleUrls`/`styleUrl` within Component metadata | | :wrench: | |
50
50
  | [`contextual-decorator`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/contextual-decorator.md) | Ensures that classes use contextual decorators in its body | | | |
51
- | [`directive-class-suffix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/directive-class-suffix.md) | Classes decorated with @Directive must have suffix "Directive" (or custom) in their name. See more at https://angular.dev/style-guide#style-02-03 | :white_check_mark: | | |
51
+ | [`directive-class-suffix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/directive-class-suffix.md) | Classes decorated with @Directive must have suffix "Directive" (or custom) in their name. Note: As of v20, this is no longer recommended by the Angular Team. | | | |
52
52
  | [`directive-selector`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/directive-selector.md) | Directive selectors should follow given naming rules. See more at https://angular.dev/style-guide#style-02-06 and https://angular.dev/style-guide#style-02-08. | | | |
53
53
  | [`no-conflicting-lifecycle`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-conflicting-lifecycle.md) | Ensures that directives not implement conflicting lifecycle interfaces. | | | |
54
54
  | [`no-duplicates-in-metadata-arrays`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-duplicates-in-metadata-arrays.md) | Ensures that metadata arrays do not contain duplicate entries. | | | |
@@ -65,12 +65,12 @@ Please see https://github.com/angular-eslint/angular-eslint for full usage instr
65
65
  | [`no-pipe-impure`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-pipe-impure.md) | Disallows the declaration of impure pipes | | | :bulb: |
66
66
  | [`no-queries-metadata-property`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-queries-metadata-property.md) | Disallows usage of the `queries` metadata property. See more at https://angular.dev/style-guide#style-05-12. | | | |
67
67
  | [`pipe-prefix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/pipe-prefix.md) | Enforce consistent prefix for pipes. | | | |
68
- | [`prefer-inject`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-inject.md) | Prefer using the inject() function over constructor parameter injection | | | |
68
+ | [`prefer-inject`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-inject.md) | Prefer using the inject() function over constructor parameter injection | :white_check_mark: | | |
69
69
  | [`prefer-on-push-component-change-detection`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-on-push-component-change-detection.md) | Ensures component's `changeDetection` is set to `ChangeDetectionStrategy.OnPush` | | | :bulb: |
70
70
  | [`prefer-output-emitter-ref`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-output-emitter-ref.md) | Use `OutputEmitterRef` instead of `@Output()` | | | |
71
71
  | [`prefer-output-readonly`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-output-readonly.md) | Prefer to declare `@Output`, `OutputEmitterRef` and `OutputRef` as `readonly` since they are not supposed to be reassigned | | | :bulb: |
72
72
  | [`prefer-signals`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-signals.md) | Use readonly signals instead of `@Input()`, `@ViewChild()` and other legacy decorators | | :wrench: | |
73
- | [`prefer-standalone`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-standalone.md) | Ensures Components, Directives and Pipes do not opt out of standalone | :white_check_mark: | :wrench: | |
73
+ | [`prefer-standalone`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-standalone.md) | Ensures Components, Directives and Pipes do not opt out of standalone. | :white_check_mark: | | :bulb: |
74
74
  | [`relative-url-prefix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/relative-url-prefix.md) | The ./ and ../ prefix is standard syntax for relative URLs; don't depend on Angular's current ability to do without that prefix. See more at https://angular.dev/style-guide#style-05-04 | | | |
75
75
  | [`require-localize-metadata`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/require-localize-metadata.md) | Ensures that $localize tagged messages contain helpful metadata to aid with translations. | | | |
76
76
  | [`runtime-localize`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/runtime-localize.md) | Ensures that $localize tagged messages can use runtime-loaded translations. | | | |
@@ -2,9 +2,7 @@
2
2
  "parser": "@typescript-eslint/parser",
3
3
  "plugins": ["@angular-eslint"],
4
4
  "rules": {
5
- "@angular-eslint/component-class-suffix": "error",
6
5
  "@angular-eslint/contextual-lifecycle": "error",
7
- "@angular-eslint/directive-class-suffix": "error",
8
6
  "@angular-eslint/no-empty-lifecycle-method": "error",
9
7
  "@angular-eslint/no-input-rename": "error",
10
8
  "@angular-eslint/no-inputs-metadata-property": "error",
@@ -12,6 +10,7 @@
12
10
  "@angular-eslint/no-output-on-prefix": "error",
13
11
  "@angular-eslint/no-output-rename": "error",
14
12
  "@angular-eslint/no-outputs-metadata-property": "error",
13
+ "@angular-eslint/prefer-inject": "error",
15
14
  "@angular-eslint/prefer-standalone": "error",
16
15
  "@angular-eslint/use-pipe-transform-interface": "error",
17
16
  "@angular-eslint/use-lifecycle-interface": "warn"
package/dist/index.d.ts CHANGED
@@ -52,9 +52,7 @@ declare const _default: {
52
52
  parser: string;
53
53
  plugins: string[];
54
54
  rules: {
55
- "@angular-eslint/component-class-suffix": string;
56
55
  "@angular-eslint/contextual-lifecycle": string;
57
- "@angular-eslint/directive-class-suffix": string;
58
56
  "@angular-eslint/no-empty-lifecycle-method": string;
59
57
  "@angular-eslint/no-input-rename": string;
60
58
  "@angular-eslint/no-inputs-metadata-property": string;
@@ -62,6 +60,7 @@ declare const _default: {
62
60
  "@angular-eslint/no-output-on-prefix": string;
63
61
  "@angular-eslint/no-output-rename": string;
64
62
  "@angular-eslint/no-outputs-metadata-property": string;
63
+ "@angular-eslint/prefer-inject": string;
65
64
  "@angular-eslint/prefer-standalone": string;
66
65
  "@angular-eslint/use-pipe-transform-interface": string;
67
66
  "@angular-eslint/use-lifecycle-interface": string;
@@ -102,7 +101,7 @@ declare const _default: {
102
101
  useTypeChecking: boolean;
103
102
  additionalSignalCreationFunctions: string[];
104
103
  }], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
105
- "prefer-standalone": import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferStandalone", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
104
+ "prefer-standalone": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/prefer-standalone").MessageIds, [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
106
105
  "prefer-inject": import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferInject", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
107
106
  "prefer-output-emitter-ref": import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferOutputEmitterRef", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
108
107
  "prefer-output-readonly": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/prefer-output-readonly").MessageIds, [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkIA,kBAkDE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkIA,kBAkDE"}
@@ -1 +1 @@
1
- {"version":3,"file":"component-class-suffix.d.ts","sourceRoot":"","sources":["../../src/rules/component-class-suffix.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAChD,eAAO,MAAM,SAAS,2BAA2B,CAAC;;AAGlD,wBAkDG"}
1
+ {"version":3,"file":"component-class-suffix.d.ts","sourceRoot":"","sources":["../../src/rules/component-class-suffix.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAChD,eAAO,MAAM,SAAS,2BAA2B,CAAC;;AAElD,wBAiDG"}
@@ -4,14 +4,12 @@ exports.RULE_NAME = void 0;
4
4
  const utils_1 = require("@angular-eslint/utils");
5
5
  const create_eslint_rule_1 = require("../utils/create-eslint-rule");
6
6
  exports.RULE_NAME = 'component-class-suffix';
7
- const STYLE_GUIDE_LINK = 'https://angular.dev/style-guide#style-02-03';
8
7
  exports.default = (0, create_eslint_rule_1.createESLintRule)({
9
8
  name: exports.RULE_NAME,
10
9
  meta: {
11
10
  type: 'suggestion',
12
11
  docs: {
13
- description: `Classes decorated with @Component must have suffix "Component" (or custom) in their name. See more at ${STYLE_GUIDE_LINK}`,
14
- recommended: 'recommended',
12
+ description: `Classes decorated with @Component must have suffix "Component" (or custom) in their name. Note: As of v20, this is no longer recommended by the Angular Team.`,
15
13
  },
16
14
  schema: [
17
15
  {
@@ -28,7 +26,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
28
26
  },
29
27
  ],
30
28
  messages: {
31
- componentClassSuffix: `Component class names should end with one of these suffixes: {{suffixes}} (${STYLE_GUIDE_LINK})`,
29
+ componentClassSuffix: `Component class names should end with one of these suffixes: {{suffixes}}`,
32
30
  },
33
31
  },
34
32
  defaultOptions: [
@@ -1 +1 @@
1
- {"version":3,"file":"directive-class-suffix.d.ts","sourceRoot":"","sources":["../../src/rules/directive-class-suffix.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,OAAO,GAAG,CAAC;IAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAChD,eAAO,MAAM,SAAS,2BAA2B,CAAC;;AAKlD,wBA6DG"}
1
+ {"version":3,"file":"directive-class-suffix.d.ts","sourceRoot":"","sources":["../../src/rules/directive-class-suffix.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,OAAO,GAAG,CAAC;IAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAChD,eAAO,MAAM,SAAS,2BAA2B,CAAC;;AAIlD,wBA4DG"}
@@ -4,7 +4,6 @@ exports.RULE_NAME = void 0;
4
4
  const utils_1 = require("@angular-eslint/utils");
5
5
  const create_eslint_rule_1 = require("../utils/create-eslint-rule");
6
6
  exports.RULE_NAME = 'directive-class-suffix';
7
- const STYLE_GUIDE_LINK = 'https://angular.dev/style-guide#style-02-03';
8
7
  const DEFAULT_SUFFIXES = ['Directive'];
9
8
  const VALIDATOR_SUFFIX = 'Validator';
10
9
  exports.default = (0, create_eslint_rule_1.createESLintRule)({
@@ -12,8 +11,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
12
11
  meta: {
13
12
  type: 'suggestion',
14
13
  docs: {
15
- description: `Classes decorated with @Directive must have suffix "Directive" (or custom) in their name. See more at ${STYLE_GUIDE_LINK}`,
16
- recommended: 'recommended',
14
+ description: `Classes decorated with @Directive must have suffix "Directive" (or custom) in their name. Note: As of v20, this is no longer recommended by the Angular Team.`,
17
15
  },
18
16
  schema: [
19
17
  {
@@ -30,7 +28,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
30
28
  },
31
29
  ],
32
30
  messages: {
33
- directiveClassSuffix: `Directive class names should end with one of these suffixes: {{suffixes}} (${STYLE_GUIDE_LINK})`,
31
+ directiveClassSuffix: `Directive class names should end with one of these suffixes: {{suffixes}}`,
34
32
  },
35
33
  },
36
34
  defaultOptions: [{ suffixes: DEFAULT_SUFFIXES }],
@@ -0,0 +1,8 @@
1
+ export type Options = [{
2
+ readonly allowStatic?: boolean;
3
+ }];
4
+ export type MessageIds = 'noHostMetadataProperty';
5
+ export declare const RULE_NAME = "no-host-metadata-property";
6
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"noHostMetadataProperty", Options, import("../utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
7
+ export default _default;
8
+ //# sourceMappingURL=no-host-metadata-property.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-host-metadata-property.d.ts","sourceRoot":"","sources":["../../src/rules/no-host-metadata-property.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,OAAO,GAAG,CAAC;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAC3D,MAAM,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAClD,eAAO,MAAM,SAAS,8BAA8B,CAAC;;AAIrD,wBA4CG"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RULE_NAME = void 0;
4
+ const utils_1 = require("@angular-eslint/utils");
5
+ const utils_2 = require("@typescript-eslint/utils");
6
+ const create_eslint_rule_1 = require("../utils/create-eslint-rule");
7
+ exports.RULE_NAME = 'no-host-metadata-property';
8
+ const DEFAULT_OPTIONS = { allowStatic: false };
9
+ const METADATA_PROPERTY_NAME = 'host';
10
+ exports.default = (0, create_eslint_rule_1.createESLintRule)({
11
+ name: exports.RULE_NAME,
12
+ meta: {
13
+ type: 'suggestion',
14
+ deprecated: true,
15
+ docs: {
16
+ description: `Disallows usage of the \`${METADATA_PROPERTY_NAME}\` metadata property. NOTE: This used to be recommended by the Angular Team, but now they recommend the exact opposite: https://github.com/angular/angular/issues/54284`,
17
+ },
18
+ schema: [
19
+ {
20
+ type: 'object',
21
+ properties: {
22
+ allowStatic: {
23
+ type: 'boolean',
24
+ default: DEFAULT_OPTIONS.allowStatic,
25
+ },
26
+ },
27
+ additionalProperties: false,
28
+ },
29
+ ],
30
+ messages: {
31
+ noHostMetadataProperty: `Use @${utils_1.ASTUtils.AngularInnerClassDecorators.HostBinding} or @${utils_1.ASTUtils.AngularInnerClassDecorators.HostListener} rather than the \`${METADATA_PROPERTY_NAME}\` metadata property`,
32
+ },
33
+ },
34
+ defaultOptions: [DEFAULT_OPTIONS],
35
+ create(context, [{ allowStatic }]) {
36
+ return {
37
+ [`${utils_1.Selectors.COMPONENT_OR_DIRECTIVE_CLASS_DECORATOR} Property[key.name="${METADATA_PROPERTY_NAME}"]`](node) {
38
+ const properties = allowStatic && utils_1.ASTUtils.isObjectExpression(node.value)
39
+ ? node.value.properties.filter(isDynamic)
40
+ : [node];
41
+ properties.forEach((property) => {
42
+ context.report({
43
+ node: property,
44
+ messageId: 'noHostMetadataProperty',
45
+ });
46
+ });
47
+ },
48
+ };
49
+ },
50
+ });
51
+ function startsWithLetter({ [0]: firstLetter }) {
52
+ return firstLetter.toLowerCase() !== firstLetter.toUpperCase();
53
+ }
54
+ function isEmptyStringValue(property) {
55
+ return (utils_1.ASTUtils.isStringLiteral(property.value) && property.value.value === '');
56
+ }
57
+ function isStatic(property) {
58
+ return (!property.computed &&
59
+ (utils_2.ASTUtils.isIdentifier(property.key) ||
60
+ (utils_1.ASTUtils.isStringLiteral(property.key) &&
61
+ startsWithLetter(property.key.value))));
62
+ }
63
+ function isDynamic(property) {
64
+ return (utils_1.ASTUtils.isProperty(property) &&
65
+ !isStatic(property) &&
66
+ !isEmptyStringValue(property));
67
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-inject.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-inject.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AAEzB,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC;AACxC,eAAO,MAAM,SAAS,kBAAkB,CAAC;;AAEzC,wBAiGG"}
1
+ {"version":3,"file":"prefer-inject.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-inject.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AAEzB,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC;AACxC,eAAO,MAAM,SAAS,kBAAkB,CAAC;;AAEzC,wBAkGG"}
@@ -11,6 +11,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
11
11
  type: 'suggestion',
12
12
  docs: {
13
13
  description: 'Prefer using the inject() function over constructor parameter injection',
14
+ recommended: 'recommended',
14
15
  },
15
16
  schema: [],
16
17
  messages: {
@@ -0,0 +1,6 @@
1
+ export type Options = [];
2
+ export type MessageIds = 'preferStandaloneComponent';
3
+ export declare const RULE_NAME = "prefer-standalone-component";
4
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferStandaloneComponent", [], import("../utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
5
+ export default _default;
6
+ //# sourceMappingURL=prefer-standalone-component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefer-standalone-component.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-standalone-component.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AACzB,MAAM,MAAM,UAAU,GAAG,2BAA2B,CAAC;AACrD,eAAO,MAAM,SAAS,gCAAgC,CAAC;;AAIvD,wBA0DG"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RULE_NAME = void 0;
4
+ const utils_1 = require("@angular-eslint/utils");
5
+ const create_eslint_rule_1 = require("../utils/create-eslint-rule");
6
+ exports.RULE_NAME = 'prefer-standalone-component';
7
+ const METADATA_PROPERTY_NAME = 'standalone';
8
+ const IS_STANDALONE = 'true';
9
+ exports.default = (0, create_eslint_rule_1.createESLintRule)({
10
+ name: exports.RULE_NAME,
11
+ meta: {
12
+ type: 'suggestion',
13
+ docs: {
14
+ description: `Ensures component \`${METADATA_PROPERTY_NAME}\` property is set to \`${IS_STANDALONE}\` in the component decorator`,
15
+ },
16
+ deprecated: true,
17
+ replacedBy: ['prefer-standalone'],
18
+ fixable: 'code',
19
+ schema: [],
20
+ messages: {
21
+ preferStandaloneComponent: `The component \`${METADATA_PROPERTY_NAME}\` property should be set to \`${IS_STANDALONE}\``,
22
+ },
23
+ },
24
+ defaultOptions: [],
25
+ create(context) {
26
+ return {
27
+ [utils_1.Selectors.COMPONENT_CLASS_DECORATOR](node) {
28
+ const standalone = utils_1.ASTUtils.getDecoratorPropertyValue(node, METADATA_PROPERTY_NAME);
29
+ if (standalone &&
30
+ utils_1.ASTUtils.isLiteral(standalone) &&
31
+ standalone.value === true) {
32
+ return;
33
+ }
34
+ context.report({
35
+ node: nodeToReport(node),
36
+ messageId: 'preferStandaloneComponent',
37
+ fix: (fixer) => {
38
+ if (standalone &&
39
+ utils_1.ASTUtils.isLiteral(standalone) &&
40
+ standalone.value !== true) {
41
+ return [fixer.replaceText(standalone, IS_STANDALONE)].filter(utils_1.isNotNullOrUndefined);
42
+ }
43
+ return [
44
+ utils_1.RuleFixes.getDecoratorPropertyAddFix(node, fixer, `${METADATA_PROPERTY_NAME}: ${IS_STANDALONE}`),
45
+ ].filter(utils_1.isNotNullOrUndefined);
46
+ },
47
+ });
48
+ },
49
+ };
50
+ },
51
+ });
52
+ function nodeToReport(node) {
53
+ if (!utils_1.ASTUtils.isProperty(node)) {
54
+ return node;
55
+ }
56
+ return utils_1.ASTUtils.isMemberExpression(node.value)
57
+ ? node.value.property
58
+ : node.value;
59
+ }
@@ -1,6 +1,6 @@
1
1
  export type Options = [];
2
- export type MessageIds = 'preferStandalone';
2
+ export type MessageIds = 'preferStandalone' | 'removeStandaloneFalse';
3
3
  export declare const RULE_NAME = "prefer-standalone";
4
- declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferStandalone", [], import("../utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
4
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, [], import("../utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
5
5
  export default _default;
6
6
  //# sourceMappingURL=prefer-standalone.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-standalone.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-standalone.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AAEzB,MAAM,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAC5C,eAAO,MAAM,SAAS,sBAAsB,CAAC;;AAE7C,wBA4DG"}
1
+ {"version":3,"file":"prefer-standalone.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-standalone.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AAEzB,MAAM,MAAM,UAAU,GAAG,kBAAkB,GAAG,uBAAuB,CAAC;AACtE,eAAO,MAAM,SAAS,sBAAsB,CAAC;;AAK7C,wBAkEG"}
@@ -4,18 +4,20 @@ exports.RULE_NAME = void 0;
4
4
  const utils_1 = require("@angular-eslint/utils");
5
5
  const create_eslint_rule_1 = require("../utils/create-eslint-rule");
6
6
  exports.RULE_NAME = 'prefer-standalone';
7
+ const RECOMMENDED_GUIDE_URL = 'https://angular.dev/reference/migrations/standalone';
7
8
  exports.default = (0, create_eslint_rule_1.createESLintRule)({
8
9
  name: exports.RULE_NAME,
9
10
  meta: {
10
11
  type: 'suggestion',
11
12
  docs: {
12
- description: `Ensures Components, Directives and Pipes do not opt out of standalone`,
13
+ description: `Ensures Components, Directives and Pipes do not opt out of standalone.`,
13
14
  recommended: 'recommended',
14
15
  },
15
- fixable: 'code',
16
+ hasSuggestions: true,
16
17
  schema: [],
17
18
  messages: {
18
- preferStandalone: `Components, Directives and Pipes should not opt out of standalone`,
19
+ preferStandalone: `Components, Directives and Pipes should not opt out of standalone. Following this guide is highly recommended: ${RECOMMENDED_GUIDE_URL}`,
20
+ removeStandaloneFalse: `Quickly remove 'standalone: false'. NOTE - Following this guide is highly recommended: ${RECOMMENDED_GUIDE_URL}`,
19
21
  },
20
22
  },
21
23
  defaultOptions: [],
@@ -34,17 +36,22 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
34
36
  node: standalone.parent,
35
37
  messageId: 'preferStandalone',
36
38
  data: { type },
37
- fix: (fixer) => {
38
- // Remove the standalone property altogether if it was set to false
39
- const tokenAfter = context.sourceCode.getTokenAfter(standalone.parent);
40
- // Remove the trailing comma, if present
41
- const removeStart = standalone.parent.range[0];
42
- let removeEnd = standalone.parent.range[1];
43
- if (tokenAfter && tokenAfter.value === ',') {
44
- removeEnd = tokenAfter.range[1];
45
- }
46
- return fixer.removeRange([removeStart, removeEnd]);
47
- },
39
+ suggest: [
40
+ {
41
+ messageId: 'removeStandaloneFalse',
42
+ fix: (fixer) => {
43
+ // Remove the standalone property altogether if it was set to false
44
+ const tokenAfter = context.sourceCode.getTokenAfter(standalone.parent);
45
+ // Remove the trailing comma, if present
46
+ const removeStart = standalone.parent.range[0];
47
+ let removeEnd = standalone.parent.range[1];
48
+ if (tokenAfter && tokenAfter.value === ',') {
49
+ removeEnd = tokenAfter.range[1];
50
+ }
51
+ return fixer.removeRange([removeStart, removeEnd]);
52
+ },
53
+ },
54
+ ],
48
55
  });
49
56
  };
50
57
  return {
@@ -0,0 +1,10 @@
1
+ export type Options = [
2
+ {
3
+ readonly locale: string;
4
+ }
5
+ ];
6
+ export type MessageIds = 'sortNgmoduleMetadataArrays';
7
+ export declare const RULE_NAME = "sort-ngmodule-metadata-arrays";
8
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"sortNgmoduleMetadataArrays", Options, import("../utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
9
+ export default _default;
10
+ //# sourceMappingURL=sort-ngmodule-metadata-arrays.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-ngmodule-metadata-arrays.d.ts","sourceRoot":"","sources":["../../src/rules/sort-ngmodule-metadata-arrays.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;KACzB;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,4BAA4B,CAAC;AACtD,eAAO,MAAM,SAAS,kCAAkC,CAAC;;AAGzD,wBA2DG"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RULE_NAME = void 0;
4
+ const utils_1 = require("@angular-eslint/utils");
5
+ const utils_2 = require("@typescript-eslint/utils");
6
+ const create_eslint_rule_1 = require("../utils/create-eslint-rule");
7
+ exports.RULE_NAME = 'sort-ngmodule-metadata-arrays';
8
+ const DEFAULT_LOCALE = 'en-US';
9
+ exports.default = (0, create_eslint_rule_1.createESLintRule)({
10
+ name: exports.RULE_NAME,
11
+ meta: {
12
+ type: 'suggestion',
13
+ deprecated: true,
14
+ docs: {
15
+ description: 'Ensures ASC alphabetical order for `NgModule` metadata arrays for easy visual scanning',
16
+ },
17
+ fixable: 'code',
18
+ schema: [
19
+ {
20
+ type: 'object',
21
+ properties: {
22
+ locale: {
23
+ type: 'string',
24
+ description: 'A string with a BCP 47 language tag.',
25
+ default: DEFAULT_LOCALE,
26
+ },
27
+ },
28
+ additionalProperties: false,
29
+ },
30
+ ],
31
+ messages: {
32
+ sortNgmoduleMetadataArrays: '`NgModule` metadata arrays should be sorted in ASC alphabetical order',
33
+ },
34
+ },
35
+ defaultOptions: [
36
+ {
37
+ locale: DEFAULT_LOCALE,
38
+ },
39
+ ],
40
+ create(context, [{ locale }]) {
41
+ return {
42
+ [`${utils_1.Selectors.MODULE_CLASS_DECORATOR} Property[key.name!="deps"] > ArrayExpression`]({ elements, }) {
43
+ const unorderedNodes = elements
44
+ .filter(utils_2.ASTUtils.isIdentifier)
45
+ .map((current, index, list) => [current, list[index + 1]])
46
+ .find(([current, next]) => {
47
+ return next && current.name.localeCompare(next.name, locale) === 1;
48
+ });
49
+ if (!unorderedNodes)
50
+ return;
51
+ const [unorderedNode, nextNode] = unorderedNodes;
52
+ context.report({
53
+ node: nextNode,
54
+ messageId: 'sortNgmoduleMetadataArrays',
55
+ fix: (fixer) => [
56
+ fixer.replaceText(unorderedNode, nextNode.name),
57
+ fixer.replaceText(nextNode, unorderedNode.name),
58
+ ],
59
+ });
60
+ },
61
+ };
62
+ },
63
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/eslint-plugin",
3
- "version": "19.6.1-alpha.3",
3
+ "version": "20.0.0-alpha.1",
4
4
  "description": "ESLint plugin for Angular applications, following https://angular.dev/style-guide",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -18,11 +18,11 @@
18
18
  "LICENSE"
19
19
  ],
20
20
  "dependencies": {
21
- "@angular-eslint/bundled-angular-compiler": "19.6.1-alpha.3",
22
- "@angular-eslint/utils": "19.6.1-alpha.3"
21
+ "@angular-eslint/bundled-angular-compiler": "20.0.0-alpha.1",
22
+ "@angular-eslint/utils": "20.0.0-alpha.1"
23
23
  },
24
24
  "devDependencies": {
25
- "@angular-eslint/test-utils": "19.6.1-alpha.3"
25
+ "@angular-eslint/test-utils": "20.0.0-alpha.1"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@typescript-eslint/utils": "^7.11.0 || ^8.0.0",