website refactor

This commit is contained in:
2026-01-16 01:32:55 +01:00
parent a98e3e3166
commit b533de8486
23 changed files with 651 additions and 159 deletions

View File

@@ -169,6 +169,7 @@ module.exports = {
// Architecture Rules
'no-index-files': require('./no-index-files'),
'no-use-mutation-in-client': require('./no-use-mutation-in-client'),
},
// Configurations for different use cases
@@ -271,6 +272,7 @@ module.exports = {
// Route Configuration Rules
'gridpilot-rules/no-hardcoded-routes': 'error',
'gridpilot-rules/no-use-mutation-in-client': 'error',
},
},

View File

@@ -0,0 +1,50 @@
/**
* ESLint Rule: No useMutation in Client Components
*
* Forbids the use of useMutation from @tanstack/react-query in client components.
* All write operations must go through Next.js Server Actions.
*/
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Forbid useMutation usage in client components',
category: 'Architecture',
recommended: true,
},
messages: {
noUseMutation: 'useMutation from @tanstack/react-query is forbidden. Use Next.js Server Actions for all write operations. See docs/architecture/website/FORM_SUBMISSION.md',
},
schema: [],
},
create(context) {
return {
ImportDeclaration(node) {
if (node.source.value === '@tanstack/react-query') {
const useMutationSpecifier = node.specifiers.find(
(specifier) =>
specifier.type === 'ImportSpecifier' &&
specifier.imported.name === 'useMutation'
);
if (useMutationSpecifier) {
context.report({
node: useMutationSpecifier,
messageId: 'noUseMutation',
});
}
}
},
CallExpression(node) {
if (node.callee.type === 'Identifier' && node.callee.name === 'useMutation') {
context.report({
node,
messageId: 'noUseMutation',
});
}
},
};
},
};