@angular-eslint/eslint-plugin-template 20.1.1-alpha.4 → 20.1.1-alpha.6
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.
|
@@ -8,4 +8,7 @@ export declare const RULE_NAME = "button-has-type";
|
|
|
8
8
|
export declare const INVALID_TYPE_DATA_KEY = "type";
|
|
9
9
|
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, Options, import("../utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
10
10
|
export default _default;
|
|
11
|
+
export declare const RULE_DOCS_EXTENSION: {
|
|
12
|
+
rationale: string;
|
|
13
|
+
};
|
|
11
14
|
//# sourceMappingURL=button-has-type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-has-type.d.ts","sourceRoot":"","sources":["../../src/rules/button-has-type.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1C;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,aAAa,CAAC;AACvD,eAAO,MAAM,SAAS,oBAAoB,CAAC;AAI3C,eAAO,MAAM,qBAAqB,SAAS,CAAC;;AAW5C,wBA4DG"}
|
|
1
|
+
{"version":3,"file":"button-has-type.d.ts","sourceRoot":"","sources":["../../src/rules/button-has-type.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1C;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,aAAa,CAAC;AACvD,eAAO,MAAM,SAAS,oBAAoB,CAAC;AAI3C,eAAO,MAAM,qBAAqB,SAAS,CAAC;;AAW5C,wBA4DG;AAEH,eAAO,MAAM,mBAAmB;;CAG/B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.INVALID_TYPE_DATA_KEY = exports.RULE_NAME = void 0;
|
|
3
|
+
exports.RULE_DOCS_EXTENSION = exports.INVALID_TYPE_DATA_KEY = exports.RULE_NAME = void 0;
|
|
4
4
|
const bundled_angular_compiler_1 = require("@angular-eslint/bundled-angular-compiler");
|
|
5
5
|
const utils_1 = require("@angular-eslint/utils");
|
|
6
6
|
const create_eslint_rule_1 = require("../utils/create-eslint-rule");
|
|
@@ -65,6 +65,9 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
65
65
|
};
|
|
66
66
|
},
|
|
67
67
|
});
|
|
68
|
+
exports.RULE_DOCS_EXTENSION = {
|
|
69
|
+
rationale: 'Buttons default to `type="submit"` when no type is specified. If placed inside a form, the button triggers a form submission on click. Enforcing the type attribute clarifies the code\'s intent and prevents unintended form submissions.',
|
|
70
|
+
};
|
|
68
71
|
function isTypeAttributePresentInElement({ inputs, attributes, }) {
|
|
69
72
|
return [...inputs, ...attributes].some(({ name }) => name === TYPE_ATTRIBUTE_NAME);
|
|
70
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-interpolation-in-attributes.d.ts","sourceRoot":"","sources":["../../src/rules/no-interpolation-in-attributes.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,OAAO,GAAG,CAAC;IAAE,2BAA2B,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,6BAA6B,CAAC;AACvD,eAAO,MAAM,SAAS,mCAAmC,CAAC;;AAY1D,
|
|
1
|
+
{"version":3,"file":"no-interpolation-in-attributes.d.ts","sourceRoot":"","sources":["../../src/rules/no-interpolation-in-attributes.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,OAAO,GAAG,CAAC;IAAE,2BAA2B,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,6BAA6B,CAAC;AACvD,eAAO,MAAM,SAAS,mCAAmC,CAAC;;AAY1D,wBAmFG"}
|
|
@@ -59,16 +59,20 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
59
59
|
messageId: 'noInterpolationInAttributes',
|
|
60
60
|
fix: isFullInterpolation
|
|
61
61
|
? (fixer) => {
|
|
62
|
-
const
|
|
62
|
+
const attrStart = boundAttribute.keySpan.start.offset;
|
|
63
|
+
const attrEnd = boundAttribute.keySpan.end.offset;
|
|
64
|
+
const attributeName = sourceCode.text
|
|
65
|
+
.slice(attrStart, attrEnd)
|
|
66
|
+
.trim();
|
|
63
67
|
const exprStart = boundAttribute.valueSpan.start.offset + 2; // +2 to remove '{{'
|
|
64
68
|
const exprEnd = boundAttribute.valueSpan.end.offset - 2; // -2 to remove '}}'
|
|
65
69
|
const expression = sourceCode.text
|
|
66
70
|
.slice(exprStart, exprEnd)
|
|
67
71
|
.trim();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
],
|
|
72
|
+
const rangeStart = boundAttribute.sourceSpan.start.offset;
|
|
73
|
+
const rangeEnd = boundAttribute.sourceSpan.end.offset;
|
|
74
|
+
const replacement = `[${attributeName}]="${expression}"`;
|
|
75
|
+
return fixer.replaceTextRange([rangeStart, rangeEnd], replacement);
|
|
72
76
|
}
|
|
73
77
|
: null,
|
|
74
78
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/eslint-plugin-template",
|
|
3
|
-
"version": "20.1.1-alpha.
|
|
3
|
+
"version": "20.1.1-alpha.6",
|
|
4
4
|
"description": "ESLint plugin for Angular Templates",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"aria-query": "5.3.2",
|
|
22
22
|
"axobject-query": "4.1.0",
|
|
23
|
-
"@angular-eslint/bundled-angular-compiler": "20.1.1-alpha.
|
|
24
|
-
"@angular-eslint/utils": "20.1.1-alpha.
|
|
23
|
+
"@angular-eslint/bundled-angular-compiler": "20.1.1-alpha.6",
|
|
24
|
+
"@angular-eslint/utils": "20.1.1-alpha.6"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/aria-query": "5.0.4",
|
|
28
|
-
"@angular-eslint/test-utils": "20.1.1-alpha.
|
|
28
|
+
"@angular-eslint/test-utils": "20.1.1-alpha.6"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@typescript-eslint/types": "^7.11.0 || ^8.0.0",
|
|
32
32
|
"@typescript-eslint/utils": "^7.11.0 || ^8.0.0",
|
|
33
33
|
"eslint": "^8.57.0 || ^9.0.0",
|
|
34
34
|
"typescript": "*",
|
|
35
|
-
"@angular-eslint/template-parser": "20.1.1-alpha.
|
|
35
|
+
"@angular-eslint/template-parser": "20.1.1-alpha.6"
|
|
36
36
|
},
|
|
37
37
|
"gitHead": "e2006e5e9c99e5a943d1a999e0efa5247d29ec24"
|
|
38
38
|
}
|