website refactor
This commit is contained in:
50
apps/website/eslint-rules/view-data-location.js
Normal file
50
apps/website/eslint-rules/view-data-location.js
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* ESLint Rule: ViewData Location
|
||||
*
|
||||
* Ensures ViewData types are in lib/view-data/, not templates/
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Ensure ViewData types are in lib/view-data/, not templates/',
|
||||
category: 'File Structure',
|
||||
recommended: true,
|
||||
},
|
||||
messages: {
|
||||
wrongLocation: 'ViewData types must be in lib/view-data/, not templates/. See apps/website/docs/architecture/website/VIEW_DATA.md',
|
||||
},
|
||||
schema: [],
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const filename = context.getFilename();
|
||||
|
||||
return {
|
||||
ImportDeclaration(node) {
|
||||
const importPath = node.source.value;
|
||||
|
||||
// Check for ViewData imports from templates
|
||||
if (importPath.includes('/templates/') &&
|
||||
importPath.includes('ViewData')) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'wrongLocation',
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Also check if the file itself is a ViewData in wrong location
|
||||
Program(node) {
|
||||
if (filename.includes('/templates/') &&
|
||||
filename.endsWith('ViewData.ts')) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'wrongLocation',
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user