@elastic/eslint-plugin-eui 2.1.0 → 2.2.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.
package/README.md CHANGED
@@ -135,10 +135,14 @@ Ensures that EUI modal components (`EuiModal`, `EuiFlyout`, `EuiConfirmModal`) h
135
135
 
136
136
  Ensures that form control components within `EuiFormRow` components have matching `isInvalid` prop values. This maintains consistent validation state between parent form rows and their child form controls, leading to a more predictable and accessible user experience.
137
137
 
138
- ### `@elastic/eui/sr_output_disabled_tooltip`
138
+ ### `@elastic/eui/sr-output-disabled-tooltip`
139
139
 
140
140
  Ensures `disableScreenReaderOutput` is set when `EuiToolTip` content matches `EuiButtonIcon` "aria-label".
141
141
 
142
+ ### `@elastic/eui/prefer-eui-icon-tip`
143
+
144
+ Ensure `EuiIconTip` is used rather than `<EuiToolTip><EuiIcon/></EuiToolTip>`, as it provides better accessibility and improved support for assistive technologies.
145
+
142
146
  ## Testing
143
147
 
144
148
  ### Running unit tests
package/lib/cjs/index.js CHANGED
@@ -6,6 +6,7 @@ var _no_css_color = require("./rules/no_css_color");
6
6
  var _require_aria_label_for_modals = require("./rules/a11y/require_aria_label_for_modals");
7
7
  var _consistent_is_invalid_props = require("./rules/a11y/consistent_is_invalid_props");
8
8
  var _sr_output_disabled_tooltip = require("./rules/a11y/sr_output_disabled_tooltip");
