diff --git a/.changeset/eighty-pillows-taste.md b/.changeset/eighty-pillows-taste.md
new file mode 100644
index 000000000..4bb4fa0db
--- /dev/null
+++ b/.changeset/eighty-pillows-taste.md
@@ -0,0 +1,5 @@
+---
+"eslint-plugin-svelte": patch
+---
+
+fix: suppress comment not working in flat config.
diff --git a/package.json b/package.json
index 1100cb529..fe8b10640 100644
--- a/package.json
+++ b/package.json
@@ -163,7 +163,7 @@
"rimraf": "^5.0.5",
"sass": "^1.71.1",
"source-map-js": "^1.0.2",
- "stylelint": "^16.2.1",
+ "stylelint": "~16.2.1",
"stylelint-config-standard": "^36.0.0",
"stylus": "^0.63.0",
"svelte": "^5.0.0-next.73",
diff --git a/src/configs/flat/base.ts b/src/configs/flat/base.ts
index ee1779aed..755a52831 100644
--- a/src/configs/flat/base.ts
+++ b/src/configs/flat/base.ts
@@ -27,6 +27,7 @@ export default [
// eslint-plugin-svelte rules
'svelte/comment-directive': 'error',
'svelte/system': 'error'
- }
+ },
+ processor: 'svelte/svelte'
}
];
diff --git a/tests/src/configs/base.ts b/tests/src/configs/base.ts
new file mode 100644
index 000000000..5bdc838d5
--- /dev/null
+++ b/tests/src/configs/base.ts
@@ -0,0 +1,85 @@
+import assert from 'assert';
+import semver from 'semver';
+import plugin from '../../../src/index';
+import { LegacyESLint, ESLint } from '../../utils/eslint-compat';
+
+describe('`base` config', () => {
+ it('legacy `base` config should work. ', async () => {
+ const code = `
+
+{@html a+b}
+{@html a+b}`;
+
+ const linter = new LegacyESLint({
+ plugins: {
+ svelte: plugin as never
+ },
+ baseConfig: {
+ parserOptions: {
+ ecmaVersion: 2020
+ },
+ extends: ['plugin:svelte/base'],
+ rules: {
+ 'svelte/no-at-html-tags': 'error'
+ }
+ },
+ useEslintrc: false
+ });
+ const result = await linter.lintText(code, { filePath: 'test.svelte' });
+ const messages = result[0].messages;
+
+ assert.deepStrictEqual(
+ messages.map((m) => ({ ruleId: m.ruleId, line: m.line, message: m.message })),
+ [
+ {
+ ruleId: 'svelte/no-at-html-tags',
+ message: '`{@html}` can lead to XSS attack.',
+ line: 4
+ }
+ ]
+ );
+ });
+ it('`base` config should work. ', async () => {
+ if (semver.satisfies(ESLint.version, '<8.0.0')) return;
+ const code = `
+
+{@html a+b}
+{@html a+b}`;
+ const linter = new ESLint({
+ overrideConfigFile: true as never,
+ overrideConfig: [
+ ...plugin.configs['flat/base'],
+ {
+ rules: {
+ 'svelte/no-at-html-tags': 'error'
+ }
+ }
+ ] as never
+ });
+ const result = await linter.lintText(code, { filePath: 'test.svelte' });
+ const messages = result[0].messages;
+
+ assert.deepStrictEqual(
+ messages.map((m) => ({ ruleId: m.ruleId, line: m.line, message: m.message })),
+ [
+ {
+ ruleId: 'svelte/no-at-html-tags',
+ message: '`{@html}` can lead to XSS attack.',
+ line: 4
+ }
+ ]
+ );
+
+ const resultWithJs = await linter.lintText(';', { filePath: 'test.js' });
+ const messagesWithJs = resultWithJs[0].messages;
+
+ assert.deepStrictEqual(
+ messagesWithJs.map((m) => ({
+ ruleId: m.ruleId,
+ line: m.line,
+ message: m.message
+ })),
+ []
+ );
+ });
+});
diff --git a/tests/src/configs/recommended.ts b/tests/src/configs/recommended.ts
index 73403a788..afb028fa8 100644
--- a/tests/src/configs/recommended.ts
+++ b/tests/src/configs/recommended.ts
@@ -3,8 +3,8 @@ import semver from 'semver';
import plugin from '../../../src/index';
import { LegacyESLint, ESLint } from '../../utils/eslint-compat';
-describe('`all` config', () => {
- it('legacy `all` config should work. ', async () => {
+describe('`recommended` config', () => {
+ it('legacy `recommended` config should work. ', async () => {
const code = `{@html a+b}`;
const linter = new LegacyESLint({
@@ -33,7 +33,7 @@ describe('`all` config', () => {
]
);
});
- it('`all` config should work. ', async () => {
+ it('`recommended` config should work. ', async () => {
if (semver.satisfies(ESLint.version, '<8.0.0')) return;
const code = `{@html a+b}`;
diff --git a/tools/update-rulesets.ts b/tools/update-rulesets.ts
index 6cc9e2d85..90e8b0139 100644
--- a/tools/update-rulesets.ts
+++ b/tools/update-rulesets.ts
@@ -139,6 +139,7 @@ export default [
})
.join(',\n ')},
},
+ processor: 'svelte/svelte'
},
]
`;