@angular-eslint/eslint-plugin 21.2.1-alpha.1 → 21.2.1-alpha.2
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/computed-must-return.d.ts +9 -0
- package/dist/rules/computed-must-return.d.ts.map +1 -0
- package/dist/rules/computed-must-return.js +62 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ Please see https://github.com/angular-eslint/angular-eslint for full usage instr
|
|
|
21
21
|
<!-- prettier-ignore-start -->
|
|
22
22
|
| Rule | Description | :white_check_mark: | :wrench: | :bulb: |
|
|
23
23
|
| --- | --- | --- | --- | --- |
|
|
24
|
+
| [`computed-must-return`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/computed-must-return.md) | Ensures that computed() returns a value. Omitting the value is likely a mistake. | | | |
|
|
24
25
|
| [`contextual-lifecycle`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/contextual-lifecycle.md) | Ensures that lifecycle methods are used in a correct context | :white_check_mark: | | |
|
|
25
26
|
| [`no-async-lifecycle-method`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-async-lifecycle-method.md) | Angular Lifecycle methods should not be async. Angular does not wait for async lifecycle but the code incorrectly suggests it does. | | | |
|
|
26
27
|
| [`no-attribute-decorator`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-attribute-decorator.md) | The @Attribute decorator is used to obtain a single value for an attribute. This is a much less common use case than getting a stream of values (using @Input), so the @Attribute decorator is often mistakenly used when @Input is intended. This rule disallows the usage of @Attribute decorator entirely to prevent these mistakes. | | | |
|
package/dist/configs/all.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"@angular-eslint/component-class-suffix": "error",
|
|
6
6
|
"@angular-eslint/component-max-inline-declarations": "error",
|
|
7
7
|
"@angular-eslint/component-selector": "error",
|
|
8
|
+
"@angular-eslint/computed-must-return": "error",
|
|
8
9
|
"@angular-eslint/consistent-component-styles": "error",
|
|
9
10
|
"@angular-eslint/contextual-decorator": "error",
|
|
10
11
|
"@angular-eslint/contextual-lifecycle": "error",
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ declare const _default: {
|
|
|
7
7
|
"@angular-eslint/component-class-suffix": string;
|
|
8
8
|
"@angular-eslint/component-max-inline-declarations": string;
|
|
9
9
|
"@angular-eslint/component-selector": string;
|
|
10
|
+
"@angular-eslint/computed-must-return": string;
|
|
10
11
|
"@angular-eslint/consistent-component-styles": string;
|
|
11
12
|
"@angular-eslint/contextual-decorator": string;
|
|
12
13
|
"@angular-eslint/contextual-lifecycle": string;
|
|
@@ -76,6 +77,7 @@ declare const _default: {
|
|
|
76
77
|
"component-class-suffix": import("@typescript-eslint/utils/ts-eslint").RuleModule<"componentClassSuffix", import("./rules/component-class-suffix").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
77
78
|
"component-max-inline-declarations": import("@typescript-eslint/utils/ts-eslint").RuleModule<"componentMaxInlineDeclarations", import("./rules/component-max-inline-declarations").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
78
79
|
"component-selector": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/component-selector").MessageIds, import("./rules/component-selector").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
80
|
+
"computed-must-return": import("@typescript-eslint/utils/ts-eslint").RuleModule<"computedMissingReturn", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
79
81
|
"consistent-component-styles": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/consistent-component-styles").MessageIds, import("./rules/consistent-component-styles").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
80
82
|
"contextual-decorator": import("@typescript-eslint/utils/ts-eslint").RuleModule<"contextualDecorator", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
81
83
|
"contextual-lifecycle": import("@typescript-eslint/utils/ts-eslint").RuleModule<"contextualLifecycle", [], 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuJA,kBAyDE"}
|
package/dist/index.js
CHANGED
|
@@ -85,6 +85,7 @@ const use_pipe_transform_interface_1 = __importStar(require("./rules/use-pipe-tr
|
|
|
85
85
|
const no_experimental_1 = __importStar(require("./rules/no-experimental"));
|
|
86
86
|
const no_developer_preview_1 = __importStar(require("./rules/no-developer-preview"));
|
|
87
87
|
const no_implicit_take_until_destroyed_1 = __importStar(require("./rules/no-implicit-take-until-destroyed"));
|
|
88
|
+
const computed_must_return_1 = __importStar(require("./rules/computed-must-return"));
|
|
88
89
|
module.exports = {
|
|
89
90
|
configs: {
|
|
90
91
|
all: all_json_1.default,
|
|
@@ -94,6 +95,7 @@ module.exports = {
|
|
|
94
95
|
[component_class_suffix_1.RULE_NAME]: component_class_suffix_1.default,
|
|
95
96
|
[component_max_inline_declarations_1.RULE_NAME]: component_max_inline_declarations_1.default,
|
|
96
97
|
[component_selector_1.RULE_NAME]: component_selector_1.default,
|
|
98
|
+
[computed_must_return_1.RULE_NAME]: computed_must_return_1.default,
|
|
97
99
|
[consistent_component_styles_1.RULE_NAME]: consistent_component_styles_1.default,
|
|
98
100
|
[contextual_decorator_1.RULE_NAME]: contextual_decorator_1.default,
|
|
99
101
|
[contextual_lifecycle_1.RULE_NAME]: contextual_lifecycle_1.default,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type Options = [];
|
|
2
|
+
export type MessageIds = 'computedMissingReturn';
|
|
3
|
+
export declare const RULE_NAME = "computed-must-return";
|
|
4
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"computedMissingReturn", [], import("../utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
5
|
+
export default _default;
|
|
6
|
+
export declare const RULE_DOCS_EXTENSION: {
|
|
7
|
+
rationale: string;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=computed-must-return.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed-must-return.d.ts","sourceRoot":"","sources":["../../src/rules/computed-must-return.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AACzB,MAAM,MAAM,UAAU,GAAG,uBAAuB,CAAC;AACjD,eAAO,MAAM,SAAS,yBAAyB,CAAC;;AAEhD,wBAqEG;AAEH,eAAO,MAAM,mBAAmB;;CAG/B,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RULE_DOCS_EXTENSION = exports.RULE_NAME = void 0;
|
|
4
|
+
const create_eslint_rule_1 = require("../utils/create-eslint-rule");
|
|
5
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
6
|
+
exports.RULE_NAME = 'computed-must-return';
|
|
7
|
+
exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
8
|
+
name: exports.RULE_NAME,
|
|
9
|
+
meta: {
|
|
10
|
+
type: 'problem',
|
|
11
|
+
docs: {
|
|
12
|
+
description: `Ensures that computed() returns a value. Omitting the value is likely a mistake.`,
|
|
13
|
+
},
|
|
14
|
+
schema: [],
|
|
15
|
+
messages: {
|
|
16
|
+
computedMissingReturn: 'computed() is missing a return value',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultOptions: [],
|
|
20
|
+
create(context) {
|
|
21
|
+
const functionStack = [];
|
|
22
|
+
function enterFunction(node) {
|
|
23
|
+
functionStack.push({
|
|
24
|
+
node,
|
|
25
|
+
hasReturn: false,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function exitFunction(node) {
|
|
29
|
+
const funcInfo = functionStack.pop();
|
|
30
|
+
if (node.parent?.type === utils_1.AST_NODE_TYPES.CallExpression &&
|
|
31
|
+
node.parent.callee.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
32
|
+
node.parent.callee.name === 'computed' &&
|
|
33
|
+
node.parent.arguments[0] === node) {
|
|
34
|
+
// Arrow function without a body
|
|
35
|
+
if (node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression &&
|
|
36
|
+
node.expression) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!funcInfo?.hasReturn) {
|
|
40
|
+
context.report({
|
|
41
|
+
node: node.parent,
|
|
42
|
+
messageId: 'computedMissingReturn',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
ArrowFunctionExpression: enterFunction,
|
|
49
|
+
'ArrowFunctionExpression:exit': exitFunction,
|
|
50
|
+
FunctionExpression: enterFunction,
|
|
51
|
+
'FunctionExpression:exit': exitFunction,
|
|
52
|
+
ReturnStatement(node) {
|
|
53
|
+
if (node.argument && functionStack.length > 0) {
|
|
54
|
+
functionStack[functionStack.length - 1].hasReturn = true;
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
exports.RULE_DOCS_EXTENSION = {
|
|
61
|
+
rationale: "`computed()` is used to transform signal values. If no value is returned from `computed()`, it's likely a mistake.",
|
|
62
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/eslint-plugin",
|
|
3
|
-
"version": "21.2.1-alpha.
|
|
3
|
+
"version": "21.2.1-alpha.2",
|
|
4
4
|
"description": "ESLint plugin for Angular applications, following https://angular.dev/style-guide",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"ts-api-utils": "^2.1.0",
|
|
22
|
-
"@angular-eslint/bundled-angular-compiler": "21.2.1-alpha.
|
|
23
|
-
"@angular-eslint/utils": "21.2.1-alpha.
|
|
22
|
+
"@angular-eslint/bundled-angular-compiler": "21.2.1-alpha.2",
|
|
23
|
+
"@angular-eslint/utils": "21.2.1-alpha.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@angular-eslint/test-utils": "21.2.1-alpha.
|
|
26
|
+
"@angular-eslint/test-utils": "21.2.1-alpha.2"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@typescript-eslint/utils": "^7.11.0 || ^8.0.0",
|