website refactor
This commit is contained in:
@@ -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',
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
50
apps/website/eslint-rules/no-use-mutation-in-client.js
Normal file
50
apps/website/eslint-rules/no-use-mutation-in-client.js
Normal 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',
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user