@angular-eslint/eslint-plugin 19.0.0-alpha.5 → 19.0.0
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 +1 -1
- package/dist/rules/prefer-standalone.d.ts.map +1 -1
- package/dist/rules/prefer-standalone.js +12 -12
- package/package.json +4 -4
- package/dist/rules/no-host-metadata-property.d.ts +0 -8
- package/dist/rules/no-host-metadata-property.d.ts.map +0 -1
- package/dist/rules/no-host-metadata-property.js +0 -67
- package/dist/rules/prefer-standalone-component.d.ts +0 -6
- package/dist/rules/prefer-standalone-component.d.ts.map +0 -1
- package/dist/rules/prefer-standalone-component.js +0 -59
- package/dist/rules/sort-ngmodule-metadata-arrays.d.ts +0 -10
- package/dist/rules/sort-ngmodule-metadata-arrays.d.ts.map +0 -1
- package/dist/rules/sort-ngmodule-metadata-arrays.js +0 -63
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
|
|
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":"
|
|
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
|
|
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: `
|
|
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,
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
3
|
+
"version": "19.0.0",
|
|
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
|
|
22
|
-
"@angular-eslint/utils": "19.0.0
|
|
21
|
+
"@angular-eslint/bundled-angular-compiler": "19.0.0",
|
|
22
|
+
"@angular-eslint/utils": "19.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@angular-eslint/test-utils": "19.0.0
|
|
25
|
+
"@angular-eslint/test-utils": "19.0.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@typescript-eslint/utils": "^7.11.0 || ^8.0.0",
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,67 +0,0 @@
|
|
|
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,6 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,59 +0,0 @@
|
|
|
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,10 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,63 +0,0 @@
|
|
|
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
|
-
});
|