51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
/**
|
|
* 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',
|
|
});
|
|
}
|
|
},
|
|
};
|
|
},
|
|
};
|