mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-06 08:06:19 +00:00
chore(frontend): enforce template interpolation layout
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -1,5 +1,48 @@
|
||||
import antfu from '@antfu/eslint-config'
|
||||
|
||||
const templateStylePlugin = {
|
||||
rules: {
|
||||
'single-line-simple-interpolation': {
|
||||
meta: {
|
||||
type: 'layout',
|
||||
fixable: 'whitespace',
|
||||
schema: [],
|
||||
messages: {
|
||||
expectedSingleLine: 'Expected a simple mustache interpolation to stay on one line.',
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
const { parserServices } = context.sourceCode
|
||||
if (!parserServices.defineTemplateBodyVisitor)
|
||||
return {}
|
||||
|
||||
return parserServices.defineTemplateBodyVisitor({
|
||||
'VExpressionContainer[expression!=null]': function (node) {
|
||||
if (node.parent.type !== 'VElement')
|
||||
return
|
||||
|
||||
const expression = node.expression
|
||||
if (
|
||||
expression.loc.start.line !== expression.loc.end.line
|
||||
|| node.loc.start.line === node.loc.end.line
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'expectedSingleLine',
|
||||
fix(fixer) {
|
||||
return fixer.replaceText(node, `{{ ${context.sourceCode.getText(expression)} }}`)
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default antfu(
|
||||
{
|
||||
type: 'app',
|
||||
@@ -18,4 +61,23 @@ export default antfu(
|
||||
a11y: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.vue'],
|
||||
plugins: {
|
||||
'template-style': templateStylePlugin,
|
||||
},
|
||||
rules: {
|
||||
'template-style/single-line-simple-interpolation': 'error',
|
||||
'vue/html-closing-bracket-newline': ['error', {
|
||||
singleline: 'never',
|
||||
multiline: 'always',
|
||||
}],
|
||||
'vue/multiline-html-element-content-newline': ['error', {
|
||||
ignores: ['pre', 'textarea'],
|
||||
ignoreWhenEmpty: true,
|
||||
allowEmptyLines: false,
|
||||
}],
|
||||
'vue/mustache-interpolation-spacing': ['error', 'always'],
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user