44aee860d9
## Summary Clean up and consolidate formatting configuration across the monorepo. ## Changes ### 1. Remove Redundant Configs - ❌ Delete `packages/twenty-server/.prettierrc` (had invalid `brakeBeforeElse` typo) - ❌ Delete `packages/twenty-zapier/.prettierrc` - ✅ Use root `.prettierrc` only (Prettier searches up directory tree automatically) ### 2. Improve Root Prettier Config - Change `endOfLine: 'auto'` → `'lf'` for consistent Unix line endings across all OSes ### 3. Enhance VSCode Settings - `files.eol: 'auto'` → `'\\n'` (consistent with Prettier) - Add `files.insertFinalNewline: true` (explicit editor behavior) - Add `files.trimTrailingWhitespace: true` (cleaner files) ### 4. Add `.gitattributes` - Enforce LF line endings at Git level - Prevents `core.autocrlf` from converting based on contributor's OS - Mark patch files as binary (they have mixed line endings by design) - Explicitly define binary file types ### 5. Fix Line Endings - Convert 3 selectable-list state files from CRLF → LF - These were the only source files with Windows line endings ## Why These Changes Matter **Before:** - 3 different Prettier configs (inconsistent, one had typo) - Mixed CRLF/LF depending on contributor's OS - No Git-level enforcement **After:** - Single source of truth for formatting - All files use LF (Unix standard) - Git enforces line endings regardless of OS - Prettier warning about invalid option removed ## Result - ✅ Single `.prettierrc` config - ✅ Consistent LF line endings enforced by Git - ✅ Better VSCode defaults - ✅ No more CRLF files sneaking in from Windows contributors
79 lines
2.3 KiB
TypeScript
79 lines
2.3 KiB
TypeScript
import { ESLintUtils, TSESTree } from '@typescript-eslint/utils';
|
|
import {
|
|
isIdentifier,
|
|
isVariableDeclarator,
|
|
} from '@typescript-eslint/utils/ast-utils';
|
|
import { type RuleContext } from '@typescript-eslint/utils/ts-eslint';
|
|
|
|
// NOTE: The rule will be available in ESLint configs as "@nx/workspace-component-props-naming"
|
|
export const RULE_NAME = 'component-props-naming';
|
|
|
|
const checkPropsTypeName = ({
|
|
node,
|
|
context,
|
|
functionName,
|
|
}: {
|
|
node: TSESTree.FunctionDeclaration | TSESTree.ArrowFunctionExpression;
|
|
context: Readonly<RuleContext<'invalidPropsTypeName', any[]>>;
|
|
functionName: string;
|
|
}) => {
|
|
const expectedPropTypeName = `${functionName}Props`;
|
|
|
|
if (!functionName.match(/^[A-Z]/)) return;
|
|
|
|
node.params.forEach((param) => {
|
|
if (
|
|
(param.type === TSESTree.AST_NODE_TYPES.ObjectPattern ||
|
|
isIdentifier(param)) &&
|
|
param.typeAnnotation?.typeAnnotation.type ===
|
|
TSESTree.AST_NODE_TYPES.TSTypeReference &&
|
|
isIdentifier(param.typeAnnotation?.typeAnnotation.typeName)
|
|
) {
|
|
const { typeName } = param.typeAnnotation.typeAnnotation;
|
|
const actualPropTypeName = typeName.name;
|
|
if (actualPropTypeName !== expectedPropTypeName) {
|
|
context.report({
|
|
node: param,
|
|
messageId: 'invalidPropsTypeName',
|
|
data: { expectedPropTypeName, actualPropTypeName },
|
|
fix: (fixer) => fixer.replaceText(typeName, expectedPropTypeName),
|
|
});
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
export const rule = ESLintUtils.RuleCreator(() => __filename)({
|
|
name: RULE_NAME,
|
|
meta: {
|
|
type: 'problem',
|
|
docs: {
|
|
description: 'Ensure component props follow naming convention',
|
|
recommended: 'recommended',
|
|
},
|
|
fixable: 'code',
|
|
schema: [],
|
|
messages: {
|
|
invalidPropsTypeName:
|
|
"Expected prop type to be '{{ expectedPropTypeName }}' but found '{{ actualPropTypeName }}'",
|
|
},
|
|
},
|
|
defaultOptions: [],
|
|
create: (context) => {
|
|
return {
|
|
ArrowFunctionExpression: (node) => {
|
|
if (isVariableDeclarator(node.parent) && isIdentifier(node.parent.id)) {
|
|
checkPropsTypeName({
|
|
node,
|
|
context,
|
|
functionName: node.parent.id.name,
|
|
});
|
|
}
|
|
},
|
|
FunctionDeclaration: (node) => {
|
|
checkPropsTypeName({ node, context, functionName: node.id.name });
|
|
},
|
|
};
|
|
},
|
|
});
|