@hero-design/snowflake-guard 1.3.0-alpha.0 → 1.3.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.
@@ -32,8 +32,8 @@ describe('parseSource', () => {
32
32
  it('reports correct snowflakes with typescript files', () => {
33
33
  const source = fs.readFileSync('./src/__mocks__/mobileSourceSample.tsx', 'utf-8');
34
34
  expect((0, parseMobileSource_1.default)(source)).toEqual({
35
- approvedLocs: [54, 56, 72, 18],
36
- styleLocs: [71, 75, 48, 50, 51, 52, 53, 64, 66, 67, 68, 69, 70],
35
+ approvedLocs: [54, 56, 72, 81, 18],
36
+ styleLocs: [71, 75, 82, 48, 50, 51, 52, 53, 64, 66, 67, 68, 69, 70],
37
37
  styledComponentLocs: [14, 23, 28],
38
38
  violatingAttributes: [
39
39
  {
@@ -57,6 +57,13 @@ describe('parseSource', () => {
57
57
  inlineStyleProps: 'style',
58
58
  loc: 75,
59
59
  },
60
+ {
61
+ attributeName: 'backgroundColor',
62
+ attributeValue: "'red'",
63
+ componentName: 'Button.Icon',
64
+ inlineStyleProps: 'style',
65
+ loc: 82,
66
+ },
60
67
  {
61
68
  attributeName: 'padding',
62
69
  attributeValue: '10',
@@ -161,8 +168,8 @@ describe('parseSource', () => {
161
168
  it('reports correct snowflakes with flow files', () => {
162
169
  const source = fs.readFileSync('./src/__mocks__/mobileSourceSample.js', 'utf-8');
163
170
  expect((0, parseMobileSource_1.default)(source)).toEqual({
164
- approvedLocs: [55, 57, 73, 19],
165
- styleLocs: [72, 76, 49, 51, 52, 53, 54, 65, 67, 68, 69, 70, 71],
171
+ approvedLocs: [55, 57, 73, 82, 19],
172
+ styleLocs: [72, 76, 83, 49, 51, 52, 53, 54, 65, 67, 68, 69, 70, 71],
166
173
  styledComponentLocs: [15, 24, 29],
167
174
  violatingAttributes: [
168
175
  {
@@ -186,6 +193,13 @@ describe('parseSource', () => {
186
193
  inlineStyleProps: 'style',
187
194
  loc: 76,
188
195
  },
196
+ {
197
+ attributeName: 'backgroundColor',
198
+ attributeValue: "'red'",
199
+ componentName: 'Button.Icon',
200
+ inlineStyleProps: 'style',
201
+ loc: 83,
202
+ },
189
203
  {
190
204
  attributeName: 'padding',
191
205
  attributeValue: '10',
@@ -287,4 +301,13 @@ describe('parseSource', () => {
287
301
  ],
288
302
  });
289
303
  });
304
+ it('does not include approved snowflakes in the report', () => {
305
+ const source = fs.readFileSync('./src/__mocks__/mobileApprovalSourceSample.tsx', 'utf-8');
306
+ expect((0, parseMobileSource_1.default)(source)).toEqual({
307
+ approvedLocs: [14, 16, 7],
308
+ styleLocs: [],
309
+ styledComponentLocs: [],
310
+ violatingAttributes: [],
311
+ });
312
+ });
290
313
  });
@@ -11,15 +11,15 @@ export declare const getNonApprovedInlineLocs: (reportedLocs: {
11
11
  comment: string;
12
12
  }[], elementLoc: number) => {
13
13
  reportedLocs: {
14
- style?: number;
15
- barStyle?: number;
16
- containerStyle?: number;
17
- textStyle?: number;
14
+ style?: number | undefined;
15
+ barStyle?: number | undefined;
16
+ containerStyle?: number | undefined;
17
+ textStyle?: number | undefined;
18
18
  };
19
19
  noneApprovedAttributes: ViolatingAttribute[];
20
20
  };
21
21
  declare const reportCustomProperties: (ast: recast.types.ASTNode, componentList: {
22
- [k: string]: MobileComponentName;
22
+ [k: string]: "Accordion" | "Alert" | "Attachment" | "Avatar" | "Badge" | "BottomNavigation" | "BottomSheet" | "Box" | "Button" | "Calendar" | "Carousel" | "Card" | "Chip" | "Collapse" | "Checkbox" | "ContentNavigator" | "DatePicker" | "Divider" | "Drawer" | "Empty" | "Error" | "FAB" | "HeroDesignProvider" | "MapPin" | "Icon" | "Image" | "List" | "PinInput" | "Progress" | "Slider" | "Spinner" | "Swipeable" | "Radio" | "SectionHeading" | "Select" | "Skeleton" | "Success" | "Switch" | "Tabs" | "Tag" | "TextInput" | "TimePicker" | "Toast" | "Toolbar" | "Typography" | "Rate" | "RefreshControl" | "RichTextEditor" | "PageControl" | "Portal" | "ScrollViewWithFAB" | "SectionListWithFAB" | "FlatListWithFAB" | "Search" | "FloatingIsland";
23
23
  }, commentList: {
24
24
  styleCmts: {
25
25
  loc: number;
@@ -11,10 +11,10 @@ export type ViolatingAttribute = {
11
11
  };
12
12
  declare const reportInlineStyle: (ast: recast.types.ASTNode, attributes: recast.types.namedTypes.JSXAttribute[], componentName: CompoundMobileComponentName) => {
13
13
  locs: {
14
- style?: number;
15
- barStyle?: number;
16
- containerStyle?: number;
17
- textStyle?: number;
14
+ style?: number | undefined;
15
+ barStyle?: number | undefined;
16
+ containerStyle?: number | undefined;
17
+ textStyle?: number | undefined;
18
18
  };
19
19
  violatingAttributes: ViolatingAttribute[];
20
20
  };
@@ -1,6 +1,6 @@
1
1
  import * as recast from 'recast';
2
2
  import type { MobileComponentName } from './types';
3
3
  declare const reportStyledComponents: (ast: recast.types.ASTNode, componentList: {
4
- [k: string]: MobileComponentName;
4
+ [k: string]: "Accordion" | "Alert" | "Attachment" | "Avatar" | "Badge" | "BottomNavigation" | "BottomSheet" | "Box" | "Button" | "Calendar" | "Carousel" | "Card" | "Chip" | "Collapse" | "Checkbox" | "ContentNavigator" | "DatePicker" | "Divider" | "Drawer" | "Empty" | "Error" | "FAB" | "HeroDesignProvider" | "MapPin" | "Icon" | "Image" | "List" | "PinInput" | "Progress" | "Slider" | "Spinner" | "Swipeable" | "Radio" | "SectionHeading" | "Select" | "Skeleton" | "Success" | "Switch" | "Tabs" | "Tag" | "TextInput" | "TimePicker" | "Toast" | "Toolbar" | "Typography" | "Rate" | "RefreshControl" | "RichTextEditor" | "PageControl" | "Portal" | "ScrollViewWithFAB" | "SectionListWithFAB" | "FlatListWithFAB" | "Search" | "FloatingIsland";
5
5
  }, styledAliasName: string) => number[];
6
6
  export default reportStyledComponents;
@@ -2,7 +2,7 @@ import * as recast from 'recast';
2
2
  import { AdditionalProp, InlineStyleProps } from './reportInlineStyle';
3
3
  import type { ComponentName, CompoundComponentName } from './types';
4
4
  declare const reportCustomProperties: (ast: recast.types.ASTNode, componentList: {
5
- [k: string]: ComponentName;
5
+ [k: string]: "Alert" | "Badge" | "Button" | "Carousel" | "Card" | "Chip" | "Collapse" | "Checkbox" | "DatePicker" | "Divider" | "Empty" | "Icon" | "Progress" | "Slider" | "Spinner" | "Radio" | "Select" | "Switch" | "Tabs" | "Tag" | "TimePicker" | "Typography" | "Rate" | "Portal" | "Banner" | "Breadcrumb" | "Chart" | "Comment" | "ContextPanel" | "Dropdown" | "File" | "Filters" | "Form" | "Grid" | "InPageNavigation" | "Input" | "MediaQuery" | "Menu" | "Modal" | "Notification" | "PageHeader" | "Pagination" | "Portlet" | "Result" | "SelectButton" | "SideBar" | "Statistic" | "Steps" | "Table" | "TagInput" | "Timeline" | "Tooltip" | "Widget";
6
6
  }, commentList: {
7
7
  classNameCmts: number[];
8
8
  styleCmts: {
@@ -16,8 +16,8 @@ export type AdditionalProp = {
16
16
  };
17
17
  declare const reportInlineStyle: (ast: recast.types.ASTNode, attributes: recast.types.namedTypes.JSXAttribute[], componentName: CompoundComponentName) => {
18
18
  locs: {
19
- style?: number;
20
- sx?: number;
19
+ style?: number | undefined;
20
+ sx?: number | undefined;
21
21
  };
22
22
  violatingAttributes: ViolatingAttribute[];
23
23
  additionalProps: AdditionalProp[];
@@ -1,6 +1,6 @@
1
1
  import * as recast from 'recast';
2
2
  import type { ComponentName } from './types';
3
3
  declare const reportStyledComponents: (ast: recast.types.ASTNode, componentList: {
4
- [k: string]: ComponentName;
4
+ [k: string]: "Alert" | "Badge" | "Button" | "Carousel" | "Card" | "Chip" | "Collapse" | "Checkbox" | "DatePicker" | "Divider" | "Empty" | "Icon" | "Progress" | "Slider" | "Spinner" | "Radio" | "Select" | "Switch" | "Tabs" | "Tag" | "TimePicker" | "Typography" | "Rate" | "Portal" | "Banner" | "Breadcrumb" | "Chart" | "Comment" | "ContextPanel" | "Dropdown" | "File" | "Filters" | "Form" | "Grid" | "InPageNavigation" | "Input" | "MediaQuery" | "Menu" | "Modal" | "Notification" | "PageHeader" | "Pagination" | "Portlet" | "Result" | "SelectButton" | "SideBar" | "Statistic" | "Steps" | "Table" | "TagInput" | "Timeline" | "Tooltip" | "Widget";
5
5
  }, styledAliasName: string) => number[];
6
6
  export default reportStyledComponents;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/snowflake-guard",
3
- "version": "1.3.0-alpha.0",
3
+ "version": "1.3.0",
4
4
  "description": "A hero-design bot detecting snowflake usage",
5
5
  "author": "Hau Dao",
6
6
  "license": "ISC",