@hero-design/snowflake-guard 1.4.3 → 1.4.4

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.
@@ -42,81 +42,81 @@ describe('parseSource', () => {
42
42
  it('reports correct snowflakes', () => {
43
43
  const source = fs.readFileSync('./src/__mocks__/sourceSample.tsx', 'utf-8');
44
44
  expect((0, parseSource_1.default)(source)).toEqual({
45
- approvedLocs: [60, 78, 85, 92, 70, 80, 10],
46
- classNameLocs: [49, 47, 48],
47
- styleLocs: [59, 73, 87, 52, 54, 55, 56, 57, 58],
48
- styledComponentLocs: [6, 15, 20],
49
- sxLocs: [69, 94, 64, 65, 66, 67, 68],
45
+ approvedLocs: [81, 101, 105, 112, 93, 103, 10],
46
+ classNameLocs: [66, 64, 65, 67, 68],
47
+ styleLocs: [78, 96, 107, 71, 73, 74, 75, 76, 77, 79, 80],
48
+ styledComponentLocs: [6, 15, 20, 24, 28],
49
+ sxLocs: [90, 114, 85, 86, 87, 88, 89, 91, 92],
50
50
  violatingAttributes: [
51
51
  {
52
52
  attributeName: 'padding',
53
53
  attributeValue: '20',
54
54
  componentName: 'Button.Link',
55
55
  inlineStyleProps: 'style',
56
- loc: 59,
56
+ loc: 78,
57
57
  },
58
58
  {
59
59
  attributeName: 'padding',
60
60
  attributeValue: '20',
61
61
  componentName: 'Button.Link',
62
62
  inlineStyleProps: 'sx',
63
- loc: 69,
63
+ loc: 90,
64
64
  },
65
65
  {
66
66
  attributeName: 'padding',
67
67
  attributeValue: '20',
68
68
  componentName: 'Button.Link',
69
69
  inlineStyleProps: 'style',
70
- loc: 73,
70
+ loc: 96,
71
71
  },
72
72
  {
73
73
  attributeName: 'backgroundColor',
74
74
  attributeValue: "'red'",
75
75
  componentName: 'Button.Link',
76
76
  inlineStyleProps: 'style',
77
- loc: 73,
77
+ loc: 96,
78
78
  },
79
79
  {
80
80
  attributeName: 'padding',
81
81
  attributeValue: '20',
82
82
  componentName: 'Button.Link',
83
83
  inlineStyleProps: 'style',
84
- loc: 87,
84
+ loc: 107,
85
85
  },
86
86
  {
87
87
  attributeName: 'backgroundColor',
88
88
  attributeValue: "'red'",
89
89
  componentName: 'Button.Link',
90
90
  inlineStyleProps: 'sx',
91
- loc: 94,
91
+ loc: 114,
92
92
  },
93
93
  {
94
94
  attributeName: 'width',
95
95
  attributeValue: '200',
96
96
  componentName: 'Empty',
97
97
  inlineStyleProps: 'style',
98
- loc: 52,
98
+ loc: 71,
99
99
  },
100
100
  {
101
101
  attributeName: 'width',
102
102
  attributeValue: '200',
103
103
  componentName: 'Card.Header',
104
104
  inlineStyleProps: 'style',
105
- loc: 54,
105
+ loc: 73,
106
106
  },
107
107
  {
108
108
  attributeName: 'padding',
109
109
  attributeValue: '30',
110
110
  componentName: 'Button',
111
111
  inlineStyleProps: 'style',
112
- loc: 55,
112
+ loc: 74,
113
113
  },
114
114
  {
115
115
  attributeName: 'padding',
116
116
  attributeValue: '30',
117
117
  componentName: 'Button',
118
118
  inlineStyleProps: 'style',
119
- loc: 56,
119
+ loc: 75,
120
120
  additionalProps: [
121
121
  {
122
122
  propName: 'variant',
@@ -129,49 +129,77 @@ describe('parseSource', () => {
129
129
  attributeValue: '30',
130
130
  componentName: 'Button',
131
131
  inlineStyleProps: 'style',
132
- loc: 57,
132
+ loc: 76,
133
133
  },
134
134
  {
135
135
  attributeName: 'padding',
136
136
  attributeValue: '30',
137
137
  componentName: 'Button',
138
138
  inlineStyleProps: 'style',
139
- loc: 58,
139
+ loc: 77,
140
+ },
141
+ {
142
+ attributeName: 'margin',
143
+ attributeValue: '15',
144
+ componentName: 'Pane',
145
+ inlineStyleProps: 'style',
146
+ loc: 79,
147
+ },
148
+ {
149
+ attributeName: 'margin',
150
+ attributeValue: '20',
151
+ componentName: 'Pane.Body',
152
+ inlineStyleProps: 'style',
153
+ loc: 80,
140
154
  },
141
155
  {
142
156
  attributeName: 'mt',
143
157
  attributeValue: '10',
144
158
  componentName: 'Badge.Count',
145
159
  inlineStyleProps: 'sx',
146
- loc: 64,
160
+ loc: 85,
147
161
  },
148
162
  {
149
163
  attributeName: 'pt',
150
164
  attributeValue: '10',
151
165
  componentName: 'Badge',
152
166
  inlineStyleProps: 'sx',
153
- loc: 65,
167
+ loc: 86,
154
168
  },
155
169
  {
156
170
  attributeName: 'pt',
157
171
  attributeValue: '10',
158
172
  componentName: 'Badge',
159
173
  inlineStyleProps: 'sx',
160
- loc: 66,
174
+ loc: 87,
161
175
  },
162
176
  {
163
177
  attributeName: 'pt',
164
178
  attributeValue: '10',
165
179
  componentName: 'Badge',
166
180
  inlineStyleProps: 'sx',
167
- loc: 67,
181
+ loc: 88,
168
182
  },
169
183
  {
170
184
  attributeName: 'pt',
171
185
  attributeValue: '10',
172
186
  componentName: 'Badge',
173
187
  inlineStyleProps: 'sx',
174
- loc: 68,
188
+ loc: 89,
189
+ },
190
+ {
191
+ attributeName: 'margin',
192
+ attributeValue: '15',
193
+ componentName: 'Pane',
194
+ inlineStyleProps: 'sx',
195
+ loc: 91,
196
+ },
197
+ {
198
+ attributeName: 'margin',
199
+ attributeValue: '20',
200
+ componentName: 'Pane.Footer',
201
+ inlineStyleProps: 'sx',
202
+ loc: 92,
175
203
  },
176
204
  ],
177
205
  });
@@ -1,3 +1,3 @@
1
- import { Probot } from 'probot';
1
+ import type { Probot } from 'probot';
2
2
  declare const _default: (app: Probot) => void;
3
3
  export = _default;
@@ -1,4 +1,4 @@
1
- import { InlineStyleProps } from './reports/mobile/reportInlineStyle';
1
+ import type { InlineStyleProps } from './reports/mobile/reportInlineStyle';
2
2
  import type { CompoundMobileComponentName } from './reports/mobile/types';
3
3
  declare const parseMobileSource: (source: string) => {
4
4
  styleLocs: number[];
@@ -1,5 +1,5 @@
1
1
  import type { CompoundComponentName } from './reports/types';
2
- import { InlineStyleProps } from './reports/reportInlineStyle';
2
+ import type { InlineStyleProps } from './reports/reportInlineStyle';
3
3
  declare const parseSource: (source: string) => {
4
4
  classNameLocs: number[];
5
5
  styleLocs: number[];
@@ -1,3 +1,3 @@
1
1
  import * as babelParser from '@babel/parser';
2
- import { Overrides } from 'recast/parsers/_babel_options';
2
+ import type { Overrides } from 'recast/parsers/_babel_options';
3
3
  export declare const parse: (source: string, options?: Overrides) => babelParser.ParseResult<import("@babel/types").File>;
@@ -1,3 +1,3 @@
1
1
  import * as babelParser from '@babel/parser';
2
- import { Overrides } from 'recast/parsers/_babel_options';
2
+ import type { Overrides } from 'recast/parsers/_babel_options';
3
3
  export declare const parse: (source: string, options?: Overrides) => babelParser.ParseResult<import("@babel/types").File>;
@@ -71,6 +71,11 @@ declare const RULESET_MAP: {
71
71
  Notification: string[];
72
72
  PageHeader: string[];
73
73
  Pagination: string[];
74
+ Pane: string[];
75
+ 'Pane.Header': string[];
76
+ 'Pane.Body': string[];
77
+ 'Pane.Footer': string[];
78
+ 'Pane.CloseButton': string[];
74
79
  Portlet: string[];
75
80
  Progress: string[];
76
81
  'Progress.Circle': string[];
@@ -180,6 +185,11 @@ declare const SX_RULESET_MAP: {
180
185
  Notification: string[];
181
186
  PageHeader: string[];
182
187
  Pagination: string[];
188
+ Pane: string[];
189
+ 'Pane.Header': string[];
190
+ 'Pane.Body': string[];
191
+ 'Pane.Footer': string[];
192
+ 'Pane.CloseButton': string[];
183
193
  Portlet: string[];
184
194
  Progress: string[];
185
195
  'Progress.Circle': string[];
@@ -216,7 +226,7 @@ declare const SX_RULESET_MAP: {
216
226
  'Typography.Text': string[];
217
227
  Widget: string[];
218
228
  };
219
- declare const HD_COMPONENTS: readonly ["Alert", "Badge", "Banner", "Breadcrumb", "Button", "Card", "Carousel", "Chart", "Checkbox", "Chip", "Collapse", "Comment", "ContextPanel", "DatePicker", "Divider", "Dropdown", "Empty", "File", "Filters", "Form", "Grid", "Icon", "InPageNavigation", "Input", "MediaQuery", "Menu", "Modal", "Notification", "PageHeader", "Pagination", "Portal", "Portlet", "Progress", "Radio", "Rate", "Result", "Select", "SelectButton", "SideBar", "Slider", "Spinner", "Statistic", "Steps", "Switch", "Table", "Tabs", "Tag", "TagInput", "TimePicker", "Timeline", "Tooltip", "Typography", "Widget"];
229
+ declare const HD_COMPONENTS: readonly ["Alert", "Badge", "Banner", "Breadcrumb", "Button", "Card", "Carousel", "Chart", "Checkbox", "Chip", "Collapse", "Comment", "ContextPanel", "DatePicker", "Divider", "Dropdown", "Empty", "File", "Filters", "Form", "Grid", "Icon", "InPageNavigation", "Input", "MediaQuery", "Menu", "Modal", "Notification", "PageHeader", "Pagination", "Pane", "Portal", "Portlet", "Progress", "Radio", "Rate", "Result", "Select", "SelectButton", "SideBar", "Slider", "Spinner", "Statistic", "Steps", "Switch", "Table", "Tabs", "Tag", "TagInput", "TimePicker", "Timeline", "Tooltip", "Typography", "Widget"];
220
230
  declare const APPROVED_INLINE_STYLE_COMMENT = "@snowflake-guard/approved-inline-style";
221
231
  declare const APPROVED_CLASSNAME_COMMENT = "@snowflake-guard/approved-classname";
222
232
  declare const APPROVED_STYLED_COMPONENTS_COMMENT = "@snowflake-guard/approved-styled-components";
@@ -441,6 +441,41 @@ const RULESET_MAP = {
441
441
  ...WIDTH_ATTRS,
442
442
  ...HEIGHT_ATTRS,
443
443
  ],
444
+ Pane: [
445
+ ...COMMON_PROHIBITED_ATTRS,
446
+ ...SHADOW_ATTRS,
447
+ ...WIDTH_ATTRS,
448
+ ...HEIGHT_ATTRS,
449
+ ...MARGIN_ATTRS,
450
+ ],
451
+ 'Pane.Header': [
452
+ ...COMMON_PROHIBITED_ATTRS,
453
+ ...SHADOW_ATTRS,
454
+ ...WIDTH_ATTRS,
455
+ ...HEIGHT_ATTRS,
456
+ ...MARGIN_ATTRS,
457
+ ],
458
+ 'Pane.Body': [
459
+ ...COMMON_PROHIBITED_ATTRS,
460
+ ...SHADOW_ATTRS,
461
+ ...WIDTH_ATTRS,
462
+ ...HEIGHT_ATTRS,
463
+ ...MARGIN_ATTRS,
464
+ ],
465
+ 'Pane.Footer': [
466
+ ...COMMON_PROHIBITED_ATTRS,
467
+ ...SHADOW_ATTRS,
468
+ ...WIDTH_ATTRS,
469
+ ...HEIGHT_ATTRS,
470
+ ...MARGIN_ATTRS,
471
+ ],
472
+ 'Pane.CloseButton': [
473
+ ...COMMON_PROHIBITED_ATTRS,
474
+ ...SHADOW_ATTRS,
475
+ ...WIDTH_ATTRS,
476
+ ...HEIGHT_ATTRS,
477
+ ...MARGIN_ATTRS,
478
+ ],
444
479
  Portlet: COMMON_PROHIBITED_ATTRS,
445
480
  Progress: [
446
481
  ...COMMON_PROHIBITED_ATTRS,
@@ -745,7 +780,27 @@ const SX_RULESET_MAP = Object.assign(Object.assign({}, RULESET_MAP), { Alert: [.
745
780
  ...RULESET_MAP.PageHeader,
746
781
  ...COMMON_SX_PROHIBITED_ATTRS,
747
782
  ...SX_MARGIN_ATTRS,
748
- ], Pagination: [...RULESET_MAP.Pagination, ...COMMON_SX_PROHIBITED_ATTRS], Portlet: [...RULESET_MAP.Portlet, ...COMMON_SX_PROHIBITED_ATTRS], Progress: [...RULESET_MAP.Progress, ...COMMON_SX_PROHIBITED_ATTRS], 'Progress.Circle': [
783
+ ], Pagination: [...RULESET_MAP.Pagination, ...COMMON_SX_PROHIBITED_ATTRS], Pane: [
784
+ ...RULESET_MAP.Pane,
785
+ ...COMMON_SX_PROHIBITED_ATTRS,
786
+ ...SX_MARGIN_ATTRS,
787
+ ], 'Pane.Header': [
788
+ ...RULESET_MAP['Pane.Header'],
789
+ ...COMMON_SX_PROHIBITED_ATTRS,
790
+ ...SX_MARGIN_ATTRS,
791
+ ], 'Pane.Body': [
792
+ ...RULESET_MAP['Pane.Body'],
793
+ ...COMMON_SX_PROHIBITED_ATTRS,
794
+ ...SX_MARGIN_ATTRS,
795
+ ], 'Pane.Footer': [
796
+ ...RULESET_MAP['Pane.Footer'],
797
+ ...COMMON_SX_PROHIBITED_ATTRS,
798
+ ...SX_MARGIN_ATTRS,
799
+ ], 'Pane.CloseButton': [
800
+ ...RULESET_MAP['Pane.CloseButton'],
801
+ ...COMMON_SX_PROHIBITED_ATTRS,
802
+ ...SX_MARGIN_ATTRS,
803
+ ], Portlet: [...RULESET_MAP.Portlet, ...COMMON_SX_PROHIBITED_ATTRS], Progress: [...RULESET_MAP.Progress, ...COMMON_SX_PROHIBITED_ATTRS], 'Progress.Circle': [
749
804
  ...RULESET_MAP['Progress.Circle'],
750
805
  ...COMMON_SX_PROHIBITED_ATTRS,
751
806
  ], Radio: [...RULESET_MAP.Radio, ...COMMON_SX_PROHIBITED_ATTRS], 'Radio.Group': [...RULESET_MAP['Radio.Group'], ...COMMON_SX_PROHIBITED_ATTRS], 'Radio.Button': [
@@ -828,6 +883,7 @@ const HD_COMPONENTS = [
828
883
  'Notification',
829
884
  'PageHeader',
830
885
  'Pagination',
886
+ 'Pane',
831
887
  'Portal',
832
888
  'Portlet',
833
889
  'Progress',
@@ -1,5 +1,5 @@
1
1
  import * as recast from 'recast';
2
- import { InlineStyleProps, ViolatingAttribute } from './reportInlineStyle';
2
+ import type { InlineStyleProps, ViolatingAttribute } from './reportInlineStyle';
3
3
  import type { CompoundMobileComponentName, MobileComponentName } from './types';
4
4
  export declare const getNonApprovedInlineLocs: (reportedLocs: {
5
5
  style?: number;
@@ -1,3 +1,3 @@
1
- import { HD_MOBILE_COMPONENTS, MOBILE_RULESET_MAP } from './constants';
1
+ import type { HD_MOBILE_COMPONENTS, MOBILE_RULESET_MAP } from './constants';
2
2
  export type MobileComponentName = typeof HD_MOBILE_COMPONENTS[number];
3
3
  export type CompoundMobileComponentName = keyof typeof MOBILE_RULESET_MAP;
@@ -1,3 +1,3 @@
1
- import { types } from 'recast';
1
+ import type { types } from 'recast';
2
2
  declare const reportClassName: (attributes: types.namedTypes.JSXAttribute[]) => number | undefined;
3
3
  export default reportClassName;
@@ -1,5 +1,5 @@
1
1
  import * as recast from 'recast';
2
- import { AdditionalProp, InlineStyleProps } from './reportInlineStyle';
2
+ import type { AdditionalProp, InlineStyleProps } from './reportInlineStyle';
3
3
  import type { ComponentName, CompoundComponentName } from './types';
4
4
  declare const reportCustomProperties: (ast: recast.types.ASTNode, componentList: {
5
5
  [k: string]: ComponentName;
@@ -1,3 +1,3 @@
1
- import { HD_COMPONENTS, RULESET_MAP } from './constants';
1
+ import type { HD_COMPONENTS, RULESET_MAP } from './constants';
2
2
  export type ComponentName = typeof HD_COMPONENTS[number];
3
3
  export type CompoundComponentName = keyof typeof RULESET_MAP;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/snowflake-guard",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "A hero-design bot detecting snowflake usage",
5
5
  "author": "Hau Dao",
6
6
  "license": "ISC",