MCPcopy Create free account
hub / github.com/pinterest/gestalt / duplicateVariablesDifferentValues

Function duplicateVariablesDifferentValues

scripts/cssValidate.js:6–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4const postcss = require('postcss');
5
6const duplicateVariablesDifferentValues = async () => {
7 const files = await globby([
8 'packages/gestalt/src/**/*.css',
9 'packages/gestalt-charts/src/**/*.css',
10 'packages/gestalt-datepicker/src/**/*.css',
11 ]);
12
13 const combined = (
14 await Promise.all(files.map(async (file) => await fs.promises.readFile(file, 'utf8')))
15 ).join('');
16
17 const astRoot = postcss.parse(combined);
18
19 const lookup = {};
20 astRoot.walkDecls(/^--g/, ({ prop, value }) => {
21 if (lookup[prop] && lookup[prop] !== value) {
22 throw new Error(
23 `CSS Validate error: ${prop} is defined multiple times with different values: ${lookup[prop]} & ${value}.\nPlease make these the same`,
24 );
25 }
26 lookup[prop] = value;
27 });
28};
29
30(async function cssValidate() {
31 try {

Callers 1

cssValidate.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected