@angular-eslint/eslint-plugin 16.0.4-alpha.3 → 16.0.4-alpha.34
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/dist/configs/all.json
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"@angular-eslint/pipe-prefix": "error",
|
|
28
28
|
"@angular-eslint/prefer-on-push-component-change-detection": "error",
|
|
29
29
|
"@angular-eslint/prefer-output-readonly": "error",
|
|
30
|
+
"@angular-eslint/prefer-standalone-component": "error",
|
|
30
31
|
"@angular-eslint/relative-url-prefix": "error",
|
|
31
32
|
"@angular-eslint/sort-ngmodule-metadata-arrays": "error",
|
|
32
33
|
"@angular-eslint/use-component-selector": "error",
|
package/dist/index.js
CHANGED
|
@@ -51,6 +51,7 @@ const no_pipe_impure_1 = __importStar(require("./rules/no-pipe-impure"));
|
|
|
51
51
|
const no_queries_metadata_property_1 = __importStar(require("./rules/no-queries-metadata-property"));
|
|
52
52
|
const pipe_prefix_1 = __importStar(require("./rules/pipe-prefix"));
|
|
53
53
|
const prefer_on_push_component_change_detection_1 = __importStar(require("./rules/prefer-on-push-component-change-detection"));
|
|
54
|
+
const prefer_standalone_component_1 = __importStar(require("./rules/prefer-standalone-component"));
|
|
54
55
|
const prefer_output_readonly_1 = __importStar(require("./rules/prefer-output-readonly"));
|
|
55
56
|
const relative_url_prefix_1 = __importStar(require("./rules/relative-url-prefix"));
|
|
56
57
|
const sort_ngmodule_metadata_arrays_1 = __importStar(require("./rules/sort-ngmodule-metadata-arrays"));
|
|
@@ -89,6 +90,7 @@ module.exports = {
|
|
|
89
90
|
[no_queries_metadata_property_1.RULE_NAME]: no_queries_metadata_property_1.default,
|
|
90
91
|
[pipe_prefix_1.RULE_NAME]: pipe_prefix_1.default,
|
|
91
92
|
[prefer_on_push_component_change_detection_1.RULE_NAME]: prefer_on_push_component_change_detection_1.default,
|
|
93
|
+
[prefer_standalone_component_1.RULE_NAME]: prefer_standalone_component_1.default,
|
|
92
94
|
[prefer_output_readonly_1.RULE_NAME]: prefer_output_readonly_1.default,
|
|
93
95
|
[relative_url_prefix_1.RULE_NAME]: relative_url_prefix_1.default,
|
|
94
96
|
[sort_ngmodule_metadata_arrays_1.RULE_NAME]: sort_ngmodule_metadata_arrays_1.default,
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
recommended: false,
|
|
16
|
+
},
|
|
17
|
+
fixable: 'code',
|
|
18
|
+
schema: [],
|
|
19
|
+
messages: {
|
|
20
|
+
preferStandaloneComponent: `The component \`${METADATA_PROPERTY_NAME}\` property should be set to \`${IS_STANDALONE}\``,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultOptions: [],
|
|
24
|
+
create(context) {
|
|
25
|
+
return {
|
|
26
|
+
[utils_1.Selectors.COMPONENT_CLASS_DECORATOR](node) {
|
|
27
|
+
const standalone = utils_1.ASTUtils.getDecoratorPropertyValue(node, METADATA_PROPERTY_NAME);
|
|
28
|
+
if (standalone &&
|
|
29
|
+
utils_1.ASTUtils.isLiteral(standalone) &&
|
|
30
|
+
standalone.value === true) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
context.report({
|
|
34
|
+
node: nodeToReport(node),
|
|
35
|
+
messageId: 'preferStandaloneComponent',
|
|
36
|
+
fix: (fixer) => {
|
|
37
|
+
if (standalone &&
|
|
38
|
+
utils_1.ASTUtils.isLiteral(standalone) &&
|
|
39
|
+
standalone.value !== true) {
|
|
40
|
+
return [fixer.replaceText(standalone, IS_STANDALONE)].filter(utils_1.isNotNullOrUndefined);
|
|
41
|
+
}
|
|
42
|
+
return [
|
|
43
|
+
utils_1.RuleFixes.getDecoratorPropertyAddFix(node, fixer, `${METADATA_PROPERTY_NAME}: ${IS_STANDALONE}`),
|
|
44
|
+
].filter(utils_1.isNotNullOrUndefined);
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
function nodeToReport(node) {
|
|
52
|
+
if (!utils_1.ASTUtils.isProperty(node)) {
|
|
53
|
+
return node;
|
|
54
|
+
}
|
|
55
|
+
return utils_1.ASTUtils.isMemberExpression(node.value)
|
|
56
|
+
? node.value.property
|
|
57
|
+
: node.value;
|
|
58
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/eslint-plugin",
|
|
3
|
-
"version": "16.0.4-alpha.
|
|
3
|
+
"version": "16.0.4-alpha.34+93464ca",
|
|
4
4
|
"description": "ESLint plugin for Angular applications, following angular.io/styleguide",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"LICENSE"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@angular-eslint/utils": "16.0.4-alpha.
|
|
21
|
-
"@typescript-eslint/utils": "5.59.
|
|
20
|
+
"@angular-eslint/utils": "16.0.4-alpha.34+93464ca",
|
|
21
|
+
"@typescript-eslint/utils": "5.59.9"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"eslint": "^7.20.0 || ^8.0.0",
|
|
25
25
|
"typescript": "*"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "93464ca55f7938a3bd99c7560d05ca24bea1e7c7"
|
|
28
28
|
}
|