mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-25 00:08:27 +08:00
f67abe4105
* feat: pagination support cssVar * feat: optimize code * Update check-cssinjs.tsx Signed-off-by: lijianan <574980606@qq.com> * feat: pagination css var * chore: code clean * chore: update snapshot --------- Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: lijianan <574980606@qq.com> Co-authored-by: MadCcc <1075746765@qq.com>
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
/* eslint-disable no-console */
|
|
import React from 'react';
|
|
import {
|
|
legacyNotSelectorLinter,
|
|
logicalPropertiesLinter,
|
|
NaNLinter,
|
|
parentSelectorLinter,
|
|
StyleProvider,
|
|
} from '@ant-design/cssinjs';
|
|
import chalk from 'chalk';
|
|
import ReactDOMServer from 'react-dom/server';
|
|
|
|
import { ConfigProvider } from '../components';
|
|
import { generateCssinjs } from './generate-cssinjs';
|
|
|
|
console.log(chalk.green(`🔥 Checking CSS-in-JS...`));
|
|
|
|
let errorCount = 0;
|
|
const originError = console.error;
|
|
console.error = (msg: any) => {
|
|
if (msg.includes('Warning: [Ant Design CSS-in-JS]')) {
|
|
errorCount += 1;
|
|
console.log(chalk.red(`❌ `), msg.slice(msg.indexOf('Error in')).replace(/\s+/g, ' '));
|
|
} else {
|
|
originError(msg);
|
|
}
|
|
};
|
|
|
|
async function checkCSSVar() {
|
|
await generateCssinjs({
|
|
key: 'check',
|
|
render(Component: any) {
|
|
ReactDOMServer.renderToString(
|
|
<StyleProvider linters={[NaNLinter]}>
|
|
<ConfigProvider theme={{ cssVar: true, hashed: false }}>
|
|
<Component />
|
|
</ConfigProvider>
|
|
</StyleProvider>,
|
|
);
|
|
},
|
|
});
|
|
}
|
|
|
|
(async () => {
|
|
await generateCssinjs({
|
|
key: 'check',
|
|
render(Component: any) {
|
|
ReactDOMServer.renderToString(
|
|
<StyleProvider
|
|
linters={[logicalPropertiesLinter, legacyNotSelectorLinter, parentSelectorLinter]}
|
|
>
|
|
<Component />
|
|
</StyleProvider>,
|
|
);
|
|
},
|
|
});
|
|
|
|
await checkCSSVar();
|
|
|
|
if (errorCount > 0) {
|
|
console.log(chalk.red(`❌ CSS-in-JS check failed with ${errorCount} errors.`));
|
|
process.exit(1);
|
|
} else {
|
|
console.log(chalk.green(`✅ CSS-in-JS check passed.`));
|
|
}
|
|
})();
|