@angular-eslint/eslint-plugin 22.5.1-alpha.17 → 22.5.1-alpha.18

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
@@ -79,7 +79,7 @@ The premade flat configs that combine these rules are provided by the umbrella [
79
79
  | [`prefer-service-decorator`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-service-decorator.md) | Prefer the `@Service()` decorator over `@Injectable({ providedIn: 'root' })` | | :wrench: | |
80
80
  | [`prefer-signal-model`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-signal-model.md) | Use `model` instead of `input` and `output` for two-way bindings | | :wrench: | |
81
81
  | [`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: | |
82
- | [`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: |
82
+ | [`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: | :bulb: |
83
83
  | [`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. | | | |
84
84
  | [`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. | | | |
85
85
  | [`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. | | | |
package/dist/index.d.ts CHANGED
@@ -122,7 +122,7 @@ declare const _default: {
122
122
  }], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
123
123
  name: string;
124
124
  };
125
- "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> & {
125
+ "prefer-standalone": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/prefer-standalone").MessageIds, import("./rules/prefer-standalone").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
126
126
  name: string;
127
127
  };
128
128
  "reactive-context-must-read-signal": import("@typescript-eslint/utils/ts-eslint").RuleModule<"mustReadSignal", import("./rules/reactive-context-must-read-signal").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
@@ -1,7 +1,9 @@
1
- export type Options = [];
2
- export type MessageIds = 'preferStandalone' | 'removeStandaloneFalse';
1
+ export type Options = [{
2
+ readonly allowExplicitStandalone?: boolean;
3
+ }];
4
+ export type MessageIds = 'preferStandalone' | 'removeStandaloneFalse' | 'redundantStandalone';
3
5
  export declare const RULE_NAME = "prefer-standalone";
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> & {
6
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, Options, import("../utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
5
7
  name: string;
6
8
  };
7
9
  export default _default;
@@ -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,GAAG,uBAAuB,CAAC;AACtE,eAAO,MAAM,SAAS,sBAAsB,CAAC;;;;AAK7C,wBAkEG;AAEH,eAAO,MAAM,mBAAmB;;CAG/B,CAAC"}
1
+ {"version":3,"file":"prefer-standalone.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-standalone.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,OAAO,GAAG,CAAC;IAAE,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAEvE,MAAM,MAAM,UAAU,GACpB,kBAAkB,GAAG,uBAAuB,GAAG,qBAAqB,CAAC;AACvE,eAAO,MAAM,SAAS,sBAAsB,CAAC;;;;AAM7C,wBAiGG;AAEH,eAAO,MAAM,mBAAmB;;CAG/B,CAAC"}
@@ -4,6 +4,7 @@ exports.RULE_DOCS_EXTENSION = 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 DEFAULT_OPTIONS = { allowExplicitStandalone: true };
7
8
  const RECOMMENDED_GUIDE_URL = 'https://angular.dev/reference/migrations/standalone';
8
9
  exports.default = (0, create_eslint_rule_1.createESLintRule)({
9
10
  name: exports.RULE_NAME,
@@ -13,25 +14,48 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
13
14
  description: `Ensures Components, Directives and Pipes do not opt out of standalone.`,
14
15
  recommended: 'recommended',
15
16
  },
17
+ fixable: 'code',
16
18
  hasSuggestions: true,
17
- schema: [],
19
+ schema: [
20
+ {
21
+ type: 'object',
22
+ properties: {
23
+ allowExplicitStandalone: {
24
+ type: 'boolean',
25
+ default: DEFAULT_OPTIONS.allowExplicitStandalone,
26
+ description: 'Whether to allow a Component, Directive or Pipe to set `standalone: true` explicitly even though it is now the default.',
27
+ },
28
+ },
29
+ additionalProperties: false,
30
+ },
31
+ ],
18
32
  messages: {
19
33
  preferStandalone: `Components, Directives and Pipes should not opt out of standalone. Following this guide is highly recommended: ${RECOMMENDED_GUIDE_URL}`,
20
34
  removeStandaloneFalse: `Quickly remove 'standalone: false'. NOTE - Following this guide is highly recommended: ${RECOMMENDED_GUIDE_URL}`,
35
+ redundantStandalone: '`standalone: true` is redundant because `standalone: true` is the default',
21
36
  },
22
- defaultOptions: [],
37
+ defaultOptions: [DEFAULT_OPTIONS],
23
38
  },
24
- create(context) {
39
+ create(context, [{ allowExplicitStandalone }]) {
25
40
  const standaloneRuleFactory = (type) => (node) => {
26
41
  const standalone = utils_1.ASTUtils.getDecoratorPropertyValue(node, 'standalone');
27
- // Leave the standalone property alone if it was set to true or not present
28
- if (!standalone ||
29
- (utils_1.ASTUtils.isLiteral(standalone) && standalone.value === true)) {
42
+ if (!standalone) {
30
43
  return;
31
44
  }
32
45
  if (!utils_1.ASTUtils.getDecoratorArgument(node)) {
33
46
  return;
34
47
  }
48
+ if (utils_1.ASTUtils.isLiteral(standalone) && standalone.value === true) {
49
+ if (allowExplicitStandalone) {
50
+ return;
51
+ }
52
+ context.report({
53
+ node: standalone.parent,
54
+ messageId: 'redundantStandalone',
55
+ fix: (fixer) => utils_1.RuleFixes.getNodeToCommaRemoveFix(context.sourceCode, standalone.parent, fixer),
56
+ });
57
+ return;
58
+ }
35
59
  context.report({
36
60
  node: standalone.parent,
37
61
  messageId: 'preferStandalone',
@@ -62,5 +86,5 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
62
86
  },
63
87
  });
64
88
  exports.RULE_DOCS_EXTENSION = {
65
- rationale: 'Standalone components, directives, and pipes are the recommended way to build Angular applications. Setting standalone: false opts out of the standalone API, tying your code to the older NgModule-based architecture. Standalone components simplify Angular applications by eliminating the need for NgModules in most cases, reducing boilerplate and making dependencies more explicit. Each standalone component declares its own dependencies directly, making it self-contained and easier to understand, test, and reuse. Standalone components also enable better tree-shaking and lazy loading. Angular provides comprehensive migration guides to help transition existing applications, such as https://angular.dev/reference/migrations/standalone. New projects should use standalone components from the start, and existing projects should avoid adding new non-standalone components as they will make future migrations harder.',
89
+ rationale: 'Standalone components, directives, and pipes are the recommended way to build Angular applications. Setting standalone: false opts out of the standalone API, tying your code to the older NgModule-based architecture. Standalone components simplify Angular applications by eliminating the need for NgModules in most cases, reducing boilerplate and making dependencies more explicit. Each standalone component declares its own dependencies directly, making it self-contained and easier to understand, test, and reuse. Standalone components also enable better tree-shaking and lazy loading. Angular provides comprehensive migration guides to help transition existing applications, such as https://angular.dev/reference/migrations/standalone. New projects should use standalone components from the start, and existing projects should avoid adding new non-standalone components as they will make future migrations harder. As of Angular v19, `standalone: true` is the default for components, directives, and pipes, so declaring `standalone: true` explicitly is redundant; set `allowExplicitStandalone` to `false` to have the rule flag and autofix redundant `standalone: true` declarations too.',
66
90
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/eslint-plugin",
3
- "version": "22.5.1-alpha.17",
3
+ "version": "22.5.1-alpha.18",
4
4
  "description": "ESLint plugin for Angular applications, following https://angular.dev/style-guide",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -19,12 +19,12 @@
19
19
  "LICENSE"
20
20
  ],
21
21
  "dependencies": {
22
- "@angular-eslint/bundled-angular-compiler": "22.5.1-alpha.17",
23
- "@angular-eslint/utils": "22.5.1-alpha.17",
22
+ "@angular-eslint/bundled-angular-compiler": "22.5.1-alpha.18",
23
+ "@angular-eslint/utils": "22.5.1-alpha.18",
24
24
  "ts-api-utils": "^2.1.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@angular-eslint/test-utils": "22.5.1-alpha.17"
27
+ "@angular-eslint/test-utils": "22.5.1-alpha.18"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@typescript-eslint/utils": "^8.0.0",