* Update scripts and documentation to use nx and new monorepo architecture * Start fixing docker * Migrate eslint plugin and postgres setup * Fix docker * Fix patches * Fix * fix: wip try to fix the patches * Apply patches --------- Co-authored-by: Jérémy Magrin <jeremy.magrin@gmail.com>
63 lines
1.7 KiB
TypeScript
63 lines
1.7 KiB
TypeScript
import {
|
|
AST_NODE_TYPES,
|
|
ESLintUtils,
|
|
TSESTree,
|
|
} from "@typescript-eslint/utils";
|
|
|
|
const createRule = ESLintUtils.RuleCreator(() => `https://docs.twenty.com`);
|
|
|
|
const styledComponentsPrefixedWithStyledRule = createRule({
|
|
create: (context) => {
|
|
return {
|
|
VariableDeclarator: (node: TSESTree.VariableDeclarator) => {
|
|
const templateExpr = node.init;
|
|
if (templateExpr?.type !== AST_NODE_TYPES.TaggedTemplateExpression) {
|
|
return;
|
|
}
|
|
const tag = templateExpr.tag;
|
|
const tagged =
|
|
tag.type === AST_NODE_TYPES.MemberExpression
|
|
? tag.object
|
|
: tag.type === AST_NODE_TYPES.CallExpression
|
|
? tag.callee
|
|
: null;
|
|
if (
|
|
tagged?.type === AST_NODE_TYPES.Identifier &&
|
|
tagged.name === "styled"
|
|
) {
|
|
const variable = node.id as TSESTree.Identifier;
|
|
if (variable.name.startsWith("Styled")) {
|
|
return;
|
|
}
|
|
context.report({
|
|
node,
|
|
messageId: "noStyledPrefix",
|
|
data: {
|
|
componentName: variable.name,
|
|
},
|
|
});
|
|
}
|
|
},
|
|
};
|
|
},
|
|
name: "styled-components-prefixed-with-styled",
|
|
meta: {
|
|
type: "suggestion",
|
|
docs: {
|
|
description: "Warn when StyledComponents are not prefixed with Styled",
|
|
recommended: "recommended",
|
|
},
|
|
messages: {
|
|
noStyledPrefix:
|
|
"{{componentName}} is a StyledComponent and is not prefixed with Styled.",
|
|
},
|
|
fixable: "code",
|
|
schema: [],
|
|
},
|
|
defaultOptions: [],
|
|
});
|
|
|
|
module.exports = styledComponentsPrefixedWithStyledRule;
|
|
|
|
export default styledComponentsPrefixedWithStyledRule;
|