Skip to content

Commit 5f00210

Browse files
committed
fixup! feat(valid-style-parse): implemented the rule
1 parent b15054e commit 5f00210

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/eslint-plugin-svelte/src/rules/valid-style-parse.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createRule } from '../utils/index.js';
2-
import { getSourceCode } from '../utils/compat.js';
2+
import { getCwd, getSourceCode } from '../utils/compat.js';
33

44
export default createRule('valid-style-parse', {
55
meta: {
@@ -9,24 +9,23 @@ export default createRule('valid-style-parse', {
99
recommended: false
1010
},
1111
schema: [],
12-
messages: {
13-
parseError: 'Error parsing style element'
14-
},
12+
messages: {},
1513
type: 'problem'
1614
},
1715
create(context) {
1816
const sourceCode = getSourceCode(context);
1917
if (!sourceCode.parserServices.isSvelte) {
2018
return {};
2119
}
20+
const cwd = `${getCwd(context)}/`;
2221

2322
return {
2423
SvelteStyleElement(node) {
2524
const styleContext = sourceCode.parserServices.getStyleContext!();
2625
if (styleContext.status === 'parse-error') {
2726
context.report({
2827
loc: node.loc,
29-
messageId: 'parseError'
28+
message: `Error parsing style element. Error message: "${styleContext.error.message.replace(cwd, '')}"`
3029
});
3130
}
3231
if (styleContext.status === 'unknown-lang') {

0 commit comments

Comments
 (0)