@angular-eslint/eslint-plugin 18.4.3 → 18.4.4-alpha.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 -11
- package/dist/configs/all.json +0 -3
- package/dist/configs/recommended.json +1 -0
- package/dist/index.d.ts +1 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -6
- package/dist/rules/prefer-signals.d.ts +15 -0
- package/dist/rules/prefer-signals.d.ts.map +1 -0
- package/dist/rules/prefer-signals.js +168 -0
- package/dist/rules/prefer-standalone.d.ts.map +1 -1
- package/dist/rules/prefer-standalone.js +15 -15
- 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. | | | |
|
|
@@ -85,14 +85,4 @@ Please see https://github.com/angular-eslint/angular-eslint for full usage instr
|
|
|
85
85
|
|
|
86
86
|
<!-- begin deprecated rule list -->
|
|
87
87
|
|
|
88
|
-
### Deprecated
|
|
89
|
-
|
|
90
|
-
<!-- prettier-ignore-start -->
|
|
91
|
-
| Rule | Replaced by |
|
|
92
|
-
| --- | --- |
|
|
93
|
-
| [`no-host-metadata-property`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-host-metadata-property.md) | |
|
|
94
|
-
| [`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.md) |
|
|
95
|
-
| [`sort-ngmodule-metadata-arrays`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/sort-ngmodule-metadata-arrays.md) | |
|
|
96
|
-
<!-- prettier-ignore-end -->
|
|
97
|
-
|
|
98
88
|
<!-- end deprecated rule list -->
|
package/dist/configs/all.json
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"@angular-eslint/no-duplicates-in-metadata-arrays": "error",
|
|
17
17
|
"@angular-eslint/no-empty-lifecycle-method": "error",
|
|
18
18
|
"@angular-eslint/no-forward-ref": "error",
|
|
19
|
-
"@angular-eslint/no-host-metadata-property": "error",
|
|
20
19
|
"@angular-eslint/no-input-prefix": "error",
|
|
21
20
|
"@angular-eslint/no-input-rename": "error",
|
|
22
21
|
"@angular-eslint/no-inputs-metadata-property": "error",
|
|
@@ -31,12 +30,10 @@
|
|
|
31
30
|
"@angular-eslint/prefer-on-push-component-change-detection": "error",
|
|
32
31
|
"@angular-eslint/prefer-output-readonly": "error",
|
|
33
32
|
"@angular-eslint/prefer-standalone": "error",
|
|
34
|
-
"@angular-eslint/prefer-standalone-component": "error",
|
|
35
33
|
"@angular-eslint/relative-url-prefix": "error",
|
|
36
34
|
"@angular-eslint/require-localize-metadata": "error",
|
|
37
35
|
"@angular-eslint/runtime-localize": "error",
|
|
38
36
|
"@angular-eslint/sort-lifecycle-methods": "error",
|
|
39
|
-
"@angular-eslint/sort-ngmodule-metadata-arrays": "error",
|
|
40
37
|
"@angular-eslint/use-component-selector": "error",
|
|
41
38
|
"@angular-eslint/use-component-view-encapsulation": "error",
|
|
42
39
|
"@angular-eslint/use-injectable-provided-in": "error",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"@angular-eslint/no-output-on-prefix": "error",
|
|
13
13
|
"@angular-eslint/no-output-rename": "error",
|
|
14
14
|
"@angular-eslint/no-outputs-metadata-property": "error",
|
|
15
|
+
"@angular-eslint/prefer-standalone": "error",
|
|
15
16
|
"@angular-eslint/use-pipe-transform-interface": "error",
|
|
16
17
|
"@angular-eslint/use-lifecycle-interface": "warn"
|
|
17
18
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ declare const _default: {
|
|
|
18
18
|
"@angular-eslint/no-duplicates-in-metadata-arrays": string;
|
|
19
19
|
"@angular-eslint/no-empty-lifecycle-method": string;
|
|
20
20
|
"@angular-eslint/no-forward-ref": string;
|
|
21
|
-
"@angular-eslint/no-host-metadata-property": string;
|
|
22
21
|
"@angular-eslint/no-input-prefix": string;
|
|
23
22
|
"@angular-eslint/no-input-rename": string;
|
|
24
23
|
"@angular-eslint/no-inputs-metadata-property": string;
|
|
@@ -33,12 +32,10 @@ declare const _default: {
|
|
|
33
32
|
"@angular-eslint/prefer-on-push-component-change-detection": string;
|
|
34
33
|
"@angular-eslint/prefer-output-readonly": string;
|
|
35
34
|
"@angular-eslint/prefer-standalone": string;
|
|
36
|
-
"@angular-eslint/prefer-standalone-component": string;
|
|
37
35
|
"@angular-eslint/relative-url-prefix": string;
|
|
38
36
|
"@angular-eslint/require-localize-metadata": string;
|
|
39
37
|
"@angular-eslint/runtime-localize": string;
|
|
40
38
|
"@angular-eslint/sort-lifecycle-methods": string;
|
|
41
|
-
"@angular-eslint/sort-ngmodule-metadata-arrays": string;
|
|
42
39
|
"@angular-eslint/use-component-selector": string;
|
|
43
40
|
"@angular-eslint/use-component-view-encapsulation": string;
|
|
44
41
|
"@angular-eslint/use-injectable-provided-in": string;
|
|
@@ -60,6 +57,7 @@ declare const _default: {
|
|
|
60
57
|
"@angular-eslint/no-output-on-prefix": string;
|
|
61
58
|
"@angular-eslint/no-output-rename": string;
|
|
62
59
|
"@angular-eslint/no-outputs-metadata-property": string;
|
|
60
|
+
"@angular-eslint/prefer-standalone": string;
|
|
63
61
|
"@angular-eslint/use-pipe-transform-interface": string;
|
|
64
62
|
"@angular-eslint/use-lifecycle-interface": string;
|
|
65
63
|
};
|
|
@@ -80,7 +78,6 @@ declare const _default: {
|
|
|
80
78
|
"no-duplicates-in-metadata-arrays": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noDuplicatesInMetadataArrays", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
81
79
|
"no-empty-lifecycle-method": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/no-empty-lifecycle-method").MessageIds, [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
82
80
|
"no-forward-ref": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noForwardRef", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
83
|
-
"no-host-metadata-property": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noHostMetadataProperty", import("./rules/no-host-metadata-property").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
84
81
|
"no-input-prefix": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noInputPrefix", import("./rules/no-input-prefix").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
85
82
|
"no-input-rename": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/no-input-rename").MessageIds, import("./rules/no-input-rename").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
86
83
|
"no-inputs-metadata-property": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noInputsMetadataProperty", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
@@ -94,13 +91,11 @@ declare const _default: {
|
|
|
94
91
|
"pipe-prefix": import("@typescript-eslint/utils/ts-eslint").RuleModule<"pipePrefix", import("./rules/pipe-prefix").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
95
92
|
"prefer-on-push-component-change-detection": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/prefer-on-push-component-change-detection").MessageIds, [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
96
93
|
"prefer-standalone": import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferStandalone", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
97
|
-
"prefer-standalone-component": import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferStandaloneComponent", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
98
94
|
"prefer-output-readonly": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/prefer-output-readonly").MessageIds, [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
99
95
|
"relative-url-prefix": import("@typescript-eslint/utils/ts-eslint").RuleModule<"relativeUrlPrefix", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
100
96
|
"require-localize-metadata": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/require-localize-metadata").MessageIds, import("./rules/require-localize-metadata").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
101
97
|
"runtime-localize": import("@typescript-eslint/utils/ts-eslint").RuleModule<"runtimeLocalize", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
102
98
|
"sort-lifecycle-methods": import("@typescript-eslint/utils/ts-eslint").RuleModule<"lifecycleMethodsNotSorted", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
103
|
-
"sort-ngmodule-metadata-arrays": import("@typescript-eslint/utils/ts-eslint").RuleModule<"sortNgmoduleMetadataArrays", import("./rules/sort-ngmodule-metadata-arrays").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
104
99
|
"use-component-selector": import("@typescript-eslint/utils/ts-eslint").RuleModule<"useComponentSelector", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
105
100
|
"use-component-view-encapsulation": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/use-component-view-encapsulation").MessageIds, [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
106
101
|
"use-injectable-provided-in": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/use-injectable-provided-in").MessageIds, import("./rules/use-injectable-provided-in").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmHA,kBA6CE"}
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,6 @@ const no_attribute_decorator_1 = __importStar(require("./rules/no-attribute-deco
|
|
|
40
40
|
const no_conflicting_lifecycle_1 = __importStar(require("./rules/no-conflicting-lifecycle"));
|
|
41
41
|
const no_empty_lifecycle_method_1 = __importStar(require("./rules/no-empty-lifecycle-method"));
|
|
42
42
|
const no_forward_ref_1 = __importStar(require("./rules/no-forward-ref"));
|
|
43
|
-
const no_host_metadata_property_1 = __importStar(require("./rules/no-host-metadata-property"));
|
|
44
43
|
const no_input_prefix_1 = __importStar(require("./rules/no-input-prefix"));
|
|
45
44
|
const no_input_rename_1 = __importStar(require("./rules/no-input-rename"));
|
|
46
45
|
const no_inputs_metadata_property_1 = __importStar(require("./rules/no-inputs-metadata-property"));
|
|
@@ -55,12 +54,10 @@ const pipe_prefix_1 = __importStar(require("./rules/pipe-prefix"));
|
|
|
55
54
|
const prefer_on_push_component_change_detection_1 = __importStar(require("./rules/prefer-on-push-component-change-detection"));
|
|
56
55
|
const prefer_output_readonly_1 = __importStar(require("./rules/prefer-output-readonly"));
|
|
57
56
|
const prefer_standalone_1 = __importStar(require("./rules/prefer-standalone"));
|
|
58
|
-
const prefer_standalone_component_1 = __importStar(require("./rules/prefer-standalone-component"));
|
|
59
57
|
const relative_url_prefix_1 = __importStar(require("./rules/relative-url-prefix"));
|
|
60
58
|
const require_localize_metadata_1 = __importStar(require("./rules/require-localize-metadata"));
|
|
61
59
|
const runtime_localize_1 = __importStar(require("./rules/runtime-localize"));
|
|
62
60
|
const sort_lifecycle_methods_1 = __importStar(require("./rules/sort-lifecycle-methods"));
|
|
63
|
-
const sort_ngmodule_metadata_arrays_1 = __importStar(require("./rules/sort-ngmodule-metadata-arrays"));
|
|
64
61
|
const use_component_selector_1 = __importStar(require("./rules/use-component-selector"));
|
|
65
62
|
const use_component_view_encapsulation_1 = __importStar(require("./rules/use-component-view-encapsulation"));
|
|
66
63
|
const use_injectable_provided_in_1 = __importStar(require("./rules/use-injectable-provided-in"));
|
|
@@ -87,7 +84,6 @@ module.exports = {
|
|
|
87
84
|
[no_duplicates_in_metadata_arrays_1.RULE_NAME]: no_duplicates_in_metadata_arrays_1.default,
|
|
88
85
|
[no_empty_lifecycle_method_1.RULE_NAME]: no_empty_lifecycle_method_1.default,
|
|
89
86
|
[no_forward_ref_1.RULE_NAME]: no_forward_ref_1.default,
|
|
90
|
-
[no_host_metadata_property_1.RULE_NAME]: no_host_metadata_property_1.default,
|
|
91
87
|
[no_input_prefix_1.RULE_NAME]: no_input_prefix_1.default,
|
|
92
88
|
[no_input_rename_1.RULE_NAME]: no_input_rename_1.default,
|
|
93
89
|
[no_inputs_metadata_property_1.RULE_NAME]: no_inputs_metadata_property_1.default,
|
|
@@ -101,13 +97,11 @@ module.exports = {
|
|
|
101
97
|
[pipe_prefix_1.RULE_NAME]: pipe_prefix_1.default,
|
|
102
98
|
[prefer_on_push_component_change_detection_1.RULE_NAME]: prefer_on_push_component_change_detection_1.default,
|
|
103
99
|
[prefer_standalone_1.RULE_NAME]: prefer_standalone_1.default,
|
|
104
|
-
[prefer_standalone_component_1.RULE_NAME]: prefer_standalone_component_1.default,
|
|
105
100
|
[prefer_output_readonly_1.RULE_NAME]: prefer_output_readonly_1.default,
|
|
106
101
|
[relative_url_prefix_1.RULE_NAME]: relative_url_prefix_1.default,
|
|
107
102
|
[require_localize_metadata_1.RULE_NAME]: require_localize_metadata_1.default,
|
|
108
103
|
[runtime_localize_1.RULE_NAME]: runtime_localize_1.default,
|
|
109
104
|
[sort_lifecycle_methods_1.RULE_NAME]: sort_lifecycle_methods_1.default,
|
|
110
|
-
[sort_ngmodule_metadata_arrays_1.RULE_NAME]: sort_ngmodule_metadata_arrays_1.default,
|
|
111
105
|
[use_component_selector_1.RULE_NAME]: use_component_selector_1.default,
|
|
112
106
|
[use_component_view_encapsulation_1.RULE_NAME]: use_component_view_encapsulation_1.default,
|
|
113
107
|
[use_injectable_provided_in_1.RULE_NAME]: use_injectable_provided_in_1.default,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
type Options = [
|
|
3
|
+
{
|
|
4
|
+
preferReadonlySignalProperties: boolean;
|
|
5
|
+
preferInputSignals: boolean;
|
|
6
|
+
preferQuerySignals: boolean;
|
|
7
|
+
useTypeChecking: boolean;
|
|
8
|
+
additionalSignalCreationFunctions: string[];
|
|
9
|
+
}
|
|
10
|
+
];
|
|
11
|
+
export type MessageIds = 'preferInputSignals' | 'preferQuerySignals' | 'preferReadonlySignalProperties' | 'suggestAddReadonlyModifier';
|
|
12
|
+
export declare const RULE_NAME = "prefer-signals";
|
|
13
|
+
declare const _default: ESLintUtils.RuleModule<MessageIds, Options, import("../utils/create-eslint-rule").RuleDocs, ESLintUtils.RuleListener>;
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=prefer-signals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-signals.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-signals.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvE,KAAK,OAAO,GAAG;IACb;QACE,8BAA8B,EAAE,OAAO,CAAC;QACxC,kBAAkB,EAAE,OAAO,CAAC;QAC5B,kBAAkB,EAAE,OAAO,CAAC;QAC5B,eAAe,EAAE,OAAO,CAAC;QACzB,iCAAiC,EAAE,MAAM,EAAE,CAAC;KAC7C;CACF,CAAC;AA4BF,MAAM,MAAM,UAAU,GAClB,oBAAoB,GACpB,oBAAoB,GACpB,gCAAgC,GAChC,4BAA4B,CAAC;AACjC,eAAO,MAAM,SAAS,mBAAmB,CAAC;;AAE1C,wBA6KG"}
|
|
@@ -0,0 +1,168 @@
|
|
|
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
|
+
const DEFAULT_OPTIONS = {
|
|
8
|
+
preferReadonlySignalProperties: true,
|
|
9
|
+
preferInputSignals: true,
|
|
10
|
+
preferQuerySignals: true,
|
|
11
|
+
useTypeChecking: false,
|
|
12
|
+
additionalSignalCreationFunctions: [],
|
|
13
|
+
};
|
|
14
|
+
const KNOWN_SIGNAL_TYPES = new Set([
|
|
15
|
+
'InputSignal',
|
|
16
|
+
'ModelSignal',
|
|
17
|
+
'Signal',
|
|
18
|
+
'WritableSignal',
|
|
19
|
+
]);
|
|
20
|
+
const KNOWN_SIGNAL_CREATION_FUNCTIONS = new Set([
|
|
21
|
+
'computed',
|
|
22
|
+
'contentChild',
|
|
23
|
+
'contentChildren',
|
|
24
|
+
'input',
|
|
25
|
+
'model',
|
|
26
|
+
'signal',
|
|
27
|
+
'toSignal',
|
|
28
|
+
'viewChild',
|
|
29
|
+
'viewChildren',
|
|
30
|
+
]);
|
|
31
|
+
exports.RULE_NAME = 'prefer-signals';
|
|
32
|
+
exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
33
|
+
name: exports.RULE_NAME,
|
|
34
|
+
meta: {
|
|
35
|
+
type: 'suggestion',
|
|
36
|
+
docs: {
|
|
37
|
+
description: 'Use readonly signals instead of `@Input()`, `@ViewChild()` and other legacy decorators',
|
|
38
|
+
recommended: 'recommended',
|
|
39
|
+
},
|
|
40
|
+
hasSuggestions: true,
|
|
41
|
+
schema: [
|
|
42
|
+
{
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: {
|
|
45
|
+
preferReadonlySignalProperties: {
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
default: DEFAULT_OPTIONS.preferReadonlySignalProperties,
|
|
48
|
+
},
|
|
49
|
+
preferInputSignals: {
|
|
50
|
+
type: 'boolean',
|
|
51
|
+
default: DEFAULT_OPTIONS.preferInputSignals,
|
|
52
|
+
},
|
|
53
|
+
preferQuerySignals: {
|
|
54
|
+
type: 'boolean',
|
|
55
|
+
default: DEFAULT_OPTIONS.preferQuerySignals,
|
|
56
|
+
},
|
|
57
|
+
useTypeChecking: {
|
|
58
|
+
type: 'boolean',
|
|
59
|
+
default: DEFAULT_OPTIONS.useTypeChecking,
|
|
60
|
+
},
|
|
61
|
+
additionalSignalCreationFunctions: {
|
|
62
|
+
type: 'array',
|
|
63
|
+
items: { type: 'string' },
|
|
64
|
+
default: DEFAULT_OPTIONS.additionalSignalCreationFunctions,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
additionalProperties: false,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
messages: {
|
|
71
|
+
preferInputSignals: 'Use `InputSignal`s (e.g. via `input()`) for Component input properties rather than the legacy `@Input()` decorator',
|
|
72
|
+
preferQuerySignals: 'Use the `{{function}}` function instead of the `{{decorator}}` decorator',
|
|
73
|
+
preferReadonlySignalProperties: 'Properties declared using signals should be marked as `readonly` since they should not be reassigned',
|
|
74
|
+
suggestAddReadonlyModifier: 'Add `readonly` modifier',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
defaultOptions: [{ ...DEFAULT_OPTIONS }],
|
|
78
|
+
create(context, [{ preferReadonlySignalProperties = DEFAULT_OPTIONS.preferReadonlySignalProperties, preferInputSignals = DEFAULT_OPTIONS.preferInputSignals, preferQuerySignals = DEFAULT_OPTIONS.preferQuerySignals, additionalSignalCreationFunctions = DEFAULT_OPTIONS.additionalSignalCreationFunctions, useTypeChecking = DEFAULT_OPTIONS.useTypeChecking, },]) {
|
|
79
|
+
let services;
|
|
80
|
+
const listener = {};
|
|
81
|
+
if (preferReadonlySignalProperties) {
|
|
82
|
+
listener[`PropertyDefinition:not([readonly=true])`] = (node) => {
|
|
83
|
+
let shouldBeReadonly = false;
|
|
84
|
+
if (node.typeAnnotation) {
|
|
85
|
+
// Use the type annotation to determine
|
|
86
|
+
// whether the property is a signal.
|
|
87
|
+
if (node.typeAnnotation.typeAnnotation.type ===
|
|
88
|
+
utils_2.AST_NODE_TYPES.TSTypeReference) {
|
|
89
|
+
const type = node.typeAnnotation.typeAnnotation;
|
|
90
|
+
if (type.typeArguments &&
|
|
91
|
+
type.typeName.type === utils_2.AST_NODE_TYPES.Identifier &&
|
|
92
|
+
KNOWN_SIGNAL_TYPES.has(type.typeName.name)) {
|
|
93
|
+
shouldBeReadonly = true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// There is no type annotation, so try to
|
|
99
|
+
// use the value assigned to the property
|
|
100
|
+
// to determine whether it would be a signal.
|
|
101
|
+
if (node.value?.type === utils_2.AST_NODE_TYPES.CallExpression) {
|
|
102
|
+
let callee = node.value.callee;
|
|
103
|
+
// Some signal-creating functions have a `.required`
|
|
104
|
+
// member. For example, `input.required()`.
|
|
105
|
+
if (callee.type === utils_2.AST_NODE_TYPES.MemberExpression) {
|
|
106
|
+
if (callee.property.type === utils_2.AST_NODE_TYPES.Identifier &&
|
|
107
|
+
callee.property.name !== 'required') {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
callee = callee.object;
|
|
111
|
+
}
|
|
112
|
+
if (callee.type === utils_2.AST_NODE_TYPES.Identifier &&
|
|
113
|
+
(KNOWN_SIGNAL_CREATION_FUNCTIONS.has(callee.name) ||
|
|
114
|
+
additionalSignalCreationFunctions.includes(callee.name))) {
|
|
115
|
+
shouldBeReadonly = true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (!shouldBeReadonly && useTypeChecking && node.value) {
|
|
119
|
+
services ??= utils_2.ESLintUtils.getParserServices(context);
|
|
120
|
+
const name = services
|
|
121
|
+
.getTypeAtLocation(node.value)
|
|
122
|
+
.getSymbol()?.name;
|
|
123
|
+
shouldBeReadonly =
|
|
124
|
+
name !== undefined && KNOWN_SIGNAL_TYPES.has(name);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (shouldBeReadonly) {
|
|
128
|
+
context.report({
|
|
129
|
+
node: node.key,
|
|
130
|
+
messageId: 'preferReadonlySignalProperties',
|
|
131
|
+
suggest: [
|
|
132
|
+
{
|
|
133
|
+
messageId: 'suggestAddReadonlyModifier',
|
|
134
|
+
fix: (fixer) => fixer.insertTextBefore(node.key, 'readonly '),
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
if (preferInputSignals) {
|
|
142
|
+
listener[utils_1.Selectors.INPUT_DECORATOR] = (node) => {
|
|
143
|
+
context.report({
|
|
144
|
+
node,
|
|
145
|
+
messageId: 'preferInputSignals',
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
if (preferQuerySignals) {
|
|
150
|
+
listener['Decorator[expression.callee.name=/^(ContentChild|ContentChildren|ViewChild|ViewChildren)$/]'] = (node) => {
|
|
151
|
+
if (node.expression.type === utils_2.AST_NODE_TYPES.CallExpression &&
|
|
152
|
+
node.expression.callee.type === utils_2.AST_NODE_TYPES.Identifier) {
|
|
153
|
+
const decoratorName = node.expression.callee.name;
|
|
154
|
+
context.report({
|
|
155
|
+
node,
|
|
156
|
+
messageId: 'preferQuerySignals',
|
|
157
|
+
data: {
|
|
158
|
+
function: decoratorName.slice(0, 1).toLowerCase() +
|
|
159
|
+
decoratorName.slice(1),
|
|
160
|
+
decorator: decoratorName,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
return listener;
|
|
167
|
+
},
|
|
168
|
+
});
|
|
@@ -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,28 +4,27 @@ 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`,
|
|
13
|
+
recommended: 'recommended',
|
|
15
14
|
},
|
|
16
15
|
fixable: 'code',
|
|
17
16
|
schema: [],
|
|
18
17
|
messages: {
|
|
19
|
-
preferStandalone: `
|
|
18
|
+
preferStandalone: `Components, Directives and Pipes should not opt out of standalone`,
|
|
20
19
|
},
|
|
21
20
|
},
|
|
22
21
|
defaultOptions: [],
|
|
23
22
|
create(context) {
|
|
24
23
|
const standaloneRuleFactory = (type) => (node) => {
|
|
25
|
-
const standalone = utils_1.ASTUtils.getDecoratorPropertyValue(node,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
standalone.value === true) {
|
|
24
|
+
const standalone = utils_1.ASTUtils.getDecoratorPropertyValue(node, 'standalone');
|
|
25
|
+
// Leave the standalone property alone if it was set to true or not present
|
|
26
|
+
if (!standalone ||
|
|
27
|
+
(utils_1.ASTUtils.isLiteral(standalone) && standalone.value === true)) {
|
|
29
28
|
return;
|
|
30
29
|
}
|
|
31
30
|
if (!utils_1.ASTUtils.getDecoratorArgument(node)) {
|
|
@@ -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": "18.4.
|
|
3
|
+
"version": "18.4.4-alpha.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/
|
|
22
|
-
"@angular-eslint/
|
|
21
|
+
"@angular-eslint/utils": "18.4.4-alpha.0",
|
|
22
|
+
"@angular-eslint/bundled-angular-compiler": "18.4.4-alpha.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@angular-eslint/test-utils": "18.4.
|
|
25
|
+
"@angular-eslint/test-utils": "18.4.4-alpha.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
|
-
});
|