@elastic/eslint-plugin-eui 2.6.0 → 2.8.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 +15 -0
- package/lib/cjs/index.js +33 -24
- package/lib/cjs/rules/a11y/badge_accessibility_rules.d.ts +3 -0
- package/lib/cjs/rules/a11y/badge_accessibility_rules.d.ts.map +1 -0
- package/lib/cjs/rules/a11y/badge_accessibility_rules.js +82 -0
- package/lib/cjs/rules/a11y/icon_accessibility_rules.d.ts +3 -0
- package/lib/cjs/rules/a11y/icon_accessibility_rules.d.ts.map +1 -0
- package/lib/cjs/rules/a11y/icon_accessibility_rules.js +82 -0
- package/lib/cjs/rules/no_css_color.d.ts.map +1 -1
- package/lib/cjs/rules/no_css_color.js +6 -4
- package/lib/cjs/rules/no_static_z_index.d.ts +3 -0
- package/lib/cjs/rules/no_static_z_index.d.ts.map +1 -0
- package/lib/cjs/rules/no_static_z_index.js +361 -0
- package/lib/cjs/utils/get_property_name.d.ts +3 -0
- package/lib/cjs/utils/get_property_name.d.ts.map +1 -0
- package/lib/cjs/utils/get_property_name.js +28 -0
- package/lib/cjs/utils/remove_attr.d.ts +26 -0
- package/lib/cjs/utils/remove_attr.d.ts.map +1 -0
- package/lib/cjs/utils/remove_attr.js +39 -0
- package/lib/esm/index.js +33 -24
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/rules/a11y/badge_accessibility_rules.d.ts +2 -0
- package/lib/esm/rules/a11y/badge_accessibility_rules.js +84 -0
- package/lib/esm/rules/a11y/badge_accessibility_rules.js.map +1 -0
- package/lib/esm/rules/a11y/icon_accessibility_rules.d.ts +2 -0
- package/lib/esm/rules/a11y/icon_accessibility_rules.js +87 -0
- package/lib/esm/rules/a11y/icon_accessibility_rules.js.map +1 -0
- package/lib/esm/rules/no_css_color.js +10 -7
- package/lib/esm/rules/no_css_color.js.map +1 -1
- package/lib/esm/rules/no_static_z_index.d.ts +2 -0
- package/lib/esm/rules/no_static_z_index.js +394 -0
- package/lib/esm/rules/no_static_z_index.js.map +1 -0
- package/lib/esm/utils/get_property_name.d.ts +2 -0
- package/lib/esm/utils/get_property_name.js +27 -0
- package/lib/esm/utils/get_property_name.js.map +1 -0
- package/lib/esm/utils/remove_attr.d.ts +25 -0
- package/lib/esm/utils/remove_attr.js +34 -0
- package/lib/esm/utils/remove_attr.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -167,6 +167,21 @@ Ensure interactive EUI components (like e.g. `EuiLink`, `EuiButton`, `EuiRadio`)
|
|
|
167
167
|
|
|
168
168
|
Ensure `EuiInMemoryTable`, `EuiBasicTable` have a `tableCaption` property for accessibility.
|
|
169
169
|
|
|
170
|
+
### `@elastic/eui/badge-accessibility-rules`
|
|
171
|
+
|
|
172
|
+
Ensure the `EuiBadge` includes appropriate accessibility attributes.
|
|
173
|
+
|
|
174
|
+
- `iconOnClick` and `onClick` must not reference the same callback. The rule autofixes by removing `iconOnClick`.
|
|
175
|
+
- `iconOnClickAriaLabel` is only valid when `iconOnClick` is present. The rule autofixes by removing `iconOnClickAriaLabel`.
|
|
176
|
+
- `onClickAriaLabel` is only valid when `onClick` is present. The rule autofixes by removing `onClickAriaLabel`.
|
|
177
|
+
|
|
178
|
+
### `@elastic/eui/icon-accessibility-rules`
|
|
179
|
+
|
|
180
|
+
Ensure the `EuiIcon` includes appropriate accessibility attributes.
|
|
181
|
+
|
|
182
|
+
- `EuiIcon` has an accessible name via `title`, `aria-label`, or `aria-labelledby`; otherwise mark it decorative with `aria-hidden={true}`
|
|
183
|
+
- Do not combine `tabIndex` with `aria-hidden`
|
|
184
|
+
|
|
170
185
|
## Testing
|
|
171
186
|
|
|
172
187
|
### Running unit tests
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _accessible_interactive_element = require("./rules/a11y/accessible_interactive_element");
|
|
4
|
+
var _callout_announce_on_mount = require("./rules/a11y/callout_announce_on_mount");
|
|
5
|
+
var _consistent_is_invalid_props = require("./rules/a11y/consistent_is_invalid_props");
|
|
3
6
|
var _href_or_on_click = require("./rules/href_or_on_click");
|
|
4
|
-
var _no_restricted_eui_imports = require("./rules/no_restricted_eui_imports");
|
|
5
7
|
var _no_css_color = require("./rules/no_css_color");
|
|
8
|
+
var _no_restricted_eui_imports = require("./rules/no_restricted_eui_imports");
|
|
9
|
+
var _no_static_z_index = require("./rules/no_static_z_index");
|
|
10
|
+
var _no_unnamed_interactive_element = require("./rules/a11y/no_unnamed_interactive_element");
|
|
11
|
+
var _no_unnamed_radio_group = require("./rules/a11y/no_unnamed_radio_group");
|
|
12
|
+
var _prefer_eui_icon_tip = require("./rules/a11y/prefer_eui_icon_tip");
|
|
6
13
|
var _require_aria_label_for_modals = require("./rules/a11y/require_aria_label_for_modals");
|
|
7
|
-
var
|
|
14
|
+
var _require_table_caption = require("./rules/a11y/require_table_caption");
|
|
8
15
|
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");
|
|
10
|
-
var _no_unnamed_radio_group = require("./rules/a11y/no_unnamed_radio_group");
|
|
11
|
-
var _no_unnamed_interactive_element = require("./rules/a11y/no_unnamed_interactive_element");
|
|
12
16
|
var _tooltip_focusable_anchor = require("./rules/a11y/tooltip_focusable_anchor");
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var _require_table_caption = require("./rules/a11y/require_table_caption");
|
|
17
|
+
var _badge_accessibility_rules = require("./rules/a11y/badge_accessibility_rules");
|
|
18
|
+
var _icon_accessibility_rules = require("./rules/a11y/icon_accessibility_rules");
|
|
16
19
|
/*
|
|
17
20
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
18
21
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -23,37 +26,43 @@ var _require_table_caption = require("./rules/a11y/require_table_caption");
|
|
|
23
26
|
|
|
24
27
|
const config = {
|
|
25
28
|
rules: {
|
|
29
|
+
'accessible-interactive-element': _accessible_interactive_element.AccessibleInteractiveElements,
|
|
30
|
+
'callout-announce-on-mount': _callout_announce_on_mount.CallOutAnnounceOnMount,
|
|
31
|
+
'consistent-is-invalid-props': _consistent_is_invalid_props.ConsistentIsInvalidProps,
|
|
26
32
|
'href-or-on-click': _href_or_on_click.HrefOnClick,
|
|
27
|
-
'no-restricted-eui-imports': _no_restricted_eui_imports.NoRestrictedEuiImports,
|
|
28
33
|
'no-css-color': _no_css_color.NoCssColor,
|
|
34
|
+
'no-restricted-eui-imports': _no_restricted_eui_imports.NoRestrictedEuiImports,
|
|
35
|
+
'no-static-z-index': _no_static_z_index.NoStaticZIndex,
|
|
36
|
+
'no-unnamed-interactive-element': _no_unnamed_interactive_element.NoUnnamedInteractiveElement,
|
|
37
|
+
'no-unnamed-radio-group': _no_unnamed_radio_group.NoUnnamedRadioGroup,
|
|
38
|
+
'prefer-eui-icon-tip': _prefer_eui_icon_tip.PreferEuiIconTip,
|
|
29
39
|
'require-aria-label-for-modals': _require_aria_label_for_modals.RequireAriaLabelForModals,
|
|
30
|
-
'
|
|
40
|
+
'require-table-caption': _require_table_caption.RequireTableCaption,
|
|
31
41
|
'sr-output-disabled-tooltip': _sr_output_disabled_tooltip.ScreenReaderOutputDisabledTooltip,
|
|
32
|
-
'prefer-eui-icon-tip': _prefer_eui_icon_tip.PreferEuiIconTip,
|
|
33
|
-
'no-unnamed-radio-group': _no_unnamed_radio_group.NoUnnamedRadioGroup,
|
|
34
|
-
'callout-announce-on-mount': _callout_announce_on_mount.CallOutAnnounceOnMount,
|
|
35
|
-
'no-unnamed-interactive-element': _no_unnamed_interactive_element.NoUnnamedInteractiveElement,
|
|
36
42
|
'tooltip-focusable-anchor': _tooltip_focusable_anchor.TooltipFocusableAnchor,
|
|
37
|
-
'
|
|
38
|
-
'
|
|
43
|
+
'badge-accessibility-rules': _badge_accessibility_rules.EuiBadgeAccessibilityRules,
|
|
44
|
+
'icon-accessibility-rules': _icon_accessibility_rules.EuiIconAccessibilityRules
|
|
39
45
|
},
|
|
40
46
|
configs: {
|
|
41
47
|
recommended: {
|
|
42
48
|
plugins: ['@elastic/eslint-plugin-eui'],
|
|
43
49
|
rules: {
|
|
50
|
+
'@elastic/eui/accessible-interactive-element': 'warn',
|
|
51
|
+
'@elastic/eui/callout-announce-on-mount': 'warn',
|
|
52
|
+
'@elastic/eui/consistent-is-invalid-props': 'warn',
|
|
44
53
|
'@elastic/eui/href-or-on-click': 'warn',
|
|
45
|
-
'@elastic/eui/no-restricted-eui-imports': 'warn',
|
|
46
54
|
'@elastic/eui/no-css-color': 'warn',
|
|
55
|
+
'@elastic/eui/no-restricted-eui-imports': 'warn',
|
|
56
|
+
'@elastic/eui/no-static-z-index': 'warn',
|
|
57
|
+
'@elastic/eui/no-unnamed-interactive-element': 'warn',
|
|
58
|
+
'@elastic/eui/no-unnamed-radio-group': 'warn',
|
|
59
|
+
'@elastic/eui/prefer-eui-icon-tip': 'warn',
|
|
47
60
|
'@elastic/eui/require-aria-label-for-modals': 'warn',
|
|
48
|
-
'@elastic/eui/
|
|
61
|
+
'@elastic/eui/require-table-caption': 'warn',
|
|
49
62
|
'@elastic/eui/sr-output-disabled-tooltip': 'warn',
|
|
50
|
-
'@elastic/eui/prefer-eui-icon-tip': 'warn',
|
|
51
|
-
'@elastic/eui/no-unnamed-radio-group': 'warn',
|
|
52
|
-
'@elastic/eui/callout-announce-on-mount': 'warn',
|
|
53
|
-
'@elastic/eui/no-unnamed-interactive-element': 'warn',
|
|
54
63
|
'@elastic/eui/tooltip-focusable-anchor': 'warn',
|
|
55
|
-
'@elastic/eui/
|
|
56
|
-
'@elastic/eui/
|
|
64
|
+
'@elastic/eui/badge-accessibility-rules': 'warn',
|
|
65
|
+
'@elastic/eui/icon-accessibility-rules': 'warn'
|
|
57
66
|
}
|
|
58
67
|
}
|
|
59
68
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
export declare const EuiBadgeAccessibilityRules: ESLintUtils.RuleModule<"sameCallback" | "iconOnClickAriaLabelWithoutIconOnClick" | "onClickAriaLabelWithoutOnClick", [], unknown, ESLintUtils.RuleListener>;
|
|
3
|
+
//# sourceMappingURL=badge_accessibility_rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge_accessibility_rules.d.ts","sourceRoot":"","sources":["../../../../src/rules/a11y/badge_accessibility_rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD,eAAO,MAAM,0BAA0B,6JAyFrC,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EuiBadgeAccessibilityRules = void 0;
|
|
7
|
+
var _utils = require("@typescript-eslint/utils");
|
|
8
|
+
const BADGE_COMPONENT = 'EuiBadge';
|
|
9
|
+
const EuiBadgeAccessibilityRules = exports.EuiBadgeAccessibilityRules = _utils.ESLintUtils.RuleCreator.withoutDocs({
|
|
10
|
+
create(context) {
|
|
11
|
+
return {
|
|
12
|
+
JSXElement(node) {
|
|
13
|
+
const {
|
|
14
|
+
openingElement
|
|
15
|
+
} = node;
|
|
16
|
+
if (openingElement.name.type !== 'JSXIdentifier' || openingElement.name.name !== BADGE_COMPONENT) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
let iconOnClick, onClick, iconOnClickAriaLabel, onClickAriaLabel;
|
|
20
|
+
for (const attr of openingElement.attributes) {
|
|
21
|
+
if (attr.type === 'JSXAttribute' && attr.name.type === 'JSXIdentifier') {
|
|
22
|
+
switch (attr.name.name) {
|
|
23
|
+
case 'iconOnClick':
|
|
24
|
+
iconOnClick = attr;
|
|
25
|
+
break;
|
|
26
|
+
case 'onClick':
|
|
27
|
+
onClick = attr;
|
|
28
|
+
break;
|
|
29
|
+
case 'iconOnClickAriaLabel':
|
|
30
|
+
iconOnClickAriaLabel = attr;
|
|
31
|
+
break;
|
|
32
|
+
case 'onClickAriaLabel':
|
|
33
|
+
onClickAriaLabel = attr;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 1. iconOnClick and onClick cannot refer to the same callback
|
|
40
|
+
if (iconOnClick && onClick && iconOnClick.value && onClick.value && iconOnClick.value.type === 'JSXExpressionContainer' && onClick.value.type === 'JSXExpressionContainer' && iconOnClick.value.expression.type === 'Identifier' && onClick.value.expression.type === 'Identifier' && iconOnClick.value.expression.name === onClick.value.expression.name) {
|
|
41
|
+
context.report({
|
|
42
|
+
node: iconOnClick,
|
|
43
|
+
messageId: 'sameCallback',
|
|
44
|
+
fix: fixer => fixer.removeRange([iconOnClick.range[0], iconOnClick.range[1]])
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 2. iconOnClickAriaLabel should be set only if iconOnClick is set
|
|
49
|
+
if (iconOnClickAriaLabel && !iconOnClick) {
|
|
50
|
+
context.report({
|
|
51
|
+
node: iconOnClickAriaLabel,
|
|
52
|
+
messageId: 'iconOnClickAriaLabelWithoutIconOnClick',
|
|
53
|
+
fix: fixer => fixer.removeRange([iconOnClickAriaLabel.range[0], iconOnClickAriaLabel.range[1]])
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 3. onClickAriaLabel should be set only if onClick is set
|
|
58
|
+
if (onClickAriaLabel && !onClick) {
|
|
59
|
+
context.report({
|
|
60
|
+
node: onClickAriaLabel,
|
|
61
|
+
messageId: 'onClickAriaLabelWithoutOnClick',
|
|
62
|
+
fix: fixer => fixer.removeRange([onClickAriaLabel.range[0], onClickAriaLabel.range[1]])
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
meta: {
|
|
69
|
+
type: 'problem',
|
|
70
|
+
docs: {
|
|
71
|
+
description: `Ensure the ${BADGE_COMPONENT} includes appropriate accessibility attributes`
|
|
72
|
+
},
|
|
73
|
+
fixable: 'code',
|
|
74
|
+
schema: [],
|
|
75
|
+
messages: {
|
|
76
|
+
sameCallback: '`iconOnClick` and `onClick` should not refer to the same callback. Remove `iconOnClick` and keep only `onClick`.',
|
|
77
|
+
iconOnClickAriaLabelWithoutIconOnClick: '`iconOnClickAriaLabel` should only be set if `iconOnClick` is present. Remove this prop.',
|
|
78
|
+
onClickAriaLabelWithoutOnClick: '`onClickAriaLabel` should only be set if `onClick` is present. Remove this prop.'
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
defaultOptions: []
|
|
82
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
export declare const EuiIconAccessibilityRules: ESLintUtils.RuleModule<"missingTitleOrAriaHidden" | "tabIndexWithAriaHidden", [], unknown, ESLintUtils.RuleListener>;
|
|
3
|
+
//# sourceMappingURL=icon_accessibility_rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon_accessibility_rules.d.ts","sourceRoot":"","sources":["../../../../src/rules/a11y/icon_accessibility_rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAY,MAAM,0BAA0B,CAAC;AAKjE,eAAO,MAAM,yBAAyB,sHAyFpC,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EuiIconAccessibilityRules = void 0;
|
|
7
|
+
var _utils = require("@typescript-eslint/utils");
|
|
8
|
+
var _remove_attr = require("../../utils/remove_attr");
|
|
9
|
+
const COMPONENT = 'EuiIcon';
|
|
10
|
+
const EuiIconAccessibilityRules = exports.EuiIconAccessibilityRules = _utils.ESLintUtils.RuleCreator.withoutDocs({
|
|
11
|
+
create(context) {
|
|
12
|
+
return {
|
|
13
|
+
JSXElement(node) {
|
|
14
|
+
const {
|
|
15
|
+
openingElement
|
|
16
|
+
} = node;
|
|
17
|
+
if (openingElement.name.type !== 'JSXIdentifier' || openingElement.name.name !== COMPONENT) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
let ariaHiddenAttr;
|
|
21
|
+
let tabIndexAttr;
|
|
22
|
+
let isIconNamed = false;
|
|
23
|
+
for (const attr of openingElement.attributes) {
|
|
24
|
+
if (attr.type !== 'JSXAttribute' || attr.name.type !== 'JSXIdentifier') continue;
|
|
25
|
+
const name = attr.name.name;
|
|
26
|
+
if (name === 'aria-hidden') ariaHiddenAttr = attr;
|
|
27
|
+
if (name === 'tabIndex') tabIndexAttr = attr;
|
|
28
|
+
if (['title', 'aria-labelledby', 'aria-label'].includes(name)) {
|
|
29
|
+
isIconNamed = true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const hasAriaHiddenTrue = !!ariaHiddenAttr && ariaHiddenAttr.value && (
|
|
33
|
+
// aria-hidden={true}
|
|
34
|
+
ariaHiddenAttr.value.type === 'JSXExpressionContainer' && ariaHiddenAttr.value.expression.type === 'Literal' && ariaHiddenAttr.value.expression.value === true ||
|
|
35
|
+
// aria-hidden='true'
|
|
36
|
+
ariaHiddenAttr.value.type === 'Literal' && ariaHiddenAttr.value.value === 'true');
|
|
37
|
+
|
|
38
|
+
// Case: `tabIndex` and `aria-hidden` cannot be used together
|
|
39
|
+
if (tabIndexAttr && hasAriaHiddenTrue) {
|
|
40
|
+
context.report({
|
|
41
|
+
node: openingElement,
|
|
42
|
+
messageId: 'tabIndexWithAriaHidden',
|
|
43
|
+
fix: fixer => {
|
|
44
|
+
if (!ariaHiddenAttr?.range) return null;
|
|
45
|
+
const [start, end] = (0, _remove_attr.removeAttribute)(context, ariaHiddenAttr);
|
|
46
|
+
return [fixer.removeRange([start, end])];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Require accessible name or `aria-hidden={true}`;
|
|
53
|
+
if (!isIconNamed && !hasAriaHiddenTrue) {
|
|
54
|
+
context.report({
|
|
55
|
+
node: openingElement,
|
|
56
|
+
messageId: 'missingTitleOrAriaHidden',
|
|
57
|
+
fix: fixer => {
|
|
58
|
+
if (tabIndexAttr) return null;
|
|
59
|
+
const end = openingElement.range[1];
|
|
60
|
+
const insertPos = openingElement.selfClosing ? end - 2 : end - 1; // before '/>' or '>'
|
|
61
|
+
const insertRange = [insertPos, insertPos];
|
|
62
|
+
return [fixer.insertTextBeforeRange(insertRange, ' aria-hidden={true}')];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
meta: {
|
|
70
|
+
type: 'suggestion',
|
|
71
|
+
docs: {
|
|
72
|
+
description: `Ensure the EuiIcon includes appropriate accessibility attributes`
|
|
73
|
+
},
|
|
74
|
+
fixable: 'code',
|
|
75
|
+
schema: [],
|
|
76
|
+
messages: {
|
|
77
|
+
missingTitleOrAriaHidden: 'Add a `title`, `aria-label`, or `aria-labelledby` to EuiIcon, or set `aria-hidden={true}` if it is decorative.',
|
|
78
|
+
tabIndexWithAriaHidden: 'Do not use `tabIndex` together with `aria-hidden`. Remove `aria-hidden` or provide an accessible name.'
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
defaultOptions: []
|
|
82
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no_css_color.d.ts","sourceRoot":"","sources":["../../../src/rules/no_css_color.ts"],"names":[],"mappings":"AASA,OAAO,EAAY,WAAW,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"no_css_color.d.ts","sourceRoot":"","sources":["../../../src/rules/no_css_color.ts"],"names":[],"mappings":"AASA,OAAO,EAAY,WAAW,EAAE,MAAM,0BAA0B,CAAC;AA+OjE,eAAO,MAAM,UAAU,2IAuRrB,CAAC"}
|
|
@@ -7,6 +7,7 @@ exports.NoCssColor = void 0;
|
|
|
7
7
|
var _cssstyle = require("cssstyle");
|
|
8
8
|
var _utils = require("@typescript-eslint/utils");
|
|
9
9
|
var _resolve_member_expression_root = require("../utils/resolve_member_expression_root");
|
|
10
|
+
var _get_property_name = require("../utils/get_property_name");
|
|
10
11
|
/*
|
|
11
12
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
12
13
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -56,13 +57,14 @@ const checkPropertySpecifiesInvalidCSSColor = ([property, value]) => {
|
|
|
56
57
|
*/
|
|
57
58
|
const raiseReportIfPropertyHasInvalidCssColor = (context, propertyNode, messageToReport) => {
|
|
58
59
|
let didReport = false;
|
|
59
|
-
|
|
60
|
+
const propertyName = (0, _get_property_name.getPropertyName)(propertyNode);
|
|
61
|
+
if (!propertyName || !htmlElementColorDeclarationRegex.test(propertyName)) {
|
|
60
62
|
return didReport;
|
|
61
63
|
}
|
|
62
64
|
if (propertyNode.value.type === 'Literal') {
|
|
63
|
-
if (didReport = checkPropertySpecifiesInvalidCSSColor([
|
|
64
|
-
// @ts-expect-error the
|
|
65
|
-
propertyNode.
|
|
65
|
+
if (didReport = checkPropertySpecifiesInvalidCSSColor([propertyName,
|
|
66
|
+
// @ts-expect-error the value is present in this scenario
|
|
67
|
+
propertyNode.value.value])) {
|
|
66
68
|
context.report(messageToReport);
|
|
67
69
|
}
|
|
68
70
|
} else if (propertyNode.value.type === 'Identifier') {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
export declare const NoStaticZIndex: ESLintUtils.RuleModule<"noStaticZIndex" | "noStaticZIndexSpecific" | "noStaticZIndexSpecificDeclaredVariable", [], unknown, ESLintUtils.RuleListener>;
|
|
3
|
+
//# sourceMappingURL=no_static_z_index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no_static_z_index.d.ts","sourceRoot":"","sources":["../../../src/rules/no_static_z_index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAY,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAkRjE,eAAO,MAAM,cAAc,uJAwOzB,CAAC"}
|