aminghadersohi commented on code in PR #44927:
URL: https://github.com/apache/superset/pull/44927#discussion_r4173182434
##########
superset-frontend/scripts/check-custom-rules.js:
##########
@@ -174,6 +174,44 @@ function checkNoFaIcons(ast, filepath) {
});
}
+/**
+ * App code (and plugins) must go through the @superset-ui/core/components
+ * wrappers rather than importing from antd directly, so theming and behavior
+ * stay centralized in one place. The wrapper packages themselves
+ * (superset-ui-core, superset-core) are the legitimate exception -- they're
+ * what the wrappers are built from -- and `theme/utils` files that introspect
+ * antd's own design tokens are exempted the same way checkNoLiteralColors
+ * already exempts that directory (there is no wrapper for "list antd's own
+ * token names").
+ */
+const ANTD_DIRECT_IMPORT_EXEMPT = [
+ /\/theme\/utils\//,
+ /packages\/superset-ui-core\//,
+ /packages\/superset-core\//,
+];
+
+function checkNoDirectAntdImports(ast, filepath) {
+ if (ANTD_DIRECT_IMPORT_EXEMPT.some(pattern => pattern.test(filepath))) {
+ return;
+ }
+
+ traverse(ast, {
+ ImportDeclaration(path) {
+ const source = path.node.source.value;
Review Comment:
Export-from never reaches this visitor: `export { Button } from 'antd'`,
`export type { TagProps } from 'antd/es/tag'` (the form this PR adds to the
wrapper) and `export * from 'antd'` all pass in a non-exempt file. Tested in
place: this catches all three; tree stays at 0.
```suggestion
'ImportDeclaration|ExportNamedDeclaration|ExportAllDeclaration'(path) {
const source = path.node.source?.value ?? '';
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]