@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.
package/README.md CHANGED
@@ -31,14 +31,34 @@ All deprecations still must follow our [deprecation process](../../wiki/eui-team
31
31
 
32
32
  ### `@elastic/eui/no-deprecated-icon-aliases`
33
33
 
34
- Disallows deprecated EUI icon aliases in static JSX props on components imported
35
- from `@elastic/eui`. The rule checks props ending in `IconType`, the `type` prop
36
- on `EuiIcon` and `EuiIconTip`, and component-specific icon props such as
37
- `timelineAvatar`, `icon`, `logo`, `iconLeft`, and `iconRight`. It automatically
38
- replaces deprecated aliases with their supported icon handles.
34
+ Disallows deprecated EUI icon aliases that still render. It automatically
35
+ replaces them with their supported icon handles.
36
+
37
+ The rule checks static icon names, including both branches of `? :` and the
38
+ operands of `&&`, `||`, and `??`, in:
39
+
40
+ - JSX props ending in `IconType` on any component, so wrappers that forward
41
+ them to EUI are covered
42
+ - the `type` prop on `EuiIcon` and `EuiIconTip`, and component-specific icon
43
+ props such as `timelineAvatar`, `icon`, `logo`, `iconLeft`, and `iconRight` on
44
+ components imported from `@elastic/eui`
45
+ - `iconType` keys in object literals, such as context menu items and table
46
+ actions. Other keys, like `icon` or `triggerIconType`, are skipped because they
47
+ often hold non-EUI values.
39
48
 
40
49
  See the full table of icon replacements here: https://github.com/elastic/eui/issues/9561
41
50
 
51
+ ### `@elastic/eui/no-removed-icons`
52
+
53
+ Disallows icon names that were removed from EUI. `EuiIcon` treats an unknown
54
+ name as an image URL, so a removed name renders as a broken image without a
55
+ console error. It checks the same props as
56
+ `@elastic/eui/no-deprecated-icon-aliases` and automatically replaces removed
57
+ names with their supported icon handles.
58
+
59
+ It's a separate rule so it can be an error while deprecated aliases stay
60
+ warnings.
61
+
42
62
  ### `@elastic/eui/no-css-color`
43
63
 
44
64
  This rule warns engineers to not use literal css color in the codebase, particularly for CSS properties that apply color to either the html element or text nodes, but rather urge users to defer to using the color tokens provided by EUI.
package/lib/cjs/index.js CHANGED
@@ -24,6 +24,7 @@ var _icon_accessibility_rules = require("./rules/a11y/icon_accessibility_rules")
24
24
  var _tooltip_no_interactive_content = require("./rules/a11y/tooltip_no_interactive_content");
25
25
  var _tooltip_button_icon_wrap = require("./rules/a11y/tooltip_button_icon_wrap");
26
26
  var _no_deprecated_icon_aliases = require("./rules/no_deprecated_icon_aliases");
27
+ var _no_removed_icons = require("./rules/no_removed_icons");
27
28
  var _button_group_no_invalid_children = require("./rules/button_group_no_invalid_children");
28
29
  var _button_group_selection_require_id = require("./rules/button_group_selection_require_id");
29
30
  /*
@@ -45,6 +46,7 @@ const config = {
45
46
  'no-deprecated-icon-aliases': _no_deprecated_icon_aliases.NoDeprecatedIconAliases,
46
47
  'no-nested-copy-tooltip': _no_nested_copy_tooltip.NoNestedCopyTooltip,
47
48
  'no-nested-interactive-element': _no_nested_interactive_element.NoNestedInteractiveElement,
49
+ 'no-removed-icons': _no_removed_icons.NoRemovedIcons,
48
50
  'no-restricted-eui-imports': _no_restricted_eui_imports.NoRestrictedEuiImports,
49
51
  'no-static-z-index': _no_static_z_index.NoStaticZIndex,
50
52
  'no-unnamed-interactive-element': _no_unnamed_interactive_element.NoUnnamedInteractiveElement,
@@ -78,6 +80,7 @@ const config = {
78
80
  '@elastic/eui/no-deprecated-icon-aliases': 'warn',
79
81
  '@elastic/eui/no-nested-copy-tooltip': 'warn',
80
82
  '@elastic/eui/no-nested-interactive-element': 'warn',
83
+ '@elastic/eui/no-removed-icons': 'error',
81
84
  '@elastic/eui/no-restricted-eui-imports': 'warn',
82
85
  '@elastic/eui/no-static-z-index': 'warn',
83
86
  '@elastic/eui/no-unnamed-interactive-element': 'warn',
@@ -2,88 +2,21 @@ import { ESLintUtils } from '@typescript-eslint/utils';
2
2
  export declare const DEPRECATED_ICON_ALIASES: {
3
3
  readonly alert: "warning";
4
4
  readonly analyzeEvent: "cube";
5
- readonly anomalyChart: "chartAnomaly";
6
5
  readonly anomalySwimLane: "chartHeatmap";
7
6
  readonly annotation: "flag";
8
7
  readonly apps: "grid";
9
- readonly apmTrace: "chartWaterfall";
10
- readonly arrowDown: "chevronSingleDown";
11
- readonly arrowEnd: "chevronLimitRight";
12
- readonly arrowLeft: "chevronSingleLeft";
13
- readonly arrowRight: "chevronSingleRight";
14
- readonly arrowStart: "chevronLimitLeft";
15
- readonly arrowUp: "chevronSingleUp";
16
- readonly beaker: "flask";
17
- readonly boxesHorizontal: "ellipsis";
18
8
  readonly boxesVertical: "ellipsis";
19
- readonly changePointDetection: "chartChangePoint";
20
- readonly checkInCircleFilled: "checkCircleFill";
21
- readonly cheer: "popper";
22
9
  readonly cloudDrizzle: "cloudRain";
23
10
  readonly cloudStormy: "cloudBolt";
24
11
  readonly cloudSunny: "cloudSun";
25
- readonly color: "paintBucket";
26
12
  readonly compute: "processor";
27
- readonly console: "commandLine";
28
13
  readonly container: "package";
29
14
  readonly continuityAbove: "upload";
30
15
  readonly continuityWithin: "maximize";
31
- readonly contrastHigh: "contrastFill";
32
- readonly controlsHorizontal: "controls";
33
- readonly controlsVertical: "controls";
34
- readonly copyClipboard: "copy";
35
- readonly crossInCircle: "crossCircle";
36
- readonly crosshairs: "crosshair";
37
- readonly currency: "money";
38
- readonly cut: "scissors";
39
- readonly desktop: "display";
40
- readonly diff: "compare";
41
- readonly discuss: "comment";
42
- readonly documentEdit: "pencil";
43
16
  readonly documents: "document";
44
- readonly doubleArrowLeft: "chevronDoubleLeft";
45
- readonly doubleArrowRight: "chevronDoubleRight";
46
- readonly editorAlignCenter: "textAlignCenter";
47
- readonly editorAlignLeft: "textAlignLeft";
48
- readonly editorAlignRight: "textAlignRight";
49
- readonly editorBold: "textBold";
50
- readonly editorChecklist: "listCheck";
51
- readonly editorCodeBlock: "code";
52
17
  readonly editorComment: "comment";
53
- readonly editorDistributeHorizontal: "distributeHorizontal";
54
- readonly editorDistributeVertical: "distributeVertical";
55
- readonly editorHeading: "textHeading";
56
- readonly editorItalic: "textItalic";
57
- readonly editorItemAlignBottom: "alignBottom";
58
- readonly editorItemAlignCenter: "alignCenterHorizontal";
59
- readonly editorItemAlignLeft: "alignLeft";
60
- readonly editorItemAlignMiddle: "alignCenterVertical";
61
- readonly editorItemAlignRight: "alignRight";
62
- readonly editorItemAlignTop: "alignTop";
63
- readonly editorLink: "link";
64
- readonly editorOrderedList: "listNumber";
65
- readonly editorPositionBottomLeft: "alignBottomLeft";
66
- readonly editorPositionBottomRight: "alignBottomRight";
67
- readonly editorPositionTopLeft: "alignTopLeft";
68
- readonly editorPositionTopRight: "alignTopRight";
69
- readonly editorRedo: "redo";
70
- readonly editorStrike: "textStrike";
71
- readonly editorTable: "table";
72
- readonly editorUnderline: "textUnderline";
73
- readonly editorUndo: "undo";
74
- readonly editorUnorderedList: "listBullet";
75
- readonly email: "mail";
76
- readonly eql: "query";
77
18
  readonly esqlVis: "query";
78
- readonly errorFilled: "errorFill";
79
- readonly exit: "logOut";
80
- readonly expand: "maximize";
81
- readonly expandMini: "maximize";
82
19
  readonly export: "upload";
83
- readonly exportAction: "upload";
84
- readonly eyeClosed: "eyeSlash";
85
- readonly fieldStatistics: "tableInfo";
86
- readonly filterInCircle: "filter";
87
20
  readonly fold: "minimize";
88
21
  readonly folderCheck: "check";
89
22
  readonly folderClose: "folder";
@@ -91,71 +24,29 @@ export declare const DEPRECATED_ICON_ALIASES: {
91
24
  readonly folderOpened: "folderOpen";
92
25
  readonly frameNext: "chevronSingleRight";
93
26
  readonly framePrevious: "chevronSingleLeft";
94
- readonly glasses: "readOnly";
95
27
  readonly help: "question";
96
- readonly grab: "dragVertical";
97
- readonly grabHorizontal: "dragHorizontal";
98
- readonly grabOmnidirectional: "drag";
99
- readonly heatmap: "chartHeatmap";
100
- readonly importAction: "download";
101
28
  readonly index: "table";
102
29
  readonly indexClose: "tableCross";
103
30
  readonly ip: "tokenIP";
104
31
  readonly indexEdit: "tablePencil";
105
- readonly indexFlush: "chartThreshold";
106
- readonly indexMapping: "mapping";
107
32
  readonly indexOpen: "tablePlus";
108
33
  readonly indexRuntime: "tablePlay";
109
34
  readonly indexSettings: "tableGear";
110
- readonly indexTemporary: "tableTime";
111
- readonly invert: "contrast";
112
- readonly kqlField: "queryField";
113
35
  readonly kqlFunction: "push";
114
- readonly kqlOperand: "queryOperand";
115
- readonly kqlSelector: "querySelector";
116
- readonly kqlValue: "queryValue";
117
36
  readonly kubernetesPod: "cube";
118
- readonly launch: "rocket";
119
- readonly lettering: "text";
120
- readonly lineDashed: "lineDash";
121
- readonly lineDotted: "lineDot";
122
37
  readonly list: "listBullet";
123
- readonly listAdd: "plusCircle";
124
- readonly logPatternAnalysis: "pattern";
125
38
  readonly logRateAnalysis: "chartBarVertical";
126
39
  readonly logstashFilter: "filter";
127
- readonly logstashIf: "if";
128
40
  readonly logstashInput: "download";
129
41
  readonly logstashOutput: "upload";
130
- readonly logstashQueue: "queue";
131
- readonly magnifyWithExclamation: "magnifyExclamation";
132
- readonly magnifyWithMinus: "magnifyMinus";
133
- readonly magnifyWithPlus: "magnifyPlus";
134
42
  readonly mapMarker: "waypoint";
135
43
  readonly menuDown: "transitionBottomOut";
136
44
  readonly menuUp: "transitionTopOut";
137
- readonly minusInCircle: "minusCircle";
138
- readonly minusInCircleFilled: "minusCircle";
139
- readonly minusInSquare: "minusSquare";
140
45
  readonly namespace: "kubernetesNamespace";
141
- readonly newChat: "plusCircle";
142
- readonly node: "vectorTriangle";
143
- readonly offline: "wifiSlash";
144
- readonly online: "wifi";
145
46
  readonly pagesSelect: "documentsCheck";
146
47
  readonly payment: "money";
147
48
  readonly pinFilled: "pinFill";
148
- readonly pipeBreaks: "lineBreak";
149
- readonly pipeNoBreaks: "lineBreakSlash";
150
- readonly playFilled: "play";
151
- readonly plusInCircle: "plusCircle";
152
- readonly plusInCircleFilled: "plusCircle";
153
- readonly plusInSquare: "plusSquare";
154
- readonly popout: "external";
155
- readonly productRobot: "productAgent";
156
- readonly returnKey: "return";
157
49
  readonly search: "magnify";
158
- readonly securitySignal: "radar";
159
50
  readonly sessionViewer: "commandLine";
160
51
  readonly singleMetricViewer: "chartArea";
161
52
  readonly spaces: "grid";
@@ -163,53 +54,25 @@ export declare const DEPRECATED_ICON_ALIASES: {
163
54
  readonly starEmptySpace: "star";
164
55
  readonly starFillSpace: "starFill";
165
56
  readonly starFilled: "starFill";
166
- readonly starFilledSpace: "starFill";
167
57
  readonly starMinusEmpty: "star";
168
58
  readonly starMinusFill: "starFill";
169
- readonly starMinusFilled: "starFill";
170
59
  readonly starPlusEmpty: "star";
171
60
  readonly starPlusFill: "starFill";
172
- readonly starPlusFilled: "starFill";
173
- readonly stopFilled: "stopFill";
174
61
  readonly stats: "chartLine";
175
- readonly streamsClassic: "productStreamsClassic";
176
- readonly streamsWired: "productStreamsWired";
177
62
  readonly string: "tokenString";
178
- readonly submodule: "merge";
179
63
  readonly tableOfContents: "listBullet";
180
- readonly tableDensityCompact: "tableDensityHigh";
181
- readonly tableDensityExpanded: "tableDensityLow";
182
- readonly tableDensityNormal: "table";
183
64
  readonly temperature: "thermometer";
184
- readonly timeRefresh: "refreshTime";
185
65
  readonly timelineWithArrow: "timelinePointer";
186
- readonly timeslider: "clockControl";
187
- readonly tokenDenseVector: "tokenVectorDense";
188
- readonly training: "presentation";
189
66
  readonly unfold: "maximize";
190
- readonly unlink: "linkSlash";
191
- readonly userAvatar: "user";
192
- readonly vector: "vectorSquare";
193
67
  readonly visArea: "chartArea";
194
- readonly visAreaStacked: "chartAreaStack";
195
- readonly visBarHorizontal: "chartBarHorizontal";
196
- readonly visBarHorizontalStacked: "chartBarHorizontalStack";
197
68
  readonly visBarVertical: "chartBarVertical";
198
- readonly visBarVerticalStacked: "chartBarVerticalStack";
199
69
  readonly visGauge: "chartGauge";
200
70
  readonly visGoal: "chartGauge";
201
71
  readonly visLine: "chartLine";
202
- readonly visMapCoordinate: "waypoint";
203
- readonly visMapRegion: "map";
204
- readonly visMetric: "chartMetric";
205
72
  readonly visPie: "chartPie";
206
73
  readonly visTable: "table";
207
- readonly visTagCloud: "chartTagCloud";
208
- readonly visText: "text";
209
74
  readonly visTimelion: "productTimelion";
210
- readonly visVega: "code";
211
75
  readonly visVisualBuilder: "productTSVB";
212
- readonly warningFilled: "warningFill";
213
76
  readonly wordWrap: "lineBreak";
214
77
  readonly wordWrapDisabled: "lineBreakSlash";
215
78
  };
@@ -1 +1 @@
1
- {"version":3,"file":"no_deprecated_icon_aliases.d.ts","sourceRoot":"","sources":["../../../src/rules/no_deprecated_icon_aliases.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAY,MAAM,0BAA0B,CAAC;AAEjE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqN1B,CAAC;AAEX,eAAO,MAAM,oCAAoC,EAAE,WAAW,CAAC,MAAM,CAQjE,CAAC;AAEL,eAAO,MAAM,8BAA8B;;;;CAOjC,CAAC;AA+EX,eAAO,MAAM,uBAAuB,oIAuHlC,CAAC"}
1
+ {"version":3,"file":"no_deprecated_icon_aliases.d.ts","sourceRoot":"","sources":["../../../src/rules/no_deprecated_icon_aliases.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4E1B,CAAC;AAEX,eAAO,MAAM,oCAAoC,EAAE,WAAW,CAAC,MAAM,CAQjE,CAAC;AAEL,eAAO,MAAM,8BAA8B;;;;CAMjC,CAAC;AAaX,eAAO,MAAM,uBAAuB,oIAoDlC,CAAC"}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.NoDeprecatedIconAliases = exports.DEPRECATED_ICON_ALIASES = exports.DEPRECATED_ICONS_WITH_GUIDANCE = exports.DEPRECATED_ICONS_WITHOUT_REPLACEMENT = void 0;
7
7
  var _utils = require("@typescript-eslint/utils");
8
+ var _icon_props = require("../utils/icon_props");
8
9
  /*
9
10
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
10
11
  * or more contributor license agreements. Licensed under the Elastic License
@@ -16,88 +17,21 @@ var _utils = require("@typescript-eslint/utils");
16
17
  const DEPRECATED_ICON_ALIASES = exports.DEPRECATED_ICON_ALIASES = {
17
18
  alert: 'warning',
18
19
  analyzeEvent: 'cube',
19
- anomalyChart: 'chartAnomaly',
20
20
  anomalySwimLane: 'chartHeatmap',
21
21
  annotation: 'flag',
22
22
  apps: 'grid',
23
- apmTrace: 'chartWaterfall',
24
- arrowDown: 'chevronSingleDown',
25
- arrowEnd: 'chevronLimitRight',
26
- arrowLeft: 'chevronSingleLeft',
27
- arrowRight: 'chevronSingleRight',
28
- arrowStart: 'chevronLimitLeft',
29
- arrowUp: 'chevronSingleUp',
30
- beaker: 'flask',
31
- boxesHorizontal: 'ellipsis',
32
23
  boxesVertical: 'ellipsis',
33
- changePointDetection: 'chartChangePoint',
34
- checkInCircleFilled: 'checkCircleFill',
35
- cheer: 'popper',
36
24
  cloudDrizzle: 'cloudRain',
37
25
  cloudStormy: 'cloudBolt',
38
26
  cloudSunny: 'cloudSun',
39
- color: 'paintBucket',
40
27
  compute: 'processor',
41
- console: 'commandLine',
42
28
  container: 'package',
43
29
  continuityAbove: 'upload',
44
30
  continuityWithin: 'maximize',
45
- contrastHigh: 'contrastFill',
46
- controlsHorizontal: 'controls',
47
- controlsVertical: 'controls',
48
- copyClipboard: 'copy',
49
- crossInCircle: 'crossCircle',
50
- crosshairs: 'crosshair',
51
- currency: 'money',
52
- cut: 'scissors',
53
- desktop: 'display',
54
- diff: 'compare',
55
- discuss: 'comment',
56
- documentEdit: 'pencil',
57
31
  documents: 'document',
58
- doubleArrowLeft: 'chevronDoubleLeft',
59
- doubleArrowRight: 'chevronDoubleRight',
60
- editorAlignCenter: 'textAlignCenter',
61
- editorAlignLeft: 'textAlignLeft',
62
- editorAlignRight: 'textAlignRight',
63
- editorBold: 'textBold',
64
- editorChecklist: 'listCheck',
65
- editorCodeBlock: 'code',
66
32
  editorComment: 'comment',
67
- editorDistributeHorizontal: 'distributeHorizontal',
68
- editorDistributeVertical: 'distributeVertical',
69
- editorHeading: 'textHeading',
70
- editorItalic: 'textItalic',
71
- editorItemAlignBottom: 'alignBottom',
72
- editorItemAlignCenter: 'alignCenterHorizontal',
73
- editorItemAlignLeft: 'alignLeft',
74
- editorItemAlignMiddle: 'alignCenterVertical',
75
- editorItemAlignRight: 'alignRight',
76
- editorItemAlignTop: 'alignTop',
77
- editorLink: 'link',
78
- editorOrderedList: 'listNumber',
79
- editorPositionBottomLeft: 'alignBottomLeft',
80
- editorPositionBottomRight: 'alignBottomRight',
81
- editorPositionTopLeft: 'alignTopLeft',
82
- editorPositionTopRight: 'alignTopRight',
83
- editorRedo: 'redo',
84
- editorStrike: 'textStrike',
85
- editorTable: 'table',
86
- editorUnderline: 'textUnderline',
87
- editorUndo: 'undo',
88
- editorUnorderedList: 'listBullet',
89
- email: 'mail',
90
- eql: 'query',
91
33
  esqlVis: 'query',
92
- errorFilled: 'errorFill',
93
- exit: 'logOut',
94
- expand: 'maximize',
95
- expandMini: 'maximize',
96
34
  export: 'upload',
97
- exportAction: 'upload',
98
- eyeClosed: 'eyeSlash',
99
- fieldStatistics: 'tableInfo',
100
- filterInCircle: 'filter',
101
35
  fold: 'minimize',
102
36
  folderCheck: 'check',
103
37
  folderClose: 'folder',
@@ -105,71 +39,29 @@ const DEPRECATED_ICON_ALIASES = exports.DEPRECATED_ICON_ALIASES = {
105
39
  folderOpened: 'folderOpen',
106
40
  frameNext: 'chevronSingleRight',
107
41
  framePrevious: 'chevronSingleLeft',
108
- glasses: 'readOnly',
109
42
  help: 'question',
110
- grab: 'dragVertical',
111
- grabHorizontal: 'dragHorizontal',
112
- grabOmnidirectional: 'drag',
113
- heatmap: 'chartHeatmap',
114
- importAction: 'download',
115
43
  index: 'table',
116
44
  indexClose: 'tableCross',
117
45
  ip: 'tokenIP',
118
46
  indexEdit: 'tablePencil',
119
- indexFlush: 'chartThreshold',
120
- indexMapping: 'mapping',
121
47
  indexOpen: 'tablePlus',
122
48
  indexRuntime: 'tablePlay',
123
49
  indexSettings: 'tableGear',
124
- indexTemporary: 'tableTime',
125
- invert: 'contrast',
126
- kqlField: 'queryField',
127
50
  kqlFunction: 'push',
128
- kqlOperand: 'queryOperand',
129
- kqlSelector: 'querySelector',
130
- kqlValue: 'queryValue',
131
51
  kubernetesPod: 'cube',
132
- launch: 'rocket',
133
- lettering: 'text',
134
- lineDashed: 'lineDash',
135
- lineDotted: 'lineDot',
136
52
  list: 'listBullet',
137
- listAdd: 'plusCircle',
138
- logPatternAnalysis: 'pattern',
139
53
  logRateAnalysis: 'chartBarVertical',
140
54
  logstashFilter: 'filter',
141
- logstashIf: 'if',
142
55
  logstashInput: 'download',
143
56
  logstashOutput: 'upload',
144
- logstashQueue: 'queue',
145
- magnifyWithExclamation: 'magnifyExclamation',
146
- magnifyWithMinus: 'magnifyMinus',
147
- magnifyWithPlus: 'magnifyPlus',
148
57
  mapMarker: 'waypoint',
149
58
  menuDown: 'transitionBottomOut',
150
59
  menuUp: 'transitionTopOut',
151
- minusInCircle: 'minusCircle',
152
- minusInCircleFilled: 'minusCircle',
153
- minusInSquare: 'minusSquare',
154
60
  namespace: 'kubernetesNamespace',
155
- newChat: 'plusCircle',
156
- node: 'vectorTriangle',
157
- offline: 'wifiSlash',
158
- online: 'wifi',
159
61
  pagesSelect: 'documentsCheck',
160
62
  payment: 'money',
161
63
  pinFilled: 'pinFill',
162
- pipeBreaks: 'lineBreak',
163
- pipeNoBreaks: 'lineBreakSlash',
164
- playFilled: 'play',
165
- plusInCircle: 'plusCircle',
166
- plusInCircleFilled: 'plusCircle',
167
- plusInSquare: 'plusSquare',
168
- popout: 'external',
169
- productRobot: 'productAgent',
170
- returnKey: 'return',
171
64
  search: 'magnify',
172
- securitySignal: 'radar',
173
65
  sessionViewer: 'commandLine',
174
66
  singleMetricViewer: 'chartArea',
175
67
  spaces: 'grid',
@@ -177,53 +69,25 @@ const DEPRECATED_ICON_ALIASES = exports.DEPRECATED_ICON_ALIASES = {
177
69
  starEmptySpace: 'star',
178
70
  starFillSpace: 'starFill',
179
71
  starFilled: 'starFill',
180
- starFilledSpace: 'starFill',
181
72
  starMinusEmpty: 'star',
182
73
  starMinusFill: 'starFill',
183
- starMinusFilled: 'starFill',
184
74
  starPlusEmpty: 'star',
185
75
  starPlusFill: 'starFill',
186
- starPlusFilled: 'starFill',
187
- stopFilled: 'stopFill',
188
76
  stats: 'chartLine',
189
- streamsClassic: 'productStreamsClassic',
190
- streamsWired: 'productStreamsWired',
191
77
  string: 'tokenString',
192
- submodule: 'merge',
193
78
  tableOfContents: 'listBullet',
194
- tableDensityCompact: 'tableDensityHigh',
195
- tableDensityExpanded: 'tableDensityLow',
196
- tableDensityNormal: 'table',
197
79
  temperature: 'thermometer',
198
- timeRefresh: 'refreshTime',
199
80
  timelineWithArrow: 'timelinePointer',
200
- timeslider: 'clockControl',
201
- tokenDenseVector: 'tokenVectorDense',
202
- training: 'presentation',
203
81
  unfold: 'maximize',
204
- unlink: 'linkSlash',
205
- userAvatar: 'user',
206
- vector: 'vectorSquare',
207
82
  visArea: 'chartArea',
208
- visAreaStacked: 'chartAreaStack',
209
- visBarHorizontal: 'chartBarHorizontal',
210
- visBarHorizontalStacked: 'chartBarHorizontalStack',
211
83
  visBarVertical: 'chartBarVertical',
212
- visBarVerticalStacked: 'chartBarVerticalStack',
213
84
  visGauge: 'chartGauge',
214
85
  visGoal: 'chartGauge',
215
86
  visLine: 'chartLine',
216
- visMapCoordinate: 'waypoint',
217
- visMapRegion: 'map',
218
- visMetric: 'chartMetric',
219
87
  visPie: 'chartPie',
220
88
  visTable: 'table',
221
- visTagCloud: 'chartTagCloud',
222
- visText: 'text',
223
89
  visTimelion: 'productTimelion',
224
- visVega: 'code',
225
90
  visVisualBuilder: 'productTSVB',
226
- warningFilled: 'warningFill',
227
91
  wordWrap: 'lineBreak',
228
92
  wordWrapDisabled: 'lineBreakSlash'
229
93
  };
@@ -233,124 +97,50 @@ const DEPRECATED_ICONS_WITH_GUIDANCE = exports.DEPRECATED_ICONS_WITH_GUIDANCE =
233
97
  stopFill: 'Use `EuiColorPickerSwatch` for a color chip or `stop` otherwise.',
234
98
  stopSlash: 'Use `EuiColorPickerSwatch` for no/transparent color or `stop` otherwise.'
235
99
  };
236
- const isDeprecatedIconWithGuidance = value => value in DEPRECATED_ICONS_WITH_GUIDANCE;
237
- const getComponentName = node => node.name.type === 'JSXIdentifier' ? node.name.name : undefined;
238
- const COMPONENT_ICON_ATTRIBUTES = {
239
- EuiCommentTimeline: new Set(['timelineAvatar']),
240
- EuiFormAppend: new Set(['iconLeft', 'iconRight']),
241
- EuiFormAppendPrepend: new Set(['iconLeft', 'iconRight']),
242
- EuiFormPrepend: new Set(['iconLeft', 'iconRight']),
243
- EuiLoadingLogo: new Set(['logo']),
244
- EuiTimelineItem: new Set(['icon'])
245
- };
246
- const isIconAttribute = (attributeName, importedComponentName) => {
247
- const normalizedName = attributeName.toLowerCase();
248
- return normalizedName.endsWith('icontype') || COMPONENT_ICON_ATTRIBUTES[importedComponentName]?.has(attributeName) === true || normalizedName === 'type' && (importedComponentName === 'EuiIcon' || importedComponentName === 'EuiIconTip');
249
- };
250
- const getStaticStringNode = node => {
251
- if (node.value?.type === 'Literal' && typeof node.value.value === 'string') {
252
- return node.value;
253
- }
254
- if (node.value?.type !== 'JSXExpressionContainer') {
255
- return;
256
- }
257
- const {
258
- expression
259
- } = node.value;
260
- if (expression.type === 'Literal' && typeof expression.value === 'string') {
261
- return expression;
262
- }
263
- if (expression.type === 'TemplateLiteral' && expression.expressions.length === 0) {
264
- return expression;
265
- }
266
- };
267
- const getStaticStringValue = node => {
268
- if (node.type === 'Literal') {
269
- return typeof node.value === 'string' ? node.value : undefined;
270
- }
271
- return node.quasis[0]?.value.cooked ?? undefined;
272
- };
273
- const isDeprecatedIconAlias = value => value in DEPRECATED_ICON_ALIASES;
100
+ const isDeprecatedIconWithGuidance = value => Object.prototype.hasOwnProperty.call(DEPRECATED_ICONS_WITH_GUIDANCE, value);
101
+ const isDeprecatedIconAlias = value => Object.prototype.hasOwnProperty.call(DEPRECATED_ICON_ALIASES, value);
274
102
  const NoDeprecatedIconAliases = exports.NoDeprecatedIconAliases = _utils.ESLintUtils.RuleCreator.withoutDocs({
275
103
  create(context) {
276
- const euiComponentImports = new Map();
277
- return {
278
- ImportDeclaration(node) {
279
- if (typeof node.source.value !== 'string' || node.source.value !== '@elastic/eui' && !node.source.value.startsWith('@elastic/eui/')) {
280
- return;
281
- }
282
- for (const specifier of node.specifiers) {
283
- if (specifier.type !== 'ImportSpecifier') {
284
- continue;
285
- }
286
- const importedName = specifier.imported.type === 'Identifier' ? specifier.imported.name : specifier.imported.value;
287
- if (importedName.startsWith('Eui')) {
288
- euiComponentImports.set(specifier.local.name, importedName);
289
- }
290
- }
291
- },
292
- JSXAttribute(node) {
293
- if (node.name.type !== 'JSXIdentifier') {
104
+ return (0, _icon_props.createIconPropVisitors)((node, iconType) => {
105
+ if (!isDeprecatedIconAlias(iconType)) {
106
+ if (isDeprecatedIconWithGuidance(iconType)) {
107
+ context.report({
108
+ node,
109
+ messageId: 'deprecatedIconGuidance',
110
+ data: {
111
+ iconType,
112
+ guidance: DEPRECATED_ICONS_WITH_GUIDANCE[iconType]
113
+ }
114
+ });
294
115
  return;
295
116
  }
296
- const openingElement = node.parent;
297
- const localComponentName = openingElement.type === 'JSXOpeningElement' ? getComponentName(openingElement) : undefined;
298
- const importedComponentName = localComponentName ? euiComponentImports.get(localComponentName) : undefined;
299
- if (!importedComponentName || !isIconAttribute(node.name.name, importedComponentName)) {
300
- return;
301
- }
302
- const staticStringNode = getStaticStringNode(node);
303
- if (!staticStringNode) {
304
- return;
305
- }
306
- const iconType = getStaticStringValue(staticStringNode);
307
- if (!iconType) {
308
- return;
309
- }
310
- if (!isDeprecatedIconAlias(iconType)) {
311
- if (isDeprecatedIconWithGuidance(iconType)) {
312
- context.report({
313
- node: staticStringNode,
314
- messageId: 'deprecatedIconGuidance',
315
- data: {
316
- iconType,
317
- guidance: DEPRECATED_ICONS_WITH_GUIDANCE[iconType]
318
- }
319
- });
320
- return;
321
- }
322
- if (DEPRECATED_ICONS_WITHOUT_REPLACEMENT.has(iconType)) {
323
- context.report({
324
- node: staticStringNode,
325
- messageId: 'deprecatedIcon',
326
- data: {
327
- iconType
328
- }
329
- });
330
- }
331
- return;
117
+ if (DEPRECATED_ICONS_WITHOUT_REPLACEMENT.has(iconType)) {
118
+ context.report({
119
+ node,
120
+ messageId: 'deprecatedIcon',
121
+ data: {
122
+ iconType
123
+ }
124
+ });
332
125
  }
333
- const replacement = DEPRECATED_ICON_ALIASES[iconType];
334
- context.report({
335
- node: staticStringNode,
336
- messageId: 'deprecatedIconAlias',
337
- data: {
338
- alias: iconType,
339
- replacement
340
- },
341
- fix(fixer) {
342
- const sourceText = context.sourceCode.getText(staticStringNode);
343
- const quote = sourceText[0];
344
- return fixer.replaceText(staticStringNode, `${quote}${replacement}${quote}`);
345
- }
346
- });
126
+ return;
347
127
  }
348
- };
128
+ const replacement = DEPRECATED_ICON_ALIASES[iconType];
129
+ context.report({
130
+ node,
131
+ messageId: 'deprecatedIconAlias',
132
+ data: {
133
+ alias: iconType,
134
+ replacement
135
+ },
136
+ fix: fixer => (0, _icon_props.replaceIconString)(fixer, node, replacement)
137
+ });
138
+ });
349
139
  },
350
140
  meta: {
351
141
  type: 'suggestion',
352
142
  docs: {
353
- description: 'Disallow deprecated EUI icons in JSX icon props.'
143
+ description: 'Disallow deprecated EUI icons in icon props.'
354
144
  },
355
145
  fixable: 'code',
356
146
  schema: [],