Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -0,0 +1,49 @@
import { createRule } from '../utils/index.js';
const findLastIndex = (array, predicate) => {
let i = array.length - 1;
while (i >= 0) {
if (predicate(array[i])) {
return i;
}
i--;
}
return -1;
};
function isNonExportStatement({ type }) {
return (type !== 'ExportDefaultDeclaration' &&
type !== 'ExportNamedDeclaration' &&
type !== 'ExportAllDeclaration');
}
export default createRule({
name: 'exports-last',
meta: {
type: 'suggestion',
docs: {
category: 'Style guide',
description: 'Ensure all exports appear after other statements.',
},
schema: [],
messages: {
end: 'Export statements should appear at the end of the file',
},
},
defaultOptions: [],
create(context) {
return {
Program({ body }) {
const lastNonExportStatementIndex = findLastIndex(body, isNonExportStatement);
if (lastNonExportStatementIndex !== -1) {
for (const node of body.slice(0, lastNonExportStatementIndex)) {
if (!isNonExportStatement(node)) {
context.report({
node,
messageId: 'end',
});
}
}
}
},
};
},
});
//# sourceMappingURL=exports-last.js.map