- 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
74 lines
2.8 KiB
JavaScript
74 lines
2.8 KiB
JavaScript
import { createRule } from '../utils/index.js';
|
|
import { getAttributeValueQuoteAndRange } from '../utils/ast-utils.js';
|
|
export default createRule('shorthand-attribute', {
|
|
meta: {
|
|
docs: {
|
|
description: 'enforce use of shorthand syntax in attribute',
|
|
category: 'Stylistic Issues',
|
|
recommended: false,
|
|
conflictWithPrettier: true
|
|
},
|
|
fixable: 'code',
|
|
schema: [
|
|
{
|
|
type: 'object',
|
|
properties: {
|
|
prefer: { enum: ['always', 'never'] }
|
|
},
|
|
additionalProperties: false
|
|
}
|
|
],
|
|
messages: {
|
|
expectedShorthand: 'Expected shorthand attribute.',
|
|
expectedRegular: 'Expected regular attribute syntax.'
|
|
},
|
|
type: 'layout'
|
|
},
|
|
create(context) {
|
|
const sourceCode = context.sourceCode;
|
|
const always = context.options[0]?.prefer !== 'never';
|
|
return always
|
|
? {
|
|
SvelteAttribute(node) {
|
|
if (node.value.length !== 1) {
|
|
return;
|
|
}
|
|
const value = node.value[0];
|
|
if (value.type !== 'SvelteMustacheTag' || value.expression.type !== 'Identifier') {
|
|
return;
|
|
}
|
|
if (node.key.name === value.expression.name) {
|
|
context.report({
|
|
node,
|
|
messageId: 'expectedShorthand',
|
|
*fix(fixer) {
|
|
const quoteAndRange = getAttributeValueQuoteAndRange(node, sourceCode);
|
|
if (!quoteAndRange) {
|
|
return;
|
|
}
|
|
if (quoteAndRange.quote === 'double' || quoteAndRange.quote === 'single') {
|
|
yield fixer.removeRange([node.range[0], quoteAndRange.firstToken.range[1]]);
|
|
yield fixer.remove(quoteAndRange.lastToken);
|
|
}
|
|
else {
|
|
yield fixer.removeRange([node.range[0], quoteAndRange.range[0]]);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
: {
|
|
SvelteShorthandAttribute(node) {
|
|
context.report({
|
|
node,
|
|
messageId: 'expectedRegular',
|
|
fix(fixer) {
|
|
return fixer.insertTextBefore(node, `${node.key.name}=`);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
}
|
|
});
|