9
+ var _prefer_eui_icon_tip = require("./rules/a11y/prefer_eui_icon_tip");
9
10
  /*
10
11
  * Licensed to Elasticsearch B.V. under one or more contributor
11
12
  * license agreements. See the NOTICE file distributed with
@@ -32,7 +33,8 @@ const config = {
32
33
  'no-css-color': _no_css_color.NoCssColor,
33
34
  'require-aria-label-for-modals': _require_aria_label_for_modals.RequireAriaLabelForModals,
34
35
  'consistent-is-invalid-props': _consistent_is_invalid_props.ConsistentIsInvalidProps,
35
- 'sr_output_disabled_tooltip': _sr_output_disabled_tooltip.ScreenReaderOutputDisabledTooltip
36
+ 'sr-output-disabled-tooltip': _sr_output_disabled_tooltip.ScreenReaderOutputDisabledTooltip,
37
+ 'prefer-eui-icon-tip': _prefer_eui_icon_tip.PreferEuiIconTip
36
38
  },
37
39
  configs: {
38
40
  recommended: {
@@ -43,7 +45,9 @@ const config = {
43
45
  '@elastic/eui/no-css-color': 'warn',
44
46
  '@elastic/eui/require-aria-label-for-modals': 'warn',
45
47
  '@elastic/eui/consistent-is-invalid-props': 'warn',
46
- '@elastic/eui/sr_output_disabled_tooltip': 'warn'
48
+ '@elastic/eui/sr-output-disabled-tooltip': 'warn',
49
+ '@elastic/eui/no-css_color': 'warn',
50
+ '@elastic/eui/prefer-eui-icon-tip': 'warn'
47
51
  }
48
52
  }
49
53
  }
@@ -0,0 +1,3 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ export declare const PreferEuiIconTip: ESLintUtils.RuleModule<"preferEuiIconTip", [], unknown, ESLintUtils.RuleListener>;
3
+ //# sourceMappingURL=prefer_eui_icon_tip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefer_eui_icon_tip.d.ts","sourceRoot":"","sources":["../../../../src/rules/a11y/prefer_eui_icon_tip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAMtE,eAAO,MAAM,gBAAgB,mFA0C3B,CAAC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PreferEuiIconTip = void 0;
7
+ var _utils = require("@typescript-eslint/utils");
8
+ const TOOLTIP_COMPONENT = 'EuiToolTip';
9
+ const ICON_COMPONENT = 'EuiIcon';
10
+ const ICON_TIP_COMPONENT = 'EuiIconTip';
11
+ const PreferEuiIconTip = exports.PreferEuiIconTip = _utils.ESLintUtils.RuleCreator.withoutDocs({
12
+ create(context) {
13
+ return {
14
+ JSXElement(node) {
15
+ const openingElement = node.openingElement;
16
+ if (openingElement.name.type !== 'JSXIdentifier' || openingElement.name.name !== TOOLTIP_COMPONENT) {
17
+ return;
18
+ }
19
+
20
+ // Find first JSX child
21
+ const firstChild = node.children.find(child => child.type === 'JSXElement');
22
+ if (firstChild && firstChild.openingElement.name.type === 'JSXIdentifier' && firstChild.openingElement.name.name === ICON_COMPONENT) {
23
+ context.report({
24
+ node: firstChild,
25
+ messageId: 'preferEuiIconTip'
26
+ });
27
+ }
28
+ }
29
+ };
30
+ },
31
+ meta: {
32
+ type: 'suggestion',
33
+ docs: {
34
+ description: `Prefer using ${ICON_TIP_COMPONENT} over <${TOOLTIP_COMPONENT}><${ICON_COMPONENT}/></${TOOLTIP_COMPONENT}>, as it delivers better accessibility and improved support for assistive technologies.`
35
+ },
36
+ schema: [],
37
+ messages: {
38
+ preferEuiIconTip: `Ensure ${ICON_TIP_COMPONENT} is used rather than <${TOOLTIP_COMPONENT}><${ICON_COMPONENT}/></${TOOLTIP_COMPONENT}>, as it delivers better accessibility and improved support for assistive technologies.`
39
+ }
40
+ },
41
+ defaultOptions: []
42
+ });
package/lib/esm/index.js CHANGED
@@ -24,6 +24,7 @@ const no_css_color_1 = require("./rules/no_css_color");
24
24
  const require_aria_label_for_modals_1 = require("./rules/a11y/require_aria_label_for_modals");
25
25
  const consistent_is_invalid_props_1 = require("./rules/a11y/consistent_is_invalid_props");
26
26
  const sr_output_disabled_tooltip_1 = require("./rules/a11y/sr_output_disabled_tooltip");
27
+ const prefer_eui_icon_tip_1 = require("./rules/a11y/prefer_eui_icon_tip");
27
28
  const config = {
28
29
  rules: {
29
30
  'href-or-on-click': href_or_on_click_1.HrefOnClick,
@@ -31,7 +32,8 @@ const config = {
31
32
  'no-css-color': no_css_color_1.NoCssColor,
32
33
  'require-aria-label-for-modals': require_aria_label_for_modals_1.RequireAriaLabelForModals,
33
34
  'consistent-is-invalid-props': consistent_is_invalid_props_1.ConsistentIsInvalidProps,
34
- 'sr_output_disabled_tooltip': sr_output_disabled_tooltip_1.ScreenReaderOutputDisabledTooltip,
35
+ 'sr-output-disabled-tooltip': sr_output_disabled_tooltip_1.ScreenReaderOutputDisabledTooltip,
36
+ 'prefer-eui-icon-tip': prefer_eui_icon_tip_1.PreferEuiIconTip,
35
37
  },
36
38
  configs: {
37
39
  recommended: {
@@ -42,7 +44,9 @@ const config = {
42
44
  '@elastic/eui/no-css-color': 'warn',
43
45
  '@elastic/eui/require-aria-label-for-modals': 'warn',
44
46
  '@elastic/eui/consistent-is-invalid-props': 'warn',
45
- '@elastic/eui/sr_output_disabled_tooltip': 'warn',
47
+ '@elastic/eui/sr-output-disabled-tooltip': 'warn',
48
+ '@elastic/eui/no-css_color': 'warn',
49
+ '@elastic/eui/prefer-eui-icon-tip': 'warn',
46
50
  },
47
51
  },
48
52
  },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAEH,+DAAuD;AACvD,iFAA2E;AAC3E,uDAAkD;AAElD,8FAAuF;AACvF,0FAAoF;AACpF,wFAA4F;AAE5F,MAAM,MAAM,GAAG;IACb,KAAK,EAAE;QACL,kBAAkB,EAAE,8BAAW;QAC/B,2BAA2B,EAAE,kDAAsB;QACnD,cAAc,EAAE,yBAAU;QAC1B,+BAA+B,EAAE,yDAAyB;QAC1D,6BAA6B,EAAE,sDAAwB;QACvD,4BAA4B,EAAE,8DAAiC;KAChE;IACD,OAAO,EAAE;QACP,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,4BAA4B,CAAC;YACvC,KAAK,EAAE;gBACL,+BAA+B,EAAE,MAAM;gBACvC,wCAAwC,EAAE,MAAM;gBAChD,2BAA2B,EAAE,MAAM;gBACnC,4CAA4C,EAAE,MAAM;gBACpD,0CAA0C,EAAE,MAAM;gBAClD,yCAAyC,EAAE,MAAM;aAClD;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAEH,+DAAuD;AACvD,iFAA2E;AAC3E,uDAAkD;AAElD,8FAAuF;AACvF,0FAAoF;AACpF,wFAA4F;AAC5F,0EAAoE;AAEpE,MAAM,MAAM,GAAG;IACb,KAAK,EAAE;QACL,kBAAkB,EAAE,8BAAW;QAC/B,2BAA2B,EAAE,kDAAsB;QACnD,cAAc,EAAE,yBAAU;QAC1B,+BAA+B,EAAE,yDAAyB;QAC1D,6BAA6B,EAAE,sDAAwB;QACvD,4BAA4B,EAAE,8DAAiC;QAC/D,qBAAqB,EAAE,sCAAgB;KACxC;IACD,OAAO,EAAE;QACP,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,4BAA4B,CAAC;YACvC,KAAK,EAAE;gBACL,+BAA+B,EAAE,MAAM;gBACvC,wCAAwC,EAAE,MAAM;gBAChD,2BAA2B,EAAE,MAAM;gBACnC,4CAA4C,EAAE,MAAM;gBACpD,0CAA0C,EAAE,MAAM;gBAClD,yCAAyC,EAAE,MAAM;gBACjD,2BAA2B,EAAE,MAAM;gBACnC,kCAAkC,EAAE,MAAM;aAC3C;SACF;KACF;CACF,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ export declare const PreferEuiIconTip: ESLintUtils.RuleModule<"preferEuiIconTip", [], unknown, ESLintUtils.RuleListener>;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PreferEuiIconTip = void 0;
4
+ const utils_1 = require("@typescript-eslint/utils");
5
+ const TOOLTIP_COMPONENT = 'EuiToolTip';
6
+ const ICON_COMPONENT = 'EuiIcon';
7
+ const ICON_TIP_COMPONENT = 'EuiIconTip';
8
+ exports.PreferEuiIconTip = utils_1.ESLintUtils.RuleCreator.withoutDocs({
9
+ create(context) {
10
+ return {
11
+ JSXElement(node) {
12
+ const openingElement = node.openingElement;
13
+ if (openingElement.name.type !== 'JSXIdentifier' ||
14
+ openingElement.name.name !== TOOLTIP_COMPONENT) {
15
+ return;
16
+ }
17
+ // Find first JSX child
18
+ const firstChild = node.children.find((child) => child.type === 'JSXElement');
19
+ if (firstChild &&
20
+ firstChild.openingElement.name.type === 'JSXIdentifier' &&
21
+ firstChild.openingElement.name.name === ICON_COMPONENT) {
22
+ context.report({
23
+ node: firstChild,
24
+ messageId: 'preferEuiIconTip'
25
+ });
26
+ }
27
+ },
28
+ };
29
+ },
30
+ meta: {
31
+ type: 'suggestion',
32
+ docs: {
33
+ description: `Prefer using ${ICON_TIP_COMPONENT} over <${TOOLTIP_COMPONENT}><${ICON_COMPONENT}/></${TOOLTIP_COMPONENT}>, as it delivers better accessibility and improved support for assistive technologies.`
34
+ },
35
+ schema: [],
36
+ messages: {
37
+ preferEuiIconTip: `Ensure ${ICON_TIP_COMPONENT} is used rather than <${TOOLTIP_COMPONENT}><${ICON_COMPONENT}/></${TOOLTIP_COMPONENT}>, as it delivers better accessibility and improved support for assistive technologies.`,
38
+ },
39
+ },
40
+ defaultOptions: [],
41
+ });
42
+ //# sourceMappingURL=prefer_eui_icon_tip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefer_eui_icon_tip.js","sourceRoot":"","sources":["../../../../src/rules/a11y/prefer_eui_icon_tip.ts"],"names":[],"mappings":";;;AAAA,oDAAsE;AAEtE,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,MAAM,cAAc,GAAG,SAAS,CAAC;AACjC,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAE3B,QAAA,gBAAgB,GAAG,mBAAW,CAAC,WAAW,CAAC,WAAW,CAAC;IAClE,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,UAAU,CAAC,IAAI;gBACb,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;gBAC3C,IACE,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;oBAC5C,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAC9C,CAAC;oBACD,OAAO;gBACT,CAAC;gBAED,uBAAuB;gBACvB,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CACnC,CAAC,KAAK,EAAgC,EAAE,CACtC,KAAK,CAAC,IAAI,KAAK,YAAY,CAC9B,CAAC;gBAEF,IACE,UAAU;oBACV,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,eAAe;oBACvD,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,KAAK,cAAc,EACtD,CAAC;oBACD,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,UAAU;wBAChB,SAAS,EAAE,kBAAkB;qBAC9B,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,gBAAgB,kBAAkB,UAAU,iBAAiB,KAAK,cAAc,OAAO,iBAAiB,yFAAyF;SAC/M;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,gBAAgB,EAAE,UAAU,kBAAkB,yBAAyB,iBAAiB,KAAK,cAAc,OAAO,iBAAiB,yFAAyF;SAC7N;KACF;IACD,cAAc,EAAE,EAAE;CACnB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elastic/eslint-plugin-eui",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",