@angular-eslint/eslint-plugin 19.6.1-alpha.2 → 19.6.1-alpha.4
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 -0
- package/dist/configs/all.json +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/rules/no-uncalled-signals.d.ts +7 -0
- package/dist/rules/no-uncalled-signals.d.ts.map +1 -0
- package/dist/rules/no-uncalled-signals.js +47 -0
- package/dist/rules/prefer-signals.d.ts.map +1 -1
- package/dist/rules/prefer-signals.js +3 -8
- package/dist/utils/signals.d.ts +2 -0
- package/dist/utils/signals.d.ts.map +1 -0
- package/dist/utils/signals.js +9 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -64,6 +64,7 @@ Please see https://github.com/angular-eslint/angular-eslint for full usage instr
|
|
|
64
64
|
| [`no-outputs-metadata-property`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-outputs-metadata-property.md) | Disallows usage of the `outputs` metadata property. See more at https://angular.dev/style-guide#style-05-12 | :white_check_mark: | | |
|
|
65
65
|
| [`no-pipe-impure`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-pipe-impure.md) | Disallows the declaration of impure pipes | | | :bulb: |
|
|
66
66
|
| [`no-queries-metadata-property`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-queries-metadata-property.md) | Disallows usage of the `queries` metadata property. See more at https://angular.dev/style-guide#style-05-12. | | | |
|
|
67
|
+
| [`no-uncalled-signals`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-uncalled-signals.md) | Warns user about unintentionally doing logic on the signal, rather than the signal's value | | | :bulb: |
|
|
67
68
|
| [`pipe-prefix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/pipe-prefix.md) | Enforce consistent prefix for pipes. | | | |
|
|
68
69
|
| [`prefer-inject`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-inject.md) | Prefer using the inject() function over constructor parameter injection | | | |
|
|
69
70
|
| [`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: |
|
package/dist/configs/all.json
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"@angular-eslint/no-outputs-metadata-property": "error",
|
|
27
27
|
"@angular-eslint/no-pipe-impure": "error",
|
|
28
28
|
"@angular-eslint/no-queries-metadata-property": "error",
|
|
29
|
+
"@angular-eslint/no-uncalled-signals": "error",
|
|
29
30
|
"@angular-eslint/pipe-prefix": "error",
|
|
30
31
|
"@angular-eslint/prefer-inject": "error",
|
|
31
32
|
"@angular-eslint/prefer-on-push-component-change-detection": "error",
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ declare const _default: {
|
|
|
28
28
|
"@angular-eslint/no-outputs-metadata-property": string;
|
|
29
29
|
"@angular-eslint/no-pipe-impure": string;
|
|
30
30
|
"@angular-eslint/no-queries-metadata-property": string;
|
|
31
|
+
"@angular-eslint/no-uncalled-signals": string;
|
|
31
32
|
"@angular-eslint/pipe-prefix": string;
|
|
32
33
|
"@angular-eslint/prefer-inject": string;
|
|
33
34
|
"@angular-eslint/prefer-on-push-component-change-detection": string;
|
|
@@ -87,6 +88,7 @@ declare const _default: {
|
|
|
87
88
|
"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>;
|
|
88
89
|
"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>;
|
|
89
90
|
"no-lifecycle-call": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noLifecycleCall", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
91
|
+
"no-uncalled-signals": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/no-uncalled-signals").MessageIds, [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
90
92
|
"no-output-native": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noOutputNative", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
91
93
|
"no-output-on-prefix": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noOutputOnPrefix", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
92
94
|
"no-output-rename": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/no-output-rename").MessageIds, [], 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqIA,kBAmDE"}
|
package/dist/index.js
CHANGED
|
@@ -61,6 +61,7 @@ const no_output_rename_1 = __importStar(require("./rules/no-output-rename"));
|
|
|
61
61
|
const no_outputs_metadata_property_1 = __importStar(require("./rules/no-outputs-metadata-property"));
|
|
62
62
|
const no_pipe_impure_1 = __importStar(require("./rules/no-pipe-impure"));
|
|
63
63
|
const no_queries_metadata_property_1 = __importStar(require("./rules/no-queries-metadata-property"));
|
|
64
|
+
const no_uncalled_signals_1 = __importStar(require("./rules/no-uncalled-signals"));
|
|
64
65
|
const pipe_prefix_1 = __importStar(require("./rules/pipe-prefix"));
|
|
65
66
|
const prefer_on_push_component_change_detection_1 = __importStar(require("./rules/prefer-on-push-component-change-detection"));
|
|
66
67
|
const prefer_output_emitter_ref_1 = __importStar(require("./rules/prefer-output-emitter-ref"));
|
|
@@ -103,6 +104,7 @@ module.exports = {
|
|
|
103
104
|
[no_input_rename_1.RULE_NAME]: no_input_rename_1.default,
|
|
104
105
|
[no_inputs_metadata_property_1.RULE_NAME]: no_inputs_metadata_property_1.default,
|
|
105
106
|
[no_lifecycle_call_1.RULE_NAME]: no_lifecycle_call_1.default,
|
|
107
|
+
[no_uncalled_signals_1.RULE_NAME]: no_uncalled_signals_1.default,
|
|
106
108
|
[no_output_native_1.RULE_NAME]: no_output_native_1.default,
|
|
107
109
|
[no_output_on_prefix_1.RULE_NAME]: no_output_on_prefix_1.default,
|
|
108
110
|
[no_output_rename_1.RULE_NAME]: no_output_rename_1.default,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
export type Options = [];
|
|
3
|
+
export type MessageIds = 'noUncalledSignals' | 'suggestCallSignal';
|
|
4
|
+
export declare const RULE_NAME = "no-uncalled-signals";
|
|
5
|
+
declare const _default: ESLintUtils.RuleModule<MessageIds, [], import("../utils/create-eslint-rule").RuleDocs, ESLintUtils.RuleListener>;
|
|
6
|
+
export default _default;
|
|
7
|
+
//# sourceMappingURL=no-uncalled-signals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-uncalled-signals.d.ts","sourceRoot":"","sources":["../../src/rules/no-uncalled-signals.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EAGZ,MAAM,0BAA0B,CAAC;AAIlC,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AACzB,MAAM,MAAM,UAAU,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;AACnE,eAAO,MAAM,SAAS,wBAAwB,CAAC;;AAE/C,wBA+CG"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RULE_NAME = void 0;
|
|
4
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
+
const create_eslint_rule_1 = require("../utils/create-eslint-rule");
|
|
6
|
+
const signals_1 = require("../utils/signals");
|
|
7
|
+
exports.RULE_NAME = 'no-uncalled-signals';
|
|
8
|
+
exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
9
|
+
name: exports.RULE_NAME,
|
|
10
|
+
meta: {
|
|
11
|
+
type: 'suggestion',
|
|
12
|
+
docs: {
|
|
13
|
+
description: "Warns user about unintentionally doing logic on the signal, rather than the signal's value",
|
|
14
|
+
},
|
|
15
|
+
hasSuggestions: true,
|
|
16
|
+
schema: [],
|
|
17
|
+
messages: {
|
|
18
|
+
noUncalledSignals: 'Doing logic operations on signals will give unexpected results, you probably want to invoke the signal to get its value',
|
|
19
|
+
suggestCallSignal: 'Call this signal to get its value.',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultOptions: [],
|
|
23
|
+
create(context) {
|
|
24
|
+
const services = utils_1.ESLintUtils.getParserServices(context);
|
|
25
|
+
return {
|
|
26
|
+
'*.test[type=Identifier],*.test Identifier,[type=LogicalExpression] Identifier'(node) {
|
|
27
|
+
if (node.parent.type === utils_1.AST_NODE_TYPES.CallExpression) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const type = services.getTypeAtLocation(node);
|
|
31
|
+
const identifierType = type.getSymbol()?.name;
|
|
32
|
+
if (identifierType && signals_1.KNOWN_SIGNAL_TYPES.has(identifierType)) {
|
|
33
|
+
context.report({
|
|
34
|
+
node,
|
|
35
|
+
messageId: 'noUncalledSignals',
|
|
36
|
+
suggest: [
|
|
37
|
+
{
|
|
38
|
+
messageId: 'suggestCallSignal',
|
|
39
|
+
fix: (fixer) => fixer.replaceText(node, `${node.name}()`),
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
});
|
|
@@ -1 +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;
|
|
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;AAIvE,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;AAuBF,MAAM,MAAM,UAAU,GAClB,oBAAoB,GACpB,oBAAoB,GACpB,gCAAgC,CAAC;AACrC,eAAO,MAAM,SAAS,mBAAmB,CAAC;;AAE1C,wBAsLG"}
|
|
@@ -4,6 +4,7 @@ exports.RULE_NAME = void 0;
|
|
|
4
4
|
const utils_1 = require("@angular-eslint/utils");
|
|
5
5
|
const utils_2 = require("@typescript-eslint/utils");
|
|
6
6
|
const create_eslint_rule_1 = require("../utils/create-eslint-rule");
|
|
7
|
+
const signals_1 = require("../utils/signals");
|
|
7
8
|
const DEFAULT_OPTIONS = {
|
|
8
9
|
preferReadonlySignalProperties: true,
|
|
9
10
|
preferInputSignals: true,
|
|
@@ -11,12 +12,6 @@ const DEFAULT_OPTIONS = {
|
|
|
11
12
|
useTypeChecking: false,
|
|
12
13
|
additionalSignalCreationFunctions: [],
|
|
13
14
|
};
|
|
14
|
-
const KNOWN_SIGNAL_TYPES = new Set([
|
|
15
|
-
'InputSignal',
|
|
16
|
-
'ModelSignal',
|
|
17
|
-
'Signal',
|
|
18
|
-
'WritableSignal',
|
|
19
|
-
]);
|
|
20
15
|
const KNOWN_SIGNAL_CREATION_FUNCTIONS = new Set([
|
|
21
16
|
'computed',
|
|
22
17
|
'contentChild',
|
|
@@ -88,7 +83,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
88
83
|
const type = node.typeAnnotation.typeAnnotation;
|
|
89
84
|
if (type.typeArguments &&
|
|
90
85
|
type.typeName.type === utils_2.AST_NODE_TYPES.Identifier &&
|
|
91
|
-
KNOWN_SIGNAL_TYPES.has(type.typeName.name)) {
|
|
86
|
+
signals_1.KNOWN_SIGNAL_TYPES.has(type.typeName.name)) {
|
|
92
87
|
shouldBeReadonly = true;
|
|
93
88
|
}
|
|
94
89
|
}
|
|
@@ -134,7 +129,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
134
129
|
.getTypeAtLocation(node.value)
|
|
135
130
|
.getSymbol()?.name;
|
|
136
131
|
shouldBeReadonly =
|
|
137
|
-
name !== undefined && KNOWN_SIGNAL_TYPES.has(name);
|
|
132
|
+
name !== undefined && signals_1.KNOWN_SIGNAL_TYPES.has(name);
|
|
138
133
|
}
|
|
139
134
|
}
|
|
140
135
|
if (shouldBeReadonly) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/utils/signals.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAKjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/eslint-plugin",
|
|
3
|
-
"version": "19.6.1-alpha.
|
|
3
|
+
"version": "19.6.1-alpha.4",
|
|
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": "19.6.1-alpha.4",
|
|
22
|
+
"@angular-eslint/bundled-angular-compiler": "19.6.1-alpha.4"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@angular-eslint/test-utils": "19.6.1-alpha.
|
|
25
|
+
"@angular-eslint/test-utils": "19.6.1-alpha.4"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@typescript-eslint/utils": "^7.11.0 || ^8.0.0",
|