Skip to content

Commit 45d66f0

Browse files
committed
more
1 parent 160294d commit 45d66f0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/eslint-plugin-svelte/src/rules/prefer-writable-derived.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import type { TSESTree } from '@typescript-eslint/types';
22
import { createRule } from '../utils/index.js';
33
import { getScope } from 'src/utils/ast-utils.js';
44
import { getSourceCode } from 'src/utils/compat.js';
5+
import { VERSION as SVELTE_VERSION } from 'svelte/compiler';
6+
import semver from 'semver';
7+
8+
// Writable derived were introduced in Svelte 5.25.0
9+
const shouldRun = semver.satisfies(SVELTE_VERSION, '>=5.25.0');
510

611
function isEffectOrEffectPre(node: TSESTree.CallExpression) {
712
if (node.callee.type === 'Identifier') {
@@ -35,6 +40,9 @@ export default createRule('prefer-writable-derived', {
3540
fixable: 'code'
3641
},
3742
create(context) {
43+
if (!shouldRun) {
44+
return {};
45+
}
3846
return {
3947
CallExpression: (node: TSESTree.CallExpression) => {
4048
if (!isEffectOrEffectPre(node)) {

0 commit comments

Comments
 (0)