@taiga-ui/eslint-plugin-experience-next 0.461.0 → 0.463.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.
Files changed (3) hide show
  1. package/README.md +3 -1
  2. package/index.esm.js +28 -29
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -46,7 +46,7 @@ export default [
46
46
  | injection-token-description | They are required to provide a description for `InjectionToken` | ✅ | | |
47
47
  | no-deep-imports | Disables deep imports of Taiga UI packages | ✅ | 🔧 | |
48
48
  | no-deep-imports-to-indexed-packages | Disallow deep imports from packages that expose an index.ts next to ng-package.json or package.json | ✅ | 🔧 | |
49
- | no-href-with-router-link | Do not use href and routerLink attributes together on the same element | | 🔧 | |
49
+ | no-href-with-router-link | Do not use href and routerLink attributes together on the same element || 🔧 | |
50
50
  | no-implicit-public | Require explicit `public` modifier for class members and parameter properties | ✅ | 🔧 | |
51
51
  | no-playwright-empty-fill | Enforce `clear()` over `fill('')` in Playwright tests | ✅ | 🔧 | |
52
52
  | no-project-as-in-ng-template | `ngProjectAs` has no effect inside `<ng-template>` or dynamic outlets | | | |
@@ -232,6 +232,8 @@ import {Foo} from '@my-lib/internal';
232
232
 
233
233
  ## no-href-with-router-link
234
234
 
235
+ > ✅ Included in `recommended` — processed by the angular-eslint template parser (`**/*.html`).
236
+
235
237
  Disallows using both `href` and `routerLink` on the same `<a>` element in Angular templates. Autofix removes the `href`
236
238
  attribute.
237
239
 
package/index.esm.js CHANGED
@@ -55,7 +55,6 @@ var htmlEslint = defineConfig([
55
55
  parserOptions: { templateEngineSyntax: { '{{': '}}' } },
56
56
  },
57
57
  rules: {
58
- '@taiga-ui/experience-next/no-href-with-router-link': 'error',
59
58
  'html/indent': 'off', // prettier conflicts
60
59
  'html/no-extra-spacing-attrs': 'off', // prettier conflicts
61
60
  'html/no-multiple-h1': 'off',
@@ -990,6 +989,7 @@ var recommended = defineConfig([
990
989
  '@angular-eslint/template/prefer-control-flow': angularVersion >= modernAngularRules.preferControlFlow ? 'error' : 'off',
991
990
  '@angular-eslint/template/prefer-self-closing-tags': 'error',
992
991
  '@angular-eslint/template/prefer-template-literal': angularVersion >= modernAngularRules.templateLiteral ? 'error' : 'off',
992
+ '@taiga-ui/experience-next/no-href-with-router-link': 'error',
993
993
  '@taiga-ui/experience-next/no-project-as-in-ng-template': 'error',
994
994
  },
995
995
  },
@@ -1991,37 +1991,34 @@ const ERROR_MESSAGE$1 = 'Do not use href and routerLink attributes together on t
1991
1991
  const config$1 = {
1992
1992
  create(context) {
1993
1993
  return {
1994
- Tag(node) {
1995
- const htmlNode = node;
1996
- if (htmlNode?.name?.toLowerCase() !== 'a') {
1994
+ Element(rawNode) {
1995
+ const node = rawNode;
1996
+ if (node.name !== 'a') {
1997
1997
  return;
1998
1998
  }
1999
- let hrefAttribute = null;
2000
- let routerLinkAttribute = null;
2001
- let hasRouterLink = false;
2002
- let hasHref = false;
2003
- for (const attr of htmlNode.attributes ?? []) {
2004
- const attrName = attr.key.value;
2005
- if (attrName?.toLowerCase() === 'href') {
2006
- hasHref = true;
2007
- hrefAttribute = attr;
2008
- }
2009
- else if (attrName?.toLowerCase() === 'routerlink') {
2010
- hasRouterLink = true;
2011
- routerLinkAttribute = attr;
2012
- }
2013
- }
2014
- if (hasHref && hasRouterLink) {
2015
- context.report({
2016
- fix: (fixer) => hrefAttribute?.range
2017
- ? fixer.removeRange(hrefAttribute.range)
2018
- : null,
2019
- messageId: MESSAGE_ID$3,
2020
- node: (routerLinkAttribute ??
2021
- hrefAttribute ??
2022
- htmlNode),
2023
- });
1999
+ const hrefAttr = node.attributes.find((attr) => attr.name === 'href');
2000
+ const hasRouterLink = node.attributes.some((attr) => attr.name.toLowerCase() === 'routerlink') ||
2001
+ node.inputs.some((input) => input.name.toLowerCase() === 'routerlink');
2002
+ if (!hrefAttr || !hasRouterLink) {
2003
+ return;
2024
2004
  }
2005
+ context.report({
2006
+ fix: (fixer) => fixer.removeRange([
2007
+ hrefAttr.sourceSpan.start.offset,
2008
+ hrefAttr.sourceSpan.end.offset,
2009
+ ]),
2010
+ loc: {
2011
+ end: {
2012
+ column: hrefAttr.sourceSpan.end.col,
2013
+ line: hrefAttr.sourceSpan.end.line + 1,
2014
+ },
2015
+ start: {
2016
+ column: hrefAttr.sourceSpan.start.col,
2017
+ line: hrefAttr.sourceSpan.start.line + 1,
2018
+ },
2019
+ },
2020
+ messageId: MESSAGE_ID$3,
2021
+ });
2025
2022
  },
2026
2023
  };
2027
2024
  },
@@ -2029,6 +2026,7 @@ const config$1 = {
2029
2026
  docs: { description: ERROR_MESSAGE$1 },
2030
2027
  fixable: 'code',
2031
2028
  messages: { [MESSAGE_ID$3]: ERROR_MESSAGE$1 },
2029
+ schema: [],
2032
2030
  type: 'problem',
2033
2031
  },
2034
2032
  };
@@ -3780,6 +3778,7 @@ Object.assign(plugin.configs, {
3780
3778
  ],
3781
3779
  recommended: [
3782
3780
  { files: ALL_TS_JS_FILES, plugins: { '@taiga-ui/experience-next': plugin } },
3781
+ { files: ['**/*.html'], plugins: { '@taiga-ui/experience-next': plugin } },
3783
3782
  ...recommended,
3784
3783
  ],
3785
3784
  ['taiga-specific']: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taiga-ui/eslint-plugin-experience-next",
3
- "version": "0.461.0",
3
+ "version": "0.463.0",
4
4
  "description": "An ESLint plugin to enforce a consistent code styles across taiga-ui projects",
5
5
  "repository": {
6
6
  "type": "git",