Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reactive_declaration_non_reactive_property is considered error instead of warning #896

Open
2 tasks done
fev4 opened this issue Oct 30, 2024 · 2 comments
Open
2 tasks done

Comments

@fev4
Copy link

fev4 commented Oct 30, 2024

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

9.13.0

What version of eslint-plugin-svelte are you using?

2.46.0

What did you do?

Configuration
import js from '@eslint/js';
import ts from 'typescript-eslint';
import svelte from 'eslint-plugin-svelte';
import prettier from 'eslint-config-prettier';
import globals from 'globals';

// /** @type {import('eslint').Linter.FlatConfig[]} */
export default [
  js.configs.recommended,
  ...ts.configs.recommended,
  ...svelte.configs['flat/recommended'],
  prettier,
  ...svelte.configs['flat/prettier'],
  {
    languageOptions: {
      globals: {
        ...globals.browser,
        ...globals.node,
      },
    },
    rules: {
      '@typescript-eslint/no-explicit-any': 'warn',
      '@typescript-eslint/no-unused-vars': [
        'warn',
        { varsIgnorePattern: '^\\$\\$(Props|Events|Slots|Generic)$' },
      ],
    },
  },
  {
    files: ['**/*.svelte'],
    languageOptions: {
      parserOptions: {
        parser: ts.parser,
      },
    },
  },
  {
    ignores: [
      '.env',
      '.env.*',
      '!.env.example',
      '/static/assets/fa',
      '.DS_Store',
      '/package',
      'build/',
      '.svelte-kit/',
      'dist/',
      'pnpm-lock.yaml',
      'package-lock.json',
      'yarn.lock.DS_Store',
      '.pnpm-debug.log',
      'node_modules',
      'vite.config.ts.timestamp-*',
      'playwright-report/**',
    ],
  },
];
  $: initial = {
    envelope_id,
    account_id: $envelope?.account_id,
    type:
      TransactionType.INFLOW == type
        ? TransactionType.INFLOW
        : TransactionType.OUTFLOW,
    amount: Number(amount),
  };

TransactionType is an enum and all it's properties have this warning when used inside $: (we haven't started migration to Svelte 5 runes yet.

Properties of objects and arrays are not reactive unless in runes mode. Changes to this property will not cause the reactive statement to updatesvelte(reactive_declaration_non_reactive_property)

Then ran:

pnpm exec eslint .

What did you expect to happen?

I was expecting this to not be an error and instead a warning.

What actually happened?

/src/routes/app/create-envelope-transaction/+page.svelte
  16:7   error  Properties of objects and arrays are not reactive unless in runes mode. Changes to this property will not cause the reactive statement to update(reactive_declaration_non_reactive_property)  svelte/valid-compile
  17:11  error  Properties of objects and arrays are not reactive unless in runes mode. Changes to this property will not cause the reactive statement to update(reactive_declaration_non_reactive_property)  svelte/valid-compile
  18:11  error  Properties of objects and arrays are not reactive unless in runes mode. Changes to this property will not cause the reactive statement to update(reactive_declaration_non_reactive_property)  svelte/valid-compile

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/fev4/reactive-non-reactive

Additional comments

When I try to ignore it with the following it persists, which makes sense since these are two different tools (one is the Svelte VSCode extension and the other ESLint):

// svelte-ignore reactive_declaration_non_reactive_property
@fev4
Copy link
Author

fev4 commented Oct 31, 2024

After thoroughly testing I seem to have found that the error steamed from an bogus node_modules (deleting and installing again seems to have fixed the issue). I'm closing this as I'm not able to reproduce in the MRE.

Error persists, please read the next comment.

@fev4 fev4 closed this as completed Oct 31, 2024
@fev4
Copy link
Author

fev4 commented Oct 31, 2024

I was thinking about this the wrong way. It's not related to node_modules, it just a different behavior between pnpm check and pnpm eslint .. The first one throws warnings as expected but pnpm eslint . throws the errors which is the unexpected part. The reason I was confused is that we have a custom formatter and it was using pnpm eslint . under the hood instead of directly pnpm check.

Here`s the MRE: https://github.com/fev4/reactive-non-reactive

I'm going to reopen this issue as I believe it's an inconsistency.

@fev4 fev4 reopened this Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant