@angular-eslint/eslint-plugin 19.0.0-alpha.5 → 19.0.0-alpha.6

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
@@ -66,7 +66,7 @@ Please see https://github.com/angular-eslint/angular-eslint for full usage instr
66
66
  | [`pipe-prefix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/pipe-prefix.md) | Enforce consistent prefix for pipes. | | | |
67
67
  | [`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: |
68
68
  | [`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: |
69
- | [`prefer-standalone`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-standalone.md) | Ensures component, directive and pipe `standalone` property is set to `true` in the component decorator | :white_check_mark: | :wrench: | |
69
+ | [`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: | |
70
70
  | [`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 | | | |
71
71
  | [`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. | | | |
72
72
  | [`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. | | | |
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-standalone.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-standalone.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AAEzB,MAAM,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAC5C,eAAO,MAAM,SAAS,sBAAsB,CAAC;;AAI7C,wBAkEG"}
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,wBA6DG"}
@@ -4,26 +4,25 @@ 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 METADATA_PROPERTY_NAME = 'standalone';
8
- const IS_STANDALONE = 'true';
9
7
  exports.default = (0, create_eslint_rule_1.createESLintRule)({
10
8
  name: exports.RULE_NAME,
11
9
  meta: {
12
10
  type: 'suggestion',
13
11
  docs: {
14
- description: `Ensures component, directive and pipe \`${METADATA_PROPERTY_NAME}\` property is set to \`${IS_STANDALONE}\` in the component decorator`,
12
+ description: `Ensures Components, Directives and Pipes do not opt out of standalone`,
15
13
  recommended: 'recommended',
16
14
  },
17
15
  fixable: 'code',
18
16
  schema: [],
19
17
  messages: {
20
- preferStandalone: `The {{type}} \`${METADATA_PROPERTY_NAME}\` property should be set to \`${IS_STANDALONE}\``,
18
+ preferStandalone: `Components, Directives and Pipes should not opt out of standalone`,
21
19
  },
22
20
  },
23
21
  defaultOptions: [],
24
22
  create(context) {
25
23
  const standaloneRuleFactory = (type) => (node) => {
26
- const standalone = utils_1.ASTUtils.getDecoratorPropertyValue(node, METADATA_PROPERTY_NAME);
24
+ const standalone = utils_1.ASTUtils.getDecoratorPropertyValue(node, 'standalone');
25
+ // Leave the standalone property alone if it was set to true or not present
27
26
  if (!standalone ||
28
27
  (utils_1.ASTUtils.isLiteral(standalone) && standalone.value === true)) {
29
28
  return;
@@ -36,14 +35,15 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
36
35
  messageId: 'preferStandalone',
37
36
  data: { type },
38
37
  fix: (fixer) => {
39
- if (standalone &&
40
- utils_1.ASTUtils.isLiteral(standalone) &&
41
- standalone.value !== true) {
42
- return [fixer.replaceText(standalone, IS_STANDALONE)].filter(utils_1.isNotNullOrUndefined);
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];
43
45
  }
44
- return [
45
- utils_1.RuleFixes.getDecoratorPropertyAddFix(node, fixer, `${METADATA_PROPERTY_NAME}: ${IS_STANDALONE}`),
46
- ].filter(utils_1.isNotNullOrUndefined);
46
+ return fixer.removeRange([removeStart, removeEnd]);
47
47
  },
48
48
  });
49
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/eslint-plugin",
3
- "version": "19.0.0-alpha.5",
3
+ "version": "19.0.0-alpha.6",
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.0.0-alpha.5",
22
- "@angular-eslint/utils": "19.0.0-alpha.5"
21
+ "@angular-eslint/bundled-angular-compiler": "19.0.0-alpha.6",
22
+ "@angular-eslint/utils": "19.0.0-alpha.6"
23
23
  },
24
24
  "devDependencies": {
25
- "@angular-eslint/test-utils": "19.0.0-alpha.5"
25
+ "@angular-eslint/test-utils": "19.0.0-alpha.6"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@typescript-eslint/utils": "^7.11.0 || ^8.0.0",