@elastic/eslint-plugin-eui 3.3.0 → 4.0.0-snapshot.1794281274327

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.
@@ -0,0 +1,141 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ export declare const REMOVED_ICON_ALIASES: {
3
+ readonly anomalyChart: "chartAnomaly";
4
+ readonly apmTrace: "chartWaterfall";
5
+ readonly arrowDown: "chevronSingleDown";
6
+ readonly arrowEnd: "chevronLimitRight";
7
+ readonly arrowLeft: "chevronSingleLeft";
8
+ readonly arrowRight: "chevronSingleRight";
9
+ readonly arrowStart: "chevronLimitLeft";
10
+ readonly arrowUp: "chevronSingleUp";
11
+ readonly beaker: "flask";
12
+ readonly boxesHorizontal: "ellipsis";
13
+ readonly changePointDetection: "chartChangePoint";
14
+ readonly checkInCircleFilled: "checkCircleFill";
15
+ readonly cheer: "popper";
16
+ readonly color: "paintBucket";
17
+ readonly console: "commandLine";
18
+ readonly contrastHigh: "contrastFill";
19
+ readonly controlsHorizontal: "controls";
20
+ readonly controlsVertical: "controls";
21
+ readonly copyClipboard: "copy";
22
+ readonly crossInCircle: "crossCircle";
23
+ readonly crosshairs: "crosshair";
24
+ readonly currency: "money";
25
+ readonly cut: "scissors";
26
+ readonly desktop: "display";
27
+ readonly diff: "compare";
28
+ readonly discuss: "comment";
29
+ readonly documentEdit: "pencil";
30
+ readonly doubleArrowLeft: "chevronDoubleLeft";
31
+ readonly doubleArrowRight: "chevronDoubleRight";
32
+ readonly editorAlignCenter: "textAlignCenter";
33
+ readonly editorAlignLeft: "textAlignLeft";
34
+ readonly editorAlignRight: "textAlignRight";
35
+ readonly editorBold: "textBold";
36
+ readonly editorChecklist: "listCheck";
37
+ readonly editorCodeBlock: "code";
38
+ readonly editorDistributeHorizontal: "distributeHorizontal";
39
+ readonly editorDistributeVertical: "distributeVertical";
40
+ readonly editorHeading: "textHeading";
41
+ readonly editorItalic: "textItalic";
42
+ readonly editorItemAlignBottom: "alignBottom";
43
+ readonly editorItemAlignCenter: "alignCenterHorizontal";
44
+ readonly editorItemAlignLeft: "alignLeft";
45
+ readonly editorItemAlignMiddle: "alignCenterVertical";
46
+ readonly editorItemAlignRight: "alignRight";
47
+ readonly editorItemAlignTop: "alignTop";
48
+ readonly editorLink: "link";
49
+ readonly editorOrderedList: "listNumber";
50
+ readonly editorPositionBottomLeft: "alignBottomLeft";
51
+ readonly editorPositionBottomRight: "alignBottomRight";
52
+ readonly editorPositionTopLeft: "alignTopLeft";
53
+ readonly editorPositionTopRight: "alignTopRight";
54
+ readonly editorRedo: "redo";
55
+ readonly editorStrike: "textStrike";
56
+ readonly editorTable: "table";
57
+ readonly editorUnderline: "textUnderline";
58
+ readonly editorUndo: "undo";
59
+ readonly editorUnorderedList: "listBullet";
60
+ readonly email: "mail";
61
+ readonly eql: "query";
62
+ readonly errorFilled: "errorFill";
63
+ readonly exit: "logOut";
64
+ readonly expand: "maximize";
65
+ readonly expandMini: "maximize";
66
+ readonly exportAction: "upload";
67
+ readonly eyeClosed: "eyeSlash";
68
+ readonly fieldStatistics: "tableInfo";
69
+ readonly filterInCircle: "filter";
70
+ readonly glasses: "readOnly";
71
+ readonly grab: "dragVertical";
72
+ readonly grabHorizontal: "dragHorizontal";
73
+ readonly grabOmnidirectional: "drag";
74
+ readonly heatmap: "chartHeatmap";
75
+ readonly importAction: "download";
76
+ readonly indexFlush: "chartThreshold";
77
+ readonly indexMapping: "mapping";
78
+ readonly indexTemporary: "tableTime";
79
+ readonly invert: "contrast";
80
+ readonly kqlField: "queryField";
81
+ readonly kqlOperand: "queryOperand";
82
+ readonly kqlSelector: "querySelector";
83
+ readonly kqlValue: "queryValue";
84
+ readonly launch: "rocket";
85
+ readonly lettering: "text";
86
+ readonly lineDashed: "lineDash";
87
+ readonly lineDotted: "lineDot";
88
+ readonly listAdd: "plusCircle";
89
+ readonly logPatternAnalysis: "pattern";
90
+ readonly logstashIf: "if";
91
+ readonly logstashQueue: "queue";
92
+ readonly magnifyWithExclamation: "magnifyExclamation";
93
+ readonly magnifyWithMinus: "magnifyMinus";
94
+ readonly magnifyWithPlus: "magnifyPlus";
95
+ readonly minusInCircle: "minusCircle";
96
+ readonly minusInCircleFilled: "minusCircle";
97
+ readonly minusInSquare: "minusSquare";
98
+ readonly newChat: "plusCircle";
99
+ readonly node: "vectorTriangle";
100
+ readonly offline: "wifiSlash";
101
+ readonly online: "wifi";
102
+ readonly pipeBreaks: "lineBreak";
103
+ readonly pipeNoBreaks: "lineBreakSlash";
104
+ readonly playFilled: "play";
105
+ readonly plusInCircle: "plusCircle";
106
+ readonly plusInCircleFilled: "plusCircle";
107
+ readonly plusInSquare: "plusSquare";
108
+ readonly popout: "external";
109
+ readonly productRobot: "productAgent";
110
+ readonly returnKey: "return";
111
+ readonly securitySignal: "radar";
112
+ readonly starFilledSpace: "starFill";
113
+ readonly starMinusFilled: "starFill";
114
+ readonly starPlusFilled: "starFill";
115
+ readonly stopFilled: "stopFill";
116
+ readonly streamsClassic: "productStreamsClassic";
117
+ readonly streamsWired: "productStreamsWired";
118
+ readonly submodule: "merge";
119
+ readonly tableDensityCompact: "tableDensityHigh";
120
+ readonly tableDensityExpanded: "tableDensityLow";
121
+ readonly tableDensityNormal: "table";
122
+ readonly timeRefresh: "refreshTime";
123
+ readonly timeslider: "clockControl";
124
+ readonly tokenDenseVector: "tokenVectorDense";
125
+ readonly training: "presentation";
126
+ readonly unlink: "linkSlash";
127
+ readonly userAvatar: "user";
128
+ readonly vector: "vectorSquare";
129
+ readonly visAreaStacked: "chartAreaStack";
130
+ readonly visBarHorizontal: "chartBarHorizontal";
131
+ readonly visBarHorizontalStacked: "chartBarHorizontalStack";
132
+ readonly visBarVerticalStacked: "chartBarVerticalStack";
133
+ readonly visMapCoordinate: "waypoint";
134
+ readonly visMapRegion: "map";
135
+ readonly visMetric: "chartMetric";
136
+ readonly visTagCloud: "chartTagCloud";
137
+ readonly visText: "text";
138
+ readonly visVega: "code";
139
+ readonly warningFilled: "warningFill";
140
+ };
141
+ export declare const NoRemovedIcons: ESLintUtils.RuleModule<"removedIcon", [], unknown, ESLintUtils.RuleListener>;
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
6
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
7
+ * Side Public License, v 1.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.NoRemovedIcons = exports.REMOVED_ICON_ALIASES = void 0;
11
+ const utils_1 = require("@typescript-eslint/utils");
12
+ const icon_props_1 = require("../utils/icon_props");
13
+ // Names no longer in EUI's icon map. `EuiIcon` treats them as image URLs and
14
+ // renders a broken image.
15
+ exports.REMOVED_ICON_ALIASES = {
16
+ anomalyChart: 'chartAnomaly',
17
+ apmTrace: 'chartWaterfall',
18
+ arrowDown: 'chevronSingleDown',
19
+ arrowEnd: 'chevronLimitRight',
20
+ arrowLeft: 'chevronSingleLeft',
21
+ arrowRight: 'chevronSingleRight',
22
+ arrowStart: 'chevronLimitLeft',
23
+ arrowUp: 'chevronSingleUp',
24
+ beaker: 'flask',
25
+ boxesHorizontal: 'ellipsis',
26
+ changePointDetection: 'chartChangePoint',
27
+ checkInCircleFilled: 'checkCircleFill',
28
+ cheer: 'popper',
29
+ color: 'paintBucket',
30
+ console: 'commandLine',
31
+ contrastHigh: 'contrastFill',
32
+ controlsHorizontal: 'controls',
33
+ controlsVertical: 'controls',
34
+ copyClipboard: 'copy',
35
+ crossInCircle: 'crossCircle',
36
+ crosshairs: 'crosshair',
37
+ currency: 'money',
38
+ cut: 'scissors',
39
+ desktop: 'display',
40
+ diff: 'compare',
41
+ discuss: 'comment',
42
+ documentEdit: 'pencil',
43
+ doubleArrowLeft: 'chevronDoubleLeft',
44
+ doubleArrowRight: 'chevronDoubleRight',
45
+ editorAlignCenter: 'textAlignCenter',
46
+ editorAlignLeft: 'textAlignLeft',
47
+ editorAlignRight: 'textAlignRight',
48
+ editorBold: 'textBold',
49
+ editorChecklist: 'listCheck',
50
+ editorCodeBlock: 'code',
51
+ editorDistributeHorizontal: 'distributeHorizontal',
52
+ editorDistributeVertical: 'distributeVertical',
53
+ editorHeading: 'textHeading',
54
+ editorItalic: 'textItalic',
55
+ editorItemAlignBottom: 'alignBottom',
56
+ editorItemAlignCenter: 'alignCenterHorizontal',
57
+ editorItemAlignLeft: 'alignLeft',
58
+ editorItemAlignMiddle: 'alignCenterVertical',
59
+ editorItemAlignRight: 'alignRight',
60
+ editorItemAlignTop: 'alignTop',
61
+ editorLink: 'link',
62
+ editorOrderedList: 'listNumber',
63
+ editorPositionBottomLeft: 'alignBottomLeft',
64
+ editorPositionBottomRight: 'alignBottomRight',
65
+ editorPositionTopLeft: 'alignTopLeft',
66
+ editorPositionTopRight: 'alignTopRight',
67
+ editorRedo: 'redo',
68
+ editorStrike: 'textStrike',
69
+ editorTable: 'table',
70
+ editorUnderline: 'textUnderline',
71
+ editorUndo: 'undo',
72
+ editorUnorderedList: 'listBullet',
73
+ email: 'mail',
74
+ eql: 'query',
75
+ errorFilled: 'errorFill',
76
+ exit: 'logOut',
77
+ expand: 'maximize',
78
+ expandMini: 'maximize',
79
+ exportAction: 'upload',
80
+ eyeClosed: 'eyeSlash',
81
+ fieldStatistics: 'tableInfo',
82
+ filterInCircle: 'filter',
83
+ glasses: 'readOnly',
84
+ grab: 'dragVertical',
85
+ grabHorizontal: 'dragHorizontal',
86
+ grabOmnidirectional: 'drag',
87
+ heatmap: 'chartHeatmap',
88
+ importAction: 'download',
89
+ indexFlush: 'chartThreshold',
90
+ indexMapping: 'mapping',
91
+ indexTemporary: 'tableTime',
92
+ invert: 'contrast',
93
+ kqlField: 'queryField',
94
+ kqlOperand: 'queryOperand',
95
+ kqlSelector: 'querySelector',
96
+ kqlValue: 'queryValue',
97
+ launch: 'rocket',
98
+ lettering: 'text',
99
+ lineDashed: 'lineDash',
100
+ lineDotted: 'lineDot',
101
+ listAdd: 'plusCircle',
102
+ logPatternAnalysis: 'pattern',
103
+ logstashIf: 'if',
104
+ logstashQueue: 'queue',
105
+ magnifyWithExclamation: 'magnifyExclamation',
106
+ magnifyWithMinus: 'magnifyMinus',
107
+ magnifyWithPlus: 'magnifyPlus',
108
+ minusInCircle: 'minusCircle',
109
+ minusInCircleFilled: 'minusCircle',
110
+ minusInSquare: 'minusSquare',
111
+ newChat: 'plusCircle',
112
+ node: 'vectorTriangle',
113
+ offline: 'wifiSlash',
114
+ online: 'wifi',
115
+ pipeBreaks: 'lineBreak',
116
+ pipeNoBreaks: 'lineBreakSlash',
117
+ playFilled: 'play',
118
+ plusInCircle: 'plusCircle',
119
+ plusInCircleFilled: 'plusCircle',
120
+ plusInSquare: 'plusSquare',
121
+ popout: 'external',
122
+ productRobot: 'productAgent',
123
+ returnKey: 'return',
124
+ securitySignal: 'radar',
125
+ starFilledSpace: 'starFill',
126
+ starMinusFilled: 'starFill',
127
+ starPlusFilled: 'starFill',
128
+ stopFilled: 'stopFill',
129
+ streamsClassic: 'productStreamsClassic',
130
+ streamsWired: 'productStreamsWired',
131
+ submodule: 'merge',
132
+ tableDensityCompact: 'tableDensityHigh',
133
+ tableDensityExpanded: 'tableDensityLow',
134
+ tableDensityNormal: 'table',
135
+ timeRefresh: 'refreshTime',
136
+ timeslider: 'clockControl',
137
+ tokenDenseVector: 'tokenVectorDense',
138
+ training: 'presentation',
139
+ unlink: 'linkSlash',
140
+ userAvatar: 'user',
141
+ vector: 'vectorSquare',
142
+ visAreaStacked: 'chartAreaStack',
143
+ visBarHorizontal: 'chartBarHorizontal',
144
+ visBarHorizontalStacked: 'chartBarHorizontalStack',
145
+ visBarVerticalStacked: 'chartBarVerticalStack',
146
+ visMapCoordinate: 'waypoint',
147
+ visMapRegion: 'map',
148
+ visMetric: 'chartMetric',
149
+ visTagCloud: 'chartTagCloud',
150
+ visText: 'text',
151
+ visVega: 'code',
152
+ warningFilled: 'warningFill',
153
+ };
154
+ const isRemovedIconAlias = (value) => Object.prototype.hasOwnProperty.call(exports.REMOVED_ICON_ALIASES, value);
155
+ exports.NoRemovedIcons = utils_1.ESLintUtils.RuleCreator.withoutDocs({
156
+ create(context) {
157
+ return (0, icon_props_1.createIconPropVisitors)((node, iconType) => {
158
+ if (!isRemovedIconAlias(iconType)) {
159
+ return;
160
+ }
161
+ const replacement = exports.REMOVED_ICON_ALIASES[iconType];
162
+ context.report({
163
+ node,
164
+ messageId: 'removedIcon',
165
+ data: { iconType, replacement },
166
+ fix: (fixer) => (0, icon_props_1.replaceIconString)(fixer, node, replacement),
167
+ });
168
+ });
169
+ },
170
+ meta: {
171
+ type: 'problem',
172
+ docs: {
173
+ description: 'Disallow EUI icons that were removed and render broken.',
174
+ },
175
+ fixable: 'code',
176
+ schema: [],
177
+ messages: {
178
+ removedIcon: 'Icon `{{iconType}}` was removed from EUI and renders as a broken image. Use `{{replacement}}` instead.',
179
+ },
180
+ },
181
+ defaultOptions: [],
182
+ });
183
+ //# sourceMappingURL=no_removed_icons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no_removed_icons.js","sourceRoot":"","sources":["../../../src/rules/no_removed_icons.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,oDAAuD;AACvD,oDAAgF;AAEhF,6EAA6E;AAC7E,0BAA0B;AACb,QAAA,oBAAoB,GAAG;IAClC,YAAY,EAAE,cAAc;IAC5B,QAAQ,EAAE,gBAAgB;IAC1B,SAAS,EAAE,mBAAmB;IAC9B,QAAQ,EAAE,mBAAmB;IAC7B,SAAS,EAAE,mBAAmB;IAC9B,UAAU,EAAE,oBAAoB;IAChC,UAAU,EAAE,kBAAkB;IAC9B,OAAO,EAAE,iBAAiB;IAC1B,MAAM,EAAE,OAAO;IACf,eAAe,EAAE,UAAU;IAC3B,oBAAoB,EAAE,kBAAkB;IACxC,mBAAmB,EAAE,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ACJ,SAAS,EAAE,aAAa;gBACxB,IAAI,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE;gBAC/B,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,8BAAiB,EAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC;aAC5D,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,yDAAyD;SACvE;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,WAAW,EACT,wGAAwG;SAC3G;KACF;IACD,cAAc,EAAE,EAAE;CACnB,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { TSESTree } from '@typescript-eslint/utils';
2
+ import type { RuleFix, RuleFixer } from '@typescript-eslint/utils/ts-eslint';
3
+ export type IconStringNode = TSESTree.Literal | TSESTree.TemplateLiteral;
4
+ export declare const createIconPropVisitors: (check: (node: IconStringNode, iconType: string) => void) => {
5
+ ImportDeclaration(node: TSESTree.ImportDeclaration): void;
6
+ JSXAttribute(node: TSESTree.JSXAttribute): void;
7
+ Property(node: TSESTree.Property): void;
8
+ };
9
+ export declare const replaceIconString: (fixer: RuleFixer, node: IconStringNode, replacement: string) => RuleFix;
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
6
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
7
+ * Side Public License, v 1.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.replaceIconString = exports.createIconPropVisitors = void 0;
11
+ const get_property_name_1 = require("./get_property_name");
12
+ const COMPONENT_ICON_ATTRIBUTES = {
13
+ EuiComment: new Set(['eventIcon']),
14
+ EuiCommentTimeline: new Set(['timelineAvatar']),
15
+ EuiContextMenuItem: new Set(['icon']),
16
+ EuiFieldNumber: new Set(['icon']),
17
+ EuiFieldText: new Set(['icon']),
18
+ EuiFormAppend: new Set(['iconLeft', 'iconRight']),
19
+ EuiFormAppendPrepend: new Set(['iconLeft', 'iconRight']),
20
+ EuiFormControlLayout: new Set(['icon']),
21
+ EuiFormControlLayoutDelimited: new Set(['icon']),
22
+ EuiFormPrepend: new Set(['iconLeft', 'iconRight']),
23
+ EuiLoadingLogo: new Set(['logo']),
24
+ EuiTextArea: new Set(['icon']),
25
+ EuiTimelineItem: new Set(['icon']),
26
+ };
27
+ // `*iconType` props are checked on any component, so wrappers that forward
28
+ // them to EUI are covered. Other icon props are only checked on EUI imports.
29
+ const isIconAttribute = (attributeName, importedComponentName) => {
30
+ const normalizedName = attributeName.toLowerCase();
31
+ if (normalizedName.endsWith('icontype')) {
32
+ return true;
33
+ }
34
+ if (!importedComponentName) {
35
+ return false;
36
+ }
37
+ return (COMPONENT_ICON_ATTRIBUTES[importedComponentName]?.has(attributeName) ===
38
+ true ||
39
+ (normalizedName === 'type' &&
40
+ (importedComponentName === 'EuiIcon' ||
41
+ importedComponentName === 'EuiIconTip')));
42
+ };
43
+ const getIconStringNodes = (node) => {
44
+ switch (node.type) {
45
+ case 'Literal':
46
+ return typeof node.value === 'string' ? [node] : [];
47
+ case 'TemplateLiteral':
48
+ return node.expressions.length === 0 ? [node] : [];
49
+ case 'JSXExpressionContainer':
50
+ case 'TSAsExpression':
51
+ case 'TSSatisfiesExpression':
52
+ case 'TSNonNullExpression':
53
+ return getIconStringNodes(node.expression);
54
+ case 'ConditionalExpression':
55
+ return [
56
+ ...getIconStringNodes(node.consequent),
57
+ ...getIconStringNodes(node.alternate),
58
+ ];
59
+ case 'LogicalExpression':
60
+ return [
61
+ ...getIconStringNodes(node.left),
62
+ ...getIconStringNodes(node.right),
63
+ ];
64
+ // Form controls accept an `IconShape` object: `icon={{ type: 'email' }}`
65
+ case 'ObjectExpression':
66
+ return node.properties.flatMap((property) => property.type === 'Property' &&
67
+ !property.computed &&
68
+ (0, get_property_name_1.getPropertyName)(property) === 'type'
69
+ ? getIconStringNodes(property.value)
70
+ : []);
71
+ default:
72
+ return [];
73
+ }
74
+ };
75
+ const getStaticStringValue = (node) => {
76
+ if (node.type === 'Literal') {
77
+ return typeof node.value === 'string' ? node.value : undefined;
78
+ }
79
+ return node.quasis[0]?.value.cooked ?? undefined;
80
+ };
81
+ const createIconPropVisitors = (check) => {
82
+ const euiComponentImports = new Map();
83
+ const checkValue = (value) => {
84
+ for (const node of getIconStringNodes(value)) {
85
+ const iconType = getStaticStringValue(node);
86
+ if (iconType) {
87
+ check(node, iconType);
88
+ }
89
+ }
90
+ };
91
+ return {
92
+ ImportDeclaration(node) {
93
+ if (typeof node.source.value !== 'string' ||
94
+ (node.source.value !== '@elastic/eui' &&
95
+ !node.source.value.startsWith('@elastic/eui/'))) {
96
+ return;
97
+ }
98
+ for (const specifier of node.specifiers) {
99
+ if (specifier.type !== 'ImportSpecifier') {
100
+ continue;
101
+ }
102
+ const importedName = specifier.imported.type === 'Identifier'
103
+ ? specifier.imported.name
104
+ : specifier.imported.value;
105
+ if (importedName.startsWith('Eui')) {
106
+ euiComponentImports.set(specifier.local.name, importedName);
107
+ }
108
+ }
109
+ },
110
+ JSXAttribute(node) {
111
+ if (node.name.type !== 'JSXIdentifier' || !node.value) {
112
+ return;
113
+ }
114
+ const openingElement = node.parent;
115
+ const importedComponentName = openingElement.type === 'JSXOpeningElement' &&
116
+ openingElement.name.type === 'JSXIdentifier'
117
+ ? euiComponentImports.get(openingElement.name.name)
118
+ : undefined;
119
+ if (isIconAttribute(node.name.name, importedComponentName)) {
120
+ checkValue(node.value);
121
+ }
122
+ },
123
+ // Exact key match: suffixed keys like Lens's `triggerIconType` hold
124
+ // non-EUI values, and bare `icon` keys are too often unrelated.
125
+ Property(node) {
126
+ if (node.parent.type === 'ObjectExpression' &&
127
+ !node.computed &&
128
+ (0, get_property_name_1.getPropertyName)(node) === 'iconType') {
129
+ checkValue(node.value);
130
+ }
131
+ },
132
+ };
133
+ };
134
+ exports.createIconPropVisitors = createIconPropVisitors;
135
+ const replaceIconString = (fixer, node, replacement) => {
136
+ const quote = node.type === 'Literal' ? node.raw[0] : '`';
137
+ return fixer.replaceText(node, `${quote}${replacement}${quote}`);
138
+ };
139
+ exports.replaceIconString = replaceIconString;
140
+ //# sourceMappingURL=icon_props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon_props.js","sourceRoot":"","sources":["../../../src/utils/icon_props.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAIH,2DAAsD;AAItD,MAAM,yBAAyB,GAC7B;IACE,UAAU,EAAE,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC;IAClC,kBAAkB,EAAE,IAAI,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC/C,kBAAkB,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IACrC,cAAc,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IACjC,YAAY,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IAC/B,aAAa,EAAE,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IACjD,oBAAoB,EAAE,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IACxD,oBAAoB,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IACvC,6BAA6B,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IAChD,cAAc,EAAE,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAClD,cAAc,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IACjC,WAAW,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IAC9B,eAAe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AC,IAAI,CAAC;gBACnD,CAAC,CAAC,SAAS,CAAC;YAEhB,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,qBAAqB,CAAC,EAAE,CAAC;gBAC3D,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;QACD,oEAAoE;QACpE,gEAAgE;QAChE,QAAQ,CAAC,IAAuB;YAC9B,IACE,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kBAAkB;gBACvC,CAAC,IAAI,CAAC,QAAQ;gBACd,IAAA,mCAAe,EAAC,IAAI,CAAC,KAAK,UAAU,EACpC,CAAC;gBACD,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAnEW,QAAA,sBAAsB,0BAmEjC;AAEK,MAAM,iBAAiB,GAAG,CAC/B,KAAgB,EAChB,IAAoB,EACpB,WAAmB,EACV,EAAE;IACX,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAE1D,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,WAAW,GAAG,KAAK,EAAE,CAAC,CAAC;AACnE,CAAC,CAAC;AARW,QAAA,iBAAiB,qBAQ5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elastic/eslint-plugin-eui",
3
- "version": "3.3.0",
3
+ "version": "4.0.0-snapshot.1794281274327",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -59,5 +59,6 @@
59
59
  "!**/*.test.js",
60
60
  "!**/*.test.js.map",
61
61
  "!**/*.test.d.ts"
62
- ]
62
+ ],
63
+ "stableVersion": "4.0.0"
63
64
  }