@angular-eslint/eslint-plugin-template 16.0.4-alpha.27 → 16.0.4-alpha.29

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.
@@ -7,6 +7,7 @@ const get_original_attribute_name_1 = require("../utils/get-original-attribute-n
7
7
  exports.RULE_NAME = 'no-duplicate-attributes';
8
8
  const DEFAULT_OPTIONS = {
9
9
  allowTwoWayDataBinding: true,
10
+ allowStylePrecedenceDuplicates: false,
10
11
  ignore: [],
11
12
  };
12
13
  exports.default = (0, create_eslint_rule_1.createESLintRule)({
@@ -27,6 +28,11 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
27
28
  default: DEFAULT_OPTIONS.allowTwoWayDataBinding,
28
29
  description: `Whether or not two-way data binding is allowed as an exception to the rule.`,
29
30
  },
31
+ allowStylePrecedenceDuplicates: {
32
+ type: 'boolean',
33
+ default: DEFAULT_OPTIONS.allowStylePrecedenceDuplicates,
34
+ description: `Whether or not Angular style precedence is allowed as an exception to the rule. See https://angular.io/guide/style-precedence#style-precedence`,
35
+ },
30
36
  ignore: {
31
37
  type: 'array',
32
38
  items: { type: 'string' },
@@ -44,14 +50,37 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
44
50
  },
45
51
  },
46
52
  defaultOptions: [DEFAULT_OPTIONS],
47
- create(context, [{ allowTwoWayDataBinding, ignore }]) {
53
+ create(context, [{ allowTwoWayDataBinding, allowStylePrecedenceDuplicates, ignore }]) {
48
54
  const parserServices = (0, utils_1.getTemplateParserServices)(context);
49
55
  return {
50
56
  Element$1({ inputs, outputs, attributes }) {
51
- const duplicateInputsAndAttributes = findDuplicates([
57
+ // According to the Angular documentation (https://angular.io/guide/style-precedence#style-precedence)
58
+ // Angular merges both attributes which means their combined use can be seen as valid
59
+ const angularStylePrecedenceDuplicatesAllowed = ['class', 'style'];
60
+ let duplicateInputsAndAttributes = findDuplicates([
52
61
  ...inputs,
53
62
  ...attributes,
54
63
  ]);
64
+ if (allowStylePrecedenceDuplicates) {
65
+ const inputsIgnored = inputs.filter((input) => angularStylePrecedenceDuplicatesAllowed.includes((0, get_original_attribute_name_1.getOriginalAttributeName)(input)));
66
+ if ((inputsIgnored === null || inputsIgnored === void 0 ? void 0 : inputsIgnored.length) > 0) {
67
+ const attributesIgnored = attributes.filter((attr) => angularStylePrecedenceDuplicatesAllowed.includes((0, get_original_attribute_name_1.getOriginalAttributeName)(attr)));
68
+ const inputsNotIgnored = inputs.filter((input) => !inputsIgnored.includes(input));
69
+ const attributesNotIgnored = attributes.filter((attr) => !attributesIgnored.includes(attr));
70
+ const ignoreDuplicated = [
71
+ ...findDuplicates(inputsIgnored),
72
+ ...findDuplicates(attributesIgnored),
73
+ ];
74
+ const notIgnoredDuplicates = [
75
+ ...findDuplicates(inputsNotIgnored),
76
+ ...findDuplicates(attributesNotIgnored),
77
+ ];
78
+ duplicateInputsAndAttributes = [
79
+ ...ignoreDuplicated,
80
+ ...notIgnoredDuplicates,
81
+ ];
82
+ }
83
+ }
55
84
  const filteredOutputs = allowTwoWayDataBinding
56
85
  ? outputs.filter((output) => {
57
86
  return !inputs.some((input) => input.sourceSpan.start === output.sourceSpan.start &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/eslint-plugin-template",
3
- "version": "16.0.4-alpha.27+90c0e91",
3
+ "version": "16.0.4-alpha.29+3bc629c",
4
4
  "description": "ESLint plugin for Angular Templates",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -17,8 +17,8 @@
17
17
  "LICENSE"
18
18
  ],
19
19
  "dependencies": {
20
- "@angular-eslint/bundled-angular-compiler": "16.0.4-alpha.27+90c0e91",
21
- "@angular-eslint/utils": "16.0.4-alpha.27+90c0e91",
20
+ "@angular-eslint/bundled-angular-compiler": "16.0.4-alpha.29+3bc629c",
21
+ "@angular-eslint/utils": "16.0.4-alpha.29+3bc629c",
22
22
  "@typescript-eslint/type-utils": "5.59.9",
23
23
  "@typescript-eslint/utils": "5.59.9",
24
24
  "aria-query": "5.1.3",
@@ -31,5 +31,5 @@
31
31
  "eslint": "^7.20.0 || ^8.0.0",
32
32
  "typescript": "*"
33
33
  },
34
- "gitHead": "90c0e916654297b29cabf8289b1811ed307018ab"
34
+ "gitHead": "3bc629c4d2e22c0484dc1069a3fd0316bf956fbc"
35
35
  }