Skip to content

Commit

Permalink
fix(language-plugin-pug): ignore duplicate attribute error of class (
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX authored Jan 22, 2025
1 parent 95c26c3 commit b89dbee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/language-plugin-pug/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { SourceMap } from '@volar/source-map';
import type { VueLanguagePlugin } from '@vue/language-core';
import type { CompilerDOM, VueLanguagePlugin } from '@vue/language-core';
import * as pug from 'volar-service-pug/lib/languageService';

const classRegex = /^class\s*=/;

const plugin: VueLanguagePlugin = ({ modules }) => {

return {
Expand Down Expand Up @@ -71,6 +73,13 @@ const plugin: VueLanguagePlugin = ({ modules }) => {
options?.onWarn?.(createProxyObject(warning));
},
onError(error) {
// #5099
if (
error.code === 2 satisfies CompilerDOM.ErrorCodes.DUPLICATE_ATTRIBUTE
&& classRegex.test(pugFile.htmlCode.slice(error.loc?.start.offset))
) {
return;
}
options?.onError?.(createProxyObject(error));
},
});
Expand Down
6 changes: 6 additions & 0 deletions test-workspace/tsc/passedFixtures/pug/#5099.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<template lang="pug">
div(
class="foo"
class="bar"
)
</template>

0 comments on commit b89dbee

Please sign in to comment.