@angular-eslint/eslint-plugin 17.2.2-alpha.8 → 17.2.2-alpha.9
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
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
| [`pipe-prefix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/pipe-prefix.md) | Enforce consistent prefix for pipes. | | | |
|
|
65
65
|
| [`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: |
|
|
66
66
|
| [`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` as `readonly` since they are not supposed to be reassigned | | | :bulb: |
|
|
67
|
-
| [`prefer-standalone
|
|
67
|
+
| [`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 | | :wrench: | |
|
|
68
68
|
| [`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.io/styleguide#style-05-04 | | | |
|
|
69
69
|
| [`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. | | | |
|
|
70
70
|
| [`sort-ngmodule-metadata-arrays`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/sort-ngmodule-metadata-arrays.md) | Ensures ASC alphabetical order for `NgModule` metadata arrays for easy visual scanning | | :wrench: | |
|
|
@@ -83,4 +83,12 @@
|
|
|
83
83
|
|
|
84
84
|
<!-- begin deprecated rule list -->
|
|
85
85
|
|
|
86
|
+
### Deprecated
|
|
87
|
+
|
|
88
|
+
<!-- prettier-ignore-start -->
|
|
89
|
+
| Rule | Replaced by |
|
|
90
|
+
| --- | --- |
|
|
91
|
+
| [`prefer-standalone-component`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-standalone-component.md) | [`prefer-standalone`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-standalone-component.md) |
|
|
92
|
+
<!-- prettier-ignore-end -->
|
|
93
|
+
|
|
86
94
|
<!-- end deprecated rule list -->
|
package/dist/configs/all.json
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"@angular-eslint/pipe-prefix": "error",
|
|
30
30
|
"@angular-eslint/prefer-on-push-component-change-detection": "error",
|
|
31
31
|
"@angular-eslint/prefer-output-readonly": "error",
|
|
32
|
+
"@angular-eslint/prefer-standalone": "error",
|
|
32
33
|
"@angular-eslint/prefer-standalone-component": "error",
|
|
33
34
|
"@angular-eslint/relative-url-prefix": "error",
|
|
34
35
|
"@angular-eslint/require-localize-metadata": "error",
|
package/dist/index.js
CHANGED
|
@@ -54,6 +54,7 @@ const no_queries_metadata_property_1 = __importStar(require("./rules/no-queries-
|
|
|
54
54
|
const pipe_prefix_1 = __importStar(require("./rules/pipe-prefix"));
|
|
55
55
|
const prefer_on_push_component_change_detection_1 = __importStar(require("./rules/prefer-on-push-component-change-detection"));
|
|
56
56
|
const prefer_output_readonly_1 = __importStar(require("./rules/prefer-output-readonly"));
|
|
57
|
+
const prefer_standalone_1 = __importStar(require("./rules/prefer-standalone"));
|
|
57
58
|
const prefer_standalone_component_1 = __importStar(require("./rules/prefer-standalone-component"));
|
|
58
59
|
const relative_url_prefix_1 = __importStar(require("./rules/relative-url-prefix"));
|
|
59
60
|
const require_localize_metadata_1 = __importStar(require("./rules/require-localize-metadata"));
|
|
@@ -96,6 +97,7 @@ module.exports = {
|
|
|
96
97
|
[no_queries_metadata_property_1.RULE_NAME]: no_queries_metadata_property_1.default,
|
|
97
98
|
[pipe_prefix_1.RULE_NAME]: pipe_prefix_1.default,
|
|
98
99
|
[prefer_on_push_component_change_detection_1.RULE_NAME]: prefer_on_push_component_change_detection_1.default,
|
|
100
|
+
[prefer_standalone_1.RULE_NAME]: prefer_standalone_1.default,
|
|
99
101
|
[prefer_standalone_component_1.RULE_NAME]: prefer_standalone_component_1.default,
|
|
100
102
|
[prefer_output_readonly_1.RULE_NAME]: prefer_output_readonly_1.default,
|
|
101
103
|
[relative_url_prefix_1.RULE_NAME]: relative_url_prefix_1.default,
|
|
@@ -13,6 +13,8 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
13
13
|
docs: {
|
|
14
14
|
description: `Ensures component \`${METADATA_PROPERTY_NAME}\` property is set to \`${IS_STANDALONE}\` in the component decorator`,
|
|
15
15
|
},
|
|
16
|
+
deprecated: true,
|
|
17
|
+
replacedBy: ['prefer-standalone'],
|
|
16
18
|
fixable: 'code',
|
|
17
19
|
schema: [],
|
|
18
20
|
messages: {
|
|
@@ -0,0 +1,61 @@
|
|
|
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';
|
|
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, directive and pipe \`${METADATA_PROPERTY_NAME}\` property is set to \`${IS_STANDALONE}\` in the component decorator`,
|
|
15
|
+
},
|
|
16
|
+
fixable: 'code',
|
|
17
|
+
schema: [],
|
|
18
|
+
messages: {
|
|
19
|
+
preferStandalone: `The {{type}} \`${METADATA_PROPERTY_NAME}\` property should be set to \`${IS_STANDALONE}\``,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultOptions: [],
|
|
23
|
+
create(context) {
|
|
24
|
+
const standaloneRuleFactory = (type) => (node) => {
|
|
25
|
+
const standalone = utils_1.ASTUtils.getDecoratorPropertyValue(node, METADATA_PROPERTY_NAME);
|
|
26
|
+
if (standalone &&
|
|
27
|
+
utils_1.ASTUtils.isLiteral(standalone) &&
|
|
28
|
+
standalone.value === true) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
context.report({
|
|
32
|
+
node: nodeToReport(node),
|
|
33
|
+
messageId: 'preferStandalone',
|
|
34
|
+
data: { type },
|
|
35
|
+
fix: (fixer) => {
|
|
36
|
+
if (standalone &&
|
|
37
|
+
utils_1.ASTUtils.isLiteral(standalone) &&
|
|
38
|
+
standalone.value !== true) {
|
|
39
|
+
return [fixer.replaceText(standalone, IS_STANDALONE)].filter(utils_1.isNotNullOrUndefined);
|
|
40
|
+
}
|
|
41
|
+
return [
|
|
42
|
+
utils_1.RuleFixes.getDecoratorPropertyAddFix(node, fixer, `${METADATA_PROPERTY_NAME}: ${IS_STANDALONE}`),
|
|
43
|
+
].filter(utils_1.isNotNullOrUndefined);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
[utils_1.Selectors.COMPONENT_CLASS_DECORATOR]: standaloneRuleFactory('component'),
|
|
49
|
+
[utils_1.Selectors.DIRECTIVE_CLASS_DECORATOR]: standaloneRuleFactory('directive'),
|
|
50
|
+
[utils_1.Selectors.PIPE_CLASS_DECORATOR]: standaloneRuleFactory('pipe'),
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
function nodeToReport(node) {
|
|
55
|
+
if (!utils_1.ASTUtils.isProperty(node)) {
|
|
56
|
+
return node;
|
|
57
|
+
}
|
|
58
|
+
return utils_1.ASTUtils.isMemberExpression(node.value)
|
|
59
|
+
? node.value.property
|
|
60
|
+
: node.value;
|
|
61
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/eslint-plugin",
|
|
3
|
-
"version": "17.2.2-alpha.
|
|
3
|
+
"version": "17.2.2-alpha.9",
|
|
4
4
|
"description": "ESLint plugin for Angular applications, following angular.io/styleguide",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"LICENSE"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@angular-eslint/utils": "17.2.2-alpha.
|
|
20
|
+
"@angular-eslint/utils": "17.2.2-alpha.9",
|
|
21
21
|
"@typescript-eslint/utils": "7.2.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|