mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-20 08:01:46 +00:00
* chore(deps-dev): bump @antfu/eslint-config in /frontend Bumps [@antfu/eslint-config](https://github.com/antfu/eslint-config) from 9.5.1 to 10.0.0. - [Release notes](https://github.com/antfu/eslint-config/releases) - [Commits](https://github.com/antfu/eslint-config/compare/v9.5.1...v10.0.0) --- updated-dependencies: - dependency-name: "@antfu/eslint-config" dependency-version: 10.0.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * chore(frontend): migrate formatting to ESLint v10 Co-authored-by: Codex <noreply@openai.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Zyy <zyycn@users.noreply.github.com> Co-authored-by: Codex <noreply@openai.com>
136 lines
3.3 KiB
TypeScript
136 lines
3.3 KiB
TypeScript
// @env node
|
|
import type { ESLint, Rule } from 'eslint'
|
|
import antfu from '@antfu/eslint-config'
|
|
import vueI18n from '@intlify/eslint-plugin-vue-i18n'
|
|
|
|
type LocatedRuleNode = Rule.Node & {
|
|
loc: NonNullable<Rule.Node['loc']>
|
|
}
|
|
|
|
interface TemplateExpressionContainer {
|
|
type: 'VExpressionContainer'
|
|
parent: { type: string }
|
|
expression: LocatedRuleNode
|
|
loc: NonNullable<Rule.Node['loc']>
|
|
range: NonNullable<Rule.Node['range']>
|
|
}
|
|
|
|
const singleLineSimpleInterpolationRule = {
|
|
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: TemplateExpressionContainer) {
|
|
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.replaceTextRange(
|
|
node.range,
|
|
`{{ ${context.sourceCode.getText(expression)} }}`,
|
|
)
|
|
},
|
|
})
|
|
},
|
|
})
|
|
},
|
|
} satisfies Rule.RuleModule
|
|
|
|
const templateStylePlugin = {
|
|
rules: {
|
|
'single-line-simple-interpolation': singleLineSimpleInterpolationRule,
|
|
},
|
|
} satisfies ESLint.Plugin
|
|
|
|
export default antfu(
|
|
{
|
|
type: 'app',
|
|
ignores: ['**/dist/**', '**/coverage/**', '**/pnpm-workspace.yaml'],
|
|
formatters: {
|
|
css: true,
|
|
html: true,
|
|
markdown: 'prettier',
|
|
},
|
|
stylistic: {
|
|
indent: 2,
|
|
quotes: 'single',
|
|
},
|
|
typescript: true,
|
|
vue: {
|
|
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'],
|
|
},
|
|
},
|
|
...vueI18n.configs.base,
|
|
{
|
|
settings: {
|
|
'vue-i18n': {
|
|
localeDir: {
|
|
pattern: './src/i18n/locales/*/*.json',
|
|
localeKey: 'path',
|
|
localePattern: /\/locales\/(?<locale>[^/]+)\//,
|
|
},
|
|
messageSyntaxVersion: '^11.0.0',
|
|
},
|
|
},
|
|
rules: {
|
|
'@intlify/vue-i18n/no-missing-keys': 'error',
|
|
'@intlify/vue-i18n/no-missing-keys-in-other-locales': 'error',
|
|
'@intlify/vue-i18n/no-duplicate-keys-in-locale': 'error',
|
|
'@intlify/vue-i18n/valid-message-syntax': 'error',
|
|
'@intlify/vue-i18n/valid-plural-forms': 'error',
|
|
'@intlify/vue-i18n/no-unused-keys': [
|
|
'error',
|
|
{
|
|
extensions: ['.ts', '.vue'],
|
|
},
|
|
],
|
|
},
|
|
},
|
|
)
|