Files
headroom/frontend/node_modules/eslint-plugin-svelte/lib/rules/no-reactive-functions.js
Santhosh Janardhanan de2d83092e feat: Reinitialize frontend with SvelteKit and TypeScript
- Delete old Vite+Svelte frontend
- Initialize new SvelteKit project with TypeScript
- Configure Tailwind CSS v4 + DaisyUI
- Implement JWT authentication with auto-refresh
- Create login page with form validation (Zod)
- Add protected route guards
- Update Docker configuration for single-stage build
- Add E2E tests with Playwright (6/11 passing)
- Fix Svelte 5 reactivity with $state() runes

Known issues:
- 5 E2E tests failing (timing/async issues)
- Token refresh implementation needs debugging
- Validation error display timing
2026-02-17 16:19:59 -05:00

59 lines
2.2 KiB
JavaScript

import { createRule } from '../utils/index.js';
export default createRule('no-reactive-functions', {
meta: {
docs: {
description: "it's not necessary to define functions in reactive statements",
category: 'Best Practices',
recommended: true
},
hasSuggestions: true,
schema: [],
messages: {
noReactiveFns: `Do not create functions inside reactive statements unless absolutely necessary.`,
fixReactiveFns: `Move the function out of the reactive statement`
},
type: 'suggestion',
conditions: [
{
svelteVersions: ['3/4']
},
{
svelteVersions: ['5'],
runes: [false, 'undetermined']
}
]
},
create(context) {
return {
// $: foo = () => { ... }
[`SvelteReactiveStatement > ExpressionStatement > AssignmentExpression > :function`](node) {
// Move upwards to include the entire label
const parent = node.parent?.parent?.parent;
if (!parent) {
return false;
}
const source = context.sourceCode;
return context.report({
node: parent,
loc: parent.loc,
messageId: 'noReactiveFns',
suggest: [
{
messageId: 'fixReactiveFns',
fix(fixer) {
const tokens = source.getFirstTokens(parent, {
includeComments: false,
count: 3
});
const noExtraSpace = source.isSpaceBetweenTokens(tokens[1], tokens[2]);
// Replace the entire reactive label with "const"
return fixer.replaceTextRange([tokens[0].range[0], tokens[1].range[1]], noExtraSpace ? 'const' : 'const ');
}
}
]
});
}
};
}
});