@hero-design/snowflake-guard 1.3.3 → 1.3.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.
- package/lib/src/index.js +13 -5
- package/package.json +1 -1
package/lib/src/index.js
CHANGED
|
@@ -20,12 +20,16 @@ const getDiffLocs_1 = require("./utils/getDiffLocs");
|
|
|
20
20
|
const WEB_REGEX = /\.tsx$/;
|
|
21
21
|
const MOBILE_REGEX = /\.(tsx|jsx|js)$/;
|
|
22
22
|
const TEST_REGEX = /__tests__/;
|
|
23
|
-
const
|
|
23
|
+
const SNOWFLAKE_COMMENTS_WEB = {
|
|
24
24
|
style: 'Snowflake detected! A component is customized using inline styles. Make sure to not use [prohibited CSS properties](https://docs.google.com/spreadsheets/d/1Dj8vqLdFaf-CSaSVoYqyYZIkGqF6OoyP7K4G1_9L62U/edit?usp=sharing).',
|
|
25
25
|
sx: 'Snowflake detected! A component is customized via sx prop. Make sure to not use [prohibited CSS properties](https://docs.google.com/spreadsheets/d/1Dj8vqLdFaf-CSaSVoYqyYZIkGqF6OoyP7K4G1_9L62U/edit?usp=sharing).',
|
|
26
26
|
'styled-component': 'Please do not use styled-component to customize this component, use sx prop or inline style instead.',
|
|
27
27
|
className: `Please make sure that this className is not used as a CSS classname for component customization purposes, use sx prop or inline style instead. In case this is none-css classname, please flag it with this comment \`${constants_1.APPROVED_CLASSNAME_COMMENT}\`.`,
|
|
28
28
|
};
|
|
29
|
+
const SNOWFLAKE_COMMENTS_MOBILE = {
|
|
30
|
+
style: 'Snowflake detected! A component is customized using inline styles. Make sure to not use [prohibited CSS properties](https://docs.google.com/spreadsheets/d/1Dj8vqLdFaf-CSaSVoYqyYZIkGqF6OoyP7K4G1_9L62U/edit?gid=1761479144#gid=1761479144).',
|
|
31
|
+
'styled-component': 'Please do not use styled-component to customize this component.',
|
|
32
|
+
};
|
|
29
33
|
const MOBILE_REPO_NAMES = JSON.parse(process.env.MOBILE_REPO_NAMES || '[]');
|
|
30
34
|
const checkIfDetectedSnowflakesInDiff = (diffLocs, locToComment) => {
|
|
31
35
|
const locIdx = diffLocs.findIndex(([start, end]) => {
|
|
@@ -76,7 +80,9 @@ module.exports = (app) => {
|
|
|
76
80
|
if (checkIfDetectedSnowflakesInDiff(diffLocs, loc)) {
|
|
77
81
|
snowflakeComments.push({
|
|
78
82
|
path: filePath,
|
|
79
|
-
body:
|
|
83
|
+
body: isMobile
|
|
84
|
+
? SNOWFLAKE_COMMENTS_MOBILE['style']
|
|
85
|
+
: SNOWFLAKE_COMMENTS_WEB['style'],
|
|
80
86
|
line: loc,
|
|
81
87
|
});
|
|
82
88
|
}
|
|
@@ -85,7 +91,9 @@ module.exports = (app) => {
|
|
|
85
91
|
if (checkIfDetectedSnowflakesInDiff(diffLocs, loc)) {
|
|
86
92
|
snowflakeComments.push({
|
|
87
93
|
path: filePath,
|
|
88
|
-
body:
|
|
94
|
+
body: isMobile
|
|
95
|
+
? SNOWFLAKE_COMMENTS_MOBILE['styled-component']
|
|
96
|
+
: SNOWFLAKE_COMMENTS_WEB['styled-component'],
|
|
89
97
|
line: loc,
|
|
90
98
|
});
|
|
91
99
|
}
|
|
@@ -100,7 +108,7 @@ module.exports = (app) => {
|
|
|
100
108
|
if (checkIfDetectedSnowflakesInDiff(diffLocs, loc)) {
|
|
101
109
|
snowflakeComments.push({
|
|
102
110
|
path: filePath,
|
|
103
|
-
body:
|
|
111
|
+
body: SNOWFLAKE_COMMENTS_WEB['sx'],
|
|
104
112
|
line: loc,
|
|
105
113
|
});
|
|
106
114
|
}
|
|
@@ -109,7 +117,7 @@ module.exports = (app) => {
|
|
|
109
117
|
if (checkIfDetectedSnowflakesInDiff(diffLocs, loc)) {
|
|
110
118
|
snowflakeComments.push({
|
|
111
119
|
path: filePath,
|
|
112
|
-
body:
|
|
120
|
+
body: SNOWFLAKE_COMMENTS_WEB['className'],
|
|
113
121
|
line: loc,
|
|
114
122
|
});
|
|
115
123
|
}
|